TBTK
TBTK::PropertyExtractor::PropertyExtractor Class Reference

#include <PropertyExtractor.h>

Inheritance diagram for TBTK::PropertyExtractor::PropertyExtractor:
TBTK::PropertyExtractor::ArnoldiIterator TBTK::PropertyExtractor::BlockDiagonalizer TBTK::PropertyExtractor::ChebyshevExpander TBTK::PropertyExtractor::Diagonalizer TBTK::PropertyExtractor::ElectronFluctuationVertex TBTK::PropertyExtractor::ExactDiagonalizer TBTK::PropertyExtractor::Greens TBTK::PropertyExtractor::LindhardSusceptibility TBTK::PropertyExtractor::RPASusceptibility TBTK::PropertyExtractor::SelfEnergy

Public Member Functions

 PropertyExtractor ()
 
virtual ~PropertyExtractor ()
 
virtual void setEnergyWindow (double lowerBound, double upperBound, int energyResolution)
 
virtual void setEnergyInfinitesimal (double energyInfinitesimal)
 
virtual Property::Density calculateDensity (Index pattern, Index ranges)
 
virtual Property::Density calculateDensity (std::vector< Index > patterns)
 
virtual Property::Magnetization calculateMagnetization (Index pattern, Index ranges)
 
virtual Property::Magnetization calculateMagnetization (std::vector< Index > patterns)
 
virtual Property::LDOS calculateLDOS (Index pattern, Index ranges)
 
virtual Property::LDOS calculateLDOS (std::vector< Index > patterns)
 
virtual Property::SpinPolarizedLDOS calculateSpinPolarizedLDOS (Index pattern, Index ranges)
 
virtual Property::SpinPolarizedLDOS calculateSpinPolarizedLDOS (std::vector< Index > patterns)
 
virtual std::complex< double > calculateExpectationValue (Index to, Index from)
 
virtual Property::DOS calculateDOS ()
 
virtual double calculateEntropy ()
 

Protected Member Functions

int getEnergyResolution () const
 
double getLowerBound () const
 
double getUpperBound () const
 
double getEnergyInfinitesimal () const
 
void calculate (void(*callback)(PropertyExtractor *cb_this, void *memory, const Index &index, int offset), void *memory, Index pattern, const Index &ranges, int currentOffset, int offsetMultiplier)
 
template<typename DataType >
void calculate (void(*callback)(PropertyExtractor *cb_this, void *memory, const Index &index, int offset), const IndexTree &allIndices, const IndexTree &memoryLayout, Property::AbstractProperty< DataType > &abstractProperty, int *spinIndexHint=nullptr)
 
void ensureCompliantRanges (const Index &pattern, Index &ranges)
 
void getLoopRanges (const Index &pattern, const Index &ranges, int *loopDimensions, int **loopRanges)
 
IndexTree generateIndexTree (std::vector< Index > patterns, const HoppingAmplitudeSet &hoppingAmplitudeSet, bool keepSummationWildcards, bool keepSpinWildcards)
 
void validatePatternsNumComponents (const std::vector< Index > &patterns, unsigned int expectedNumComponentIndices, const std::string &functionName) const
 
void validatePatternsSpecifiers (const std::vector< Index > &patterns, const std::vector< int > specifiers, const std::string &functionName) const
 

Protected Attributes

void * hint
 

Detailed Description

The PropertyExtractor extracts is a base class for derived PropertyExtractors that are used to extract common physical properties such as DOS, Density, LDOS, etc. from a Solvers.

Constructor & Destructor Documentation

TBTK::PropertyExtractor::PropertyExtractor::PropertyExtractor ( )
virtual TBTK::PropertyExtractor::PropertyExtractor::~PropertyExtractor ( )
virtual

Destructor.

Member Function Documentation

void TBTK::PropertyExtractor::PropertyExtractor::calculate ( void(*)(PropertyExtractor *cb_this, void *memory, const Index &index, int offset)  callback,
void *  memory,
Index  pattern,
const Index ranges,
int  currentOffset,
int  offsetMultiplier 
)
protected

Loops over range indices and calls the given callback function to calculate the correct quantity. The function recursively calls itself replacing any IDX_SUM_ALL, IDX_X, IDX_Y, and IDX_Z specifiers by actual subindices in the range [0, ranges[s]), where s is the subindex at which the specifier appears. For example, the pattern ranges pair {IDX_SUM_ALL, 2, IDX_X} and {2, 1, 3} will result in the callback being called for {0, 2, 0}, {0, 2, 1}, {0, 2, 2}, {1, 2, 0}, {1, 2, 1}, and {1, 2, 2}. The first and fourth, second and fifth, and third and sixth Index will further be passed to the callback with the same memory offset since their result should be summed.

The memory offset is further calculated by traversing the subindices of the apttern from right to left and multiplying the current offset multiplier by the number of indices in the range size for the given subindex. This results in an offset that places the elements in consequtive order in increasing order of the Index order. Where an Index is considered to come before another Index if the first subindex to differ between two Indices from the left is smaller than the other Index.

Parameters
callbackA callback function that is called to perform the actual calculation for a given Index.
memoryPointer to the memory where the result is to be stored.
patternAn Index specifying the pattern for which to perform the calculation.
rangesThe upper limit (exclusive) for which subindices with wildcard specifiers will be replaced. The lower limit is 0.
currentOffsetThe memory offset calculated for the given pattern Index. Should be zero for the initial call to the function.
offsetMultiplierNumber indicating the block size associated with increasing the current subindex by one. Should be equal to the number of data elements per Index for the initial call to the function.
template<typename DataType >
void TBTK::PropertyExtractor::PropertyExtractor::calculate ( void(*)(PropertyExtractor *cb_this, void *memory, const Index &index, int offset)  callback,
const IndexTree allIndices,
const IndexTree memoryLayout,
Property::AbstractProperty< DataType > &  abstractProperty,
int *  spinIndexHint = nullptr 
)
protected

Loops over the indices satisfying the specified patterns and calls the appropriate callback function to calculate the correct quantity.

Parameters
callbackA callback function that is called to perform the actual calculation for a given Index.
allIndicesAn IndexTree containing all the Indices for which the callback should be called.
memoryLayoutThe memory layout used for the Property.
abstractPropertyThe Property that is being calculated.
spinIndexHintPointer to a memory location that provides information about which subindex that corresponds to a spin index. If the specification of a spin subindex is not necessary for the given Property, this should be nullptr.
virtual Property::Density TBTK::PropertyExtractor::PropertyExtractor::calculateDensity ( Index  pattern,
Index  ranges 
)
virtual

Calculate the density. This function should be overriden by those deriving classes that provide support for calculating the density. By default the PropertyExtractor prints an error message that the given property is not supported.

Parameters
patternSpecifies the index pattern for which to calculate the density. For example, assume that the index scheme is {x, y, z, spin}. {ID_X, 5, 10, IDX_SUM_ALL} will calculate the density for each x along (y,z)=(5,10) by summing over spin. Similarly {ID_X, 5, IDX_Y, IDX_SUM_ALL} will return a two dimensional density for all x and z and y = 5. Note that IDX_X IDX_Y, and IDX_Z refers to the first, second, and third index used by the routine to create a one-, two-, or three-dimensional output, rather than being tied to the x, y, and z used as physical subindices.
rangesSpeifies the number of elements for each subindex. Is ignored for indices specified with positive integers in the pattern, but is used to loop from 0 to the value in ranges for IDX_X, IDX_Y, IDX_Z, and IDX_SUM_ALL. Appropriate ranges corresponding to the two pattern examples above are {SIZE_X, 1, 1, NUM_SPINS} and {SIZE_X, 1, SIZE_Z, NUM_SPINS}, respectively.
Returns
A density array with size equal to the number of points included by specified patter-range combination.

Reimplemented in TBTK::PropertyExtractor::Diagonalizer, TBTK::PropertyExtractor::ChebyshevExpander, TBTK::PropertyExtractor::Greens, and TBTK::PropertyExtractor::ExactDiagonalizer.

