24 #ifndef COM_DAFER45_TBTK_RPA_MOMENTUM_SPACE_CONTEXT
25 #define COM_DAFER45_TBTK_RPA_MOMENTUM_SPACE_CONTEXT
27 #include "TBTK/BrillouinZone.h"
28 #include "TBTK/Solver/BlockDiagonalizer.h"
34 class MomentumSpaceContext{
37 MomentumSpaceContext();
40 ~MomentumSpaceContext();
43 void setModel(Model &model);
46 const Model& getModel()
const;
49 void setBrillouinZone(
const BrillouinZone &brillouinZone);
52 const BrillouinZone& getBrillouinZone()
const;
55 void setNumMeshPoints(
const std::vector<unsigned int> &numMeshPoints);
58 const std::vector<unsigned int>& getNumMeshPoints()
const;
61 const std::vector<std::vector<double>>& getMesh()
const;
64 void setNumOrbitals(
unsigned int numOrbitals);
67 unsigned int getNumOrbitals()
const;
73 double getEnergy(
unsigned int state)
const;
76 double getEnergy(
unsigned int block,
unsigned int state)
const;
79 std::complex<double> getAmplitude(
82 unsigned int amplitude
86 Index getKIndex(
const std::vector<double> &k)
const;
89 const PropertyExtractor::BlockDiagonalizer& getPropertyExtractorBlockDiagonalizer()
const;
95 const BrillouinZone *brillouinZone;
98 std::vector<unsigned int> numMeshPoints;
101 std::vector<std::vector<double>> mesh;
104 unsigned int numOrbitals;
107 Solver::BlockDiagonalizer solver;
110 PropertyExtractor::BlockDiagonalizer *propertyExtractor;
116 std::complex<double> *amplitudes;
124 inline void MomentumSpaceContext::setModel(Model &model){
125 this->model = &model;
127 isInitialized =
false;
130 inline const Model& MomentumSpaceContext::getModel()
const{
134 inline void MomentumSpaceContext::setBrillouinZone(
135 const BrillouinZone &brillouinZone
137 this->brillouinZone = &brillouinZone;
139 isInitialized =
false;
142 inline const BrillouinZone& MomentumSpaceContext::getBrillouinZone()
const{
143 return *brillouinZone;
146 inline void MomentumSpaceContext::setNumMeshPoints(
147 const std::vector<unsigned int> &numMeshPoints
149 this->numMeshPoints = numMeshPoints;
151 brillouinZone !=
nullptr,
152 "MomentumSpaceContext::setNumMeshPoints()",
153 "BrillouinZone not set.",
154 "First set the BrillouinZone using"
155 <<
" MomentumSpaceContext::setBrillouinZone()"
157 mesh = brillouinZone->getMinorMesh(numMeshPoints);
159 isInitialized =
false;
162 inline const std::vector<unsigned int>& MomentumSpaceContext::getNumMeshPoints(
164 return numMeshPoints;
167 inline const std::vector<std::vector<double>>& MomentumSpaceContext::getMesh(
172 inline void MomentumSpaceContext::setNumOrbitals(
unsigned int numOrbitals){
173 this->numOrbitals = numOrbitals;
175 isInitialized =
false;
178 inline unsigned int MomentumSpaceContext::getNumOrbitals()
const{
182 inline double MomentumSpaceContext::getEnergy(
unsigned int state)
const{
183 return energies[state];
186 inline double MomentumSpaceContext::getEnergy(
190 return energies[block*numOrbitals + state];
193 inline std::complex<double> MomentumSpaceContext::getAmplitude(
196 unsigned int amplitude
198 return amplitudes[numOrbitals*(numOrbitals*block + state) + amplitude];
201 inline Index MomentumSpaceContext::getKIndex(
202 const std::vector<double> &k
204 return brillouinZone->getMinorCellIndex(
210 inline const PropertyExtractor::BlockDiagonalizer& MomentumSpaceContext::getPropertyExtractorBlockDiagonalizer(
212 return *propertyExtractor;