GQCP
Loading...
Searching...
No Matches
G2DM.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
26
27
28namespace GQCP {
29
30
31/*
32 * MARK: G2DM implementation
33 */
34
40template <typename _Scalar>
41class G2DM:
42 public Simple2DM<_Scalar, G2DM<_Scalar>> {
43public:
44 // The scalar type used for a density matrix element: real or complex.
45 using Scalar = _Scalar;
46
47public:
48 /*
49 * MARK: Constructors
50 */
51
52 // Inherit `Simple2DM`'s constructors.
54
55
64
65 // Prepare some variables.
66 const auto& d_aaaa = d.alphaAlpha().tensor();
67 const auto& d_aabb = d.alphaBeta().tensor();
68 const auto& d_bbaa = d.betaAlpha().tensor();
69 const auto& d_bbbb = d.betaBeta().tensor();
70
71 // The goal in this named constructor is to build up the general density matrix from the spin-resolved ones.
72 const auto K = d_aaaa.dimension(); // Assume that aaaa, aabb, bbaa and bbbb have the same number of orbitals.
73 const auto M = 2 * K;
75
76 // Primed indices are indices in the larger representation, normal ones are those in the smaller tensors.
77 for (size_t mu_ = 0; mu_ < M; mu_++) { // mu 'prime'
78 const size_t mu = mu_ % K;
79
80 for (size_t nu_ = 0; nu_ < M; nu_++) { // nu 'prime'
81 const size_t nu = nu_ % K;
82
83 for (size_t rho_ = 0; rho_ < M; rho_++) { // rho 'prime'
84 const size_t rho = rho_ % K;
85
86 for (size_t lambda_ = 0; lambda_ < M; lambda_++) { // lambda 'prime'
87 const size_t lambda = lambda_ % K;
88
89 if ((mu_ < K) && (nu_ < K) && (rho_ < K) && (lambda_ < K)) {
90 d_generalized(mu_, nu_, rho_, lambda_) = d_aaaa(mu, nu, rho, lambda);
91 } else if ((mu_ < K) && (nu_ < K) && (rho_ >= K) && (lambda_ >= K)) {
92 d_generalized(mu_, nu_, rho_, lambda_) = d_aabb(mu, nu, rho, lambda);
93 } else if ((mu_ >= K) && (nu_ >= K) && (rho_ < K) && (lambda_ < K)) {
94 d_generalized(mu_, nu_, rho_, lambda_) = d_bbaa(mu, nu, rho, lambda);
95 } else if ((mu_ >= K) && (nu_ >= K) && (rho_ >= K) && (lambda_ >= K)) {
96 d_generalized(mu_, nu_, rho_, lambda_) = d_bbbb(mu, nu, rho, lambda);
97 }
98 }
99 }
100 }
101 }
102
103 return G2DM<Scalar> {d_generalized};
104 }
105};
106
107
108/*
109 * MARK: `DensityMatrixTraits`
110 */
111
115template <typename Scalar>
116struct DensityMatrixTraits<G2DM<Scalar>> {
117
118 // The type of transformation that is naturally related to a `G2DM`.
120
121 // The type of the one-electron density matrix that is naturally related to a `G2DM`.
123};
124
125
126/*
127 * MARK: `BasisTransformableTraits`
128 */
129
133template <typename Scalar>
135
136 // The type of transformation that is naturally related to a `G2DM`.
138};
139
140
141/*
142 * MARK: `JacobiRotatableTraits`
143 */
144
148template <typename Scalar>
150
151 // The type of Jacobi rotation that is naturally related to a `G2DM`.
153};
154
155
156} // namespace GQCP
const Mixed & betaAlpha() const
Definition: DoublySpinResolvedBase.hpp:112
const Mixed & alphaBeta() const
Definition: DoublySpinResolvedBase.hpp:102
const Pure & alphaAlpha() const
Definition: DoublySpinResolvedBase.hpp:92
const Pure & betaBeta() const
Definition: DoublySpinResolvedBase.hpp:122
Definition: G1DM.hpp:41
Definition: G2DM.hpp:42
static G2DM< Scalar > FromSpinResolved(const SpinResolved2DM< Scalar > &d)
Definition: G2DM.hpp:63
_Scalar Scalar
Definition: G2DM.hpp:45
Definition: JacobiRotation.hpp:33
const SquareRankFourTensor< Scalar > & tensor() const
Definition: MixedSpinResolved2DMComponent.hpp:79
Definition: Simple2DM.hpp:47
Simple2DM()
Definition: Simple2DM.hpp:87
const SquareRankFourTensor< Scalar > & tensor() const
Definition: Simple2DM.hpp:98
Definition: SpinResolved2DM.hpp:44
Definition: SquareRankFourTensor.hpp:36
size_t dimension() const
Definition: SquareRankFourTensor.hpp:209
static Self Zero(const size_t dim)
Definition: SquareRankFourTensor.hpp:147
Definition: BaseOneElectronIntegralBuffer.hpp:25
Definition: BasisTransformable.hpp:37
Definition: DensityMatrixTraits.hpp:28
Definition: JacobiRotatable.hpp:37