TBTK
ElectronFluctuationVertexCalculator.h
1 /* Copyright 2017 Kristofer Bj√∂rnson
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
23 #ifndef COM_DAFER45_TBTK_ELECTRON_FLUCTUATION_VERTEX_CALCULATOR
24 #define COM_DAFER45_TBTK_ELECTRON_FLUCTUATION_VERTEX_CALCULATOR
25 
26 #include "TBTK/BrillouinZone.h"
27 #include "TBTK/IndexedDataTree.h"
28 #include "TBTK/RPA/RPASusceptibilityCalculator.h"
29 
30 namespace TBTK{
31 
33 public:
36  const MomentumSpaceContext &momentumSpaceContext
37  );
38 
41 
46 
49 
52  enum class EnergyType {Real, Imaginary, Complex};
53 
55  void setEnergyType(EnergyType energyType);
56 
58  EnergyType getEnergyType() const;
59 
62  void setEnergies(
63  const std::vector<std::complex<double>> &energies
64  );
65 
75  bool energiesAreInversionSymmetric
76  );
77 
80 
82  std::vector<std::complex<double>> calculateSelfEnergyVertex(
83  const std::vector<double> &k,
84  const std::vector<int> &orbitalIndices
85  );
86 
88  void setU(std::complex<double> U);
89 
91  void setUp(std::complex<double> Up);
92 
94  void setJ(std::complex<double> J);
95 
97  void setJp(std::complex<double> Jp);
98 
102 
104  void saveSusceptibilities(const std::string &filename) const;
105 
107  void loadSusceptibilities(const std::string &filename);
108 private:
110  RPASusceptibilityCalculator *rpaSusceptibilityCalculator;
111 
113  EnergyType energyType;
114 
116  std::vector<std::complex<double>> energies;
117 
119  bool isInitialized;
120 
123 
125  std::complex<double> U, Up, J, Jp;
126 
128  std::vector<InteractionAmplitude> u1;
129  std::vector<InteractionAmplitude> u2;
130  std::vector<InteractionAmplitude> u3;
131 
134  bool interactionAmplitudesAreGenerated;
135 
138  RPASusceptibilityCalculator &rpaSusceptibilityCalculator
139  );
140 };
141 
143 ) const{
144  return rpaSusceptibilityCalculator->getMomentumSpaceContext();
145 }
146 
148  EnergyType energyType
149 ){
150  this->energyType = energyType;
151  switch(energyType){
152  case EnergyType::Real:
153  rpaSusceptibilityCalculator->setEnergyType(
154  RPASusceptibilityCalculator::EnergyType::Real
155  );
156  break;
157  case EnergyType::Imaginary:
158  rpaSusceptibilityCalculator->setEnergyType(
159  RPASusceptibilityCalculator::EnergyType::Imaginary
160  );
161  break;
162  case EnergyType::Complex:
163  rpaSusceptibilityCalculator->setEnergyType(
164  RPASusceptibilityCalculator::EnergyType::Complex
165  );
166  break;
167  default:
168  TBTKExit(
169  "ElectronFluctuationVertexCalculator::setEnergyType()",
170  "Unknown energy type.",
171  "This should never happen, contact the developer."
172  );
173  }
174 }
175 
177 ) const{
178  return energyType;
179 }
180 
182  const std::vector<std::complex<double>> &energies
183 ){
184  this->energies = energies;
185  vertexTree.clear();
186 
187  rpaSusceptibilityCalculator->setEnergies(energies);
188 }
189 
191  bool energiesAreInversionSymmetric
192 ){
193  rpaSusceptibilityCalculator->setEnergiesAreInversionSymmetric(
194  energiesAreInversionSymmetric
195  );
196 }
197 
199 ) const{
200  return rpaSusceptibilityCalculator->getEnergiesAreInversionSymmetric();
201 }
202 
203 inline void ElectronFluctuationVertexCalculator::setU(std::complex<double> U){
204  this->U = U;
205  rpaSusceptibilityCalculator->setU(U);
206  vertexTree.clear();
207  interactionAmplitudesAreGenerated = false;
208 }
209 
210 inline void ElectronFluctuationVertexCalculator::setUp(std::complex<double> Up){
211  this->Up = Up;
212  rpaSusceptibilityCalculator->setUp(Up);
213  vertexTree.clear();
214  interactionAmplitudesAreGenerated = false;
215 }
216 
217 inline void ElectronFluctuationVertexCalculator::setJ(std::complex<double> J){
218  this->J = J;
219  rpaSusceptibilityCalculator->setJ(J);
220  vertexTree.clear();
221  interactionAmplitudesAreGenerated = false;
222 }
223 
224 inline void ElectronFluctuationVertexCalculator::setJp(std::complex<double> Jp){
225  this->Jp = Jp;
226  rpaSusceptibilityCalculator->setJp(Jp);
227  vertexTree.clear();
228  interactionAmplitudesAreGenerated = false;
229 }
230 
232  const std::string &filename
233 ) const{
234  rpaSusceptibilityCalculator->saveSusceptibilities(filename);
235 }
236 
238  const std::string &filename
239 ){
240  rpaSusceptibilityCalculator->loadSusceptibilities(filename);
241 }
242 
243 }; //End of namespace TBTK
244 
245 #endif
void setUp(std::complex< double > Up)
Definition: ElectronFluctuationVertexCalculator.h:210
Definition: RPASusceptibilityCalculator.h:38
void setEnergyType(EnergyType energyType)
Definition: ElectronFluctuationVertexCalculator.h:147
void setU(std::complex< double > U)
Definition: ElectronFluctuationVertexCalculator.h:203
Brillouin zone.
bool getEnergiesAreInversionSymmetric() const
Definition: ElectronFluctuationVertexCalculator.h:198
Data structure for storing data associated with an index.
void loadSusceptibilities(const std::string &filename)
Definition: ElectronFluctuationVertexCalculator.h:237
Definition: ElectronFluctuationVertexCalculator.h:32
void setEnergiesAreInversionSymmetric(bool energiesAreInversionSymmetric)
Definition: ElectronFluctuationVertexCalculator.h:190
Definition: IndexedDataTree.h:38
ElectronFluctuationVertexCalculator(const MomentumSpaceContext &momentumSpaceContext)
Definition: MomentumSpaceContext.h:32
void setJ(std::complex< double > J)
Definition: ElectronFluctuationVertexCalculator.h:217
ElectronFluctuationVertexCalculator * createSlave()
void setJp(std::complex< double > Jp)
Definition: ElectronFluctuationVertexCalculator.h:224
Definition: ModelFactory.h:35
void saveSusceptibilities(const std::string &filename) const
Definition: ElectronFluctuationVertexCalculator.h:231
EnergyType getEnergyType() const
Definition: ElectronFluctuationVertexCalculator.h:176
EnergyType
Definition: ElectronFluctuationVertexCalculator.h:52
void setEnergies(const std::vector< std::complex< double >> &energies)
Definition: ElectronFluctuationVertexCalculator.h:181
std::vector< std::complex< double > > calculateSelfEnergyVertex(const std::vector< double > &k, const std::vector< int > &orbitalIndices)
const MomentumSpaceContext & getMomentumSpaceContext() const
Definition: ElectronFluctuationVertexCalculator.h:142