GQCP
Loading...
Searching...
No Matches
T2Amplitudes.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
25
26
27namespace GQCP {
28
29
37template <typename _Scalar>
39 public VectorSpaceArithmetic<T2Amplitudes<_Scalar>, _Scalar> {
40
41public:
42 // The scalar type that represents one of the amplitudes.
43 using Scalar = _Scalar;
44
45 // The type of 'this'.
47
48private:
49 // The orbital space which encapsulates the occupied-virtual separation.
50 OrbitalSpace orbital_space;
51
52 // The T2-amplitudes as an implicit tensor, implementing intuitive operator(i,j,a,b) calls.
54
55
56public:
57 /*
58 * MARK: Constructors
59 */
60
68 orbital_space {orbital_space},
69 t {t} {}
70
71
79 T2Amplitudes(const ImplicitRankFourTensorSlice<Scalar>& t, const size_t N, const size_t M) :
81
82
83 /*
84 * MARK: Named constructors
85 */
86
97
98 // Zero-initialize a tensor representation for the (occupied-occupied-virtual-virtual) T2-amplitudes t_{ij}^{ab}.
100
101
102 // Provide the perturbative T2-amplitudes, by setting the RHS amplitudes in Stanton1991, equation (2) to zero.
103 for (const auto& i : orbital_space.indices(OccupationType::k_occupied)) {
104 for (const auto& j : orbital_space.indices(OccupationType::k_occupied)) {
105 for (const auto& a : orbital_space.indices(OccupationType::k_virtual)) {
106 for (const auto& b : orbital_space.indices(OccupationType::k_virtual)) {
107 const auto denominator = f(i, i) + f(j, j) - f(a, a) - f(b, b);
108
109 t2(i, j, a, b) = V_A(i, j, a, b) / denominator;
110 }
111 }
112 }
113 }
114
115 return T2Amplitudes<Scalar>(t2, orbital_space);
116 }
117
118
119 /*
120 * MARK: Access
121 */
122
133 Scalar operator()(const size_t i, const size_t j, const size_t a, const size_t b) const { return this->t(i, j, a, b); }
134
145 Scalar& operator()(const size_t i, const size_t j, const size_t a, const size_t b) { return this->t(i, j, a, b); }
146
151
155 const OrbitalSpace& orbitalSpace() const { return this->orbital_space; }
156
157
158 /*
159 * MARK: Linear algebra
160 */
161
165 Scalar norm() const { return this->asImplicitRankFourTensorSlice().asMatrix().norm(); }
166
167
168 /*
169 * MARK: Vector space arithmetic
170 */
171
175 Self& operator+=(const Self& rhs) override {
176
177 // Prepare some variables.
178 const auto& index_maps = this->asImplicitRankFourTensorSlice().indexMaps();
179
180 // Add the tensor representations.
182 const ImplicitRankFourTensorSlice<Scalar> t_sum_slice {index_maps, t_sum_dense};
183
184 this->t = t_sum_slice;
185
186 return *this;
187 }
188
189
193 Self& operator*=(const Scalar& a) override {
194
195 // Prepare some variables.
196 const auto& index_maps = this->asImplicitRankFourTensorSlice().indexMaps();
197
198 // Multiply the tensor representation.
199 const Tensor<Scalar, 4> t_multiplied_dense = a * this->asImplicitRankFourTensorSlice().asTensor().Eigen();
200 const ImplicitRankFourTensorSlice<Scalar> t_multiplied_slice {index_maps, t_multiplied_dense};
201
202 this->t = t_multiplied_slice;
203
204 return *this;
205 }
206};
207
208} // namespace GQCP
Definition: ImplicitRankFourTensorSlice.hpp:38
const Tensor< Scalar, 4 > & asTensor() const
Definition: ImplicitRankFourTensorSlice.hpp:280
MatrixX< Scalar > asMatrix() const
Definition: ImplicitRankFourTensorSlice.hpp:275
const std::vector< std::map< size_t, size_t > > & indexMaps() const
Definition: ImplicitRankFourTensorSlice.hpp:297
Definition: OrbitalSpace.hpp:40
const std::vector< size_t > & indices() const
Definition: OrbitalSpace.hpp:150
ImplicitMatrixSlice< Scalar > initializeRepresentableObjectFor(const OccupationType row_type, const OccupationType column_type) const
Definition: OrbitalSpace.hpp:173
Definition: SquareMatrix.hpp:39
Definition: SquareRankFourTensor.hpp:36
Definition: T2Amplitudes.hpp:39
Scalar norm() const
Definition: T2Amplitudes.hpp:165
const OrbitalSpace & orbitalSpace() const
Definition: T2Amplitudes.hpp:155
Self & operator+=(const Self &rhs) override
Definition: T2Amplitudes.hpp:175
T2Amplitudes(const ImplicitRankFourTensorSlice< Scalar > &t, const size_t N, const size_t M)
Definition: T2Amplitudes.hpp:79
T2Amplitudes(const ImplicitRankFourTensorSlice< Scalar > &t, const OrbitalSpace &orbital_space)
Definition: T2Amplitudes.hpp:67
static T2Amplitudes< Scalar > Perturbative(const SquareMatrix< Scalar > &f, const SquareRankFourTensor< Scalar > &V_A, const OrbitalSpace &orbital_space)
Definition: T2Amplitudes.hpp:96
Scalar operator()(const size_t i, const size_t j, const size_t a, const size_t b) const
Definition: T2Amplitudes.hpp:133
_Scalar Scalar
Definition: T2Amplitudes.hpp:43
const ImplicitRankFourTensorSlice< Scalar > & asImplicitRankFourTensorSlice() const
Definition: T2Amplitudes.hpp:150
Scalar & operator()(const size_t i, const size_t j, const size_t a, const size_t b)
Definition: T2Amplitudes.hpp:145
Self & operator*=(const Scalar &a) override
Definition: T2Amplitudes.hpp:193
Definition: Tensor.hpp:46
const Base & Eigen() const
Definition: Tensor.hpp:116
Definition: VectorSpaceArithmetic.hpp:35
Definition: BaseOneElectronIntegralBuffer.hpp:25