TBTK
Need a break? Support the development by playing Polarity Puzzles
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 
17 
24 #ifndef COM_DAFER45_TBTK_ELECTRON_FLUCTUATION_VERTEX_CALCULATOR
25 #define COM_DAFER45_TBTK_ELECTRON_FLUCTUATION_VERTEX_CALCULATOR
26 
27 #include "TBTK/BrillouinZone.h"
28 #include "TBTK/IndexedDataTree.h"
29 #include "TBTK/RPA/RPASusceptibilityCalculator.h"
30 
31 namespace TBTK{
32 
33 class ElectronFluctuationVertexCalculator{
34 public:
36  ElectronFluctuationVertexCalculator(
37  const RPA::MomentumSpaceContext &momentumSpaceContext
38  );
39 
41  ~ElectronFluctuationVertexCalculator();
42 
46  ElectronFluctuationVertexCalculator* createSlave();
47 
49  const RPA::MomentumSpaceContext& getMomentumSpaceContext() const;
50 
53  enum class EnergyType {Real, Imaginary, Complex};
54 
56  void setEnergyType(EnergyType energyType);
57 
59  EnergyType getEnergyType() const;
60 
63  void setEnergies(
64  const std::vector<std::complex<double>> &energies
65  );
66 
75  void setEnergiesAreInversionSymmetric(
76  bool energiesAreInversionSymmetric
77  );
78 
80  bool getEnergiesAreInversionSymmetric() const;
81 
83  std::vector<std::complex<double>> calculateSelfEnergyVertex(
84  const std::vector<double> &k,
85  const std::vector<int> &orbitalIndices
86  );
87 
89  void setU(std::complex<double> U);
90 
92  void setUp(std::complex<double> Up);
93 
95  void setJ(std::complex<double> J);
96 
98  void setJp(std::complex<double> Jp);
99 
102  void generateInteractionAmplitudes();
103 
105  void saveSusceptibilities(const std::string &filename) const;
106 
108  void loadSusceptibilities(const std::string &filename);
109 private:
111  RPASusceptibilityCalculator *rpaSusceptibilityCalculator;
112 
114  EnergyType energyType;
115 
117  std::vector<std::complex<double>> energies;
118 
120  bool isInitialized;
121 
123  IndexedDataTree<SerializableVector<std::complex<double>>> vertexTree;
124 
126  std::complex<double> U, Up, J, Jp;
127 
129  std::vector<InteractionAmplitude> u1;
130  std::vector<InteractionAmplitude> u2;
131  std::vector<InteractionAmplitude> u3;
132 
135  bool interactionAmplitudesAreGenerated;
136 
138  ElectronFluctuationVertexCalculator(
139  RPASusceptibilityCalculator &rpaSusceptibilityCalculator
140  );
141 };
142 
143 inline const RPA::MomentumSpaceContext& ElectronFluctuationVertexCalculator::getMomentumSpaceContext(
144 ) const{
145  return rpaSusceptibilityCalculator->getMomentumSpaceContext();
146 }
147 
148 inline void ElectronFluctuationVertexCalculator::setEnergyType(
149  EnergyType energyType
150 ){
151  this->energyType = energyType;
152  switch(energyType){
153  case EnergyType::Real:
154  rpaSusceptibilityCalculator->setEnergyType(
155  RPASusceptibilityCalculator::EnergyType::Real
156  );
157  break;
158  case EnergyType::Imaginary:
159  rpaSusceptibilityCalculator->setEnergyType(
160  RPASusceptibilityCalculator::EnergyType::Imaginary
161  );
162  break;
163  case EnergyType::Complex:
164  rpaSusceptibilityCalculator->setEnergyType(
165  RPASusceptibilityCalculator::EnergyType::Complex
166  );
167  break;
168  default:
169  TBTKExit(
170  "ElectronFluctuationVertexCalculator::setEnergyType()",
171  "Unknown energy type.",
172  "This should never happen, contact the developer."
173  );
174  }
175 }
176 
177 inline ElectronFluctuationVertexCalculator::EnergyType ElectronFluctuationVertexCalculator::getEnergyType(
178 ) const{
179  return energyType;
180 }
181 
182 inline void ElectronFluctuationVertexCalculator::setEnergies(
183  const std::vector<std::complex<double>> &energies
184 ){
185  this->energies = energies;
186  vertexTree.clear();
187 
188  rpaSusceptibilityCalculator->setEnergies(energies);
189 }
190 
191 inline void ElectronFluctuationVertexCalculator::setEnergiesAreInversionSymmetric(
192  bool energiesAreInversionSymmetric
193 ){
194  rpaSusceptibilityCalculator->setEnergiesAreInversionSymmetric(
195  energiesAreInversionSymmetric
196  );
197 }
198 
199 inline bool ElectronFluctuationVertexCalculator::getEnergiesAreInversionSymmetric(
200 ) const{
201  return rpaSusceptibilityCalculator->getEnergiesAreInversionSymmetric();
202 }
203 
204 inline void ElectronFluctuationVertexCalculator::setU(std::complex<double> U){
205  this->U = U;
206  rpaSusceptibilityCalculator->setU(U);
207  vertexTree.clear();
208  interactionAmplitudesAreGenerated = false;
209 }
210 
211 inline void ElectronFluctuationVertexCalculator::setUp(std::complex<double> Up){
212  this->Up = Up;
213  rpaSusceptibilityCalculator->setUp(Up);
214  vertexTree.clear();
215  interactionAmplitudesAreGenerated = false;
216 }
217 
218 inline void ElectronFluctuationVertexCalculator::setJ(std::complex<double> J){
219  this->J = J;
220  rpaSusceptibilityCalculator->setJ(J);
221  vertexTree.clear();
222  interactionAmplitudesAreGenerated = false;
223 }
224 
225 inline void ElectronFluctuationVertexCalculator::setJp(std::complex<double> Jp){
226  this->Jp = Jp;
227  rpaSusceptibilityCalculator->setJp(Jp);
228  vertexTree.clear();
229  interactionAmplitudesAreGenerated = false;
230 }
231 
232 inline void ElectronFluctuationVertexCalculator::saveSusceptibilities(
233  const std::string &filename
234 ) const{
235  rpaSusceptibilityCalculator->saveSusceptibilities(filename);
236 }
237 
238 inline void ElectronFluctuationVertexCalculator::loadSusceptibilities(
239  const std::string &filename
240 ){
241  rpaSusceptibilityCalculator->loadSusceptibilities(filename);
242 }
243 
244 }; //End of namespace TBTK
245 
246 #endif
247 
Data structure for storing data associated with an index.
Definition: Boolean.h:32