GQCP
Loading...
Searching...
No Matches
CCSDAmplitudesUpdate.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 * PUBLIC OVERRIDDEN METHODS
45 */
46
50 std::string description() const override {
51 return "Calculate the new T1 and T2-amplitudes using an update formula from the current T1- and T2-amplitudes.";
52 }
53
54
60 void execute(Environment& environment) override {
61
62 // Extract the current T1- and T2-amplitudes and intermediates.
63 const auto& f = environment.f;
64 const auto& V_A = environment.V_A;
65 const auto& t1 = environment.t1_amplitudes.back();
66 const auto& t2 = environment.t2_amplitudes.back();
67
68 const auto& tau2 = environment.tau2;
69 const auto& tau2_tilde = environment.tau2_tilde;
70
71 const auto& F1 = environment.F1;
72 const auto& F2 = environment.F2;
73 const auto& F3 = environment.F3;
74
75 const auto& W1 = environment.W1;
76 const auto& W2 = environment.W2;
77 const auto& W3 = environment.W3;
78
79 const auto& orbital_space = t1.orbitalSpace(); // assume the orbital spaces are equal for the T1- and T2-amplitudes.
80
81
82 // Update the T1-amplitudes.
83 auto t1_updated = t1;
84 for (const auto& i : orbital_space.indices(OccupationType::k_occupied)) {
85 for (const auto& a : orbital_space.indices(OccupationType::k_virtual)) {
86
87 // Determine the current value for the corresponding T1-amplitude equation, and use it to update the T1-amplitude.
88 const auto f_ia = QCModel::CCSD<Scalar>::calculateT1AmplitudeEquation(i, a, f, V_A, t1, t2, F1, F2, F3);
89 t1_updated(i, a) += f_ia / (f(i, i) - f(a, a));
90 }
91 }
92
93 // Update the T2-amplitudes.
94 auto t2_updated = t2;
95 for (const auto& i : orbital_space.indices(OccupationType::k_occupied)) {
96 for (const auto& j : orbital_space.indices(OccupationType::k_occupied)) {
97 for (const auto& a : orbital_space.indices(OccupationType::k_virtual)) {
98 for (const auto& b : orbital_space.indices(OccupationType::k_virtual)) {
99
100 // Determine the current value for the corresponding T2-amplitude equation, and use it to update the T2-amplitude.
101 const auto f_ijab = QCModel::CCSD<Scalar>::calculateT2AmplitudeEquation(i, j, a, b, f, V_A, t1, t2, tau2, F1, F2, F3, W1, W2, W3);
102 t2_updated(i, j, a, b) += f_ijab / (f(i, i) + f(j, j) - f(a, a) - f(b, b));
103 }
104 }
105 }
106 }
107
108 // Write the updated amplitudes back to the environment.
109 environment.t1_amplitudes.push_back(t1_updated);
110 environment.t2_amplitudes.push_back(t2_updated);
111 }
112};
113
114
115} // namespace GQCP
Definition: CCSDAmplitudesUpdate.hpp:35
void execute(Environment &environment) override
Definition: CCSDAmplitudesUpdate.hpp:60
_Scalar Scalar
Definition: CCSDAmplitudesUpdate.hpp:38
std::string description() const override
Definition: CCSDAmplitudesUpdate.hpp:50
Definition: CCSDEnvironment.hpp:39
ImplicitRankFourTensorSlice< Scalar > tau2_tilde
Definition: CCSDEnvironment.hpp:66
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
ImplicitRankFourTensorSlice< Scalar > tau2
Definition: CCSDEnvironment.hpp:65
SquareMatrix< Scalar > f
Definition: CCSDEnvironment.hpp:54
ImplicitMatrixSlice< Scalar > F3
Definition: CCSDEnvironment.hpp:59
std::deque< T1Amplitudes< Scalar > > t1_amplitudes
Definition: CCSDEnvironment.hpp:48
ImplicitMatrixSlice< Scalar > F2
Definition: CCSDEnvironment.hpp:58
ImplicitRankFourTensorSlice< Scalar > W3
Definition: CCSDEnvironment.hpp:63
ImplicitRankFourTensorSlice< Scalar > W1
Definition: CCSDEnvironment.hpp:61
static Scalar calculateT1AmplitudeEquation(const size_t i, const size_t a, const SquareMatrix< Scalar > &f, const SquareRankFourTensor< Scalar > &V_A, const T1Amplitudes< Scalar > &t1, const T2Amplitudes< Scalar > &t2, const ImplicitMatrixSlice< Scalar > &F1, const ImplicitMatrixSlice< Scalar > &F2, const ImplicitMatrixSlice< Scalar > &F3)
Definition: CCSD.hpp:120
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 T1Amplitudes< Scalar > &t1, const T2Amplitudes< Scalar > &t2, const ImplicitRankFourTensorSlice< Scalar > &tau2, const ImplicitMatrixSlice< Scalar > &F1, const ImplicitMatrixSlice< Scalar > &F2, const ImplicitMatrixSlice< Scalar > &F3, const ImplicitRankFourTensorSlice< Scalar > &W1, const ImplicitRankFourTensorSlice< Scalar > &W2, const ImplicitRankFourTensorSlice< Scalar > &W3)
Definition: CCSD.hpp:202
Definition: Step.hpp:37
Definition: BaseOneElectronIntegralBuffer.hpp:25