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

class that computes phonon energies, velocities and eigenvectors. More...

#include <phonon_h0.h>

Inheritance diagram for PhononH0:
Collaboration diagram for PhononH0:

Public Member Functions

 PhononH0 (Crystal &crystal, Eigen::Tensor< double, 5 > &forceConstants_, Eigen::Vector3i &qCoarseGrid, const Eigen::MatrixXd &bravaisVectors_, const Eigen::VectorXd &weights_, const int fcRangeType)
 Constructor, which stores all input data. More...
 
 PhononH0 (const PhononH0 &that)
 Copy constructor.
 
PhononH0operator= (const PhononH0 &that)
 Copy assignment operator.
 
 ~PhononH0 ()
 Destructor.
 
int getNumBands () override
 Returns the number of phonon bands for the crystal in consideration.
 
Particle getParticle () override
 Returns the underlying phonon-boson particle.
 
std::tuple< Eigen::VectorXd, Eigen::MatrixXcd > diagonalize (Point &point) override
 get the phonon energies (in Ry) at a single q-point. More...
 
std::tuple< Eigen::VectorXd, Eigen::MatrixXcd > diagonalizeFromCoordinates (Eigen::Vector3d &q, const bool &withMassScaling)
 Equivalent to diagonalize() computes phonon eigenValues/Vectors given the wavevector, but the wavevector is passed by coordinates. More...
 
std::tuple< Eigen::VectorXd, Eigen::MatrixXcd > diagonalizeFromCoordinates (Eigen::Vector3d &q) override
 Diagonalize the Harmonic Hamiltonian at an arbitrary wavevector. More...
 
Eigen::Tensor< std::complex< double >, 3 > diagonalizeVelocity (Point &point) override
 get the phonon velocities (in atomic units) at a single q-point. More...
 
Eigen::Tensor< std::complex< double >, 3 > diagonalizeVelocityFromCoordinates (Eigen::Vector3d &coordinates) override
 
FullBandStructure populate (Points &points, const bool &withVelocities, const bool &withEigenvectors, const bool isDistributed=false) override
 This method constructs a phonon band structure. More...
 
FullBandStructure cpuPopulate (Points &points, const bool &withVelocities, const bool &withEigenvectors, bool isDistributed=false)
 
FullBandStructure kokkosPopulate (Points &points, const bool &withVelocities, const bool &withEigenvectors, const bool isDistributed=false)
 Make a bandstructure for all the k-points.
 
StridedComplexView3D kokkosBatchedBuildBlochHamiltonian (const DoubleView2D &cartesianCoordinates) override
 Build the Hamiltonian matrix for a batch of q-points.
 
std::tuple< DoubleView2D, StridedComplexView3D > kokkosBatchedDiagonalizeFromCoordinates (const DoubleView2D &cartesianCoordinates, const bool withMassScaling=true) override
 Create and diagonalize Hamiltonians for a batch of k-points.
 
std::tuple< DoubleView2D, StridedComplexView3D, ComplexView4D > kokkosBatchedDiagonalizeWithVelocities (const DoubleView2D &cartesianCoordinates) override
 Create and diagonalize Hamiltonians for a batch of k-points, with velocities Returns the energies (nk, nb), eigenvectors (nk, nb, nb) and velocities (nk, nb, nb, 3) at each k-point. More...
 
void kokkosBatchedScaleEigenvectors (StridedComplexView3D &eigenvectors)
 
Eigen::Vector3i getCoarseGrid ()
 Returns the size of the q-point coarse grid on which the force constants have been computed. More...
 
int getIndexEigenvector (const int &iAt, const int &iPol) const
 Utility to convert the indices of atom basis and polarization into the index that has to be used with the eigenvector in matrix form. More...
 
Eigen::Matrix3d getDielectricMatrix ()
 Get the static dielectric constant matrix. More...
 
Eigen::Tensor< double, 3 > getBornCharges ()
 Get the Born effective charges for the ions in the unit cell. More...
 
int estimateBatchSize (const bool &withVelocity) override
 Estimate how many k-points we can compute on the GPU in one batch. More...
 
void printDynToHDF5 (Eigen::Vector3d &qCrys)
 Helper function to print the dynamical matrix file to HDF5, for developer testing purposes. More...
 
- Public Member Functions inherited from HarmonicHamiltonian
void kokkosBatchedTreatDegenerateVelocities (const DoubleView2D &cartesianCoordinates, const DoubleView2D &resultEnergies, ComplexView4D &resultVelocities, const double &threshold)
 

Static Public Member Functions

static int getIndexEigenvector (const int &iAt, const int &iPol, const int &nAtoms)
 same as getIndexEigenvector, but as a static member More...
 

Static Public Attributes

static const int mediumRange = 0
 
static const int shortRange = 1
 

