GQCP
Loading...
Searching...
No Matches
SpinResolved1DM.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
39template <typename _Scalar>
41 public SpinResolvedBase<SpinResolved1DMComponent<_Scalar>, SpinResolved1DM<_Scalar>>,
42 public SpinResolvedBasisTransformable<SpinResolved1DM<_Scalar>>,
43 public SpinResolvedJacobiRotatable<SpinResolved1DM<_Scalar>>,
44 public VectorSpaceArithmetic<SpinResolved1DM<_Scalar>, _Scalar> {
45public:
46 // The scalar type of one of the density matrix elements: real or complex.
47 using Scalar = _Scalar;
48
49 // The type of the transformation that is naturally related to a `SpinResolved1DM`.
51
52 // The type of 'this'.
54
55 // The type component this spin resolved object is made of.
57
58
59public:
60 /*
61 * MARK: Constructors
62 */
63
64 // Inherit `SpinResolvedBase`'s constructors.
66
67
68 /*
69 * MARK: Named constructors
70 */
71
80
81 const SpinResolved1DMComponent<Scalar> D_half {(D / 2).matrix()};
82 return SpinResolved1DM<Scalar>(D_half, D_half);
83 }
84
85
86 /*
87 * MARK: General information
88 */
89
93 double norm() const {
94
95 // Determine the dimensions of the generalized, spin-blocked 1-DM.
96 const auto K_alpha = this->alpha().numberOfOrbitals();
97 const auto K_beta = this->beta().numberOfOrbitals();
98 const auto M = K_alpha + K_beta;
99
100 // The generalized 1-DM contains the alpha part in the top-left corner, and the beta part in the bottom right corner.
102 D_generalized.topLeftCorner(K_alpha, K_alpha) = this->alpha().matrix();
103 D_generalized.bottomRightCorner(K_beta, K_beta) = this->beta().matrix();
104
105 return D_generalized.norm();
106 }
107
113 size_t numberOfOrbitals(const Spin sigma) const { return this->component(sigma).numberOfOrbitals(); }
114
115
116 /*
117 * MARK: Spin-related operations
118 */
119
124 return SpinDensity1DM<Scalar> {(this->alpha() - this->beta()).matrix()};
125 }
126
131 return Orbital1DM<Scalar> {(this->alpha() + this->beta()).matrix()};
132 }
133
134
135 /*
136 * MARK: Conforming to `VectorSpaceArithmetic`
137 */
138
142 Self& operator+=(const Self& rhs) override {
143
144 // For addition, the alpha- and beta-parts should be added component-wise.
145 this->alpha() += rhs.alpha();
146 this->beta() += rhs.beta();
147
148 return *this;
149 }
150
154 Self& operator*=(const Scalar& a) override {
155
156 // For scalar multiplication, the alpha- and beta-parts should be multiplied with the scalar.
157 this->alpha() *= a;
158 this->beta() *= a;
159
160 return *this;
161 }
162
163
168 // Since `rotate` and `rotated` are both defined in `SpinResolvedBasisTransformable` and `SpinResolvedJacobiRotatable`, we have to explicitly enable these methods here.
169
170 // Allow the `rotate` method from `SpinResolvedBasisTransformable`, since there's also a `rotate` from `SpinResolvedJacobiRotatable`.
172
173 // Allow the `rotated` method from `SpinResolvedBasisTransformable`, since there's also a `rotated` from `SpinResolvedJacobiRotatable`.
175
176 // Allow the `rotate` method from `SpinResolvedJacobiRotatable`, since there's also a `rotate` from `SpinResolvedBasisTransformable`.
178
179 // Allow the `rotated` method from `SpinResolvedJacobiRotatable`, since there's also a `rotated` from `SpinResolvedBasisTransformable`.
181};
182
183
184/*
185 * MARK: BasisTransformableTraits
186 */
187
191template <typename Scalar>
193
194 // The type of the transformation that is naturally related to a `SpinResolved1DM`.
196};
197
198
199/*
200 * MARK: JacobiRotatableTraits
201 */
202
206template <typename Scalar>
208
209 // The type of Jacobi rotation for which the Jacobi rotation should be defined.
211};
212
213
214} // namespace GQCP
void rotate(const Transformation &U)
Definition: BasisTransformable.hpp:107
Definition: Orbital1DM.hpp:42
size_t numberOfOrbitals() const
Definition: Simple1DM.hpp:111
const SquareMatrix< Scalar > & matrix() const
Definition: Simple1DM.hpp:96
Definition: SpinDensity1DM.hpp:42
Definition: SpinResolved1DMComponent.hpp:41
Definition: SpinResolved1DM.hpp:44
typename SpinResolvedBase< SpinResolved1DMComponent< Scalar >, Self >::Of ComponentType
Definition: SpinResolved1DM.hpp:56
size_t numberOfOrbitals(const Spin sigma) const
Definition: SpinResolved1DM.hpp:113
_Scalar Scalar
Definition: SpinResolved1DM.hpp:47
Self & operator*=(const Scalar &a) override
Definition: SpinResolved1DM.hpp:154
SpinDensity1DM< Scalar > spinDensity() const
Definition: SpinResolved1DM.hpp:123
static SpinResolved1DM< Scalar > FromOrbital1DM(const Orbital1DM< Scalar > &D)
Definition: SpinResolved1DM.hpp:79
Orbital1DM< Scalar > orbitalDensity() const
Definition: SpinResolved1DM.hpp:130
Self & operator+=(const Self &rhs) override
Definition: SpinResolved1DM.hpp:142
double norm() const
Definition: SpinResolved1DM.hpp:93
SpinResolved1DM< Scalar > Self
Definition: SpinResolved1DM.hpp:53
Definition: SpinResolvedBase.hpp:39
SpinResolved1DMComponent< _Scalar > Of
Definition: SpinResolvedBase.hpp:42
const Of & component(const Spin sigma) const
Definition: SpinResolvedBase.hpp:154
Definition: SpinResolvedBasisTransformable.hpp:34
Definition: SpinResolvedJacobiRotatable.hpp:35
SpinResolved1DM< _Scalar > rotated(const JacobiRotationType &jacobi_rotation) const override
Definition: SpinResolvedJacobiRotatable.hpp:54
Definition: SquareMatrix.hpp:39
static Self Zero(const size_t dim)
Definition: SquareMatrix.hpp:289
Definition: UJacobiRotation.hpp:32
Definition: VectorSpaceArithmetic.hpp:35
Definition: BaseOneElectronIntegralBuffer.hpp:25
Spin
Definition: Spin.hpp:27
Definition: BasisTransformable.hpp:37
Definition: JacobiRotatable.hpp:37