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

Class for diagonalizing electronic energies with the Wannier interpolation The object is built passing the information produced by the file _tb.dat of Wannier90, and can be used to compute the interpolated band structure.

#include <electron_h0_wannier.h>

Inheritance diagram for ElectronH0Wannier:
Collaboration diagram for ElectronH0Wannier:

Public Member Functions

 ElectronH0Wannier (const Eigen::Matrix3d &directUnitCell_, const Eigen::MatrixXd &bravaisVectors_, const Eigen::VectorXd &vectorsDegeneracies_, const Eigen::Tensor< std::complex< double >, 3 > &h0R_, const Eigen::Tensor< std::complex< double >, 4 > *rMatrix_=nullptr)
 Constructor for the electronic Hamiltonian in the Wannier case. More...
 
 ElectronH0Wannier (const ElectronH0Wannier &that)
 Copy constructor.
 
ElectronH0Wannieroperator= (const ElectronH0Wannier &that)
 Copy assignment.
 
 ~ElectronH0Wannier ()
 Class destructor.
 
Particle getParticle () override
 Method to return that the underlying is that of an electronic Fermion.
 
int getNumBands () override
 get the total number of bands. More...
 
std::tuple< Eigen::VectorXd, Eigen::MatrixXcd > diagonalize (Point &point) override
 get the electronic energies (in Ry) at a single k-point. More...
 
std::tuple< Eigen::VectorXd, Eigen::MatrixXcd > diagonalizeFromCoordinates (Eigen::Vector3d &k) override
 Diagonalize the Harmonic Hamiltonian at an arbitrary wavevector. More...
 
std::tuple< std::vector< Eigen::VectorXd >, std::vector< Eigen::MatrixXcd > > batchedDiagonalizeFromCoordinates (std::vector< Eigen::Vector3d > &cartesianWavevectors)
 Computes energies and eigenvectors of electrons for a batch of nk wavevectors. More...
 
std::vector< Eigen::MatrixXcd > batchedBuildHamiltonians (std::vector< Eigen::Vector3d > &cartesianWavevectors)
 Computes the Fourier transform of the Wannier Hamiltonian at a batch of wavevectors. More...
 
StridedComplexView3D kokkosBatchedBuildBlochHamiltonian (const DoubleView2D &cartesianCoordinates) override
 Computes the Fourier transform of the Wannier Hamiltonian at a batch of wavevectors. More...
 
std::tuple< DoubleView2D, StridedComplexView3D > kokkosBatchedDiagonalizeFromCoordinates (const DoubleView2D &cartesianCoordinates, const bool withMassScaling=true) override
 Computes energies and eigenvectors of electrons for a batch of nk wavevectors. More...
 
std::tuple< DoubleView2D, StridedComplexView3D, ComplexView4D > kokkosBatchedDiagonalizeWithVelocities (const DoubleView2D &cartesianCoordinates) override
 Using kokkos, computes the electronic properties of a batch of wavevectors. More...
 
Eigen::Tensor< std::complex< double >, 3 > diagonalizeVelocity (Point &point) override
 get the electron velocities (in atomic units) at a single k-point. More...
 
Eigen::Tensor< std::complex< double >, 3 > diagonalizeVelocityFromCoordinates (Eigen::Vector3d &coordinates) override
 
std::tuple< std::vector< Eigen::VectorXd >, std::vector< Eigen::MatrixXcd >, std::vector< Eigen::Tensor< std::complex< double >, 3 > > > batchedDiagonalizeWithVelocities (std::vector< Eigen::Vector3d > cartesianCoordinates)
 Same as diagonalizeVelocityFromCoordinates, but constructs the velocity operator for a batch of wavevectors. More...
 
FullBandStructure populate (Points &fullPoints, const bool &withVelocities, const bool &withEigenvectors, const bool isDistributed=false) override
 This method constructs an electron band structure. More...
 
