TBTK
Need a break? Support the development by playing Polarity Puzzles
LindhardSusceptibilityCalculator.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_LINDHARD_SUSCEPTIBILITY_CALCULATOR
25 #define COM_DAFER45_TBTK_LINDHARD_SUSCEPTIBILITY_CALCULATOR
26 
27 #include "TBTK/RPA/MomentumSpaceContext.h"
28 #include "TBTK/RPA/SusceptibilityCalculator.h"
29 
30 #include <complex>
31 
32 //#include <omp.h>
33 
34 namespace TBTK{
35 
36 class LindhardSusceptibilityCalculator : public SusceptibilityCalculator{
37 public:
39  LindhardSusceptibilityCalculator(
40  const RPA::MomentumSpaceContext &momentumSpaceContext
41  );
42 
44  virtual ~LindhardSusceptibilityCalculator();
45 
49  virtual LindhardSusceptibilityCalculator* createSlave();
50 
52  virtual std::complex<double> calculateSusceptibility(
53  const std::vector<double> &k,
54  const std::vector<int> &orbitalIndices,
55  std::complex<double> energy
56  );
57 
59  virtual std::vector<std::complex<double>> calculateSusceptibility(
60  const DualIndex &kDual,
61  const std::vector<int> &orbitalIndices
62  );
63 
67  void precompute(unsigned int numWorkers = 129);
68 
71  void setSusceptibilityIsSafeFromPoles(
72  bool susceptibilityIsSafeFromPoles
73  );
74 
77  bool getSusceptibilityIsSafeFromPoles() const;
78 private:
81  bool susceptibilityIsSafeFromPoles;
82 
84  double *fermiDiracLookupTable;
85 
87  LindhardSusceptibilityCalculator(
88  const RPA::MomentumSpaceContext &momentumSpaceContext,
89  int *kPlusQLookupTable,
90  double *fermiDiracLookupTable
91  );
92 
94  std::complex<double> calculateSusceptibilityLindhard(
95  const std::vector<double> &k,
96  const std::vector<int> &orbitalIndices,
97  std::complex<double> energy
98  );
99 
101  template<bool useKPlusQLookupTable, bool isSafeFromPoles>
102  std::vector<std::complex<double>> calculateSusceptibilityLindhard(
103  const DualIndex &kDual,
104  const std::vector<int> &orbitalIndices
105  );
106 
109  std::complex<double> getPoleTimesTwoFermi(
110  std::complex<double> energy,
111  double e2,
112  double e1,
113  double chemicalPotential,
114  double temperature,
115  int kPlusQLinearIndex,
116  unsigned int meshPoint,
117  unsigned int state2,
118  unsigned int state1,
119  unsigned int numOrbitals
120  ) const;
121 };
122 
123 inline void LindhardSusceptibilityCalculator::setSusceptibilityIsSafeFromPoles(
124  bool susceptibilityIsSafeFromPoles
125 ){
126  this->susceptibilityIsSafeFromPoles = susceptibilityIsSafeFromPoles;
127 }
128 
129 inline bool LindhardSusceptibilityCalculator::getSusceptibilityIsSafeFromPoles() const{
130  return susceptibilityIsSafeFromPoles;
131 }
132 
133 }; //End of namespace TBTK
134 
135 #endif
136 
Definition: Boolean.h:32