GQCP
Loading...
Searching...
No Matches
USpinOrbitalBasisComponent.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
29
30
31namespace GQCP {
32
33
40template <typename _ExpansionScalar, typename _Shell>
42 public SimpleSpinOrbitalBasis<_ExpansionScalar, _Shell, USpinOrbitalBasisComponent<_ExpansionScalar, _Shell>> {
43public:
44 // The scalar type used to represent an expansion coefficient of the spinors in the underlying scalar orbitals: real or complex.
45 using ExpansionScalar = _ExpansionScalar;
46
47 // The type of shell the underlying scalar bases contain.
48 using Shell = _Shell;
49
50 // The type that is used for representing the primitive for a basis function of this spin-orbital basis' underlying AO basis.
51 using Primitive = typename Shell::Primitive;
52
53 // The type that is used for representing the underlying basis functions of this spin-orbital basis.
54 using BasisFunction = typename Shell::BasisFunction;
55
56
57public:
58 /*
59 * MARK: Constructors
60 */
61
62 // Inherit `SimpleSpinOrbitalBasis`'s constructors.
64
65
66 /*
67 * MARK: Quantization of first-quantized operators (GTOShell)
68 */
69
79 template <typename FQOneElectronOperator, typename Z = Shell>
80 auto quantize(const FQOneElectronOperator& fq_one_op) const -> enable_if_t<std::is_same<Z, GTOShell>::value, USQOneElectronOperatorComponent<product_t<typename FQOneElectronOperator::Scalar, ExpansionScalar>, typename FQOneElectronOperator::Vectorizer>> {
81
82 // FIXME: Try to move this API to SimpleSpinOrbitalBasis.
85
86 const auto f_par = IntegralCalculator::calculateLibintIntegrals(fq_one_op, this->scalarBasis()); // Currently f is expressed in the AO basis. 'par' for 'parameters'
87
88 ResultOperator f {f_par};
89 f.transform(this->expansion()); // Now, f is expressed in the spin-orbital basis.
90 return f;
91 }
92
93
94 /*
95 * MARK: Quantization of first-quantized operators (LondonGTOShell)
96 */
97
107 template <typename FQOneElectronOperator, typename Z = Shell>
109
112 using Vectorizer = typename FQOneElectronOperator::Vectorizer;
113
114 const auto N = FQOneElectronOperator::NumberOfComponents;
115 const auto& vectorizer = FQOneElectronOperator::vectorizer;
116
117
118 // The strategy for calculating the matrix representation of the one-electron operator in this spin-orbital basis is to:
119 // 1. Express the operator in the underlying scalar bases and;
120 // 2. Afterwards transform them using the current coefficient matrix.
121 const auto K = this->scalarBasis().numberOfBasisFunctions();
122
123
124 // 1. Express the operator in the underlying scalar basis.
125 auto engine = GQCP::IntegralEngine::InHouse<GQCP::LondonGTOShell>(fq_one_op);
126 const auto F = GQCP::IntegralCalculator::calculate(engine, this->scalarBasis().shellSet(), this->scalarBasis().shellSet());
127
128
129 // For each of the components of the operator, place the scalar basis representations into the spinor basis representation.
130 std::array<SquareMatrix<ResultScalar>, N> fs;
131 for (size_t i = 0; i < N; i++) {
132 fs[i] = SquareMatrix<ResultScalar>(F[i]);
133 }
134
135
136 // 2. Transform using the current coefficient matrix.
137 StorageArray<SquareMatrix<ResultScalar>, Vectorizer> array {fs, vectorizer};
138 ResultOperator op {array}; // 'op' for 'operator'.
139 op.transform(this->expansion());
140 return op;
141 }
142
143
151 template <typename Z = Shell>
153
154 // Return the orbital Zeeman operator as a contraction beween the magnetic field and the angular momentum operator.
155 const auto L = this->quantize(op.angularMomentum());
156 const auto& B = op.magneticField().strength();
157 return 0.5 * L.dot(B);
158 }
159
160
168 template <typename Z = Shell>
170
173
174
175 // Return the diamagnetic operator as a contraction beween the magnetic field and the electronic quadrupole operator.
176 const auto Q = this->quantize(op.electronicQuadrupole()).allParameters();
177 const auto& B = op.magneticField().strength();
178
179 // Prepare some variables.
180 const auto& B_x = B(CartesianDirection::x);
181 const auto& B_y = B(CartesianDirection::y);
182 const auto& B_z = B(CartesianDirection::z);
183
184 const auto& Q_xx = Q[DyadicCartesianDirection::xx];
185 const auto& Q_xy = Q[DyadicCartesianDirection::xy];
186 const auto& Q_xz = Q[DyadicCartesianDirection::xz];
187 const auto& Q_yy = Q[DyadicCartesianDirection::yy];
188 const auto& Q_yz = Q[DyadicCartesianDirection::yz];
189 const auto& Q_zz = Q[DyadicCartesianDirection::zz];
190
191
192 SquareMatrix<ResultScalar> D_par = 0.125 * ((std::pow(B_y, 2) + std::pow(B_z, 2)) * Q_xx +
193 (std::pow(B_x, 2) + std::pow(B_z, 2)) * Q_yy +
194 (std::pow(B_x, 2) + std::pow(B_y, 2)) * Q_zz -
195 2 * B_x * B_y * Q_xy -
196 2 * B_x * B_z * Q_xz -
197 2 * B_y * B_z * Q_yz);
198
199 return ResultOperator {D_par};
200 }
201
202
214 UMullikenDomainComponent<ExpansionScalar> mullikenDomain(const std::function<bool(const BasisFunction&)>& selector) const {
215
216 // FIXME: Try to move this API to SimpleSpinOrbitalBasis.
217
218 const auto ao_indices = this->scalarBasis().basisFunctionIndices(selector);
219 return UMullikenDomainComponent<ExpansionScalar> {ao_indices, ao_indices.size()};
220 }
221
222
230 UMullikenDomainComponent<ExpansionScalar> mullikenDomain(const std::function<bool(const Shell&)>& selector) const {
231
232 // FIXME: Try to move this API to SimpleSpinOrbitalBasis.
233
234 const auto ao_indices = this->scalarBasis().basisFunctionIndices(selector);
235 return UMullikenDomainComponent<ExpansionScalar> {ao_indices, ao_indices.size()};
236 }
237};
238
239
240/*
241 * MARK: SpinorBasisTraits
242 */
243
247template <typename ExpansionScalar, typename Shell>
248struct SpinorBasisTraits<USpinOrbitalBasisComponent<ExpansionScalar, Shell>> {
249
250 // The type of transformation that is naturally related to a `USpinOrbitalBasisComponent`.
252
253 // The second-quantized representation of the overlap operator related to a `USpinOrbitalBasisComponent`.
255};
256
257
258/*
259 * MARK: BasisTransformableTraits
260 */
261
265template <typename _ExpansionScalar, typename _Shell>
266struct BasisTransformableTraits<USpinOrbitalBasisComponent<_ExpansionScalar, _Shell>> {
267
268 // The type of transformation that is naturally related to a `USpinOrbitalBasisComponent`.
270};
271
272
273/*
274 * MARK: JacobiRotatableTraits
275 */
276
280template <typename _ExpansionScalar, typename _Shell>
281struct JacobiRotatableTraits<USpinOrbitalBasisComponent<_ExpansionScalar, _Shell>> {
282
283 // The type of Jacobi rotation that is naturally related to a `USpinOrbitalBasisComponent`.
285};
286
287
288} // namespace GQCP
Definition: DenseVectorizer.hpp:49
Definition: DiamagneticOperator.hpp:35
static Matrix< double > calculateLibintIntegrals(const FQOneElectronOperator &fq_one_op, const ScalarBasis< GTOShell > &left_scalar_basis, const ScalarBasis< GTOShell > &right_scalar_basis)
Definition: IntegralCalculator.hpp:181
static auto calculate(BaseOneElectronIntegralEngine< Shell, N, IntegralScalar > &engine, const ShellSet< Shell > &left_shell_set, const ShellSet< Shell > &right_shell_set) -> std::array< MatrixX< IntegralScalar >, N >
Definition: IntegralCalculator.hpp:61
Definition: JacobiRotation.hpp:33
Definition: OrbitalZeemanOperator.hpp:35
size_t numberOfBasisFunctions() const
Definition: ScalarBasis.hpp:155
std::vector< size_t > basisFunctionIndices(const std::function< bool(const Shell &)> &selector) const
Definition: ScalarBasis.hpp:164
Definition: SimpleSpinOrbitalBasis.hpp:39
const ScalarBasis< Shell > & scalarBasis() const
Definition: SimpleSpinOrbitalBasis.hpp:133
const Transformation & expansion() const
Definition: SimpleSpinorBasis.hpp:98
Definition: SquareMatrix.hpp:39
Definition: StorageArray.hpp:38
Definition: UMullikenDomainComponent.hpp:35
Definition: USQOneElectronOperatorComponent.hpp:40
Definition: USpinOrbitalBasisComponent.hpp:42
auto quantize(const DiamagneticOperator &op) const -> enable_if_t< std::is_same< Z, LondonGTOShell >::value, USQOneElectronOperatorComponent< product_t< DiamagneticOperator::Scalar, ExpansionScalar >, DiamagneticOperator::Vectorizer > >
Definition: USpinOrbitalBasisComponent.hpp:169
typename Shell::Primitive Primitive
Definition: USpinOrbitalBasisComponent.hpp:51
typename Shell::BasisFunction BasisFunction
Definition: USpinOrbitalBasisComponent.hpp:54
UMullikenDomainComponent< ExpansionScalar > mullikenDomain(const std::function< bool(const Shell &)> &selector) const
Definition: USpinOrbitalBasisComponent.hpp:230
auto quantize(const OrbitalZeemanOperator &op) const -> enable_if_t< std::is_same< Z, LondonGTOShell >::value, USQOneElectronOperatorComponent< product_t< OrbitalZeemanOperator::Scalar, ExpansionScalar >, OrbitalZeemanOperator::Vectorizer > >
Definition: USpinOrbitalBasisComponent.hpp:152
_Shell Shell
Definition: USpinOrbitalBasisComponent.hpp:48
UMullikenDomainComponent< ExpansionScalar > mullikenDomain(const std::function< bool(const BasisFunction &)> &selector) const
Definition: USpinOrbitalBasisComponent.hpp:214
auto quantize(const FQOneElectronOperator &fq_one_op) const -> enable_if_t< std::is_same< Z, GTOShell >::value, USQOneElectronOperatorComponent< product_t< typename FQOneElectronOperator::Scalar, ExpansionScalar >, typename FQOneElectronOperator::Vectorizer > >
Definition: USpinOrbitalBasisComponent.hpp:80
auto quantize(const FQOneElectronOperator &fq_one_op) const -> enable_if_t< std::is_same< Z, LondonGTOShell >::value, USQOneElectronOperatorComponent< product_t< typename FQOneElectronOperator::Scalar, ExpansionScalar >, typename FQOneElectronOperator::Vectorizer > >
Definition: USpinOrbitalBasisComponent.hpp:108
_ExpansionScalar ExpansionScalar
Definition: USpinOrbitalBasisComponent.hpp:45
Definition: UTransformationComponent.hpp:41
Definition: BaseOneElectronIntegralBuffer.hpp:25
typename std::enable_if< B, T >::type enable_if_t
Definition: type_traits.hpp:37
decltype(std::declval< T >() *std::declval< U >()) product_t
Definition: aliases.hpp:35
@ xz
Definition: DyadicCartesianDirection.hpp:30
@ yy
Definition: DyadicCartesianDirection.hpp:32
@ xy
Definition: DyadicCartesianDirection.hpp:29
@ xx
Definition: DyadicCartesianDirection.hpp:28
@ yz
Definition: DyadicCartesianDirection.hpp:33
@ zz
Definition: DyadicCartesianDirection.hpp:36
@ z
Definition: CartesianDirection.hpp:30
@ x
Definition: CartesianDirection.hpp:28
@ y
Definition: CartesianDirection.hpp:29
Definition: BasisTransformable.hpp:37
Definition: JacobiRotatable.hpp:37
Definition: SimpleSpinorBasis.hpp:38