virtual Property::Density TBTK::PropertyExtractor::PropertyExtractor::calculateDensity ( std::vector< Index patterns)
virtual

Calculate the density. This function should be overriden by those deriving classes that provide support for calculating the density. By default the PropertyExtractor prints an error message that the given property is not supported.

Parameters
patternsA list of patterns that will be matched against the Indices in the Model to determine which Indices for which to calculate the Density.
Returns
A Property::Density for the Indices that match the patterns.

Reimplemented in TBTK::PropertyExtractor::BlockDiagonalizer, TBTK::PropertyExtractor::Diagonalizer, TBTK::PropertyExtractor::ChebyshevExpander, and TBTK::PropertyExtractor::Greens.

virtual Property::DOS TBTK::PropertyExtractor::PropertyExtractor::calculateDOS ( )
virtual

Calculate the density of states. This function should be overriden by those deriving classes that provide support for calculating the density of states. By default the PropertyExtractor prints an error message that the given property is not supported.

Returns
A Property::DOS containing the density of states.

Reimplemented in TBTK::PropertyExtractor::BlockDiagonalizer, TBTK::PropertyExtractor::Diagonalizer, and TBTK::PropertyExtractor::ArnoldiIterator.

virtual double TBTK::PropertyExtractor::PropertyExtractor::calculateEntropy ( )
virtual

Calculate the entropy. This function should be overriden by those deriving classes that provide support for calculating the entropy. By default the PropertyExtractor prints an error message that the given property is not supported.

Returns
The entropy.

Reimplemented in TBTK::PropertyExtractor::BlockDiagonalizer, and TBTK::PropertyExtractor::Diagonalizer.

virtual std::complex<double> TBTK::PropertyExtractor::PropertyExtractor::calculateExpectationValue ( Index  to,
Index  from 
)
virtual

Calculate the expectation value \(\langle c_{to}^{\dagger}c_{from}\). This function should be overriden by those deriving classes that provide support for calculating the expecation value. By default the PropertyExtractor prints an error message that the given property is not supported.

Parameters
toThe Index on the left operator.
fromThe index on the right operator.
Returns
The expectation value \(\langle c_{to}^{\dagger}c_{from}\).

Reimplemented in TBTK::PropertyExtractor::BlockDiagonalizer, TBTK::PropertyExtractor::Diagonalizer, TBTK::PropertyExtractor::ChebyshevExpander, and TBTK::PropertyExtractor::ExactDiagonalizer.

virtual Property::LDOS TBTK::PropertyExtractor::PropertyExtractor::calculateLDOS ( Index  pattern,
Index  ranges 
)
virtual

Calculate the local density of states. This function should be overriden by those deriving classes that provide support for calculating the local density of states. By default the PropertyExtractor prints an error message that the given property is not supported.

Parameters
patternSpecifies the index pattern for which to calculate the LDOS. For example, assume that the index scheme is {x, y, z, spin}. {ID_X, 5, 10, IDX_SUM_ALL} will calculate the LDOS for each x along (y,z)=(5,10) by summing over spin. Similarly {ID_X, 5, IDX_Y, IDX_SUM_ALL} will return a two dimensional LDOS for all x and z and y = 5. Note that IDX_X, IDX_Y, and IDX_Z refers to the first, second, and third index used by the routine to create a one-, two-, or three-dimensional output, rather than being tied to the x, y, and z used as physical subindices.
rangesSpeifies the number of elements for each subindex. Is ignored for indices specified with positive integers in the pattern, but is used to loop from 0 to the value in ranges for IDX_X, IDX_Y, IDX_Z, and IDX_SUM_ALL. Appropriate ranges corresponding to the two pattern examples above are {SIZE_X, 1, 1, NUM_SPINS} and {SIZE_X, 1, SIZE_Z, NUM_SPINS}, respectively.
Returns
A density array with size equal to the number of points included by specified patter-range combination.

