GQCP
Loading...
Searching...
No Matches
SimpleOrbitalRotationGenerators.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
24
25
26namespace GQCP {
27
28
41template <typename _Scalar, typename _DerivedOrbitalRotationGenerators>
43
44public:
45 // The scalar type used for an orbital rotation generator: real or complex.
46 using Scalar = _Scalar;
47
48 // The type of the orbital rotation generator that derives from this class, enabling CRTP and compile-time polymorphism.
49 using DerivedOrbitalRotationGenerators = _DerivedOrbitalRotationGenerators;
50
51private:
52 // The number of orbitals (spinors for the general(ized) case, spin-orbitals for the restricted and unrestricted case) that can be rotated using these orbital rotation generators.
53 size_t number_of_orbitals;
54
55 // The strict lower triangle of the kappa matrix. The entries of the matrix are stored in a `column major`format in this vector.
57
58
59public:
70 v {v},
71 number_of_orbitals {strictTriangularRootOf(v.size())} {}
72
73
80
81 SimpleOrbitalRotationGenerators(kappa.pairWiseStrictReduced()) {
82 if (!kappa.isAntiHermitian()) {
83 throw std::invalid_argument("SimpleOrbitalRotationGenerators(const SquareMatrix<Scalar>& kappa): The given kappa matrix is not anti-Hermitian.");
84 }
85 }
86
87
102 static DerivedOrbitalRotationGenerators FromOccupationTypes(const DerivedOrbitalRotationGenerators& generators, const OccupationType row_occupation_type, const OccupationType column_occupation_type, const size_t K) {
103 if (row_occupation_type != column_occupation_type) {
104 throw std::invalid_argument("SimpleOrbitalRotationGenerators::FromOccupationTypes(const DerivedOrbitalRotationGenerators& generators, const OccupationType row_occupation_type, const OccupationType column_occupation_type, const size_t K): Occupied/virtual and virtual/occupied rotations are currently disabled. The row and column occupation types should be the same.");
105 }
106
107 // The total number of orbitals determines the size of the total kappa matrix.
109
110 // Depending on the row and column occupation types, we fill in the correct block of the total kappa matrix and leave the rest to be zero.
111 if (row_occupation_type == OccupationType::k_occupied && column_occupation_type == OccupationType::k_occupied) {
112 kappa.topLeftCorner(generators.numberOfOrbitals(), generators.numberOfOrbitals()) = generators.asMatrix();
113 } else {
114 kappa.bottomRightCorner(generators.numberOfOrbitals(), generators.numberOfOrbitals()) = generators.asMatrix();
115 }
116
118 }
119
120
129
130 const auto kappa = SquareMatrix<Scalar>::FromStrictTriangle(this->v); // Lower triangle only.
131
132 return kappa - kappa.adjoint();
133 }
134
138 const VectorX<Scalar>& asVector() const { return this->v; }
139
140
144 size_t numberOfOrbitals() const { return this->number_of_orbitals; }
145};
146
147
148} // namespace GQCP
Definition: Matrix.hpp:47
Definition: SimpleOrbitalRotationGenerators.hpp:42
_Scalar Scalar
Definition: SimpleOrbitalRotationGenerators.hpp:46
_DerivedOrbitalRotationGenerators DerivedOrbitalRotationGenerators
Definition: SimpleOrbitalRotationGenerators.hpp:49
size_t numberOfOrbitals() const
Definition: SimpleOrbitalRotationGenerators.hpp:144
static DerivedOrbitalRotationGenerators FromOccupationTypes(const DerivedOrbitalRotationGenerators &generators, const OccupationType row_occupation_type, const OccupationType column_occupation_type, const size_t K)
Definition: SimpleOrbitalRotationGenerators.hpp:102
const VectorX< Scalar > & asVector() const
Definition: SimpleOrbitalRotationGenerators.hpp:138
SimpleOrbitalRotationGenerators(const VectorX< Scalar > &v)
Definition: SimpleOrbitalRotationGenerators.hpp:69
SimpleOrbitalRotationGenerators(const SquareMatrix< Scalar > &kappa)
Definition: SimpleOrbitalRotationGenerators.hpp:79
const SquareMatrix< Scalar > asMatrix() const
Definition: SimpleOrbitalRotationGenerators.hpp:128
Definition: SquareMatrix.hpp:39
static Self Zero(const size_t dim)
Definition: SquareMatrix.hpp:289
static Self FromStrictTriangle(const VectorX< Scalar > &v)
Definition: SquareMatrix.hpp:115
bool isAntiHermitian(const double threshold=1.0e-08) const
Definition: SquareMatrix.hpp:317
Definition: BaseOneElectronIntegralBuffer.hpp:25
size_t strictTriangularRootOf(const size_t x)
Definition: miscellaneous.cpp:226
OccupationType
Definition: OccupationType.hpp:29