6 #include "delta_function.h"
7 #include "vector_bte.h"
64 double&
operator()(
const int &row,
const int &col);
71 std::vector<VectorBTE>
offDiagonalDot(std::vector<VectorBTE> &inPopulations);
78 std::vector<VectorBTE>
dot(std::vector<VectorBTE> &inPopulations);
157 std::tuple<Eigen::VectorXd, ParallelMatrix<double>>
201 void relaxonsToJSON(
const std::string& fileName,
const Eigen::VectorXd& eigenvalues);
213 const Eigen::VectorXd& energies1,
214 const Eigen::VectorXd& energies2,
215 const Eigen::VectorXd& energies3);
243 enum MatrixCase matrixCase;
247 bool constantRTA =
false;
248 bool highMemory =
true;
249 bool outputUNTimes =
false;
251 double boundaryLength;
261 bool isMatrixOmega =
false;
265 bool isCoupled =
false;
273 std::function<std::tuple<long,long>(
long,
long,
const Particle&,
const Particle &)> shiftToCoupledIndices
274 = [](
long iBte1,
long iBte2, [[maybe_unused]]
const Particle &p1, [[maybe_unused]]
const Particle &p2){
275 return std::make_tuple(iBte1, iBte2); };
278 std::shared_ptr<VectorBTE> internalDiagonal, internalDiagonalUmklapp, internalDiagonalNormal;
298 std::vector<int> excludeIndices;
303 virtual void builder(std::shared_ptr<VectorBTE> linewidth,
304 std::vector<VectorBTE> &inPopulations,
305 std::vector<VectorBTE> &outPopulations) = 0;
325 const bool &rowMajor =
false);
363 void setMatrixCase(std::shared_ptr<VectorBTE> linewidth,
364 std::vector<VectorBTE> &inPopulations,
365 std::vector<VectorBTE> &outPopulations);
378 int iCalc,
int is1,
int is2Irr,
int iBte1,
int iBte2,
380 const Eigen::Matrix3d &rotation,
381 std::shared_ptr<VectorBTE> linewidth,
382 const std::vector<VectorBTE> &inPopulations,
383 std::vector<VectorBTE> &outPopulations);
419 const std::array<Point, n> &crysPoints,
auto momentumConsExpr) {
426 std::array<Eigen::Vector3d, n> wsVectors;
427 for(
size_t ipt = 0; ipt < n; ipt++) {
428 Eigen::Vector3d wvCart = crysPoints[ipt].getCoordinates(Points::cartesianCoordinates);
429 Eigen::Vector3d wvWS = outerBandStructure.
getPoints().
bzToWs(wvCart, Points::cartesianCoordinates);
430 wsVectors[ipt] = wvWS;
434 Eigen::Vector3d wvFinalCart = std::apply(momentumConsExpr, wsVectors);
435 Eigen::Vector3d wvFinalFold = outerBandStructure.
getPoints().
bzToWs(wvFinalCart, Points::cartesianCoordinates);
436 if(abs((wvFinalCart-wvFinalFold).norm()) > 1e-6) {
437 internalDiagonalUmklapp->operator()(iCalc, 0, iBte) += rate;
439 internalDiagonalNormal->operator()(iCalc, 0, iBte) += rate;
446 std::vector<VectorBTE> &inPopulations,
447 std::vector<VectorBTE> &outPopulations,
449 std::shared_ptr<VectorBTE> linewidth);
Base class for describing objects containing the band structure, i.e.
Definition: bandstructure.h:15
virtual Points getPoints()=0
Returns the wavevectors on which the band structure is computed.
Class containing the user input variables.
Definition: context.h:15
Class for implementing strong typing.
Definition: utilities.h:51
Determines whether we are dealing with phonons or electrons.
Definition: particle.h:17
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
Base class of the scattering matrix.
Definition: scattering_matrix.h:22
VectorBTE offDiagonalDot(VectorBTE &inPopulation)
Computes the product A*f - diagonal(A)*f where A is the scattering matrix and f is the vector of quas...
Definition: scattering_matrix.cpp:188
void replaceMatrixLinewidths()
Replace the linewidths of the scatterng matrix with the supplied VectorBTE values.
Definition: scattering_matrix.cpp:1322
void relaxonsToJSON(const std::string &fileName, const Eigen::VectorXd &eigenvalues)
Output relaxons scattering matrix quantities to file (particularly the tau values) Jenny's note: Howe...
Definition: scattering_matrix.cpp:668
std::tuple< int, int > coupledToBandStructureIndices(const int &iBte1, const int &iBte2, const Particle &p1, const Particle &p2)
If we have a coupled scattering matrix, we need to shift the matrix element indices back to those ass...
Definition: scattering_matrix.cpp:1362
void symmetrize()
Reinforce the condition that the matrix is symmetric.
Definition: scattering_matrix.cpp:1001
VectorBTE getLinewidths()
Converts symmetrized internal scattering matrix diagonal to linewidths and returns the result.
Definition: scattering_matrix.cpp:534
VectorBTE dot(VectorBTE &inPopulation)
Computes the product A*f where A is the scattering matrix and f is the vector of quasiparticle popula...
Definition: scattering_matrix.cpp:276
std::vector< std::tuple< int, int > > getAllLocalStates()
Call the underlying PMatrix function to return the iterator of all elements of the matrix which are l...
Definition: scattering_matrix.cpp:1315
void setLinewidths(VectorBTE &linewidths)
Call to set the single-particle linewidths.
Definition: scattering_matrix.cpp:592
void a2Omega()
Converts the scattering matrix from the form A to the symmetrised Omega.
Definition: scattering_matrix.cpp:366
virtual void builder(std::shared_ptr< VectorBTE > linewidth, std::vector< VectorBTE > &inPopulations, std::vector< VectorBTE > &outPopulations)=0
Method that actually computes the scattering matrix.
std::vector< std::tuple< std::vector< int >, int > > getIteratorWavevectorPairs(const bool &rowMajor=false)
Returns a vector of pairs of wavevector indices to iterate over during the construction of the scatte...
Definition: scattering_matrix.cpp:763
std::vector< int > getExcludeIndices(BaseBandStructure &bandStructure)
Method which for a phonon bandstructure returns the indices to be discarded in a phonon calculation d...
Definition: scattering_matrix.cpp:1289
void enforceDetailedBalance()
A function to fix the linewidths to agree with the off diagonal elements, to enforce finding the spec...
Definition: scattering_matrix.cpp:1432
void addRateToMatrix(const Context &context, double linewidthRate, double matrixRate, int iCalc, int is1, int is2Irr, int iBte1, int iBte2, const Particle &p1, const Particle &p2, const Eigen::Matrix3d &rotation, std::shared_ptr< VectorBTE > linewidth, const std::vector< VectorBTE > &inPopulations, std::vector< VectorBTE > &outPopulations)
Method to add scattering rate to matrix and linewidth containers.
Definition: scattering_matrix.cpp:1071
void outputToHDF5(const std::string &outFileName)
Outputs the matrix to an hdf5 file.
Definition: scattering_matrix.cpp:661
void setup()
This method needs to be called right after the constructor.
Definition: scattering_matrix.cpp:94
VectorBTE diagonal()
Returns the diagonal matrix elements.
Definition: scattering_matrix.cpp:178
double & operator()(const int &row, const int &col)
Get and set operator.
Definition: scattering_matrix.cpp:172
void degeneracyAveragingLinewidths(std::shared_ptr< VectorBTE > linewidth)
Performs an average of the linewidths over degenerate states.
Definition: scattering_matrix.cpp:1029
std::tuple< BaseBandStructure *, BaseBandStructure * > getStateBandStructures(const BteIndex &iBte1, const BteIndex &iBte2)
Returns a tuple of final and initial particles for a give state.
Definition: scattering_matrix.cpp:1391
VectorBTE getSingleModeTimes()
Call to obtain the single-particle relaxation times of the systems.
Definition: scattering_matrix.cpp:531
int getSMatrixIndex(BteIndex &bteIndex, CartIndex &cartIndex)
Function to combine a BTE index and a cartesian index into one index of the scattering matrix.
Definition: scattering_matrix.cpp:982
Eigen::MatrixXd precomputeOccupations(BaseBandStructure &bandStructure)
Function to precompute particle populations before scattering rates are calculated.
Definition: scattering_matrix.cpp:1259
ScatteringMatrix()
Default constructor.
void omega2A()
The inverse of a2Omega, converts the matrix Omega to A.
Definition: scattering_matrix.cpp:435
std::tuple< Eigen::VectorXd, ParallelMatrix< double > > diagonalize(int numEigenvalues=0)
Diagonalize the scattering matrix.
Definition: scattering_matrix.cpp:721
static void symmetrizeCoupling(Eigen::Tensor< double, 3 > &coupling, const Eigen::VectorXd &energies1, const Eigen::VectorXd &energies2, const Eigen::VectorXd &energies3)
Average the coupling for degenerate states.
Definition: scattering_matrix.cpp:1147
void addUNRates(int iCalc, int iBte, double rate, const std::array< Point, n > &crysPoints, auto momentumConsExpr)
Generic function to add UN times to their containers.
Definition: scattering_matrix.h:418
Class for managing a (serial) matrix stored in memory.
Definition: SMatrix.h:20
Object for controlling the loop over temperatures and chemical potentials.
Definition: statistics_sweep.h:26
Class used to store the "vector" of out-of-equilibrium populations.
Definition: vector_bte.h:16