Reimplemented in TBTK::PropertyExtractor::Diagonalizer, TBTK::PropertyExtractor::ChebyshevExpander, TBTK::PropertyExtractor::ArnoldiIterator, and TBTK::PropertyExtractor::ExactDiagonalizer.

virtual Property::LDOS TBTK::PropertyExtractor::PropertyExtractor::calculateLDOS ( std::vector< Index patterns)
virtual

Calculate the local density of states. This function should be overriden by those deriving classes that provide support for calculating the local density of states. By default the PropertyExtractor prints an error message that the given property is not supported.

Parameters
patternsA list of patterns that will be matched against the Indices in the Model to determine which Indices for which to calculate the local density of states.
Returns
A Property::LDOS for the Indices that match the patterns.

Reimplemented in TBTK::PropertyExtractor::BlockDiagonalizer, TBTK::PropertyExtractor::Diagonalizer, TBTK::PropertyExtractor::ChebyshevExpander, TBTK::PropertyExtractor::ArnoldiIterator, and TBTK::PropertyExtractor::Greens.

virtual Property::Magnetization TBTK::PropertyExtractor::PropertyExtractor::calculateMagnetization ( Index  pattern,
Index  ranges 
)
virtual

Calculate the magnetization. This function should be overriden by those deriving classes that provide support for calculating the magnetization. By default the PropertyExtractor prints an error message that the given property is not supported.

Parameters
patternSpecifies the index pattern for which to calculate the magnetization. For example, assume that the index scheme is {x, y, z, spin}. {ID_X, 5, 10, IDX_SPIN} will calculate the magnetization for each x along (y,z)=(5,10). Similarly {ID_X, 5, IDX_Y, IDX_SPIN} will return a two dimensional magnetiation for all x and z and y = 5. Note that IDX_X, IDX_Y, and IDX_Z refers to the first, second, and third index used by the routine to create a one-, two-, or three-dimensional output, rather than being tied to the x, y, and z used as physical subindices.
rangesSpeifies the number of elements for each subindex. Is ignored for indices specified with positive integers in the pattern, but is used to loop from 0 to the value in ranges for IDX_X, IDX_Y, IDX_Z, and IDX_SUM_ALL. Appropriate ranges corresponding to the two pattern examples above are {SIZE_X, 1, 1, NUM_SPINS} and {SIZE_X, 1, SIZE_Z, NUM_SPINS}, respectively.
Returns
A magnetization array with size equal to four times the number of points included by specified patter-range combination. The four entries are

\[ \left[\begin{array}{cc} 0 & 1\\ 2 & 3 \end{array}\right] = \left[\begin{array}{cc} \langle c_{i\uparrow}^{\dagger}c_{i\uparrow}\rangle & \langle c_{i\uparrow}^{\dagger}c_{i\downarrow}\rangle\\ \langle c_{i\downarrow}^{\dagger}c_{u\uparrow}\rangle & \langle c_{i\downarrow}^{\dagger}c_{i\downarrow}\rangle \end{array}\right]. \]

Reimplemented in TBTK::PropertyExtractor::Diagonalizer, TBTK::PropertyExtractor::ChebyshevExpander, and TBTK::PropertyExtractor::ExactDiagonalizer.

virtual Property::Magnetization TBTK::PropertyExtractor::PropertyExtractor::calculateMagnetization ( std::vector< Index patterns)
virtual

Calculate the Magnetization. This function should be overriden by those deriving classes that provide support for calculating the magnetization. By default the PropertyExtractor prints an error message that the given property is not supported.

Parameters
patternsA list of patterns that will be matched against the Indices in the Model to determine which Indices for which to calculate the Magnetization.
Returns
A Property::Magnetization for the Indices that match the patterns.

Reimplemented in TBTK::PropertyExtractor::BlockDiagonalizer, TBTK::PropertyExtractor::Diagonalizer, and TBTK::PropertyExtractor::ChebyshevExpander.

virtual Property::SpinPolarizedLDOS TBTK::PropertyExtractor::PropertyExtractor::calculateSpinPolarizedLDOS ( Index  pattern,
Index  ranges 
)
virtual

