TBTK
Need a break? Support the development by playing Polarity Puzzles
SelfEnergy.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_SOLVER_SELF_ENERGY
25 #define COM_DAFER45_TBTK_SOLVER_SELF_ENERGY
26 
27 #include "TBTK/BrillouinZone.h"
28 #include "TBTK/IndexedDataTree.h"
29 #include "TBTK/Property/InteractionVertex.h"
30 #include "TBTK/RPA/MomentumSpaceContext.h"
31 #include "TBTK/Solver/Solver.h"
32 
33 namespace TBTK{
34 namespace Solver{
35 
36 class SelfEnergy : public Solver{
37 public:
39  SelfEnergy(
40  const RPA::MomentumSpaceContext &momentumSpaceContext,
41  const Property::InteractionVertex &interactionVertex
42  );
43 
45  ~SelfEnergy();
46 
48  const RPA::MomentumSpaceContext& getMomentumSpaceContext() const;
49 
53  const Property::InteractionVertex& getInteractionVertex() const;
54 
56  void init();
57 
59  std::vector<std::complex<double>> calculateSelfEnergy(
60  const Index &index,
61  const std::vector<std::complex<double>> &energies
62  );
63 
65  std::vector<std::complex<double>> calculateSelfEnergySelfConsistently(
66  unsigned int numMatsubaraFrequencies,
67  const std::vector<std::complex<double>> &energies
68  );
69 private:
71  const RPA::MomentumSpaceContext &momentumSpaceContext;
72 
74  const Property::InteractionVertex &interactionVertex;
75 
77  int *kMinusQLookupTable;
78 
81  void generateKMinusQLookupTable();
82 
84  template<bool useKPlusKLookupTable>
85  int getKMinusQLinearIndex(
86  unsigned int meshIndex,
87  const std::vector<double> &k,
88  int kLinearIndex
89  ) const;
90 
92  bool isInitialized;
93 
95  template<bool singleSelfEnergyEnergy>
96  void selfEnergyMainLoop(
97  const Index &index,
98  const std::vector<std::complex<double>> &energies,
99  std::vector<std::complex<double>> &result
100  );
101 };
102 
103 inline const RPA::MomentumSpaceContext& SelfEnergy::getMomentumSpaceContext(
104 ) const{
105  return momentumSpaceContext;
106 }
107 
108 inline const Property::InteractionVertex& SelfEnergy::getInteractionVertex(
109 ) const{
110  return interactionVertex;
111 }
112 
113 }; //End of namespace Solver
114 }; //End of namespace TBTK
115 
116 #endif
117 
Data structure for storing data associated with an index.
Base class for Solvers.
Definition: Boolean.h:32