Phoebe developer's documentation  1.1.0
Phonon and Electron Boltzmann Equations
points.h
1 #ifndef POINTS_H
2 #define POINTS_H
3 
4 #include "crystal.h"
5 #include "eigen.h"
6 #include "exceptions.h"
7 
8 // TODO this should be an enum
9 const int crystalCoordinates_ = 0;
10 const int cartesianCoordinates_ = 1;
11 
14 class Points;
15 
18 class Point {
19 public:
26  Point(Points &points_, const int &index_,
27  const Eigen::Vector3d &umklappVector = Eigen::Vector3d::Zero());
28 
31  Point(const Point &that);
32 
35  Point &operator=(const Point &that);
36 
42  Eigen::Vector3d getCoordinates(const int &basis = crystalCoordinates_,
43  const bool &inWignerSeitz = false) const;
44 
48  Point operator+(Point &b);
49 
53  Point operator-(Point &b);
54 
57  bool hasUmklapp();
58 
61  int getIndex() const;
62 
63 private:
64  Eigen::Vector3d umklappVector;
65  int index;
66  Points &points;
67 };
68 
73 class Points {
74 public:
75 
77  Points(Crystal &crystalObj_);
78 
85  Points(Crystal &crystalObj_, const Eigen::Vector3i &mesh_,
86  const Eigen::Vector3d &offset_ = Eigen::Vector3d::Zero());
87 
103  Points(Crystal &crystal_, const Eigen::Tensor<double, 3> &pathExtrema,
104  const double &delta);
105 
110  void setActiveLayer(const Eigen::VectorXi &filter_);
111 
114  Points(const Points &obj);
115 
118  Points &operator=(const Points &obj);
119 
125  std::tuple<Eigen::Vector3i, Eigen::Vector3d> getMesh();
126 
129  int getNumPoints() const;
130 
135  Eigen::Vector3d crystalToCartesian(const Eigen::Vector3d &point);
136 
141  Eigen::Vector3d cartesianToCrystal(const Eigen::Vector3d &point);
142 
149  Eigen::Vector3d bzToWs(const Eigen::Vector3d &point, const int &basis);
150 
151  Eigen::Vector3d foldToBz(const Eigen::Vector3d &pointCrystal,
152  const int &basis);
153 
161  static std::tuple<Eigen::Vector3i, Eigen::Vector3d>
162  findMesh(const Eigen::Matrix<double, 3, Eigen::Dynamic> &points);
163 
167  Crystal &getCrystal();
168 
175  Point getPoint(const int &index);
176 
183  Eigen::Vector3d getPointCoordinates(const int &index,
184  const int &basis = crystalCoordinates);
185 
191  int getIndex(const Eigen::Vector3d &point);
192 
200  int isPointStored(const Eigen::Vector3d &crystalCoordinates_);
201 
202  // note: we could use constexpr to tell the compiler that the class member is
203  // available at compilation time. But it wouldn't be compatible on old
204  // clusters
205  static const int crystalCoordinates;
206  static const int cartesianCoordinates;
207 
220  void
221  setIrreduciblePoints(std::vector<Eigen::MatrixXd> *groupVelocities = nullptr);
222 
228  std::vector<int> irrPointsIterator();
229 
243  std::vector<int> parallelIrrPointsIterator();
244 
251  int asIrreducibleIndex(const int &ik);
252 
259  int asReducibleIndex(const int &ik);
260 
274  std::tuple<int, Eigen::Matrix3d>
275  getRotationToIrreducible(const Eigen::Vector3d &x,
276  const int &basis = cartesianCoordinates);
277 
285  std::vector<Eigen::Matrix3d> getRotationsStar(const int &ik);
286 
293  std::vector<int> getReducibleStarFromIrreducible(const int &ik);
294 
299  //void swapCrystal(Crystal &newCrystal);
300 
301 protected:
302  void setMesh(const Eigen::Vector3i &mesh_, const Eigen::Vector3d &offset_);
303 
304  Crystal &crystalObj;
305  Eigen::Vector3i mesh;
306  Eigen::Vector3d offset;
307  int numPoints = 0;
308  // for Wigner Seitz folding
309  Eigen::MatrixXd gVectors;
310 
311  // to store points on a path or active points
312  bool explicitlyStored = false;
313  bool isPointsListSorted = false;
314  Eigen::MatrixXd pointsList;
315 
316  // for active Points:
317  Eigen::VectorXi filteredToFullIndices;
318 
319  void setupGVectors();
320 
321  //------------------------------------------
322  // Symmetries
323 
324  std::vector<Eigen::Matrix3d> rotationMatricesCrystal;
325  std::vector<Eigen::Matrix3d> rotationMatricesCartesian;
326 
327  // vector of size 0 to numPoints: given index i, mERI(i) is the index of
328  // the rotation R such that R*kIrr = k(i)
329  Eigen::VectorXi mapEquivalenceRotationIndex;
330 
331  // vector of size 0 to numIrrPoints: given an irreducible wavevector i,
332  // where i runs from 0 to numIrrPoints,
333  // mapIrreducibleToReducibleList(i) is the index of the irreducible point in
334  // the reducible list
335  Eigen::VectorXi mapIrreducibleToReducibleList;
336 
337  // vector of size 0 to numPoints. Given a reducible wavevector i,
338  // mRTI
339  Eigen::VectorXi mapReducibleToIrreducibleList;
340  int numIrrPoints = 0;
341 
342  // vector of size numIrrPoints. Given an irreducible point i
343  // (i from 0,numIrrPoints), gets the list of reducible point indices
344  // that are symmetry equivalent to point i.
345  std::vector<std::vector<int>> irreducibleStars;
346 
347  // if equiv(i) == i, point is irreducible, otherwise, equiv(i) gives the
348  // index of the irreducible equivalent index.
349  Eigen::VectorXi equiv;
350  //------------------------------------------
351 };
352 
353 #endif
Object to store the information on the crystal unit cell, such as atomic positions,...
Definition: crystal.h:18
Class used to pass a single wavevector.
Definition: points.h:18
bool hasUmklapp()
checks whether the Point has been constructed with an Umklapp vector
Definition: points.cpp:674
Point operator-(Point &b)
Difference of two wavevectors (this-b).
Definition: points.cpp:693
Eigen::Vector3d getCoordinates(const int &basis=crystalCoordinates_, const bool &inWignerSeitz=false) const
Get the coordinates of the k-point.
Definition: points.cpp:660
Point operator+(Point &b)
Sum of two wavevectors (this + b) The vector is folded in the Wigner Seitz zone with an Umklapp vecto...
Definition: points.cpp:682
int getIndex() const
Get the index of the wavevector in the referenced Points object.
Definition: points.cpp:270
Point & operator=(const Point &that)
copy assignment operator
Definition: points.cpp:651
Point(Points &points_, const int &index_, const Eigen::Vector3d &umklappVector=Eigen::Vector3d::Zero())
Constructor.
Definition: points.cpp:642
Base class for storing wavevectors in the Brillouin zone.
Definition: points.h:73
int asReducibleIndex(const int &ik)
Given the index of an irreducible point in the set [0,numIrredPoints[, returns its index in the set o...
Definition: points.cpp:939
int asIrreducibleIndex(const int &ik)
Given an index of an irreducible point in the set [0,numPoints[, returns its index in the set of [0,...
Definition: points.cpp:930
int isPointStored(const Eigen::Vector3d &crystalCoordinates_)
Like getIndex, get the wavevector index given the crystal coordinates of a wavevector,...
Definition: points.cpp:416
std::vector< int > parallelIrrPointsIterator()
Similar to irrPointsIterator, returns an iterator on the index of irreducible points.
Definition: points.cpp:919
void setIrreduciblePoints(std::vector< Eigen::MatrixXd > *groupVelocities=nullptr)
setIrreduciblePoints analyzes a current set of points to find its irreducible set.
Definition: points.cpp:704
Eigen::Vector3d cartesianToCrystal(const Eigen::Vector3d &point)
Converts a wavevector from cartesian to crystal coordinates.
Definition: points.cpp:473
Crystal & getCrystal()
Returns a reference to the crystal object on which the Points are defined.
Definition: points.cpp:536
std::vector< Eigen::Matrix3d > getRotationsStar(const int &ik)
Given the index of an irreducible point in the reducible list, returns the set of rotations that allo...
Definition: points.cpp:977
int getIndex(const Eigen::Vector3d &point)
Get the wavevector index given the crystal coordinates of a wavevector.
Definition: points.cpp:262
int getNumPoints() const
Returns the number of wavevectors stored in the points class.
Definition: points.cpp:538
static std::tuple< Eigen::Vector3i, Eigen::Vector3d > findMesh(const Eigen::Matrix< double, 3, Eigen::Dynamic > &points)
Given a list of points, finds the monkhorst-pack mesh.
Definition: points.cpp:576
Eigen::Vector3d bzToWs(const Eigen::Vector3d &point, const int &basis)
Folds a wavevector in crystal coordinates to the Wigner Seitz zone.
Definition: points.cpp:478
Point getPoint(const int &index)
Returns a Point object given its integer index.
Definition: points.cpp:230
std::vector< int > irrPointsIterator()
Returns an iterator on the index of irreducible points.
Definition: points.cpp:903
void setActiveLayer(const Eigen::VectorXi &filter_)
Constructor for Active Points.
Definition: points.cpp:138
Eigen::Vector3d crystalToCartesian(const Eigen::Vector3d &point)
Converts a wavevector from crystal to cartesian coordinates.
Definition: points.cpp:469
std::vector< int > getReducibleStarFromIrreducible(const int &ik)
Given the index of an irreducible point in the reducible list, returns the list of indices of the sym...
Definition: points.cpp:999
Points & operator=(const Points &obj)
Copy assignment operator.
Definition: points.cpp:207
std::tuple< int, Eigen::Matrix3d > getRotationToIrreducible(const Eigen::Vector3d &x, const int &basis=cartesianCoordinates)
Given the coordinates of a wavevector, getRotationToIrreducible returns the index of the irreducible ...
Definition: points.cpp:949
Points(Crystal &crystalObj_)
Default constructor.
Definition: points.cpp:20
Eigen::Vector3d getPointCoordinates(const int &index, const int &basis=crystalCoordinates)
Get the coordinates of a wavevector from its index.
Definition: points.cpp:234
std::tuple< Eigen::Vector3i, Eigen::Vector3d > getMesh()
Returns the details of the Monkhorst-pack mesh of wavevectors.
Definition: points.cpp:571
void setMesh(const Eigen::Vector3i &mesh_, const Eigen::Vector3d &offset_)
Change the crystal object for a different one.
Definition: points.cpp:540