Phoebe developer's documentation  1.1.0
Phonon and Electron Boltzmann Equations
context.h
1 #ifndef CONTEXT_H
2 #define CONTEXT_H
3 
4 #include <limits> // NaN
5 #include <string>
6 #include <vector>
7 
8 #include "eigen.h"
9 
15 class Context {
16  private:
17  std::string phFC2FileName;
18  std::string phFC3FileName;
19  std::string phonopyDispFileName;
20  std::string phonopyBORNFileName;
21 
22  std::string electronH0Name;
23  std::string wannier90Prefix;
24  std::string jdftxScfOutFile;
25  std::string quantumEspressoPrefix;
26  std::string elPhInterpolation;
27 
28  std::string appName;
29  std::string sumRuleFC2;
30  int smearingMethod = -1;
31  double smearingWidth = std::numeric_limits<double>::quiet_NaN();
32  double elSmearingWidth = std::numeric_limits<double>::quiet_NaN();
33  double phSmearingWidth = std::numeric_limits<double>::quiet_NaN();
34  //double dragSmearingWidth = std::numeric_limits<double>::quiet_NaN();
35  double adaptiveSmearingPrefactor = std::numeric_limits<double>::quiet_NaN();
36  Eigen::VectorXd temperatures;
37  std::vector<std::string> solverBTE;
38  double convergenceThresholdBTE = 1e-2;
39  int maxIterationsBTE = 50;
40 
41  bool scatteringMatrixInMemory = true;
42  bool useSymmetries = false;
43  bool symmetrizeBandStructure = false;
44 
45  std::string windowType = "nothing";
46  Eigen::Vector2d windowEnergyLimit = Eigen::Vector2d::Zero();
47  double windowPopulationLimit = std::numeric_limits<double>::quiet_NaN();
48 
49  Eigen::VectorXd dopings;
50  Eigen::VectorXd chemicalPotentials;
51  double electronFourierCutoff = std::numeric_limits<double>::quiet_NaN();
52 
53  Eigen::Vector3i qMesh = Eigen::Vector3i::Zero();
54  Eigen::Vector3i kMesh = Eigen::Vector3i::Zero();
55 
56  double fermiLevel = std::numeric_limits<double>::quiet_NaN();
57  double numOccupiedStates = std::numeric_limits<double>::quiet_NaN();
58  bool hasSpinOrbit = false;
59  double spinDegeneracyFactor = 2.;
60 
61  int dimensionality = 3;
62  double thickness = 1.; // material thickness or cross area for lower dimensions
63 
64  double dosMinEnergy = std::numeric_limits<double>::quiet_NaN();
65  double dosMaxEnergy = std::numeric_limits<double>::quiet_NaN();
66  double dosDeltaEnergy = std::numeric_limits<double>::quiet_NaN();
67 
68  Eigen::MatrixXd inputAtomicPositions;
69  Eigen::VectorXi inputAtomicSpecies;
70  std::vector<std::string> inputSpeciesNames;
71 
72  Eigen::Tensor<double, 3> pathExtrema;
73  std::vector<std::string> pathLabels;
74  double deltaPath = 0.05;
75 
76  bool outputEigendisplacements = false; // used by bands app if phonon eigdisps are dumped
77  bool outputUNTimes = false; // triggers scattering matrix to output times for U and N processes
78 
79  double constantRelaxationTime = std::numeric_limits<double>::quiet_NaN();
80  bool withIsotopeScattering = true; // add isotopes in phonon scattering matrix
81 
82  // for custom masses and custom isotope scattering
83  Eigen::VectorXd customIsotopeCouplings;
84  Eigen::VectorXd customMasses;
85 
86  // the C coefficient as in the ee self energy for a Fermi liquid
87  // will be internally stored in 1/Ry
88  double eeFermiLiquidCoefficient = 0;
89 
90  // add RTA boundary scattering in scattering matrix
91  double boundaryLength = std::numeric_limits<double>::quiet_NaN();
92 
93  std::string elphFileName;
94  double minChemicalPotential = std::numeric_limits<double>::quiet_NaN();
95  double maxChemicalPotential = std::numeric_limits<double>::quiet_NaN();
96  double deltaChemicalPotential = std::numeric_limits<double>::quiet_NaN();
97  double minTemperature = std::numeric_limits<double>::quiet_NaN();
98  double maxTemperature = std::numeric_limits<double>::quiet_NaN();
99  double deltaTemperature = std::numeric_limits<double>::quiet_NaN();
100  double eFermiRange = std::numeric_limits<double>::quiet_NaN();
101 
102  std::string epaFileName;
103  double epaEnergyRange = std::numeric_limits<double>::quiet_NaN();
104  double epaEnergyStep = std::numeric_limits<double>::quiet_NaN();
105  double epaMinEnergy = std::numeric_limits<double>::quiet_NaN();
106  double epaMaxEnergy = std::numeric_limits<double>::quiet_NaN();
107  int epaNumBins;
108  double epaSmearingEnergy = std::numeric_limits<double>::quiet_NaN();
109  double epaDeltaEnergy = std::numeric_limits<double>::quiet_NaN();
110 
111  // plot of el-ph coupling
112  std::string g2PlotStyle = "allToAll";
113  std::string g2MeshStyle = "pointsMesh";
114  Eigen::Vector3d g2PlotFixedPoint = {0,0,0};
115  std::pair<int,int> g2PlotEl1Bands = std::make_pair(0,-1);
116  std::pair<int,int> g2PlotEl2Bands = std::make_pair(0,-1);
117  std::pair<int,int> g2PlotPhBands = std::make_pair(0,-1);
118 
119  // utilities for parsing
120 
121  static std::vector<std::string> &split(const std::string &s, char delimiter,
122  std::vector<std::string> &elements);
123  static std::vector<std::string> split(const std::string &s, char delimiter);
124 
125  // variable used for the polarization
126  Eigen::VectorXi numCoreElectrons;
127 
128  bool distributedElPhCoupling = true; // MPI parallelize the el-ph coupling
129  // currently only support parallelization of the qe2Phoebe app
130 
131  // if true, enforce the symmetrization of the scattering matrix
132  bool symmetrizeMatrix = false;
133  // if true, and symmetrize matrix = false,
134  // only compute the upper triangle of the matrix
135  bool useUpperTriangle = false;
136 
137  // number of eigenvalues to use the in the relaxons solver
138  int numRelaxonsEigenvalues = 0;
139  // toggle the check for negative relaxons eigenvalues in few eigenvalues case
140  bool checkNegativeRelaxons = true;
141  // toggle the enforcement of the matrix being positive semidefinite
142  bool enforcePositiveSemiDefinite = false;
143 
144  // for coupled transport
145  bool useDragTerms = true;
146  bool enforceDetailedBalance = false;
147 
148  int hdf5ElphFileFormat = 1;
149  std::string wsVecFileName;
150 
151 public:
152 
153  // Setter and getter for all the variables above ----------------
154 
155  // Methods for the apps of plotting the electron-phonon coupling
156  std::string getG2PlotStyle();
157  void setG2PlotStyle(const std::string &x);
158 
159  std::string getG2MeshStyle();
160  void setG2MeshStyle(const std::string &x);
161 
162  Eigen::Vector3d getG2PlotFixedPoint();
163  void setG2PlotFixedPoint(const Eigen::Vector3d &x);
164 
165  std::pair<int,int> getG2PlotEl1Bands();
166  void setG2PlotEl1Bands(const std::pair<int,int> &x);
167 
168  std::pair<int,int> getG2PlotEl2Bands();
169  void setG2PlotEl2Bands(const std::pair<int,int> &x);
170 
171  std::pair<int,int> getG2PlotPhBands();
172  void setG2PlotPhBands(const std::pair<int,int> &x);
173 
178  std::string getPhFC2FileName();
179  void setPhFC2FileName(const std::string &x);
180 
181  std::string getPhFC3FileName();
182  void setPhFC3FileName(const std::string &x);
183 
184  std::string getPhonopyDispFileName();
185  void setPhonopyDispFileName(const std::string &x);
186 
187  std::string getPhonopyBORNFileName();
188 
189  std::string getElphFileName();
190  void setElphFileName(const std::string &x);
191 
192  std::string getWannier90Prefix();
193  void setWannier90Prefix(const std::string &x);
194 
195  std::string getQuantumEspressoPrefix();
196  void setQuantumEspressoPrefix(const std::string &x);
197 
198  std::string getJDFTxScfOutFile();
199  void setJDFTxScfOutFile(const std::string &x);
200 
201  std::string getElPhInterpolation();
202 
203  double getEpaSmearingEnergy() const;
204  double getEpaDeltaEnergy() const;
205  double getEpaMinEnergy() const;
206  double getEpaMaxEnergy() const;
207  int getEpaNumBins() const;
208 
213  std::string getElectronH0Name();
214  void setElectronH0Name(const std::string &x);
215 
220  double getElectronFourierCutoff() const;
221 
226  std::string getAppName();
227 
231  std::string getSumRuleFC2();
232  void setSumRuleFC2(const std::string &x);
233 
237  Eigen::Vector3i getQMesh();
238 
242  Eigen::Vector3i getKMesh();
243 
247  Eigen::Vector3i getKMeshPhEl();
251  void setKMeshPhEl(Eigen::Vector3i newKMeshPhEl);
252 
259  std::string getWindowType();
260  void setWindowType(const std::string &x);
261 
266  Eigen::Vector2d getWindowEnergyLimit();
267  void setWindowEnergyLimit(const Eigen::Vector2d &x);
268 
274  double getWindowPopulationLimit() const;
275  void setWindowPopulationLimit(const double &x);
276 
281  Eigen::VectorXd getChemicalPotentials();
282 
287  Eigen::VectorXd getDopings();
288  void setDopings(const Eigen::VectorXd &x);
289 
294  Eigen::VectorXd getTemperatures();
295  void setTemperatures(const Eigen::VectorXd &x);
296 
297  std::vector<std::string> getSolverBTE();
298 
299  double getConvergenceThresholdBTE() const;
300 
301  int getMaxIterationsBTE() const;
302 
303  int getDimensionality() const;
304 
305  double getThickness() const;
306 
307  double getDosMinEnergy() const;
308 
309  double getDosMaxEnergy() const;
310 
311  double getDosDeltaEnergy() const;
312 
313  // Wannier90 output doesn't contain the crystal information.
314  // the user must then supplement it in the input
315  // at least, if there's no phonon run
316  // we may change the behavior in the future, parsing another file
317  Eigen::MatrixXd getInputAtomicPositions();
318 
319  Eigen::VectorXi getInputAtomicSpecies();
320 
321  std::vector<std::string> getInputSpeciesNames();
322 
323  void setInputAtomicPositions(const Eigen::MatrixXd &x);
324  void setInputAtomicSpecies(const Eigen::VectorXi &x);
325  void setInputSpeciesNames(const std::vector<std::string> &x);
326 
327  Eigen::Tensor<double, 3> getPathExtrema();
328  std::vector<std::string> getPathLabels();
329 
330  double getDeltaPath() const;
331 
332  bool getOutputEigendisplacements() const;
333  bool getOutputUNTimes() const;
334 
335  double getFermiLevel() const;
336  void setFermiLevel(const double &x);
337 
338  double getNumOccupiedStates() const;
339  void setNumOccupiedStates(const double &x);
340 
341  bool getHasSpinOrbit() const;
342  void setHasSpinOrbit(const bool &x);
343 
344  double getSpinDegeneracyFactor() const;
345  void setSpinDegeneracyFactor(const double &x);
346 
347  int getSmearingMethod() const;
348 
349  double getSmearingWidth() const;
350  void setSmearingWidth(const double &x);
351 
352  double getElSmearingWidth() const;
353  void setElSmearingWidth(const double &x);
354 
355  double getPhSmearingWidth() const;
356  void setPhSmearingWidth(const double &x);
357 
358  //double getDragSmearingWidth() const;
359  //void setDragSmearingWidth(const double &x);
360 
361  double getAdaptiveSmearingPrefactor() const;
362  void setAdaptiveSmearingPrefactor(const double &x);
363 
364  double getConstantRelaxationTime() const;
365 
366  bool getScatteringMatrixInMemory() const;
367  void setScatteringMatrixInMemory(const bool &x);
368 
369  bool getUseSymmetries() const;
370  void setUseSymmetries(const bool &x);
371  bool getSymmetrizeBandStructure() const;
372  void setSymmetrizeBandStructure(const bool &x);
373 
374  bool getWithIsotopeScattering() const;
375 
376  Eigen::VectorXd getMasses();
377  Eigen::VectorXd getIsotopeCouplings();
378 
379  double getEeFermiLiquidCoefficient() const;
380  double getBoundaryLength() const;
381 
382  // EPA:
383  std::string getEpaFileName();
384  double getMinChemicalPotential() const;
385  double getMaxChemicalPotential() const;
386  double getDeltaChemicalPotential() const;
387  double getMinTemperature() const;
388  double getMaxTemperature() const;
389  double getDeltaTemperature() const;
390  double getEpaEnergyRange() const;
391  double getEpaEnergyStep() const;
392  double getEFermiRange() const;
393 
397  void setupFromInput(const std::string &fileName);
398 
402  void printInputSummary(const std::string &fileName);
403 
407  void inputSanityCheck();
408 
409  Eigen::VectorXi getCoreElectrons();
410  void setCoreElectrons(const Eigen::VectorXi &x);
411 
412  bool getDistributedElPhCoupling() const;
413  void setDistributedElPhCoupling(const bool &x);
414 
415  int getHdf5ElPhFileFormat() const;
416  void setHdf5ElPhFileFormat(const int &x);
417 
418  std::string getWsVecFileName() const;
419  void setWsVecFileName(const std::string& x);
420 
421  bool getUseDragTerms() const;
422  void setUseDragTerms(const bool &x);
423  bool getEnforceDetailedBalance() const;
424  void setEnforceDetailedBalance(const bool &x);
425 
426  // relaxons variables
427 
428  bool getSymmetrizeMatrix() const;
429  void setSymmetrizeMatrix(const bool &x);
430 
431  bool getUseUpperTriangle() const;
432  void setUseUpperTriangle(const bool &x);
433 
434  int getNumRelaxonsEigenvalues() const;
435  void setNumRelaxonsEigenvalues(const int &x);
436 
437  bool getCheckNegativeRelaxons() const;
438  bool setCheckNegativeRelaxons() const;
439 
440  bool getEnforcePositiveSemiDefinite() const;
441  void setEnforcePositiveSemiDefinite(const bool &x);
442 
443 };
444 
445 #endif
Class containing the user input variables.
Definition: context.h:15
Eigen::VectorXd getTemperatures()
gets the value of temperatures (in Rydberg) to be used in the calculation of transport properties
Definition: context.cpp:1333
Eigen::Vector3i getKMeshPhEl()
getter for the kMesh used to sample the fermi surface in phEl scattering calculation
double getElectronFourierCutoff() const
gets the value of the cutoff to be used for the Fourier interpolation of the band structure.
Definition: context.cpp:1302
Eigen::VectorXd getChemicalPotentials()
gets the value of chemical potentials (in Rydberg) to be used in the calculation of transport propert...
Definition: context.cpp:1327
void setupFromInput(const std::string &fileName)
Reads the user-provided input file and saves the input parameters.
Definition: context.cpp:422
void printInputSummary(const std::string &fileName)
Prints the user-provided input variables to output, including default values.
Definition: context.cpp:871
std::string getElectronH0Name()
gets the name of the file containing the electronic band structure.
Definition: context.cpp:1276
std::string getAppName()
gets the type of calculation to be run.
Definition: context.cpp:1306
Eigen::Vector2d getWindowEnergyLimit()
gets the values of energy limits to be used with a window on energies.
Definition: context.cpp:1314
Eigen::Vector3i getKMesh()
gets the mesh of points for harmonic electronic properties.
Definition: context.cpp:1309
std::string getPhFC2FileName()
gets the name of the file containing the lattice force constants.
Definition: context.cpp:1257
Eigen::Vector3i getQMesh()
gets the mesh of points for harmonic phonon properties.
Definition: context.cpp:1308
double getWindowPopulationLimit() const
gets the value of population above which a state is considered active.
Definition: context.cpp:1320
Eigen::VectorXd getDopings()
gets the value of chemical potentials (in Rydberg) to be used in the calculation of transport propert...
Definition: context.cpp:1329
void setKMeshPhEl(Eigen::Vector3i newKMeshPhEl)
setter for the kMesh used to sample the fermi surface in phEl scattering calculation
std::string getWindowType()
gets the Window type to be used to filter out states that don't contribute to transport.
Definition: context.cpp:1311
std::string getSumRuleFC2()
gets the sum rule to be imposed on the lattice force constants.
Definition: context.cpp:1270
void inputSanityCheck()
Sanity checks the input variables to make sure they agree.
Definition: context.cpp:811