Phoebe developer's documentation  1.1.0
Phonon and Electron Boltzmann Equations
bandstructure.h
1 #ifndef BAND_STRUCTURE_H
2 #define BAND_STRUCTURE_H
3 
4 #include "exceptions.h"
5 #include "particle.h"
6 #include "points.h"
7 #include "utilities.h"
8 #include "Matrix.h"
9 #include <utility>
10 
16  public:
17 
19  virtual ~BaseBandStructure() = default;
20 
25  virtual Particle getParticle() = 0;
26 
30  virtual Points getPoints() = 0;
31 
35  virtual Point getPoint(const int &pointIndex) = 0;
36 
43  virtual int getNumPoints(const bool &useFullGrid = false) = 0;
44 
49  virtual int getNumBands() = 0;
50  virtual int getFullNumBands() = 0;
51 
59  virtual int getNumBands(WavevectorIndex &ik) = 0;
60 
66  virtual int hasWindow() = 0;
70  virtual bool getIsDistributed() = 0;
71 
72  // needed in the BTE
80  virtual size_t getIndex(const WavevectorIndex &ik, const BandIndex &ib) = 0;
81 
89  virtual std::tuple<WavevectorIndex, BandIndex> getIndex(const int &is) = 0;
90  virtual std::tuple<WavevectorIndex, BandIndex> getIndex(StateIndex &is) = 0;
91 
95  virtual int getNumStates() = 0;
96 
100  virtual std::vector<size_t> parallelStateIterator();
101 
112  virtual const double &getEnergy(StateIndex &is) = 0;
113  virtual Eigen::VectorXd getEnergies(WavevectorIndex &ik) = 0;
114 
119  virtual double getMaxEnergy() = 0;
120 
127  virtual Eigen::Vector3d getGroupVelocity(StateIndex &is) = 0;
128  virtual Eigen::MatrixXd getGroupVelocities(WavevectorIndex &ik) = 0;
129  virtual Eigen::Tensor<std::complex<double>, 3> getVelocities(
130  WavevectorIndex &ik) = 0;
131 
132  virtual Eigen::MatrixXcd getEigenvectors(WavevectorIndex &ik) = 0;
133  virtual Eigen::Tensor<std::complex<double>, 3> getPhEigenvectors(
134  WavevectorIndex &ik) = 0;
135 
142  virtual Eigen::Vector3d getWavevector(StateIndex &is) = 0;
143  virtual Eigen::Vector3d getWavevector(WavevectorIndex &ik) = 0;
144 
151  virtual void setEnergies(Point &point, Eigen::VectorXd &energies_) = 0;
152 
161  virtual void setEigenvectors(Point &point,
162  Eigen::MatrixXcd &eigenvectors_) = 0;
163 
171  virtual void setVelocities(
172  Point &point, Eigen::Tensor<std::complex<double>, 3> &velocities_) = 0;
173 
182  virtual std::vector<Eigen::Matrix3d> getRotationsStar(WavevectorIndex &ikIndex) = 0;
183 
192  virtual std::vector<Eigen::Matrix3d> getRotationsStar(StateIndex &isIndex) = 0;
193 
205  virtual std::tuple<int, Eigen::Matrix3d> getRotationToIrreducible(
206  const Eigen::Vector3d &x,
207  const int &basis = Points::crystalCoordinates) = 0;
208 
216  virtual BteIndex stateToBte(StateIndex &isIndex) = 0;
217 
225  virtual StateIndex bteToState(BteIndex &iBteIndex) = 0;
226 
233  virtual std::vector<int> irrStateIterator() = 0;
234 
241  virtual std::vector<int> parallelIrrStateIterator() = 0;
242 
249  virtual std::vector<int> irrPointsIterator() = 0;
250 
257  virtual std::vector<int> parallelIrrPointsIterator() = 0;
258 
261  virtual int getNumIrrStates() = 0;
262 
271  virtual int getPointIndex(const Eigen::Vector3d &crystalCoordinates,
272  const bool &suppressError=false) = 0;
273 
281  virtual std::vector<int> getReducibleStarFromIrreducible(const int &ik) = 0;
282 
287  void outputComponentsToJSON(const std::string &outFileName = "bandstructure.json");
288 
294  void printBandStructureStateInfo(const int& fullNumBands);
295 
296 };
297 
298 class ActiveBandStructure;
299 // forward declaration of friend class
300 // we could remove this by making ActiveBS a subclass of FullBS
301 
319  public:
331  FullBandStructure(int numBands_, Particle &particle_, bool withVelocities,
332  bool withEigenvectors, Points &points_,
333  bool isDistributed_ = false);
334 
336 
337  /* Note, these explicit constructors are needed because we want to make deep copies
338  when these objects are created and assigned as FBS fbs = h0.populate() */
339 
343 
347 
350  void symmetrize();
351 
356  Particle getParticle() override;
357 
361  Points getPoints() override;
362 
366  Point getPoint(const int &pointIndex) override;
367 
373  int getNumPoints(const bool &useFullGrid = false) override;
374 
378  int getNumBands() override;
379  int getFullNumBands() override;
380 
385  int getNumBands(WavevectorIndex &ik) override;
386 
387  int hasWindow() override;
388 
389  bool getIsDistributed() override;
390 
391  bool getHasEigenvectors();
392 
400  size_t getIndex(const WavevectorIndex &ik, const BandIndex &ib) override;
401 
408  std::tuple<WavevectorIndex, BandIndex> getIndex(const int &is) override;
409 
417  std::tuple<WavevectorIndex, BandIndex> getIndex(StateIndex &is) override;
418 
422  int getNumStates() override;
423 
429  std::vector<int> getLocalWavevectorIndices();
430 
436  std::vector<std::tuple<WavevectorIndex, BandIndex>> getLocalEnergyStateIndices();
437 
443  //std::vector<size_t> getLocalStateIndices();
444 
449  std::vector<int> getLocalBandIndices() const;
450 
462  const double &getEnergy(StateIndex &is) override;
463 
477  const double &getEnergy(WavevectorIndex &ik, BandIndex &ib);
478 
490  Eigen::VectorXd getEnergies(WavevectorIndex &ik) override;
491 
496  double getMaxEnergy() override;
497 
505  Eigen::Vector3d getGroupVelocity(StateIndex &is) override;
506 
515  Eigen::MatrixXd getGroupVelocities(WavevectorIndex &ik) override;
516 
525  Eigen::Tensor<std::complex<double>, 3> getVelocities(WavevectorIndex &ik) override;
526 
535  Eigen::MatrixXcd getEigenvectors(WavevectorIndex &ik) override;
536 
547  Eigen::Tensor<std::complex<double>, 3> getPhEigenvectors(WavevectorIndex &ik) override;
548 
555  Eigen::Vector3d getWavevector(StateIndex &is) override;
556 
563  Eigen::Vector3d getWavevector(WavevectorIndex &ik) override;
564 
570  void setEnergies(Point &point, Eigen::VectorXd &energies_) override;
571 
580  void setEigenvectors(Point &point, Eigen::MatrixXcd &eigenvectors_) override;
581 
589  void setVelocities(Point &point,
590  Eigen::Tensor<std::complex<double>, 3> &velocities_) override;
591 
598  void setEnergies(Eigen::Vector3d &point, Eigen::VectorXd &energies_);
599 
606  Eigen::VectorXd getBandEnergies(int &bandIndex);
607 
616  std::vector<Eigen::Matrix3d> getRotationsStar(WavevectorIndex &ikIndex) override;
617 
626  std::vector<Eigen::Matrix3d> getRotationsStar(StateIndex &isIndex) override;
627 
639  std::tuple<int, Eigen::Matrix3d> getRotationToIrreducible(
640  const Eigen::Vector3d &x,
641  const int &basis = Points::crystalCoordinates) override;
642 
650  BteIndex stateToBte(StateIndex &isIndex) override;
651 
659  StateIndex bteToState(BteIndex &iBteIndex) override;
660 
667  std::vector<int> irrStateIterator() override;
668 
675  std::vector<int> parallelIrrStateIterator() override;
676 
683  std::vector<int> irrPointsIterator() override;
684 
691  std::vector<int> parallelIrrPointsIterator() override;
692 
695  int getNumIrrStates() override;
696 
705  int getPointIndex(const Eigen::Vector3d &crystalCoordinates,
706  const bool &suppressError=false) override;
707 
715  std::vector<int> getReducibleStarFromIrreducible(const int &ik) override;
716 
717 protected:
718  // stores the quasiparticle kind
719  Particle particle;
720 
721  // link to the underlying mesh of points
722  Points &points; // these may be FullPoints or PathPoints
723 
724  // if the bands are distributed or not
725  bool isDistributed = false;
726 
727  bool hasEigenvectors = false;
728  bool hasVelocities = false;
729 
730  // matrices storing the raw data
731  Matrix<double> energies; // size(bands,points)
732  Matrix<std::complex<double>> velocities; // size(3*bands^2,points)
733  Matrix<std::complex<double>> eigenvectors; // size(bands^2,points)
734 
735  // auxiliary variables
736  int numBands = 0;
737  int numAtoms = 0;
738  size_t numPoints = 0;
739  int numLocalPoints = 0;
740 
741  // method to find the index of the point, from its crystal coordinates
742  //int getIndex(Eigen::Vector3d &pointCoordinates);
743 
744  // ActiveBandStructure, which restricts the FullBandStructure to a subset
745  // of wavevectors, needs low-level access to the raw data (for now)
746  friend class ActiveBandStructure;
747 };
748 
749 #endif
Class container of the quasiparticle band structure, i.e.
Definition: active_bandstructure.h:22
Base class for describing objects containing the band structure, i.e.
Definition: bandstructure.h:15
virtual std::tuple< WavevectorIndex, BandIndex > getIndex(const int &is)=0
Given a Bloch state index, finds the corresponding wavevector and band index.
virtual std::tuple< int, Eigen::Matrix3d > getRotationToIrreducible(const Eigen::Vector3d &x, const int &basis=Points::crystalCoordinates)=0
Given a point in crystal or cartesian coordinates, returns the index of the irreducible point and the...
virtual const double & getEnergy(StateIndex &is)=0
Returns the energy of a quasiparticle from its Bloch index Used for accessing the band structure in t...
virtual std::vector< Eigen::Matrix3d > getRotationsStar(WavevectorIndex &ikIndex)=0
Given a irreducible point index, find the list of rotations to reconstruct the equivalent points.
virtual Eigen::Vector3d getWavevector(StateIndex &is)=0
Returns the wavevector of a quasiparticle from its Bloch index Used for accessing the band structure ...
virtual std::vector< int > parallelIrrStateIterator()=0
Iterator over the Bloch states in the band structure, distributed over MPI processes,...
virtual Particle getParticle()=0
Get the Particle object associated with this class.
virtual double getMaxEnergy()=0
Return the maximum energy of a bandstructure.
virtual void setVelocities(Point &point, Eigen::Tensor< std::complex< double >, 3 > &velocities_)=0
Saves in the class the velocities computed at a particular point.
virtual int hasWindow()=0
Checks whether the bandStructure has been built discarding some Bloch states from those available.
virtual std::vector< int > parallelIrrPointsIterator()=0
Iterator over the irreducible points indices.
virtual Eigen::Vector3d getGroupVelocity(StateIndex &is)=0
Returns the velocity of a quasiparticle from its Bloch index Used for accessing the band structure in...
virtual StateIndex bteToState(BteIndex &iBteIndex)=0
Utility method to convert an index over Bloch states in a VectorBTE into the Bloch state index in the...
virtual std::vector< size_t > parallelStateIterator()
Returns an iterator to be used for loops over the Bloch state index.
Definition: bandstructure.cpp:13
virtual Points getPoints()=0
Returns the wavevectors on which the band structure is computed.
virtual BteIndex stateToBte(StateIndex &isIndex)=0
Utility method to convert an index over Bloch states in the band structure into a Bloch state index u...
virtual bool getIsDistributed()=0
Returns the boolean determining if this band structure is distributed or not.
virtual std::vector< Eigen::Matrix3d > getRotationsStar(StateIndex &isIndex)=0
Given an irreducible Bloch state (i.e.
virtual Point getPoint(const int &pointIndex)=0
Returns a wavevector, given a wavevector index.
virtual int getNumBands()=0
Returns the number of bands.
virtual int getNumPoints(const bool &useFullGrid=false)=0
Returns the total number of k/q-points.
virtual int getNumIrrStates()=0
Returns number of irr points for this band structure.
virtual void setEnergies(Point &point, Eigen::VectorXd &energies_)=0
Method to save quasiparticle eigenvectors inside FullBandStructure().
void outputComponentsToJSON(const std::string &outFileName="bandstructure.json")
Outputs the bandstructure information to file, either sym reduced or not.
Definition: bandstructure.cpp:20
virtual std::vector< int > irrPointsIterator()=0
Iterator over the irreducible points indices.
virtual std::vector< int > getReducibleStarFromIrreducible(const int &ik)=0
Method to find the points equivalent to an irreducible point.
virtual int getNumBands(WavevectorIndex &ik)=0
Returns the number of bands.
virtual std::vector< int > irrStateIterator()=0
Iterator over the Bloch states in the band structure, over just the irreducible wavevectors,...
virtual int getPointIndex(const Eigen::Vector3d &crystalCoordinates, const bool &suppressError=false)=0
Find the index of a point in the reducible list of points, given its coordinates in the crystal basis...
virtual void setEigenvectors(Point &point, Eigen::MatrixXcd &eigenvectors_)=0
Method to save quasiparticle eigenvectors inside FullBandStructure().
virtual int getNumStates()=0
Returns the total number of Bloch states.
void printBandStructureStateInfo(const int &fullNumBands)
A function to print information about how many states are in this bandstructure, and how things were ...
Definition: bandstructure.cpp:135
virtual size_t getIndex(const WavevectorIndex &ik, const BandIndex &ib)=0
Builds a Bloch state index, which combines both wavevector index and band index.
virtual ~BaseBandStructure()=default
Base destructor for bandstructure class, silences warnings.
FullBandStructure is the class that stores the energies, velocities and eigenvectors of a quasipartic...
Definition: bandstructure.h:318
void setEnergies(Point &point, Eigen::VectorXd &energies_) override
Method to save quasiparticle energies inside FullBandStructure().
Definition: bandstructure.cpp:521
Eigen::Vector3d getWavevector(StateIndex &is) override
Returns the energy of a quasiparticle from its Bloch index.
Definition: bandstructure.cpp:497
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: bandstructure.cpp:633
int getNumBands() override
Returns the number of bands.
Definition: bandstructure.cpp:292
void setEigenvectors(Point &point, Eigen::MatrixXcd &eigenvectors_) override
Method to save quasiparticle eigenvectors inside FullBandStructure().
Definition: bandstructure.cpp:561
std::vector< int > irrStateIterator() override
Iterator over the Bloch states in the band structure, over just the irreducible wavevectors,...
Definition: bandstructure.cpp:647
int getNumBands(WavevectorIndex &ik) override
Returns the number of bands, to provide flexibility in cases where full or activeBandStructure could ...
std::vector< std::tuple< WavevectorIndex, BandIndex > > getLocalEnergyStateIndices()
Returns the indices of all n,k indices on this process, or in an undistributed case,...
Definition: bandstructure.cpp:340
FullBandStructure & operator=(const FullBandStructure &that)
Copy assignment operator.
Definition: bandstructure.cpp:180
std::vector< int > parallelIrrStateIterator() override
Iterator over the Bloch states in the band structure, distributed over MPI processes,...
Definition: bandstructure.cpp:661
Eigen::MatrixXd getGroupVelocities(WavevectorIndex &ik) override
Returns the group velocity of a quasiparticle for all bands at a specified wavevector index.
Definition: bandstructure.cpp:428
double getMaxEnergy() override
Return the maximum energy of a bandstructure.
Definition: bandstructure.cpp:407
const double & getEnergy(StateIndex &is) override
Returns the energy of a quasiparticle from its Bloch index.
Definition: bandstructure.cpp:385
std::vector< int > irrPointsIterator() override
Iterator over the irreducible points indices.
Definition: bandstructure.cpp:672
void setVelocities(Point &point, Eigen::Tensor< std::complex< double >, 3 > &velocities_) override
Saves in the class the velocities computed at a particular point.
Definition: bandstructure.cpp:532
std::vector< int > getLocalWavevectorIndices()
Returns the indices of all wavevector indices on this process, or in an undistributed case,...
Definition: bandstructure.cpp:326
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: bandstructure.cpp:443
Particle getParticle() override
Get the Particle object associated with this class.
Definition: bandstructure.cpp:276
int getNumIrrStates() override
Returns the number of irreducible points for this band structure.
Definition: bandstructure.cpp:680
std::vector< Eigen::Matrix3d > getRotationsStar(WavevectorIndex &ikIndex) override
Given a irreducible point index, find the list of rotations to reconstruct the equivalent points.
Definition: bandstructure.cpp:599
Eigen::Vector3d getGroupVelocity(StateIndex &is) override
Returns the group velocity of a quasiparticle from its Bloch index.
Definition: bandstructure.cpp:412
Points getPoints() override
Returns the wavevectors on which the band structure is computed.
Definition: bandstructure.cpp:278
Eigen::VectorXd getEnergies(WavevectorIndex &ik) override
Returns the energies of all quasiparticle computed at a specified wavevector.
Definition: bandstructure.cpp:396
std::vector< int > getReducibleStarFromIrreducible(const int &ik) override
Method to find the points equivalent to an irreducible point.
Definition: bandstructure.cpp:693
Eigen::VectorXd getBandEnergies(int &bandIndex)
Returns all electronic energies for all wavevectors at fixed band index Used by the Fourier interpola...
Definition: bandstructure.cpp:586
int getNumPoints(const bool &useFullGrid=false) override
Returns the total number of k/q-points.
Definition: bandstructure.cpp:284
Eigen::MatrixXcd getEigenvectors(WavevectorIndex &ik) override
Obtain the eigenvectors of the quasiparticles at a specified wavevector.
Definition: bandstructure.cpp:461
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: bandstructure.cpp:684
Point getPoint(const int &pointIndex) override
Returns a wavevector, given a wavevector index.
Definition: bandstructure.cpp:280
std::vector< int > getLocalBandIndices() const
Returns the indices of all state indices on this process, or in an undistributed case,...
Definition: bandstructure.cpp:367
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: bandstructure.cpp:611
Eigen::Tensor< std::complex< double >, 3 > getPhEigenvectors(WavevectorIndex &ik) override
Obtain the eigenvectors of the quasiparticles at a specified wavevector.
Definition: bandstructure.cpp:479
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: bandstructure.cpp:304
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: bandstructure.cpp:616
void symmetrize()
Symmetrizes the full band structure energies.
int hasWindow() override
Checks whether the bandStructure has been built discarding some Bloch states from those available.
Definition: bandstructure.cpp:298
std::vector< int > parallelIrrPointsIterator() override
Iterator over the irreducible points indices.
Definition: bandstructure.cpp:676
int getNumStates() override
Returns the total number of Bloch states, equal to numPoints*numBands.
Definition: bandstructure.cpp:323
bool getIsDistributed() override
Returns the boolean determining if this band structure is distributed or not.
Definition: bandstructure.cpp:300
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