Protected Member Functions

Eigen::Tensor< double, 5 > wsInit (const Eigen::MatrixXd &unitCell, const Eigen::Matrix3d &directUnitCell, const int &nr1Big, const int &nr2Big, const int &nr3Big)
 In wsInit, starting from the primitive crystal unit cell, we build the list of bravais lattice vectors used for the phonon Fourier transform.
 
void addLongRangeTerm (Eigen::Tensor< std::complex< double >, 4 > &dyn, const Eigen::VectorXd &q)
 Adds the long range correction to the dynamical matrix due to dipole-ion interaction. More...
 
void shortRangeTerm (Eigen::Tensor< std::complex< double >, 4 > &dyn, const Eigen::VectorXd &q)
 This part computes the short-range part of the dynamical matrix, which is the Fourier transform of the force constants. More...
 
void addMediumRangeTerm (Eigen::Tensor< std::complex< double >, 4 > &dyn, const Eigen::VectorXd &q)
 This part computes the "medium"-range part of the dynamical matrix, which is needed for the polar correction to the dynamical matrix when finite differences are used. More...
 
std::tuple< Eigen::VectorXd, Eigen::MatrixXcd > dynDiagonalize (Eigen::Tensor< std::complex< double >, 4 > &dyn)
 dynDiagonalize diagonalizes the dynamical matrix and returns eigenvalues and eigenvectors. More...
 
void correctMediumRangeIFCs (Eigen::Tensor< double, 4 > &fq, const Eigen::VectorXd &q)
 Function analogous to nonanal_ifc in QE's matdyn – returns f_of_q, which is a correction to be applied to the "medium range" fcs before performing the fourier transform. More...
 
double getDeviceMemoryUsage ()
 Checks the size of Device-allocated views. More...
 

Protected Attributes

Particle particle
 
Crystalcrystal
 
bool hasDielectric = false
 
int numAtoms
 
int numBands
 
double volumeUnitCell
 
Eigen::MatrixXi atomicSpecies
 
Eigen::VectorXd speciesMasses
 
Eigen::MatrixXd atomicPositions
 
Eigen::Matrix3d dielectricMatrix
 
Eigen::Tensor< double, 3 > bornCharges
 
Eigen::Vector3i qCoarseGrid
 
Eigen::Matrix3d directUnitCell
 
int dimensionality
 
int fcRangeType
 
bool longRange2d = false
 
double alpha
 
double alat
 
int numBravaisVectors = 0
 
Eigen::MatrixXd bravaisVectors
 
Eigen::VectorXd weights
 
Eigen::Tensor< double, 5 > mat2R
 
Eigen::MatrixXd gVectors
 
Eigen::Tensor< double, 3 > longRangeCorrection1
 
const double gMax = 14.
 
const double e2 = 4
 
DoubleView1D atomicMasses_d
 
DoubleView3D longRangeCorrection1_d
 
DoubleView2D gVectors_d
 
DoubleView2D dielectricMatrix_d
 
DoubleView3D bornCharges_d
 
DoubleView2D atomicPositions_d
 
DoubleView2D bravaisVectors_d
 
DoubleView1D weights_d
 
DoubleView3D mat2R_d
 

Detailed Description

First, it contains the force constants, i.e. the second derivative of the total energy w.r.t. ionic displacements. Additionally, it has all the infrastructure to Fourier transform this matrix, and diagonalize it to get the harmonic phonon properties.

Constructor & Destructor Documentation

◆ PhononH0()

PhononH0::PhononH0 ( Crystal crystal,
Eigen::Tensor< double, 5 > &  forceConstants_,
Eigen::Vector3i &  qCoarseGrid,
const Eigen::MatrixXd &  bravaisVectors_,
const Eigen::VectorXd &  weights_,
const int  fcRangeType 
)
Parameters
crystalthe object with the information on the crystal structure
forceConstantsa tensor of doubles with the force constants size is (3, 3, meshX, meshY, meshZ, numAtoms, numAtoms)
qCoarseGridthe supercell/coarse qmesh of this calculation as a 3vector
bravaisVectorsthe R vectors used in the harmonic phonon real space representation
weightsthe R vector weights used in the Fourier transform to recip space
Here is the call graph for this function:

Member Function Documentation

◆ addLongRangeTerm()

void PhononH0::addLongRangeTerm ( Eigen::Tensor< std::complex< double >, 4 > &  dyn,
const Eigen::VectorXd &  q 
)
protected
Parameters
dyn: a container to which the short-range part of the dynamical matrix is added
q: the phonon wavevector at which to calculate this part of the dyn mat, cartesian coords
Here is the caller graph for this function:

◆ addMediumRangeTerm()

void PhononH0::addMediumRangeTerm ( Eigen::Tensor< std::complex< double >, 4 > &  dyn,
const Eigen::VectorXd &  q 
)
protected


follows nonanal from rigid.f90 and the paper of Wang 2012

Parameters
dyn: a container to which the short-range part of the dynamical matrix is added
q: the phonon wavevector at which to calculate this part of the dyn mat, cartesian coords
Here is the caller graph for this function:

◆ correctMediumRangeIFCs()

void PhononH0::correctMediumRangeIFCs ( Eigen::Tensor< double, 4 > &  fq,
const Eigen::VectorXd &  q 
)
protected
Parameters
qthe phonon wavevector associated with the correction.
Returns
correction to be applied to the IFCS before fourier transforming
Here is the caller graph for this function:

◆ diagonalize()

std::tuple< Eigen::VectorXd, Eigen::MatrixXcd > PhononH0::diagonalize ( Point point)
overridevirtual
Parameters
qa point object with the wavevector. Must know the cartesian coordinates of the wavevector.
Returns
tuple(energies, eigenvectors): the energies are a double vector of size (numBands=3*numAtoms). Eigenvectors are a complex tensor of size (3,numAtoms,numBands). The eigenvector is rescaled by the sqrt(masses) (masses in rydberg)

Implements HarmonicHamiltonian.

Here is the call graph for this function:

◆ diagonalizeFromCoordinates() [1/2]

std::tuple< Eigen::VectorXd, Eigen::MatrixXcd > PhononH0::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:

◆ diagonalizeFromCoordinates() [2/2]

std::tuple< Eigen::VectorXd, Eigen::MatrixXcd > PhononH0::diagonalizeFromCoordinates ( Eigen::Vector3d &  q,
const bool &  withMassScaling 
)
Parameters
qa 3d eigen vector with the cartesian coordinates of the phonon wavevector.
withMassScalingif true, rescales the eigenvectors by the mass z -> z/sqrt(m)
Returns
eigenvalues: all values of phonon energies for this point.
eigenvectors: the phonon eigenvectors, in matrix form, for this point.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ diagonalizeVelocity()

Eigen::Tensor< std::complex< double >, 3 > PhononH0::diagonalizeVelocity ( Point point)
overridevirtual
Parameters
qa 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:

◆ dynDiagonalize()

std::tuple< Eigen::VectorXd, Eigen::MatrixXcd > PhononH0::dynDiagonalize ( Eigen::Tensor< std::complex< double >, 4 > &  dyn)
protected
Parameters
dynthe dynamical matrix in the shape 3,3,natoms,natoms
Here is the caller graph for this function:

◆ estimateBatchSize()

int PhononH0::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:

◆ getBornCharges()

Eigen::Tensor< double, 3 > PhononH0::getBornCharges ( )
Returns
bornCharges: a real tensor of shape (numAtoms,3,3) with the charges
Here is the caller graph for this function:

◆ getCoarseGrid()

Eigen::Vector3i PhononH0::getCoarseGrid ( )
Returns
qCoarseGrid: an Eigen vector of 3 integers.
Here is the caller graph for this function:

◆ getDeviceMemoryUsage()

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

◆ getDielectricMatrix()

Eigen::Matrix3d PhononH0::getDielectricMatrix ( )
Returns
dielectricMatrix: a 3x3 eigen matrix.
Here is the caller graph for this function:

◆ getIndexEigenvector() [1/2]

int PhononH0::getIndexEigenvector ( const int &  iAt,
const int &  iPol 
) const
Parameters
iAtatomic basis index.
iPolpolarization index (0,1,2).
Returns
k: index to be used in the phonon eigenvector.
Here is the caller graph for this function:

◆ getIndexEigenvector() [2/2]

int PhononH0::getIndexEigenvector ( const int &  iAt,
const int &  iPol,
const int &  nAtoms 
)
static
Parameters
nAtomsthe number of atoms in the unit cell

◆ kokkosBatchedDiagonalizeWithVelocities()

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

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()

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

Implements HarmonicHamiltonian.

Here is the caller graph for this function:

◆ printDynToHDF5()

void PhononH0::printDynToHDF5 ( Eigen::Vector3d &  qCrys)
Parameters
qCrysa 3d eigen vector in crystal coordinates of the phonon wavevector.
pointsthe points object with with q belongs to. Here, used only to convert q to cartesian internally.
Here is the call graph for this function:

◆ shortRangeTerm()

void PhononH0::shortRangeTerm ( Eigen::Tensor< std::complex< double >, 4 > &  dyn,
const Eigen::VectorXd &  q 
)
protected
Parameters
dyn: a container to which the short-range part of the dynamical matrix is added
q: the phonon wavevector at which to calculate this part of the dyn mat, cartesian coords
Here is the call graph for this function:
Here is the caller graph for this function: