GQCP
Loading...
Searching...
No Matches
T2ErrorCalculation.hpp
Go to the documentation of this file.
1// This file is part of GQCG-GQCP.
2//
3// Copyright (C) 2017-2020 the GQCG developers
4//
5// GQCG-GQCP is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// GQCG-GQCP is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with GQCG-GQCP. If not, see <http://www.gnu.org/licenses/>.
17
18#pragma once
19
20
23
24
25namespace GQCP {
26
27
33template <typename _Scalar>
35 public Step<CCSDEnvironment<_Scalar>> {
36
37public:
38 // The scalar type used to represent the T2 amplitudes.
39 using Scalar = _Scalar;
40
41 // The environment related to this step.
43
44
45public:
46 /*
47 * MARK: Conforming to `Step`
48 */
49
53 std::string description() const override {
54 return "Calculate the current T2 error vector and add it to the environment.";
55 }
56
57
63 void execute(Environment& environment) override {
64
65 // Read the last two T2 amplitudes iterations and calculate the error as their difference.
66 const auto second_to_last_it = environment.t2_amplitudes.end() - 2;
67 const auto& T2_previous = *second_to_last_it; // Dereference the iterator.
68
69 const auto& T2_current = environment.t2_amplitudes.back();
70
71 // Calculate the current T2 error vector and add it to the environment (as a vector).
72 const auto t2_error = T2_current - T2_previous;
73 environment.t2_amplitude_errors.push_back(t2_error.asImplicitRankFourTensorSlice().asMatrix().pairWiseReduced());
74 }
75};
76
77
78} // namespace GQCP
Definition: CCSDEnvironment.hpp:39
std::deque< T2Amplitudes< Scalar > > t2_amplitudes
Definition: CCSDEnvironment.hpp:49
std::deque< VectorX< Scalar > > t2_amplitude_errors
Definition: CCSDEnvironment.hpp:52
Definition: Step.hpp:37
Definition: T2ErrorCalculation.hpp:35
std::string description() const override
Definition: T2ErrorCalculation.hpp:53
_Scalar Scalar
Definition: T2ErrorCalculation.hpp:39
void execute(Environment &environment) override
Definition: T2ErrorCalculation.hpp:63
Definition: BaseOneElectronIntegralBuffer.hpp:25