GQCP
Loading...
Searching...
No Matches
CCDAmplitudesUpdate.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 using Scalar = _Scalar;
40
41
42public:
43 /*
44 * OVERRIDDEN PUBLIC METHODS
45 */
46
50 std::string description() const override {
51 return "Calculate the new T2-amplitudes using an update formula from the current T2-amplitudes.";
52 }
53
59 void execute(Environment& environment) override {
60
61 // Extract the current T2-amplitudes and intermediates.
62 const auto& f = environment.f;
63 const auto& V_A = environment.V_A;
64 const auto& t2 = environment.t2_amplitudes.back();
65
66 const auto& F1 = environment.F1;
67 const auto& F2 = environment.F2;
68
69 const auto& W1 = environment.W1;
70 const auto& W2 = environment.W2;
71 const auto& W3 = environment.W3;
72
73 const auto& orbital_space = t2.orbitalSpace();
74
75
76 // Update the T2-amplitudes.
77 auto t2_updated = t2;
78 for (const auto& i : orbital_space.indices(OccupationType::k_occupied)) {
79 for (const auto& j : orbital_space.indices(OccupationType::k_occupied)) {
80 for (const auto& a : orbital_space.indices(OccupationType::k_virtual)) {
81 for (const auto& b : orbital_space.indices(OccupationType::k_virtual)) {
82
83 // Determine the current value for the corresponding T2-amplitude equation, and use it to update the T2-amplitude.
84 const auto f_ijab = QCModel::CCD<Scalar>::calculateT2AmplitudeEquation(i, j, a, b, f, V_A, t2, F1, F2, W1, W2, W3);
85 t2_updated(i, j, a, b) += f_ijab / (f(i, i) + f(j, j) - f(a, a) - f(b, b));
86 }
87 }
88 }
89 }
90
91 // Write the updated amplitudes back to the environment.
92 environment.t2_amplitudes.push_back(t2_updated);
93 }
94};
95
96
97} // namespace GQCP
Definition: CCDAmplitudesUpdate.hpp:35
std::string description() const override
Definition: CCDAmplitudesUpdate.hpp:50
void execute(Environment &environment) override
Definition: CCDAmplitudesUpdate.hpp:59
_Scalar Scalar
Definition: CCDAmplitudesUpdate.hpp:38
Definition: CCSDEnvironment.hpp:39
SquareRankFourTensor< Scalar > V_A
Definition: CCSDEnvironment.hpp:55
std::deque< T2Amplitudes< Scalar > > t2_amplitudes
Definition: CCSDEnvironment.hpp:49
ImplicitRankFourTensorSlice< Scalar > W2
Definition: CCSDEnvironment.hpp:62
ImplicitMatrixSlice< Scalar > F1
Definition: CCSDEnvironment.hpp:57
SquareMatrix< Scalar > f
Definition: CCSDEnvironment.hpp:54
ImplicitMatrixSlice< Scalar > F2
Definition: CCSDEnvironment.hpp:58
ImplicitRankFourTensorSlice< Scalar > W3
Definition: CCSDEnvironment.hpp:63
ImplicitRankFourTensorSlice< Scalar > W1
Definition: CCSDEnvironment.hpp:61
static Scalar calculateT2AmplitudeEquation(const size_t i, const size_t j, const size_t a, const size_t b, const SquareMatrix< Scalar > &f, const SquareRankFourTensor< Scalar > &V_A, const T2Amplitudes< Scalar > &t2, const ImplicitMatrixSlice< Scalar > &F1, const ImplicitMatrixSlice< Scalar > &F2, const ImplicitRankFourTensorSlice< Scalar > &W1, const ImplicitRankFourTensorSlice< Scalar > &W2, const ImplicitRankFourTensorSlice< Scalar > &W3)
Definition: CCD.hpp:113
Definition: Step.hpp:37
Definition: BaseOneElectronIntegralBuffer.hpp:25