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

Main driver for the transport calculation.

#include <elph_qe_to_phoebe_app.h>

Inheritance diagram for ElPhQeToPhoebeApp:
Collaboration diagram for ElPhQeToPhoebeApp:

Public Member Functions

void run (Context &context) override
 Executes the program contained in this class.
 
void checkRequirements (Context &context) override
 Check that user provided all necessary input.
 
void postProcessingWannier (Context &context, Crystal &crystal, PhononH0 &phononH0, Points &kPoints, Points &qPoints, int numQEBands, int numModes, int numIrrQPoints, int numElectrons, int numSpin, const Eigen::MatrixXd &energies, const Eigen::MatrixXd &kGridFull, const Eigen::Vector3i &kMesh, const Eigen::Vector3i &qMesh, bool runTests=false)
 This is the driver for converting QE data to Phoebe data for Wannier interpolation of the el-ph coupling. More...
 

Static Public Member Functions

static std::tuple< Eigen::Vector3i, Eigen::Vector3i, Eigen::MatrixXd, Eigen::MatrixXd, Eigen::MatrixXd, int, int, int, int > readQEPhoebeHeader (Crystal &crystal, const std::string &phoebePrefixQE)
 In this function, we read the header file produced by the patched QE version. More...
 
- Static Public Member Functions inherited from App
static std::unique_ptr< ApploadApp (const std::string &choice)
 Factory method, used to load the desired subclass. More...
 

Protected Member Functions

Eigen::Tensor< std::complex< double >, 5 > BlochToWannierEfficient (Context &context, const Eigen::MatrixXd &energies, const Eigen::MatrixXd &kGridFull, const int &numIrrQPoints, const int &numQEBands, const Eigen::MatrixXd &elBravaisVectors, const Eigen::MatrixXd &phBravaisVectors, const Eigen::Tensor< std::complex< double >, 3 > &uMatrices, Points &kPoints, Points &qPoints, Crystal &crystal, PhononH0 &phononH0)
 
std::tuple< Eigen::Tensor< std::complex< double >, 5 >, Eigen::Tensor< std::complex< double >, 3 >, Eigen::MatrixXd > readGFromQEFile (Context &context, const int &numModes, const int &numBands, const int &numWannier, Points &kPoints, Points &qPoints, const Eigen::MatrixXd &kGridFull, const int &numIrrQPoints, const int &numQEBands, const Eigen::MatrixXd &energies)
 Reads the electron-phonon coupling computed by QE on a coarse grid. More...
 
std::tuple< Eigen::Tensor< std::complex< double >, 5 >, Eigen::Tensor< std::complex< double >, 3 >, Eigen::MatrixXd, Eigen::MatrixXd > readChunkGFromQE (const int &iqIrr, Context &context, Points &kPoints, const int &numModes, const int &numQEBands, const Eigen::VectorXi &ikMap)
 
void epaPostProcessing (Context &context, Eigen::MatrixXd &elEnergies, Points &kPoints, Points &qPoints, const int &numElectrons, const int &numSpin, const int &numModes, const int &numIrrQPoints, const int &numQEBands, const Eigen::MatrixXd &kGridFull)
 Main driver for generating the EPA coupling. More...
 

Static Protected Member Functions

static Eigen::Tensor< std::complex< double >, 5 > blochToWannier (const Eigen::MatrixXd &elBravaisVectors, const Eigen::MatrixXd &phBravaisVectors, Eigen::Tensor< std::complex< double >, 5 > &gFull, const Eigen::Tensor< std::complex< double >, 3 > &uMatrices, const Eigen::Tensor< std::complex< double >, 3 > &phEigenvectors, Points &kPoints, Points &qPoints, Crystal &crystal, PhononH0 &phononH0)
 Transform the electron-phonon coupling computed by QE from the Bloch to the Wannier representation. More...
 
static Eigen::Tensor< std::complex< double >, 3 > setupRotationMatrices (const std::string &wannierPrefix, Points &fullPoints)
 Returns the rotation that moves the wave-function from the (entangled) Bloch representation to the disentangled Wannier representation. More...
 
static int computeOffset (const Eigen::MatrixXd &energies, const std::string &wannierPrefix)
 This method compares the energies computed by qe2wannier90 and the energies of quantum espresso pw.x, to compute the offset between the two sets (wannier90 may skip some core states).
 
static void testElectronicTransform (Points &kPoints, const std::string &wannierPrefix, const Eigen::MatrixXd &elBravaisVectors, const Eigen::Tensor< std::complex< double >, 3 > &uMatrices, const Eigen::VectorXd &elDegeneracies, ElectronH0Wannier &electronH0)
 Test that the transform Wannier To Bloch of the electronic Hamiltonian returns the original results computed by QE/Wannier90 on a coarse grid. More...
 
static void testPhononTransform (Crystal &crystal, PhononH0 &phononH0, Points &qPoints, const Eigen::Tensor< std::complex< double >, 3 > &phEigenvectors, const Eigen::MatrixXd &phBravaisVectors, const Eigen::VectorXd &phDegeneracies, const Eigen::MatrixXd &phEnergies)
 Test that the transform Wannier To Bloch of the phonon harmonic Hamiltonian returns the original results computed by QE on a coarse grid. More...
 
static void testBackTransform (Context &context, PhononH0 &phononH0, Points &kPoints, Points &qPoints, ElectronH0Wannier &electronH0, Crystal &crystal, Eigen::Tensor< std::complex< double >, 5 > &gFull)
 Test that the transform Wannier To Bloch of the electron-phonon coupling returns the original results computed by QE on a coarse grid, and that it is correctly computed tby the class InteractionElPh. More...
 
static void writeWannierCoupling (Context &context, Eigen::Tensor< std::complex< double >, 5 > &gWannier, const int &numFilledWannier, const int &numSpin, const int &numModes, const int &numWannier, const Eigen::VectorXd &phDegeneracies, const Eigen::VectorXd &elDegeneracies, const Eigen::MatrixXd &phBravaisVectors, const Eigen::MatrixXd &elBravaisVectors, const Eigen::Vector3i &qMesh, const Eigen::Vector3i &kMesh)
 This function writes the el-ph coupling to file. More...
 
- Static Protected Member Functions inherited from App
static void throwErrorIfUnset (const std::string &x, const std::string &name)
 
static void throwErrorIfUnset (const std::vector< std::string > &x, const std::string &name)
 
static void throwErrorIfUnset (const double &x, const std::string &name)
 
static void throwErrorIfUnset (const Eigen::VectorXi &x, const std::string &name)
 
static void throwErrorIfUnset (const Eigen::Vector3i &x, const std::string &name)
 
static void throwErrorIfUnset (const Eigen::VectorXd &x, const std::string &name)
 
static void throwErrorIfUnset (const Eigen::MatrixXd &x, const std::string &name)
 
static void throwErrorIfUnset (const Eigen::Tensor< double, 3 > &x, const std::string &name)
 
static void throwWarningIfUnset (const std::string &x, const std::string &name)
 

Protected Attributes

std::vector< std::string > choices
 

Member Function Documentation

◆ blochToWannier()

Eigen::Tensor< std::complex< double >, 5 > ElPhQeToPhoebeApp::blochToWannier ( const Eigen::MatrixXd &  elBravaisVectors,
const Eigen::MatrixXd &  phBravaisVectors,
Eigen::Tensor< std::complex< double >, 5 > &  gFull,
const Eigen::Tensor< std::complex< double >, 3 > &  uMatrices,
const Eigen::Tensor< std::complex< double >, 3 > &  phEigenvectors,
Points kPoints,
Points qPoints,
Crystal crystal,
PhononH0 phononH0 
)
staticprotected

Follows roughly the procedure described in [PRB 76, 165108 (2007)]. This is the expensive function of this app.

Parameters
elBravaisVectorslist of Bravais lattice vectors for the electronic Fourier transform
phBravaisVectorslist of Bravais lattice vectors for the phonon Fourier transform
gFullelectron-phonon coupling in the Bloch space, with size gFull(nBands, nBands, nModes, nKPoints, nQPoints), where in the notation of [PRB 76, 165108 (2007)], is g(i,j,nu,k,q) = g_{i,j,nu}(k,q)
uMatricesthe matrices for the rotation to the maximally localized basis set of Wannier functions. Has size U(nBands,nWannier,k). Note that there can be more bands than Wannier functions due to the disentanglement procedure of Wannier90.
phEigenvectorstensor (nu,mu,q) with the phonon eigenvectors, where the first index is the index on cartesian and atomic basis, the second is the index on phonon modes, and the third is on q-points.
kPointsFullPoints class of k-points.
qPointsFullPoints class of q-points.
crystalclass describing the crystal unit cell.
phononH0class with the Phonon harmonic Hamiltonian.
Returns
g: the electron-phonon coupling in the Wannier representation. in the notation of [PRB 76, 165108 (2007)], is g(n,m,mu,R_p,R_e) = g_{m,n,mu}(R_e,R_p). Note that the first index refers to what must be Fourier transformed to k, whereas PRB refers that to the band at k+q.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ epaPostProcessing()

void ElPhQeToPhoebeApp::epaPostProcessing ( Context context,
Eigen::MatrixXd &  elEnergies,
Points kPoints,
Points qPoints,
const int &  numElectrons,
const int &  numSpin,
const int &  numModes,
const int &  numIrrQPoints,
const int &  numQEBands,
const Eigen::MatrixXd &  kGridFull 
)
protected

UNTESTED!

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

◆ postProcessingWannier()

void ElPhQeToPhoebeApp::postProcessingWannier ( Context context,
Crystal crystal,
PhononH0 phononH0,
Points kPoints,
Points qPoints,
int  numQEBands,
int  numModes,
int  numIrrQPoints,
int  numElectrons,
int  numSpin,
const Eigen::MatrixXd &  energies,
const Eigen::MatrixXd &  kGridFull,
const Eigen::Vector3i &  kMesh,
const Eigen::Vector3i &  qMesh,
bool  runTests = false 
)
Parameters
contextclass with user input values.
crystalclass describing crystal unit cell.
phononH0class with the phonon harmonic Hamiltonian.
kPointscoarse grid of k-points used by QE.
qPointscoarse grid of q-points used by QE. Equal to kPoints.
numQEBandsnumber of Kohn-Sham states used by QE.
numModesnumber of phonon modes = 3*numAtoms.
numIrrQPointsnumber of irreducible q-points computed by QE.
numElectronsnumber of electrons in the crystal unit cell.
numSpinnumber of spin components used by QE.
energiesmatrix with electronic energies.
kGridFulllist of k-point cartesian coordinates in Bohr^-1.
kMeshmesh of k-points used by QE.
qMeshmesh of q-points used by QE.
runTestsif true (*default False) runs some sanity checks.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readGFromQEFile()

std::tuple< Eigen::Tensor< std::complex< double >, 5 >, Eigen::Tensor< std::complex< double >, 3 >, Eigen::MatrixXd > ElPhQeToPhoebeApp::readGFromQEFile ( Context context,
const int &  numModes,
const int &  numBands,
const int &  numWannier,
Points kPoints,
Points qPoints,
const Eigen::MatrixXd &  kGridFull,
const int &  numIrrQPoints,
const int &  numQEBands,
const Eigen::MatrixXd &  energies 
)
protected

Note: numQEBands != numBands. The first is the number of bands computes in QE, while the latter is the number of bands passed to Wannier90.

Note: we pass kGridFull because we need to align the list of kPoints used by QE with the "list" of kPoints of Phoebe.

Parameters
contextclass with user input.
numModesnumber of phonon modes.
numBandsnumber of bands used in QE
numWanniernumber of Wannier functions
kPointsFullPoints class with kPoints
qPointsFullPoints class with qPoints
kGridFulllist of kPoints in cartesian coordinates in QE
numIrrQPointsnumber of irreducible qPoints used by QE
numQEBandsnumber of KS bands used by QE.
energiesmatrix with electronic energies
Returns
tuple with:
  • gFull: electron-phonon coupling in the Bloch space, with size gFull(nBands, nBands, nModes, nKPoints, nQPoints), where in the notation of [PRB 76, 165108 (2007)], is g(i,j,nu,k,q) = g_{i,j,nu}(k,q)
  • complex tensor (nu,mu,q) with the phonon eigenvectors, where the first index is the index on cartesian and atomic basis, the second is the index on phonon modes, and the third is on q-points.
  • MatrixXd(nb,nq) containing phonon energies
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readQEPhoebeHeader()

std::tuple< Eigen::Vector3i, Eigen::Vector3i, Eigen::MatrixXd, Eigen::MatrixXd, Eigen::MatrixXd, int, int, int, int > ElPhQeToPhoebeApp::readQEPhoebeHeader ( Crystal crystal,
const std::string &  phoebePrefixQE 
)
static

The header contains some global and/or electronic information coming from Quantum-ESPRESSO.

Parameters
crystalclass with the crystal info,
phoebePrefixQEprefix of file, e.g. "si" corresponds to the file "si.phoebe.****.dat"
Returns
tuple: with elements:
  • Eigen::Vector3i: mesh of q-points
  • Eigen::Vector3i: mesh of k-points
  • Eigen::MatrixXd(3,nk): kPoint cartesian coordinates in Bohr^-1
  • Eigen::MatrixXd(3,nq): qPoint cartesian coordinates in Bohr^-1
  • Eigen::Matrix(nb,nk): electronic energies
  • int : number of irreducible q-points.
  • numQEBands: number of KS states used by QE in the ph.x run
  • numElectrons: number of electrons in the unit cell (KS states>= electrons)
  • numSpin: number of spin components.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setupRotationMatrices()

Eigen::Tensor< std::complex< double >, 3 > ElPhQeToPhoebeApp::setupRotationMatrices ( const std::string &  wannierPrefix,
Points fullPoints 
)
staticprotected
Parameters
wannierPrefixpath with the prefix used for the Wannier90 calculation (e.g. "si" or "./si")
fullPointscoarse grid of wavevectors. Must be aligned with the grid used in Wannier90 or an error will be raised.
Returns
U: tensor of shape (numBands, numWannier, numPoints), where the wavevector index is aligned with fullPoints. If no disentanglement was used in Wannier90, numWannier = numBands, otherwise, numBands > numWannier due to the disentanglement. See Wannier90 docs.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ testBackTransform()

void ElPhQeToPhoebeApp::testBackTransform ( Context context,
PhononH0 phononH0,
Points kPoints,
Points qPoints,
ElectronH0Wannier electronH0,
Crystal crystal,
Eigen::Tensor< std::complex< double >, 5 > &  gFull 
)
staticprotected

This is the important test of el-ph Wannier interpolation We compute the band structure Read the el-ph interaction from file Check that the el-ph coupling, interpolated on the same initial grid, is the same of the el-ph coupling read from QE.

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

◆ testElectronicTransform()

void ElPhQeToPhoebeApp::testElectronicTransform ( Points kPoints,
const std::string &  wannierPrefix,
const Eigen::MatrixXd &  elBravaisVectors,
const Eigen::Tensor< std::complex< double >, 3 > &  uMatrices,
const Eigen::VectorXd &  elDegeneracies,
ElectronH0Wannier electronH0 
)
staticprotected

This is a simple test: 1) Fourier Transform the electronic Hamiltonian to Wannier representation Here I use the U matrices from file 2) FT back to Bloch representation, using the U matrices from ElectronH0 on the original grid of k-points If everything works, I expect to find the same electronic energies Phases of rotation matrices in the back-FT will be random.

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

◆ testPhononTransform()

void ElPhQeToPhoebeApp::testPhononTransform ( Crystal crystal,
PhononH0 phononH0,
Points qPoints,
const Eigen::Tensor< std::complex< double >, 3 > &  phEigenvectors,
const Eigen::MatrixXd &  phBravaisVectors,
const Eigen::VectorXd &  phDegeneracies,
const Eigen::MatrixXd &  phEnergies 
)
staticprotected

Like the test above, we 1) FT to real space phonon basis representation. Since these are force constants, they should be real. 2) FT back to Bloch space and check that we find the same results.

We also verify that the eigenvectors are normalized by masses Note that the test works fine for non-polar systems.

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

◆ writeWannierCoupling()

void ElPhQeToPhoebeApp::writeWannierCoupling ( Context context,
Eigen::Tensor< std::complex< double >, 5 > &  gWannier,
const int &  numFilledWannier,
const int &  numSpin,
const int &  numModes,
const int &  numWannier,
const Eigen::VectorXd &  phDegeneracies,
const Eigen::VectorXd &  elDegeneracies,
const Eigen::MatrixXd &  phBravaisVectors,
const Eigen::MatrixXd &  elBravaisVectors,
const Eigen::Vector3i &  qMesh,
const Eigen::Vector3i &  kMesh 
)
staticprotected

There are three modes of writing file. 1) plain text file. The slowest option, but we allow the user to not use the HDF5 file format. 2) HDF5 v1 (default and preferred). The el-ph tensor is written to a single dataspace. if compiled with parallel HDf5, the write operation is done in parallel. Note that we do the write operation in bunches of siez ~2Gb. This is done to avoid a limitation of the MPI library, which has problem when offsets to the tensor become > max(INT_32). 3) HDF5 v2. The el-ph tensor is split along the R_e index into different datasets. This format has been introduced because we suspect the HDF5 library has limitations when the electron-phonon tensor is very large. We suspect this happens when the tensor size > max(UINT_32).

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