TBTK
Need a break? Support the development by playing Polarity Puzzles
ZFactorCalculator.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_Z_FACTOR_CALCULATOR
25 #define COM_DAFER45_TBTK_Z_FACTOR_CALCULATOR
26 
27 #include "TBTK/BrillouinZone.h"
28 #include "TBTK/IndexedDataTree.h"
29 #include "TBTK/RPA/SelfEnergyCalculator.h"
30 
31 namespace TBTK{
32 
33 class ZFactorCalculator{
34 public:
36  ZFactorCalculator(
37  const RPA::MomentumSpaceContext &momentumSpaceContext,
38  unsigned int numWorkers = 1
39  );
40 
42  ~ZFactorCalculator();
43 
45  void setNumSummationEnergies(unsigned int numSummationEnergies);
46 
48  void init();
49 
51  std::vector<std::complex<double>> calculateZFactor(
52  const std::vector<double> &k
53  );
54 
56 /* std::vector<std::complex<double>> calculateZFactor2(
57  const std::vector<double> &k
58  );*/
59 
61  void setU(std::complex<double> U);
62 
64  void setUp(std::complex<double> Up);
65 
67  void setJ(std::complex<double> J);
68 
70  void setJp(std::complex<double> Jp);
71 
73 // void precomputeSusceptibilities(unsigned int numWorkers = 128);
74 
76  void saveSusceptibilities(const std::string &filename) const;
77 
79  void loadSusceptibilities(const std::string &filename);
80 private:
82  SelfEnergyCalculator selfEnergyCalculator;
83 
85  unsigned int numSummationEnergies;
86 
88  bool isInitialized;
89 
91  void invertMatrix(
92  std::complex<double> *matrix,
93  unsigned int dimensions
94  );
95 
97  void multiplyMatrices(
98  std::complex<double> *matrix1,
99  std::complex<double> *matrix2,
100  std::complex<double> *result,
101  unsigned int dimensions
102  );
103 
105  void printMatrix(
106  std::complex<double> *matrix,
107  unsigned int dimensions
108  );
109 
111  std::complex<double> U, Up, J, Jp;
112 };
113 
114 inline void ZFactorCalculator::setNumSummationEnergies(
115  unsigned int numSummationEnergies
116 ){
117  this->numSummationEnergies = numSummationEnergies;
118 }
119 
120 inline void ZFactorCalculator::setU(std::complex<double> U){
121  this->U = U;
122  selfEnergyCalculator.setU(U);
123 }
124 
125 inline void ZFactorCalculator::setUp(std::complex<double> Up){
126  this->Up = Up;
127  selfEnergyCalculator.setUp(Up);
128 }
129 
130 inline void ZFactorCalculator::setJ(std::complex<double> J){
131  this->J = J;
132  selfEnergyCalculator.setJ(J);
133 }
134 
135 inline void ZFactorCalculator::setJp(std::complex<double> Jp){
136  this->Jp = Jp;
137  selfEnergyCalculator.setJp(Jp);
138 }
139 
140 /*inline void ZFactorCalculator::precomputeSusceptibilities(
141  unsigned int numWorkers
142 ){
143  selfEnergyCalculator.precomputeSusceptibilities(numWorkers);
144 }*/
145 
146 inline void ZFactorCalculator::saveSusceptibilities(
147  const std::string &filename
148 ) const{
149  selfEnergyCalculator.saveSusceptibilities(filename);
150 }
151 
152 inline void ZFactorCalculator::loadSusceptibilities(
153  const std::string &filename
154 ){
155  selfEnergyCalculator.loadSusceptibilities(filename);
156 }
157 
158 }; //End of namespace TBTK
159 
160 #endif
161 
Data structure for storing data associated with an index.
Definition: Boolean.h:32