GQCP
Loading...
Searching...
No Matches
OrbitalSpace.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#include <cstdlib>
26#include <map>
27#include <string>
28#include <vector>
29
30
31namespace GQCP {
32
33
41private:
42 std::vector<size_t> occupied_indices; // the indices of the orbitals that are considered occupied by the electrons
43 std::vector<size_t> active_indices; // the indices of the orbitals that are considered 'active', i.e. those spinor indices that are occupied in some set of configurations but not in others
44 std::vector<size_t> virtual_indices; // the indices of the orbitals that are considered virtual (i.e. unoccupied) by the electrons
45
46 std::vector<size_t> all_indices;
47
48
49public:
50 // CONSTRUCTORS
51
59 OrbitalSpace(const std::vector<size_t>& occupied_indices, const std::vector<size_t>& active_indices, const std::vector<size_t>& virtual_indices);
60
69 OrbitalSpace(const std::vector<size_t>& occupied_indices, const std::vector<size_t>& virtual_indices);
70
71
72 // NAMED CONSTRUCTORS
73
81 static OrbitalSpace Implicit(const std::map<OccupationType, size_t>& occupation_type_numbers);
82
83
84 // PUBLIC METHODS
85
101 template <typename Scalar>
103
104 // Prepare the necessary members for ImplicitMatrixSlice.
105 const auto row_indices = this->indices(row_type);
106 const auto column_indices = this->indices(column_type);
107
108 return ImplicitMatrixSlice<Scalar>::FromIndices(row_indices, column_indices, M);
109 }
110
111
129 template <typename Scalar>
130 ImplicitRankFourTensorSlice<Scalar> createRepresentableObjectFor(const OccupationType axis1_type, const OccupationType axis2_type, const OccupationType axis3_type, const OccupationType axis4_type, const Tensor<Scalar, 4>& T) const {
131
132 // Prepare the necessary members for ImplicitRankFourTensor.
133 const auto axis1_indices = this->indices(axis1_type);
134 const auto axis2_indices = this->indices(axis2_type);
135 const auto axis3_indices = this->indices(axis3_type);
136 const auto axis4_indices = this->indices(axis4_type);
137
138 return ImplicitRankFourTensorSlice<Scalar>::FromIndices(axis1_indices, axis2_indices, axis3_indices, axis4_indices, T);
139 }
140
141
145 std::string description() const;
146
150 const std::vector<size_t>& indices() const { return this->all_indices; }
151
157 const std::vector<size_t>& indices(const OccupationType type) const;
158
172 template <typename Scalar>
174
175 // Prepare the necessary members for the other method.
176 const auto rows = this->numberOfOrbitals(row_type);
177 const auto columns = this->numberOfOrbitals(column_type);
178
179 const MatrixX<Scalar> M = MatrixX<Scalar>::Zero(rows, columns);
180
181 return this->createRepresentableObjectFor<Scalar>(row_type, column_type, M);
182 }
183
184
200 template <typename Scalar>
201 ImplicitRankFourTensorSlice<Scalar> initializeRepresentableObjectFor(const OccupationType axis1_type, const OccupationType axis2_type, const OccupationType axis3_type, const OccupationType axis4_type) const {
202
203 // Prepare the necessary members for the other method.
204 const auto axis1_dimension = static_cast<long>(this->numberOfOrbitals(axis1_type)); // need static_cast for Tensor
205 const auto axis2_dimension = static_cast<long>(this->numberOfOrbitals(axis2_type));
206 const auto axis3_dimension = static_cast<long>(this->numberOfOrbitals(axis3_type));
207 const auto axis4_dimension = static_cast<long>(this->numberOfOrbitals(axis4_type));
208
209 Tensor<Scalar, 4> T {axis1_dimension, axis2_dimension, axis3_dimension, axis4_dimension};
210 T.setZero();
211
212 return this->createRepresentableObjectFor(axis1_type, axis2_type, axis3_type, axis4_type, T);
213 }
214
215
222 bool isIndex(const OccupationType type, const size_t p) const;
223
230 size_t numberOfExcitations(const OccupationType from, const OccupationType to) const;
231
235 size_t numberOfOrbitals() const { return this->indices().size(); }
236
242 size_t numberOfOrbitals(const OccupationType type) const { return this->indices(type).size(); }
243};
244
245
246} // namespace GQCP
Definition: ImplicitMatrixSlice.hpp:38
static ImplicitMatrixSlice< Scalar > FromIndices(const std::vector< size_t > &row_indices, const std::vector< size_t > &col_indices, const MatrixX< Scalar > &M)
Definition: ImplicitMatrixSlice.hpp:134
Definition: ImplicitRankFourTensorSlice.hpp:38
static ImplicitRankFourTensorSlice< Scalar > FromIndices(const std::vector< std::vector< size_t > > &axes_indices, const Tensor< Scalar, 4 > &T)
Definition: ImplicitRankFourTensorSlice.hpp:128
Definition: Matrix.hpp:47
Definition: OrbitalSpace.hpp:40
const std::vector< size_t > & indices() const
Definition: OrbitalSpace.hpp:150
size_t numberOfExcitations(const OccupationType from, const OccupationType to) const
Definition: OrbitalSpace.cpp:187
ImplicitRankFourTensorSlice< Scalar > createRepresentableObjectFor(const OccupationType axis1_type, const OccupationType axis2_type, const OccupationType axis3_type, const OccupationType axis4_type, const Tensor< Scalar, 4 > &T) const
Definition: OrbitalSpace.hpp:130
static OrbitalSpace Implicit(const std::map< OccupationType, size_t > &occupation_type_numbers)
Definition: OrbitalSpace.cpp:74
size_t numberOfOrbitals(const OccupationType type) const
Definition: OrbitalSpace.hpp:242
ImplicitMatrixSlice< Scalar > initializeRepresentableObjectFor(const OccupationType row_type, const OccupationType column_type) const
Definition: OrbitalSpace.hpp:173
ImplicitRankFourTensorSlice< Scalar > initializeRepresentableObjectFor(const OccupationType axis1_type, const OccupationType axis2_type, const OccupationType axis3_type, const OccupationType axis4_type) const
Definition: OrbitalSpace.hpp:201
size_t numberOfOrbitals() const
Definition: OrbitalSpace.hpp:235
bool isIndex(const OccupationType type, const size_t p) const
Definition: OrbitalSpace.cpp:174
ImplicitMatrixSlice< Scalar > createRepresentableObjectFor(const OccupationType row_type, const OccupationType column_type, const MatrixX< Scalar > &M) const
Definition: OrbitalSpace.hpp:102
std::string description() const
Definition: OrbitalSpace.cpp:119
Definition: Tensor.hpp:46
Definition: BaseOneElectronIntegralBuffer.hpp:25
OccupationType
Definition: OccupationType.hpp:29