Phoebe developer's documentation  1.1.0
Phonon and Electron Boltzmann Equations
CoupledScatteringMatrix Class Reference

class representing the combined scattering matrix. More...

#include <coupled_scattering_matrix.h>

Inheritance diagram for CoupledScatteringMatrix:
Collaboration diagram for CoupledScatteringMatrix:

Public Member Functions

 CoupledScatteringMatrix (Context &context_, StatisticsSweep &statisticsSweep_, BaseBandStructure &innerBandStructure_, BaseBandStructure &outerBandStructure_, ElectronH0Wannier *electronH0_=nullptr, PhononH0 *phononH0_=nullptr)
 Default constructor. More...
 
BaseBandStructuregetPhBandStructure ()
 Outputs the quantity to a json file. More...
 
BaseBandStructuregetElBandStructure ()
 
- Public Member Functions inherited from BaseElScatteringMatrix
 BaseElScatteringMatrix (Context &context_, StatisticsSweep &statisticsSweep_, BaseBandStructure &innerBandStructure_, BaseBandStructure &outerBandStructure_)
 Constructor that just calls the constructor of scattering matrix.
 
- Public Member Functions inherited from ScatteringMatrix
 ScatteringMatrix (Context &context_, StatisticsSweep &statisticsSweep_, BaseBandStructure &innerBandStructure_, BaseBandStructure &outerBandStructure_)
 Scattering matrix constructor. More...
 
 ScatteringMatrix ()
 Default constructor.
 
void setup ()
 This method needs to be called right after the constructor. More...
 
VectorBTE diagonal ()
 Returns the diagonal matrix elements. More...
 
double & operator() (const int &row, const int &col)
 Get and set operator. More...
 
VectorBTE offDiagonalDot (VectorBTE &inPopulation)
 Computes the product A*f - diagonal(A)*f where A is the scattering matrix and f is the vector of quasiparticle populations.
 
std::vector< VectorBTEoffDiagonalDot (std::vector< VectorBTE > &inPopulations)
 
VectorBTE dot (VectorBTE &inPopulation)
 Computes the product A*f where A is the scattering matrix and f is the vector of quasiparticle populations.
 
std::vector< VectorBTEdot (std::vector< VectorBTE > &inPopulations)
 
VectorBTE getSingleModeTimes ()
 Call to obtain the single-particle relaxation times of the systems. More...
 
VectorBTE getLinewidths ()
 Converts symmetrized internal scattering matrix diagonal to linewidths and returns the result. More...
 
void setLinewidths (VectorBTE &linewidths)
 Call to set the single-particle linewidths. More...
 
VectorBTE getSingleModeTimes (const VectorBTE &anyInternalDiagonal)
 Call to obtain the single-particle relaxation times of the systems given any internal diagonal like object – (basically, the linewidths but potentially scaled by some symmetrization factor) More...
 
VectorBTE getLinewidths (const VectorBTE &anyInternalDiagonal)
 Call to obtain the single-particle linewidths. More...
 
void a2Omega ()
 Converts the scattering matrix from the form A to the symmetrised Omega. More...
 
void omega2A ()
 The inverse of a2Omega, converts the matrix Omega to A.
 
std::tuple< Eigen::VectorXd, ParallelMatrix< double > > diagonalize (int numEigenvalues=0)
 Diagonalize the scattering matrix. More...
 
int getSMatrixIndex (BteIndex &bteIndex, CartIndex &cartIndex)
 Function to combine a BTE index and a cartesian index into one index of the scattering matrix. More...
 
std::tuple< BteIndex, CartIndexgetSMatrixIndex (const int &iMat)
 Function to split a scattering matrix index (on rows/columns of S) into a BTE index and a cartesian index. More...
 
void symmetrize ()
 Reinforce the condition that the matrix is symmetric.
 
void relaxonsToJSON (const std::string &fileName, const Eigen::VectorXd &eigenvalues)
 Output relaxons scattering matrix quantities to file (particularly the tau values) Jenny's note: However, I have a feeling this should be elsewhere, as we're actually passing the eigenvalues back into this function. More...
 
std::vector< std::tuple< int, int > > getAllLocalStates ()
 Call the underlying PMatrix function to return the iterator of all elements of the matrix which are local. More...
 
void outputToHDF5 (const std::string &outFileName)
 Outputs the matrix to an hdf5 file. More...
 
- Public Member Functions inherited from BasePhScatteringMatrix
 BasePhScatteringMatrix (Context &context_, StatisticsSweep &statisticsSweep_, BaseBandStructure &innerBandStructure_, BaseBandStructure &outerBandStructure_)
 Constructor that just calls the constructor of scattering matrix.
 

Protected Member Functions

void phononOnlyA2Omega ()
 convert the phonon part of the coupled scattering matrix to Omega format. More...
 
void builder (std::shared_ptr< VectorBTE > linewidth, std::vector< VectorBTE > &inPopulations, std::vector< VectorBTE > &outPopulations)
 Method that actually computes the scattering matrix. More...
 
int bteStateToWavevector (BteIndex &iMat, BaseBandStructure &bandStructure)
 A function to get the wavevector index given the index of an element of theMatrix. More...
 
std::vector< std::vector< std::tuple< std::vector< int >, int > > > getIteratorWavevectorPairs (const bool &rowMajor=0)
 A function to generate the wavevector index pairs for which scattering rates are computed. More...
 
- Protected Member Functions inherited from ScatteringMatrix
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 scattering matrix. More...
 
void degeneracyAveragingLinewidths (std::shared_ptr< VectorBTE > linewidth)
 Performs an average of the linewidths over degenerate states. More...
 
Eigen::MatrixXd precomputeOccupations (BaseBandStructure &bandStructure)
 Function to precompute particle populations before scattering rates are calculated. More...
 
std::vector< int > getExcludeIndices (BaseBandStructure &bandStructure)
 Method which for a phonon bandstructure returns the indices to be discarded in a phonon calculation due to very low phonon frequencies. More...
 
void setMatrixCase (std::shared_ptr< VectorBTE > linewidth, std::vector< VectorBTE > &inPopulations, std::vector< VectorBTE > &outPopulations)
 
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. More...
 
void enforceDetailedBalance ()
 A function to fix the linewidths to agree with the off diagonal elements, to enforce finding the special eigenvectors.
 
void replaceMatrixLinewidths ()
 Replace the linewidths of the scatterng matrix with the supplied VectorBTE values.
 
std::tuple< BaseBandStructure *, BaseBandStructure * > getStateBandStructures (const BteIndex &iBte1, const BteIndex &iBte2)
 Returns a tuple of final and initial particles for a give state. More...
 
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 associated with ph and el bandstructures before accessing their quantities. More...
 
template<size_t n>
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. More...
 

Protected Attributes

ElectronH0WannierelectronH0
 
PhononH0phononH0
 
int numPhStates
 
- Protected Attributes inherited from BaseElScatteringMatrix
std::shared_ptr< VectorBTElinewidthMR
 
- Protected Attributes inherited from ScatteringMatrix
Contextcontext
 
StatisticsSweepstatisticsSweep
 
BaseBandStructureinnerBandStructure
 
BaseBandStructureouterBandStructure
 
enum MatrixCase matrixCase
 
bool constantRTA = false
 
bool highMemory = true
 
bool outputUNTimes = false
 
double boundaryLength
 
bool doBoundary
 
bool isMatrixOmega = false
 
bool isCoupled = false
 
std::function< std::tuple< long, long >long, long, const Particle &, const Particle &)> shiftToCoupledIndices
 
std::shared_ptr< VectorBTEinternalDiagonal
 
std::shared_ptr< VectorBTEinternalDiagonalUmklapp
 
std::shared_ptr< VectorBTEinternalDiagonalNormal
 
ParallelMatrix< double > theMatrix
 
int numStates
 
int numCalculations
 
int dimensionality_
 
int numElStates = 0
 
std::vector< int > excludeIndices
 

Friends

void addPhPhScattering (BasePhScatteringMatrix &matrix, Context &context, std::vector< VectorBTE > &inPopulations, std::vector< VectorBTE > &outPopulations, std::vector< std::tuple< std::vector< int >, int >> qPairIterator, Eigen::MatrixXd &innerBose, Eigen::MatrixXd &outerBose, BaseBandStructure &innerBandStructure, BaseBandStructure &outerBandStructure, PhononH0 *phononH0, Interaction3Ph &coupling3Ph, VectorBTE *linewidth)
 Function to reweight the different quadrants of the matrix coupled matrix to account for spin dengeneracy.
 
void addIsotopeScattering (BasePhScatteringMatrix &matrix, Context &context, std::vector< VectorBTE > &inPopulations, std::vector< VectorBTE > &outPopulations, std::vector< std::tuple< std::vector< int >, int >> qPairIterator, Eigen::MatrixXd &innerBose, Eigen::MatrixXd &outerBose, BaseBandStructure &innerBandStructure, BaseBandStructure &outerBandStructure, VectorBTE *linewidth)
 
void addPhElScattering (BasePhScatteringMatrix &matrix, Context &context, std::vector< VectorBTE > &inPopulations, std::vector< VectorBTE > &outPopulations, BaseBandStructure &phBandStructure, BaseBandStructure &elBandStructure, StatisticsSweep &statisticsSweep, InteractionElPhWan &couplingElPhWan, std::shared_ptr< VectorBTE > linewidth)
 