std::tuple< std::vector< Eigen::VectorXd >, std::vector< Eigen::MatrixXcd >, std::vector< Eigen::Tensor< std::complex< double >, 3 > > > populate (const std::vector< Eigen::Vector3d > &cartesianCoordinates, const bool &withVelocities, const bool &withEigenvectors)
 Runs populate on a points list, without creating a new bandstructure object this is necessary if we need energies for some non-uniform grid of points currently this only used by the phonon electron scattering calculation. More...
 
FullBandStructure cpuPopulate (Points &fullPoints, const bool &withVelocities, const bool &withEigenvectors, const bool isDistributed=false)
 Internal helper function for cpu diag of electron H0.
 
std::tuple< std::vector< Eigen::VectorXd >, std::vector< Eigen::MatrixXcd >, std::vector< Eigen::Tensor< std::complex< double >, 3 > > > kokkosPopulate (const std::vector< Eigen::Vector3d > &cartesianCoordinates, const bool &withVelocities, const bool &withEigenvectors, const std::vector< int > &iks)
 Internal helper function for kokkos diag of electron H0.
 
std::vector< Eigen::MatrixXcd > getBerryConnection (Point &point)
 compute the Berry connection <u_mk| nabla_k |u_nk> at arb. More...
 
void addShiftedVectors (Eigen::Tensor< double, 3 > degeneracyShifts_, Eigen::Tensor< double, 5 > vectorsShifts_)
 Function used during parsing, to add the shifts used in the phases for the Fourier interpolation. More...
 
int estimateBatchSize (const bool &withVelocity) override
 Estimate how many k-points we can compute on the GPU in one batch. More...
 
- Public Member Functions inherited from HarmonicHamiltonian
void kokkosBatchedTreatDegenerateVelocities (const DoubleView2D &cartesianCoordinates, const DoubleView2D &resultEnergies, ComplexView4D &resultVelocities, const double &threshold)
 

Protected Member Functions

double getDeviceMemoryUsage ()
 Checks the size of Device-allocated views. More...
 

Protected Attributes

Particle particle
 
Eigen::MatrixXd bravaisVectors
 
Eigen::VectorXd vectorsDegeneracies
 
Eigen::Matrix3d directUnitCell
 
Eigen::Tensor< std::complex< double >, 3 > h0R
 
Eigen::Tensor< std::complex< double >, 4 > rMatrix
 
int numWannier
 
int numVectors
 
Eigen::Tensor< double, 3 > degeneracyShifts
 
Eigen::Tensor< double, 5 > vectorsShifts
 
bool hasShiftedVectors = false
 
ComplexView3D h0R_d
 
DoubleView3D degeneracyShifts_d
 
DoubleView5D vectorsShifts_d
 
DoubleView1D vectorsDegeneracies_d
 
DoubleView2D bravaisVectors_d
 

Constructor & Destructor Documentation

◆ ElectronH0Wannier()

ElectronH0Wannier::ElectronH0Wannier ( const Eigen::Matrix3d &  directUnitCell_,
const Eigen::MatrixXd &  bravaisVectors_,
const Eigen::VectorXd &  vectorsDegeneracies_,
const Eigen::Tensor< std::complex< double >, 3 > &  h0R_,
const Eigen::Tensor< std::complex< double >, 4 > *  rMatrix_ = nullptr 
)
Parameters
directUnitCell_the real space unit cell of the crystal in Bohr
bravaisVectors_the R vectors for the Fourier transform, dimension (3, nRVectors)
vectorsDegeneracies_the weights of the R vectors for the Fourier transform
h0R_the Wannier Hamiltonian in real space
rMatrix_position matrix elements <0m|r|nR>
Here is the call graph for this function:

Member Function Documentation

◆ addShiftedVectors()

void ElectronH0Wannier::addShiftedVectors ( Eigen::Tensor< double, 3 >  degeneracyShifts_,
Eigen::Tensor< double, 5 >  vectorsShifts_ 
)

Results will be slightly more expensive but more accurate, especially for very small mesh sizes.

Parameters
degeneracyShifts_vector with the degeneracy of each shifted bravais lattice vector
vectorsShifts_the shifts to be added to the bravais lattice vectors.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ batchedBuildHamiltonians()

std::vector< Eigen::MatrixXcd > ElectronH0Wannier::batchedBuildHamiltonians ( std::vector< Eigen::Vector3d > &  cartesianWavevectors)
Parameters
cartesianWavevectorsa std::vector containing the cartesian coordinates of nk wavevectors.
Returns
a vector of hamiltonian matrices in the Bloch representation.
Here is the caller graph for this function:

◆ batchedDiagonalizeFromCoordinates()

std::tuple< std::vector< Eigen::VectorXd >, std::vector< Eigen::MatrixXcd > > ElectronH0Wannier::batchedDiagonalizeFromCoordinates ( std::vector< Eigen::Vector3d > &  cartesianWavevectors)
Parameters
cartesianWavevectorsa std::vector containing the cartesian coordinates of nk wavevectors.
Returns
tuple with vectors of energies(nk,nb) and eigenvectors(nk,nb,nb).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ batchedDiagonalizeWithVelocities()

std::tuple< std::vector< Eigen::VectorXd >, std::vector< Eigen::MatrixXcd >, std::vector< Eigen::Tensor< std::complex< double >, 3 > > > ElectronH0Wannier::batchedDiagonalizeWithVelocities ( std::vector< Eigen::Vector3d >  cartesianCoordinates)

Do diagonalization for a batch of k-points on the CPU.

Parameters
cartesianCoordinatesof size(nK,3), contains the cartesian coordinates of the wavevectors at which we want the electronic properties.
Returns
tuple, containing vectors of energies, eigenvectors and velocities at each input wavevector.

Returns the energies (nk, nb), eigenvectors (nk, nb, nb) and velocities (nk, nb, nb, 3) at each k-point.

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

◆ diagonalize()

std::tuple< Eigen::VectorXd, Eigen::MatrixXcd > ElectronH0Wannier::diagonalize ( Point point)
overridevirtual

Energies don't have any reference value, and must be used in connection with a chemical potential.

Parameters
ka point object with the wavevector. Must have the cartesian coordinates of the wavevector.
Returns
tuple(energies, eigenvectors): the energies are a double vector of size (numBands). Eigenvectors of size (numBands,numBands) are the complex unitary transformation matrix U, connecting the Wannier gauge with the Bloch gauge.

Implements HarmonicHamiltonian.

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

◆ diagonalizeFromCoordinates()

std::tuple< Eigen::VectorXd, Eigen::MatrixXcd > ElectronH0Wannier::diagonalizeFromCoordinates ( Eigen::Vector3d &  k)
overridevirtual

Same as diagonalize(), but the wavevector coordinates are explicitly passed in input.

Parameters
pointthe wavevector in cartesian coordinates.
Returns
eigenvalues: the values of quasiparticle energies, a double vector of size numBands.
eigenvectors: a complex matrix of size (numBands,numBands) with the eigenvectors, ordered in columns, computed at the input wavevector.

Implements HarmonicHamiltonian.

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

◆ diagonalizeVelocity()

Eigen::Tensor< std::complex< double >, 3 > ElectronH0Wannier::diagonalizeVelocity ( Point point)
overridevirtual
Parameters
ka Point object with the wavevector coordinates.
Returns
velocity(numBands,numBands,3): values of the velocity operator for this state, in atomic units.

Implements HarmonicHamiltonian.

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

◆ estimateBatchSize()

int ElectronH0Wannier::estimateBatchSize ( const bool &  withVelocity)
overridevirtual
Parameters
withVelocityset to true if computing also the velocity operator, which requires more memory
Returns
numBatches: an estimate on how many k-point we can compute in one call of the kokkosBatched functions.

Reimplemented from HarmonicHamiltonian.

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

◆ getBerryConnection()

std::vector< Eigen::MatrixXcd > ElectronH0Wannier::getBerryConnection ( Point point)

wavevectors.

Parameters
pointthe Point coordinates of the wavevector.
Returns
Berry connection: a generalized Berry connection in the form of a matrix <u_mk| nabla_k |u_nk> for a fixed wavevector. The Berry connection is actually just the diagonal matrix elements.
Here is the call graph for this function:

◆ getDeviceMemoryUsage()

double ElectronH0Wannier::getDeviceMemoryUsage ( )
protected
Returns
size occupied by Kokkos views, in bytes.
Here is the caller graph for this function:

◆ getNumBands()

int ElectronH0Wannier::getNumBands ( )
overridevirtual

This is a constant for all wavevectors.

Implements HarmonicHamiltonian.

Here is the caller graph for this function:

◆ kokkosBatchedBuildBlochHamiltonian()

StridedComplexView3D ElectronH0Wannier::kokkosBatchedBuildBlochHamiltonian ( const DoubleView2D &  cartesianCoordinates)
overridevirtual

Build Hamiltonians for a batch of k-points.

Parameters
cartesianCoordinatesa ComplexView2D object of size (nk,3) (must already be on the GPU), containing the cartesian coordinates of a batch of nk wavevectors.
Returns
a View object of size nk,nb,nb containing the nk Hamiltonian matrices.

Implements HarmonicHamiltonian.

Here is the caller graph for this function:

◆ kokkosBatchedDiagonalizeFromCoordinates()

std::tuple< DoubleView2D, StridedComplexView3D > ElectronH0Wannier::kokkosBatchedDiagonalizeFromCoordinates ( const DoubleView2D &  cartesianCoordinates,
const bool  withMassScaling = true 
)
overridevirtual

Create and diagonalize Hamiltonians for a batch of k-points.

Parameters
cartesianCoordinatesa ComplexView2D object of size (nk,3) (must already be on the GPU), containing the cartesian coordinates of a batch of nk wavevectors.
Returns
a tuple of views of energy(nk,nb) and eigenvectors(nk,nb,nb) at each wavevector.

Implements HarmonicHamiltonian.

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

◆ kokkosBatchedDiagonalizeWithVelocities()

std::tuple< DoubleView2D, StridedComplexView3D, ComplexView4D > ElectronH0Wannier::kokkosBatchedDiagonalizeWithVelocities ( const DoubleView2D &  cartesianCoordinates)
overridevirtual

Build and diagonalize Hamiltonians, with velocities Returns the energies (nk, nb), eigenvectors (nk, nb, nb) and velocities (nk, nb, nb, 3) at each k-point.

Parameters
cartesianCoordinatesa ComplexView2D object of size (nk,3) (must already be on the GPU), containing the cartesian coordinates of a batch of nk wavevectors.
Returns
a tuple with energies(nk,nb), eigenvectors(nk,nb,nb) and velocities(nk,nb,nb,3) at each wavevector.

Note that for each k-point, the (nb, nb) eigenvector matrix is column-major, as required by the cuSOLVER routine, hence the StridedLayout.

Implements HarmonicHamiltonian.

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

◆ populate() [1/2]

std::tuple< std::vector< Eigen::VectorXd >, std::vector< Eigen::MatrixXcd >, std::vector< Eigen::Tensor< std::complex< double >, 3 > > > ElectronH0Wannier::populate ( const std::vector< Eigen::Vector3d > &  cartesianCoordinates,
const bool &  withVelocities,
const bool &  withEigenvectors 
)
Parameters
cartesianCoordinatesthe vector with the list of wavevectors in cartesianCoords
withVelocitiesif true, compute the electron velocity operator.
withEigenvectorsif true, stores the Wannier eigenvectors.
Returns
std::tuple: A tuple of std::vectors of eigen objs containing energies, velocities, and eigenvectors of the electronic band structure on the provided points
Here is the call graph for this function:

◆ populate() [2/2]

FullBandStructure ElectronH0Wannier::populate ( Points fullPoints,
const bool &  withVelocities,
const bool &  withEigenvectors,
const bool  isDistributed = false 
)
overridevirtual
Parameters
pointsthe object with the list/mesh of wavevectors
withVelocitiesif true, compute the electron velocity operator.
withEigenvectorsif true, stores the Wannier eigenvectors.
Returns
FullBandStructure: the band structure object containing the complete electronic band structure.

Implements HarmonicHamiltonian.

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