Calculate the spin-polarized local density of states. This function should be overriden by those deriving classes that provide support for calculating the spin-polarized local density of states. By default the PropertyExtractor prints an error message that the given property is not supported.

Parameters
patternSpecifies the index pattern for which to calculate the spin-polarized LDOS. For example, assume that the index scheme is {x, y, z, spin}. {ID_X, 5, 10, IDX_SPIN} will calculate the spin-polarized LDOS for each x along (y,z)=(5,10). Similarly {ID_X, 5, IDX_Y, IDX_SPIN} will return a two dimensional spin-polarized LDOS for all x and z and y = 5. Note that IDX_X, IDX_Y, and IDX_Z refers to the first, second, and third index used by the routine to create a one-, two-, or three-dimensional output, rather than being tied to the x, y, and z used as physical subindices.
rangesSpeifies the number of elements for each subindex. Is ignored for indices specified with positive integers in the pattern, but is used to loop from 0 to the value in ranges for IDX_X, IDX_Y, IDX_Z, and IDX_SUM_ALL. Appropriate ranges corresponding to the two pattern examples above are {SIZE_X, 1, 1, NUM_SPINS} and {SIZE_X, 1, SIZE_Z, NUM_SPINS}, respectively.
Returns
A spin-polarized LDOS array with size equal to four times the number of points included by specified patter-range combination. The four entries are

\[ \left[\begin{array}{cc} 0 & 1\\ 2 & 3 \end{array}\right] = \left[\begin{array}{cc} \rho_{i\uparrow i\uparrow}(E) & \rho_{i\uparrow i\downarrow}(E)\\ \rho_{i\downarrow i\uparrow}(E) & \rho_{i\downarrow i\downarrow}(E)\\ \end{array}\right], \]

where

\[ \rho_{i\sigma i\sigma'}(E) = \sum_{E_n}\langle\Psi_n|c_{i\sigma}^{\dagger}c_{i\sigma'}|\Psi_n\rangle\delta(E - E_n) . \]

Reimplemented in TBTK::PropertyExtractor::Diagonalizer, TBTK::PropertyExtractor::ChebyshevExpander, TBTK::PropertyExtractor::ArnoldiIterator, and TBTK::PropertyExtractor::ExactDiagonalizer.

virtual Property::SpinPolarizedLDOS TBTK::PropertyExtractor::PropertyExtractor::calculateSpinPolarizedLDOS ( std::vector< Index patterns)
virtual

Calculate the spin-polarized local density of states. This function should be overriden by those deriving classes that provide support for calculating the spin-polarized local density of states. By default the PropertyExtractor prints an error message that the given property is not supported.

Parameters
patternsA list of patterns that will be matched against the Indices in the Model to determine which Indices for which to calculate the spin-polarized local density of states.
Returns
A Property::SpinPolarizedLDOS for the Indices that match the patterns.

Reimplemented in TBTK::PropertyExtractor::BlockDiagonalizer, TBTK::PropertyExtractor::Diagonalizer, TBTK::PropertyExtractor::ChebyshevExpander, and TBTK::PropertyExtractor::ArnoldiIterator.

void TBTK::PropertyExtractor::PropertyExtractor::ensureCompliantRanges ( const Index pattern,
Index ranges 
)
protected

Ensure that range indices are on compliant format. I.e., sets the range to one for indices with non-negative pattern value.

Parameters
patternThe pattern.
rangesThe ranges that will have its subindices set to one for every pattern subindex that is non negative.
IndexTree TBTK::PropertyExtractor::PropertyExtractor::generateIndexTree ( std::vector< Index patterns,
const HoppingAmplitudeSet hoppingAmplitudeSet,
bool  keepSummationWildcards,
bool  keepSpinWildcards 
)
protected

Generate an IndexTree containing all the Indices in the HoppingAmplitudeSet that matches the given patterns. Before being added to the IndexTree, the Indices may be modified to replace subindices by their corresponding pattern value. I.e. A summation or spin subindex may still be labeld such in the IndexTree depending on the flags that are passed to the function.

The pattern can also be a compund Index consisting of two Indices, in which case the pattern matching is applied to each component Index separately.

Parameters
patternsList of patterns to match against.
TheHoppingAmplitudeSet cntaining all the Indices that will be matched against the patterns.
keepSummationWildcardsIf true, summation wildcards in the pattern will be preserved in the IndexTree.
keepSpinWildcardsIf true, spin wildcards in the pattern will be preserved in the IndexTree.
int TBTK::PropertyExtractor::PropertyExtractor::getEnergyResolution ( ) const
inlineprotected

Get the energy resolution.

Returns
The energy resolution for the energy window.
void TBTK::PropertyExtractor::PropertyExtractor::getLoopRanges ( const Index pattern,
const Index ranges,
int *  loopDimensions,
int **  loopRanges 
)
protected

Extract ranges for loop indices. The subindices with IDX_X, IDX_Y and IDX_Z are identified and counted and an array of the same size as the number of loop indices is created and filled with the ranges for the corrsponding loop subindices.

Parameters
patternA pattern.
rangesThe ranges for the given pattern.
loopDimensionsPointer to int that will hold the number of loop dimensions after the call has completed.
loopRanges*loopRange will point to an array of size *loopDimensions that contain the ranges for the loop subindices.
double TBTK::PropertyExtractor::PropertyExtractor::getLowerBound ( ) const
inlineprotected

Get lower bound for the energy window.

Returns
The lower bound for the energy window.
double TBTK::PropertyExtractor::PropertyExtractor::getUpperBound ( ) const
inlineprotected

Get the upper bound for the energy window.

Returns
The upper bound for the energy window.
virtual void TBTK::PropertyExtractor::PropertyExtractor::setEnergyInfinitesimal ( double  energyInfinitesimal)
virtual

Set the size of the energy infinitesimal that can be used to add for example an \(i\delta\) term to the denominator of the Green's function.

Parameters
energyInfinitesimalThe energy infinitesimal \(\delta\).
virtual void TBTK::PropertyExtractor::PropertyExtractor::setEnergyWindow ( double  lowerBound,
double  upperBound,
int  energyResolution 
)
virtual

Set the energy window used for energy dependent quantities.

Parameters
lowerBoundThe lower bound for the energy window.
upperBoundThe upper bound for the energy window.
energyResolutionThe number of energy points used to resolve the energy window.

Reimplemented in TBTK::PropertyExtractor::BlockDiagonalizer, TBTK::PropertyExtractor::ChebyshevExpander, TBTK::PropertyExtractor::Greens, TBTK::PropertyExtractor::ElectronFluctuationVertex, TBTK::PropertyExtractor::LindhardSusceptibility, TBTK::PropertyExtractor::RPASusceptibility, and TBTK::PropertyExtractor::SelfEnergy.

void TBTK::PropertyExtractor::PropertyExtractor::validatePatternsNumComponents ( const std::vector< Index > &  patterns,
unsigned int  expectedNumComponentIndices,
const std::string &  functionName 
) const
inlineprotected

Check that a given set of patterns has the correct number of component Indices per pattern. Prints error message if not.

Parameters
patternsList of patterns to check.
numComponentsThe expected number of component Indices .
functionNameString that should contain the name of the function from which the function is called. Is used to print an error message if the validation fails.
void TBTK::PropertyExtractor::PropertyExtractor::validatePatternsSpecifiers ( const std::vector< Index > &  patterns,
const std::vector< int >  specifiers,
const std::string &  functionName 
) const
inlineprotected

Check that a given set of patterns only has non-negative subindices or one of the allowed subindex specifiers. Prints error message if not.

Parameters
patternsList of patterns to check.
numComponentsThe allowed subindex specifiers.
functionNameString that should contain the name of the function from which the function is called. Is used to print an error message if the validation fails.

Member Data Documentation

void* TBTK::PropertyExtractor::PropertyExtractor::hint
protected

Hint used to pass information between calculate[Property] and calculate[Property]Callback.


The documentation for this class was generated from the following file: