24 #ifndef COM_DAFER45_TBTK_SELF_ENERGY_CALCULATOR
25 #define COM_DAFER45_TBTK_SELF_ENERGY_CALCULATOR
27 #include "TBTK/BrillouinZone.h"
29 #include "TBTK/RPA/ElectronFluctuationVertexCalculator.h"
33 class SelfEnergyCalculator{
37 const RPA::MomentumSpaceContext &momentumSpaceContext,
38 unsigned int numWorkers
42 ~SelfEnergyCalculator();
45 const RPA::MomentumSpaceContext& getMomentumSpaceContext()
const;
55 void setNumSummationEnergies(
unsigned int numSummationEnergies);
65 void setSelfEnergyEnergies(
66 const std::vector<std::complex<double>> &selfEnergyEnergies
70 std::vector<std::complex<double>> calculateSelfEnergy(
71 const std::vector<double> &k,
72 const std::vector<int> &orbitalIndices
76 std::vector<std::complex<double>> calculateSelfEnergySelfConsistently(
77 unsigned int numMatsubaraFrequencies
81 void setU(std::complex<double> U);
84 void setUp(std::complex<double> Up);
87 void setJ(std::complex<double> J);
90 void setJp(std::complex<double> Jp);
96 void saveSusceptibilities(
const std::string &filename)
const;
99 void loadSusceptibilities(
const std::string &filename);
102 std::vector<ElectronFluctuationVertexCalculator*> electronFluctuationVertexCalculators;
105 int *kMinusQLookupTable;
109 void generateKMinusQLookupTable();
112 template<
bool useKPlusKLookupTable>
113 int getKMinusQLinearIndex(
114 unsigned int meshIndex,
115 const std::vector<double> &k,
120 unsigned int numSummationEnergies;
123 std::vector<std::complex<double>> summationEnergies;
129 std::vector<std::complex<double>> selfEnergyEnergies;
135 IndexedDataTree<SerializableVector<std::complex<double>>> selfEnergyTree;
138 template<
bool singleSelfEnergyEnergy>
139 void selfEnergyMainLoop(
140 const std::vector<double> &k,
141 const std::vector<int> &orbitalIndices,
142 std::vector<std::complex<double>> &result
146 std::complex<double> U, Up, J, Jp;
149 inline const RPA::MomentumSpaceContext& SelfEnergyCalculator::getMomentumSpaceContext(
151 return electronFluctuationVertexCalculators[0]->getMomentumSpaceContext();
154 inline void SelfEnergyCalculator::setNumSummationEnergies(
155 unsigned int numSummationEnergies
157 this->numSummationEnergies = numSummationEnergies;
171 inline void SelfEnergyCalculator::setSelfEnergyEnergies(
172 const std::vector<std::complex<double>> &selfEnergyEnergies
174 this->selfEnergyEnergies = selfEnergyEnergies;
175 selfEnergyTree.clear();
178 inline void SelfEnergyCalculator::setU(std::complex<double> U){
183 n < electronFluctuationVertexCalculators.size();
186 electronFluctuationVertexCalculators[n]->setU(U);
189 selfEnergyTree.clear();
192 inline void SelfEnergyCalculator::setUp(std::complex<double> Up){
197 n < electronFluctuationVertexCalculators.size();
200 electronFluctuationVertexCalculators[n]->setUp(Up);
203 selfEnergyTree.clear();
206 inline void SelfEnergyCalculator::setJ(std::complex<double> J){
211 n < electronFluctuationVertexCalculators.size();
214 electronFluctuationVertexCalculators[n]->setJ(J);
217 selfEnergyTree.clear();
220 inline void SelfEnergyCalculator::setJp(std::complex<double> Jp){
225 n < electronFluctuationVertexCalculators.size();
228 electronFluctuationVertexCalculators[n]->setJp(Jp);
231 selfEnergyTree.clear();
240 inline void SelfEnergyCalculator::saveSusceptibilities(
241 const std::string &filename
243 size_t lastPos = filename.find_last_of(
'/');
245 std::string fname = filename;
246 if(lastPos != std::string::npos){
247 path = filename.substr(0, lastPos+1);
248 fname = filename.substr(lastPos+1, filename.size());
253 n < electronFluctuationVertexCalculators.size();
256 electronFluctuationVertexCalculators[n]->saveSusceptibilities(
257 path +
"Slice" + std::to_string(n) +
"_" + fname
262 inline void SelfEnergyCalculator::loadSusceptibilities(
263 const std::string &filename
265 size_t lastPos = filename.find_last_of(
'/');
267 std::string fname = filename;
268 if(lastPos != std::string::npos){
269 path = filename.substr(0, lastPos+1);
270 fname = filename.substr(lastPos+1, filename.size());
275 n < electronFluctuationVertexCalculators.size();
278 electronFluctuationVertexCalculators[n]->loadSusceptibilities(
279 path +
"Slice" + std::to_string(n) +
"_" + fname