void addElPhScattering (BaseElScatteringMatrix &matrix, Context &context, std::vector< VectorBTE > &inPopulations, std::vector< VectorBTE > &outPopulations, std::vector< std::tuple< std::vector< int >, int >> kPairIterator, Eigen::MatrixXd &innerFermi, Eigen::MatrixXd &outerBose, BaseBandStructure &innerBandStructure, BaseBandStructure &outerBandStructure, PhononH0 &phononH0, InteractionElPhWan &couplingElPhWan, VectorBTE *linewidth)
 
void addChargedImpurityScattering (BaseElScatteringMatrix &matrix, Context &context, std::vector< VectorBTE > &inPopulations, std::vector< VectorBTE > &outPopulations, std::vector< std::tuple< std::vector< int >, int >> kPairIterator, BaseBandStructure &innerBandStructure, BaseBandStructure &outerBandStructure, std::shared_ptr< VectorBTE > linewidth)
 
void addDragTerm (CoupledScatteringMatrix &matrix, Context &context, std::vector< std::tuple< std::vector< int >, int >> kqPairIterator, const int &dragTermType, InteractionElPhWan &couplingElPhWan, BaseBandStructure &innerBandStructure, BaseBandStructure &outerBandStructure)
 
void phononElectronAcousticSumRule (CoupledScatteringMatrix &matrix, Context &context, BaseBandStructure &elBandStructure, BaseBandStructure &phBandStructure)
 

Additional Inherited Members

- Static Public Member Functions inherited from ScatteringMatrix
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. More...
 

Detailed Description

This class contains the logic to compute the combined scattering matrix. For a coupled BTE solve. The parent class ScatteringMatrix instead contains the logic for managing the operations with distribution vectors.

electron-self | electron-drag

phonon-drag | phonon-self

Constructor & Destructor Documentation

◆ CoupledScatteringMatrix()

CoupledScatteringMatrix::CoupledScatteringMatrix ( Context context_,
StatisticsSweep statisticsSweep_,
BaseBandStructure innerBandStructure_,
BaseBandStructure outerBandStructure_,
ElectronH0Wannier electronH0_ = nullptr,
PhononH0 phononH0_ = nullptr 
)
Parameters
contextthe user-initialized variables.
statisticsSweepthe object containing the information on the temperatures to be used in the calculation.
innerBandStructurethis is the band structure object used for integrating the sum over final state wavevectors.
outerBandStructurethis is the bandStructure object used for integrating the sum over initial state wavevectors.
coupling3Pha pointer to the class handling the 3-phonon interaction calculation.
couplingElPha pointer to the class handling the el-ph interaction calculation.
PhononH0the object used for constructing phonon energies.
ElectronH0the object used for constructing electron energies.

Note: For transport calculations inner=outer. Other scattering matrices allow for the possibility that they aren't equal, but this matrix will only be used for transport.

Here is the call graph for this function:

Member Function Documentation

◆ bteStateToWavevector()

int CoupledScatteringMatrix::bteStateToWavevector ( BteIndex iMat,
BaseBandStructure bandStructure 
)
protected
Parameters
bandstructurethe bandstructure object to which the state corresponds
iMatthe matrix element index to be converted
Returns
: wavevectorIndex of this iMat element
Here is the call graph for this function:
Here is the caller graph for this function:

◆ builder()

void CoupledScatteringMatrix::builder ( std::shared_ptr< VectorBTE linewidth,
std::vector< VectorBTE > &  inPopulations,
std::vector< VectorBTE > &  outPopulations 
)
protectedvirtual

Pure virtual function: needs an implementation in every subclass.

Implements ScatteringMatrix.

Here is the call graph for this function:

◆ getIteratorWavevectorPairs()

std::vector< std::vector< std::tuple< std::vector< int >, int > > > CoupledScatteringMatrix::getIteratorWavevectorPairs ( const bool &  rowMajor = 0)
protected

The coupled scattering matrix is a special case. It will always be in memory, and pairs will always be between final and initial bandstructures which are either the same, or el-ph pairs. Therefore, we always distribute over the states of the parallel matrix which are local, and return these kq pairs. Both arguments here are unused, but left in place because this function should override the scattering matrix one, to ensure that function isn't called for this Smatrix.

Parameters
rowMajordummy variable
Returns
: a vector containing the four necessary iterators, over k pairs, kq pairs, or q pairs needed to compute the scattering rates.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPhBandStructure()

BaseBandStructure * CoupledScatteringMatrix::getPhBandStructure ( )
Parameters
outFileNamestring representing the name of the json file
Here is the caller graph for this function:

◆ phononOnlyA2Omega()

void CoupledScatteringMatrix::phononOnlyA2Omega ( )
protected

this is needed because the electron part is already Omega by default, but the phonon scattering rate functions output A.

Here is the call graph for this function:
Here is the caller graph for this function: