NanoStructures  1.0
DMFT solver for layered, strongly correlated nanostructures
nanostructure.h
1 #ifndef NANOSTRUCTURE_H
2 #define NANOSTRUCTURE_H
3 
4 #include "../math/cfunction.h"
5 #include "../math/function.h"
6 #include "../dmft/dos.h"
7 #include "../math/physics.h"
8 #include "../config/configuration.h"
9 #include "layerparameters.h"
10 
11 #include <map>
12 
13 namespace libconfig {
14  class Config;
15 }
16 
17 namespace mpi {
18  class OpenMPI;
19 }
20 
21 namespace nano {
22 class NanoStructure;
24  NanoStructure* structure;
25  int nLayer;
26 };
28  NanoStructure* structure;
29  int alpha;
30  int beta;
31 };
32 
34  NanoStructure* structure;
35  int alpha;
36  int gamma;
37  int delta;
38 };
39 
41 {
42 public:
43  NanoStructure();
44  NanoStructure(std::string filename);
45  NanoStructure(int n);
46  ~NanoStructure();
47 
48  void configure(config::Configuration& config);
49 
50  void solve();
51  void solve(mpi::OpenMPI& mpi);
52  std::complex<double> left(int nLayer, int nOmega, double epsk);
53  std::complex<double> right(int nLayer, int nOmega, double epsk);
54 
55  void precalc_L(int nLayer, int nOmega, double epsk);
56  void precalc_R(int nLayer, int nOmega, double epsk);
57  void precalc_dL(int nLayer, int nOmega, double epsk);
58  void precalc_dR(int nLayer, int nOmega, double epsk);
59 
60  double Pi(int alpha, int gamma, int delta, int nOmega, double epsk);
61 
62  std::complex<double> G(int nLayer, int nOmega, double epsk);
63  std::complex<double> F(int nLayer, int nOmega, double epsk);
64  void F_local(int nLayer, math::CFunction& fLocal);
65  void G_local(int nLayer, math::CFunction& gLocal);
66  void F_local(int nLayer, math::CFunction& fLocal, mpi::OpenMPI& mpi);
67  void G_local(int nLayer, math::CFunction& gLocal, mpi::OpenMPI& mpi);
68  std::complex<double> GOff(int alpha, int beta, int nOmega, double epsk);
69 
70  //ECR
71  void updatePotentials();
72  void initializePotentials();
73  void updatePotentials(mpi::OpenMPI& mpi);
74  double calculateOccupationFromG(int layer, double mu = 0.0);
75  double totalExcessCharge(double mu);
76  double adjustMu();
77 
78  // conductivities
79  double calculateSigmaXX(int alpha, int beta);
80  double calculatePiXY(int alpha, int gamma, int delta);
81  double calculateSigmaXX(int alpha, int beta, mpi::OpenMPI& mpi);
82  double calculatePiXY(int alpha, int gamma, int delta, mpi::OpenMPI& mpi);
83 
84  //consistency questions
85  bool areAllSelfEnergySizesEqual();
86  bool isScalingCompatibleWithSelfEnergies();
87 
88  // convenience
89  void setMaxIterations(int maxIterations) { m_maxIterations = maxIterations; }
90  void setSelfEnergies(const math::CFunction& selfEnergy);
91  void setHoppings(double tL, double tR);
92  void setUs(double U);
93  bool isConverged();
94  inline double getT() const { return m_T; }
95 
96  void setAlphaV(double alphaV) { m_alphaV = alphaV; }
97  void setCalculateRhoXX(bool calc) { m_calculateRhoXX = calc; }
98  void setCalculateRhoXY(bool calc) { m_calculateRhoXY = calc; }
99  void setVerbose(bool verbose) { m_verbose = verbose; }
100  void setSymmetricNano(bool symmetric) { m_symmetricNano = symmetric; }
101  bool isSymmetricNano() { return m_symmetricNano; }
102 
103  void setMu(int nLayer, double mu) { m_mu[nLayer] = mu; }
104  void setSelfEnergy(int nLayer, const math::CFunction& S) { m_selfEnergies[nLayer] = S; }
105  void setU(int nLayer, double U) { m_U[nLayer] = U; }
106  void setDoECR(bool ecr) { m_doECR = ecr; }
107  //io
108  void writeBinary(std::string directory);
109  void readBinary(std::string directory);
110  void showInfo();
111 protected:
112  double doNRG(int layer);
113  void calculateEffectiveMedia(mpi::OpenMPI& mpi);
114  void allocate(int N);
115  void free();
116  typedef std::map<std::string, nano::LayerParameters> tPMap;
117  tPMap parseStructure(const libconfig::Config& structure);
118 
119  int m_nLayers;
120  math::Function* m_n;
121  math::CFunction* m_selfEnergies;
122  math::CFunction* m_greensFunctions;
123  math::CFunction* m_fFunctions;
124  math::CFunction* m_effectiveMedia;
125 
126  // physical parameters
127  // -- on-site U
128  double* m_U;
129  double* m_mu;
130  double m_T;
131 
132  // electronic charge reconstruction
133  bool m_doECR;
134  double* m_rho;
135  double* m_rhoBackground;
136  double* m_V;
137  double m_rhoBar;
138 
139  // symmetries
140  bool m_symmetricNano;
141 
142  // -- hopping
143  double* m_tL;
144  double* m_tR;
145 
146 
147  //numerical parameters
148  double* m_similarities;
149  double m_delta;
150  double m_scaling;
151  double m_alphaV;
152  double m_tolerance;
153  int m_iteration;
154  int m_maxIterations;
155 
156  //post processing
157  bool m_calculateRhoXX;
158  bool m_calculateRhoXY;
159 
160  bool m_verbose;
161 
162  //temp space
163  std::complex<double> *m_L;
164  std::complex<double> *m_dL;
165  std::complex<double> *m_R;
166  std::complex<double> *m_dR;
167  std::complex<double> *m_temp;
168 
169  config::Configuration* m_configuration;
170 
171 
172  // wrapper for fermi function
173  inline static std::complex<double> fermiWrapper(double omega, std::complex<double> fomega, void* parameters) {
174  double * beta = static_cast<double*>(parameters);
175  return math::physics::fermi(*beta, omega);
176  }
177 
178  //integrands
179  inline static double gReal(double epsk, int nOmega, double omega, std::complex<double> fomega, void * params) {
180  const IntegrationParametersG* parameters = static_cast<const IntegrationParametersG*>(params);
181  return dmft::dos::rho2(epsk) * parameters->structure->G(parameters->nLayer, nOmega, epsk ).real();
182  }
183  inline static double gImag(double epsk, int nOmega, double omega, std::complex<double> fomega, void * params) {
184  const IntegrationParametersG* parameters = static_cast<const IntegrationParametersG*>(params);
185  return dmft::dos::rho2(epsk) * parameters->structure->G(parameters->nLayer, nOmega, epsk ).imag();
186  }
187  inline static double fReal(double epsk, int nOmega, double omega, std::complex<double> fomega, void * params) {
188  const IntegrationParametersG* parameters = static_cast<const IntegrationParametersG*>(params);
189  return dmft::dos::rho2(epsk) * parameters->structure->F(parameters->nLayer, nOmega, epsk ).real();
190  }
191  inline static double fImag(double epsk, int nOmega, double omega, std::complex<double> fomega, void * params) {
192  const IntegrationParametersG* parameters = static_cast<const IntegrationParametersG*>(params);
193  return dmft::dos::rho2(epsk) * parameters->structure->F(parameters->nLayer, nOmega, epsk ).imag();
194  }
195 
196  //conductivity
197  // inline static double sigmaXX(double epsk, int nOmega, double omega, std::complex<double> fomega, void * params) {
198  // const IntegrationParametersSigmaXX* parameters = static_cast<const IntegrationParametersSigmaXX*>(params);
199  // return std::pow(parameters->structure->GOff(parameters->alpha, parameters->beta, nOmega, epsk ).imag(),2) * math::physics::dfermi( 1.0 / parameters->structure->getT(), epsk);
200  //}
201 
202  //conductivity
203  inline static double sigmaXX(double epsk, int nOmega, double omega, std::complex<double> fomega, void * params) {
204  const IntegrationParametersSigmaXX* parameters = static_cast<const IntegrationParametersSigmaXX*>(params);
205  return std::pow(parameters->structure->GOff(parameters->alpha, parameters->beta, nOmega, epsk ).imag(),2) * dmft::dos::rhoXX(epsk);
206  }
207 
208  inline static double piXY(double epsk, int nOmega, double omega, std::complex<double> fomega, void * params) {
209  const IntegrationParametersPiXY* parameters = static_cast<const IntegrationParametersPiXY*>(params);
210  return parameters->structure->Pi(parameters->alpha, parameters->gamma, parameters->delta, nOmega, epsk);
211  }
212 
213 };
214 }
215 
216 #endif // NANOSTRUCTURE_H
Definition: function.h:9
The MPI singleton is responsible for data exchange between compute nodes via OpenMPI.
Definition: openmpi.h:35
Definition: nanostructure.h:23
Definition: nanostructure.h:40
A configuration object which is populated from a configuration file and allows to query and modify co...
Definition: configuration.h:46
Definition: nanostructure.h:27
Definition: nanostructure.h:33
Discretized complex-valued function for real arguments.
Definition: cfunction.h:34