24 #ifndef COM_DAFER45_TBTK_MATSUBARA_SUSCEPTIBILITY_CALCULATOR
25 #define COM_DAFER45_TBTK_MATSUBARA_SUSCEPTIBILITY_CALCULATOR
27 #include "TBTK/RPA/SusceptibilityCalculator.h"
35 class MatsubaraSusceptibilityCalculator :
public SusceptibilityCalculator{
38 MatsubaraSusceptibilityCalculator(
39 const RPA::MomentumSpaceContext &momentumSpaceContext
43 ~MatsubaraSusceptibilityCalculator();
48 MatsubaraSusceptibilityCalculator* createSlave();
51 std::complex<double> calculateSusceptibility(
52 const std::vector<double> &k,
53 const std::vector<int> &orbitalIndices,
54 std::complex<double> energy
58 std::vector<std::complex<double>> calculateSusceptibility(
59 const DualIndex &kDual,
60 const std::vector<int> &orbitalIndices
64 void setNumSummationEnergies(
unsigned int numSummationEnergies);
67 std::complex<double> *greensFunction;
70 std::vector<std::complex<double>> summationEnergies;
73 MatsubaraSusceptibilityCalculator(
74 const RPA::MomentumSpaceContext &momentumSpaceContext,
75 int *kPlusQLookupTable
79 std::complex<double> calculateSusceptibilityMatsubara(
80 const std::vector<double> &k,
81 const std::vector<int> &orbitalIndices,
82 std::complex<double> energy
86 template<
bool useKPlusQLookupTable>
87 std::vector<std::complex<double>> calculateSusceptibilityMatsubara(
88 const DualIndex &kDual,
89 const std::vector<int> &orbitalIndices
93 void calculateGreensFunction();
96 std::complex<double>& getGreensFunctionValue(
97 unsigned int meshPoint,
98 unsigned int orbital0,
99 unsigned int orbital1,
101 unsigned int numEnergies,
102 unsigned int numOrbitals
106 inline void MatsubaraSusceptibilityCalculator::setNumSummationEnergies(
107 unsigned int numSummationEnergies
110 numSummationEnergies%2 == 1,
111 "MatsubaraSusceptibilityCalculator::setNumSummationEnergies()",
112 "The number of summation energies must be an odd number.",
117 = UnitHandler::convertNaturalToBase<Quantity::Temperature>(
118 getMomentumSpaceContext().getModel().getTemperature()
123 summationEnergies.clear();
124 for(
unsigned int n = 0; n < numSummationEnergies; n++){
125 summationEnergies.push_back(
126 M_PI*(2*(n - numSummationEnergies/2))*kT/hbar
131 if(greensFunction !=
nullptr){
132 delete [] greensFunction;
133 greensFunction =
nullptr;
150 inline std::complex<double>& MatsubaraSusceptibilityCalculator::getGreensFunctionValue(
151 unsigned int meshPoint,
152 unsigned int orbital0,
153 unsigned int orbital1,
155 unsigned int numEnergies,
156 unsigned int numOrbitals
158 return greensFunction[
160 numOrbitals*(numOrbitals*meshPoint + orbital0)