Phoebe developer's documentation  1.1.0
Phonon and Electron Boltzmann Equations
active_bandstructure.h
1 #ifndef ACT_BAND_STRUCTURE_H
2 #define ACT_BAND_STRUCTURE_H
3 
4 #include "bandstructure.h"
5 #include "constants.h"
6 #include "harmonic.h"
7 #include "particle.h"
8 #include "points.h"
9 #include "statistics_sweep.h"
10 #include "window.h"
11 
23 public:
26  ActiveBandStructure(Particle &particle_, Points &points_);
27 
28 
37  ActiveBandStructure(const Points &points_,
38  HarmonicHamiltonian *h0, const bool &withEigenvectors,
39  const bool &withVelocities);
40 
45  Particle getParticle() override;
46 
51  Points getPoints() override;
52 
57  Point getPoint(const int &pointIndex) override;
58 
69  int getNumPoints(const bool &useFullGrid = false) override;
70 
78  int getNumBands() override;
79  int getFullNumBands() override;
80 
84  int getNumBands(WavevectorIndex &ik) override;
85 
91  int hasWindow() override;
92 
96  bool getIsDistributed() override;
97 
105  size_t getIndex(const WavevectorIndex &ik, const BandIndex &ib) override;
106 
113  std::tuple<WavevectorIndex, BandIndex> getIndex(const int &is) override;
114 
122  std::tuple<WavevectorIndex, BandIndex> getIndex(StateIndex &is) override;
123 
127  int getNumStates() override;
128 
140  const double &getEnergy(StateIndex &is) override;
141 
153  Eigen::VectorXd getEnergies(WavevectorIndex &ik) override;
154 
160  double getMaxEnergy() override;
161 
169  Eigen::Vector3d getGroupVelocity(StateIndex &is) override;
170 
180  Eigen::MatrixXd getGroupVelocities(WavevectorIndex &ik) override;
181 
192  Eigen::Tensor<std::complex<double>, 3> getVelocities(WavevectorIndex &ik) override;
193 
204  Eigen::MatrixXcd getEigenvectors(WavevectorIndex &ik) override;
205 
216  Eigen::Tensor<std::complex<double>, 3> getPhEigenvectors(WavevectorIndex &ik) override;
217 
225  Eigen::Vector3d getWavevector(StateIndex &is) override;
232  Eigen::Vector3d getWavevector(WavevectorIndex &ik) override;
233 
240  void setEnergies(Point &point, Eigen::VectorXd &energies_) override;
241 
248  void setEnergies(Point &point, std::vector<double> &energies_);
249 
256  void setEigenvectors(Point &point, Eigen::MatrixXcd &eigenvectors_) override;
257 
264  void setVelocities(Point &point,
265  Eigen::Tensor<std::complex<double>, 3> &velocities_) override;
266 
278  static std::tuple<ActiveBandStructure, StatisticsSweep>
279  builder(Context &context, HarmonicHamiltonian &h0, Points &points,
280  const bool &withEigenvectors = true,
281  const bool &withVelocities = true, const bool &forceBuildAPP = false);
282 
291  std::vector<Eigen::Matrix3d> getRotationsStar(WavevectorIndex &ikIndex) override;
292 
301  std::vector<Eigen::Matrix3d> getRotationsStar(StateIndex &isIndex) override;
302 
314  std::tuple<int, Eigen::Matrix3d> getRotationToIrreducible(
315  const Eigen::Vector3d &x, const int &basis = Points::crystalCoordinates) override;
316 
324  BteIndex stateToBte(StateIndex &isIndex) override;
325 
333  StateIndex bteToState(BteIndex &iBteIndex) override;
334 
341  std::vector<int> irrStateIterator() override;
342 
349  std::vector<int> parallelIrrStateIterator() override;
350 
357  std::vector<int> irrPointsIterator() override;
358 
365  std::vector<int> parallelIrrPointsIterator() override;
366 
369  int getNumIrrStates() override;
370 
379  int getPointIndex(const Eigen::Vector3d &crystalCoordinates,
380  const bool &suppressError = false) override;
381 
389  std::vector<int> getReducibleStarFromIrreducible(const int &ik) override;
390  protected:
391  // stores the quasiparticle kind
392  Particle particle;
393 
394  Points points;
395 
396  // note: we don't store a matrix: we are storing an object (Nk,Nb),
397  // with a variable number of bands Nb per point
398  std::vector<double> energies;
399  std::vector<std::complex<double>> velocities, eigenvectors;
400 
401  bool hasEigenvectors = false;
402  bool hasVelocities = false;
403  int numStates = 0;
404  int numIrrStates;
405  int numIrrPoints;
406  int numPoints;
407 
408  Eigen::VectorXi numBands;
409  int numFullBands = 0;
410  int windowMethod = 0;
411 
412  // index management
413  // these are two auxiliary vectors to store indices
414  Eigen::MatrixXi auxBloch2Comb;
415  Eigen::VectorXi cumulativeKbOffset;
416  Eigen::MatrixXi bteAuxBloch2Comb;
417  Eigen::VectorXi bteCumulativeKbOffset;
418  Eigen::VectorXi cumulativeKbbOffset;
419  // this is the functionality to build the indices
420  void buildIndices(); // to be called after building the band structure
421  // and these are the tools to convert indices
422  void buildSymmetries();
423  // symmetrizes the band energies, velocities, and eigenvectors
424  //void symmetrize(Context &context, const bool& withVelocities);
425 
426  // utilities to convert Bloch indices into internal indices
427  size_t velBloch2Comb(const int &ik, const int &ib1, const int &ib2,
428  const int &i);
429  size_t eigBloch2Comb(const int &ik, const int &ibFull, const int &ibRed);
430  size_t bloch2Comb(const int &k, const int &b);
431  std::tuple<int, int> comb2Bloch(const int &is);
432 
433  size_t bteBloch2Comb(const int &k, const int &b);
434  std::tuple<int, int> bteComb2Bloch(const int &is);
435 
436  void buildOnTheFly(Window &window, Points points_, HarmonicHamiltonian &h0,
437  const bool &withEigenvectors = true,
438  const bool &withVelocities = true);
439 
442  const bool &withEigenvector = true,
443  const bool &withVelocities = true);
444 
448  /*void enforceBandNumSymmetry(Context& context, const int& numFullBands,
449  const std::vector<int>& myFilteredPoints,
450  Eigen::MatrixXi& filteredBands,
451  const std::vector<int>& displacements,
452  HarmonicHamiltonian& h0, const bool &withVelocities);
453  */
454 };
455 
456 #endif
Class container of the quasiparticle band structure, i.e.
Definition: active_bandstructure.h:22
ActiveBandStructure(Particle &particle_, Points &points_)
Almost empty constructor, to be used internally.
Definition: active_bandstructure.cpp:10
std::tuple< int, Eigen::Matrix3d > getRotationToIrreducible(const Eigen::Vector3d &x, const int &basis=Points::crystalCoordinates) override
Given a point in crystal or cartesian coordinates, returns the index of the irreducible point and the...
Definition: active_bandstructure.cpp:1229
StateIndex bteToState(BteIndex &iBteIndex) override
Utility method to convert an index over Bloch states in a VectorBTE into the Bloch state index in the...
Definition: active_bandstructure.cpp:1219
std::vector< Eigen::Matrix3d > getRotationsStar(WavevectorIndex &ikIndex) override
Given a irreducible point index, find the list of rotations to reconstruct the equivalent points.
Definition: active_bandstructure.cpp:1194
int getNumBands() override
Returns the number of bands.
Definition: active_bandstructure.cpp:215
Point getPoint(const int &pointIndex) override
Returns a wavevector, given a wavevector index.
Definition: active_bandstructure.cpp:199
Particle getParticle() override
Get the Particle object associated with this class.
Definition: active_bandstructure.cpp:195
Points getPoints() override
Returns the wavevectors on which the band structure is computed.
Definition: active_bandstructure.cpp:197
size_t getIndex(const WavevectorIndex &ik, const BandIndex &ib) override
Builds a Bloch state index, which runs on both wavevector index and band index.
Definition: active_bandstructure.cpp:236
double getMaxEnergy() override
Returns the maximum energy value.
Definition: active_bandstructure.cpp:278
int getPointIndex(const Eigen::Vector3d &crystalCoordinates, const bool &suppressError=false) override
Find the index of a point in the reducible list of points, given its coordinates in the crystal basis...
Definition: active_bandstructure.cpp:1234
BteIndex stateToBte(StateIndex &isIndex) override
Utility method to convert an index over Bloch states in the band structure into a Bloch state index u...
Definition: active_bandstructure.cpp:1205
bool getIsDistributed() override
Returns if this band structure is distributed.
Definition: active_bandstructure.cpp:234
int getNumPoints(const bool &useFullGrid=false) override
Returns the total number of k/q-points.
Definition: active_bandstructure.cpp:207
Eigen::Vector3d getWavevector(StateIndex &is) override
Returns the energy of a quasiparticle from its Bloch index Used for accessing the band structure in t...
Definition: active_bandstructure.cpp:357
const double & getEnergy(StateIndex &is) override
Returns the energy of a quasiparticle from its Bloch index.
Definition: active_bandstructure.cpp:259
StatisticsSweep buildAsPostprocessing(Context &context, Points points_, HarmonicHamiltonian &h0, const bool &withEigenvector=true, const bool &withVelocities=true)
in this function, useful for electrons, we first compute the band structure on a dense grid of waveve...
Definition: active_bandstructure.cpp:833
static std::tuple< ActiveBandStructure, StatisticsSweep > builder(Context &context, HarmonicHamiltonian &h0, Points &points, const bool &withEigenvectors=true, const bool &withVelocities=true, const bool &forceBuildAPP=false)
Preferred method to initialize the ActiveBandStructure class.
Definition: active_bandstructure.cpp:503
std::vector< int > irrStateIterator() override
Iterator over the Bloch states in the band structure, over just the irreducible wavevectors,...
Definition: active_bandstructure.cpp:1161
Eigen::MatrixXcd getEigenvectors(WavevectorIndex &ik) override
Obtain the eigenvectors of the quasiparticles at a specified wavevector.
Definition: active_bandstructure.cpp:326
int getNumStates() override
Returns the total number of Bloch states, equal to numPoints*numBands.
Definition: active_bandstructure.cpp:257
std::vector< int > parallelIrrStateIterator() override
Iterator over the Bloch states in the band structure, distributed over MPI processes,...
Definition: active_bandstructure.cpp:1174
Eigen::MatrixXd getGroupVelocities(WavevectorIndex &ik) override
Returns the group velocity of a quasiparticle for all bands at a specified wavevector index.
Definition: active_bandstructure.cpp:299
void setEnergies(Point &point, Eigen::VectorXd &energies_) override
Method to save quasiparticle energies inside ActiveBandStructure().
Definition: active_bandstructure.cpp:367
Eigen::Tensor< std::complex< double >, 3 > getVelocities(WavevectorIndex &ik) override
Returns the velocity operator (including off-diagonal matrix elements) of the quasiparticles at the s...
Definition: active_bandstructure.cpp:312
void setEigenvectors(Point &point, Eigen::MatrixXcd &eigenvectors_) override
Method to save quasiparticle eigenvectors inside ActiveBandStructure.
Definition: active_bandstructure.cpp:385
std::vector< int > irrPointsIterator() override
Iterator over the irreducible points indices.
Definition: active_bandstructure.cpp:1185
Eigen::Vector3d getGroupVelocity(StateIndex &is) override
Returns the group velocity of a quasiparticle from its Bloch index.
Definition: active_bandstructure.cpp:284
Eigen::VectorXd getEnergies(WavevectorIndex &ik) override
Returns the energies of all quasiparticle computed at a specified wavevector.
Definition: active_bandstructure.cpp:267
void setVelocities(Point &point, Eigen::Tensor< std::complex< double >, 3 > &velocities_) override
Method to save quasiparticle velocity operator in ActiveBandStructure.
Definition: active_bandstructure.cpp:396
int getNumIrrStates() override
Returns the number of irr points in this band structure.
Definition: active_bandstructure.cpp:203
std::vector< int > parallelIrrPointsIterator() override
Iterator over the irreducible points indices.
Definition: active_bandstructure.cpp:1189
std::vector< int > getReducibleStarFromIrreducible(const int &ik) override
Method to find the points equivalent to an irreducible point.
Definition: active_bandstructure.cpp:1248
int hasWindow() override
Checks whether the bandStructure has been built discarding some Bloch states from those available.
Definition: active_bandstructure.cpp:232
Eigen::Tensor< std::complex< double >, 3 > getPhEigenvectors(WavevectorIndex &ik) override
Obtain the eigenvectors of the quasiparticles at a specified wavevector.
Definition: active_bandstructure.cpp:341
Base class for describing objects containing the band structure, i.e.
Definition: bandstructure.h:15
Class containing the user input variables.
Definition: context.h:15
Virtual base class for Harmonic Hamiltonian.
Definition: harmonic.h:15
Class for implementing strong typing.
Definition: utilities.h:51
Determines whether we are dealing with phonons or electrons.
Definition: particle.h:17
Class used to pass a single wavevector.
Definition: points.h:18
Base class for storing wavevectors in the Brillouin zone.
Definition: points.h:73
Object for controlling the loop over temperatures and chemical potentials.
Definition: statistics_sweep.h:26
The window class contains the logic to decide whether to keep or discard a Bloch state.
Definition: window.h:17