TBTK Need a break? Support the development by playing Polarity Puzzles
TBTK::PropertyExtractor::PropertyExtractor Class Reference

Base class for PropertyExtractors. More...

#include <PropertyExtractor.h>

Inheritance diagram for TBTK::PropertyExtractor::PropertyExtractor:

Classes

class  Information

Public Member Functions

PropertyExtractor ()

virtual ~PropertyExtractor ()

virtual void setEnergyWindow (double lowerBound, double upperBound, int energyResolution)

virtual void setEnergyWindow (int lowerFermionicMatsubaraEnergyIndex, int upperFermionicMatsubaraEnergyIndex, int lowerBosonicMatsubaraEnergyIndex, int upperBosonicMatsubaraEnergyIndex)

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 Property::DOS sampleDOS (unsigned int numSamples, const std::vector< Index > &patterns={}, unsigned int seed=time(nullptr))

virtual double calculateEntropy ()

Protected Types

enum  EnergyType { Real, Matsubara }

Protected Member Functions

EnergyType getEnergyType () const

int getEnergyResolution () const

double getLowerBound () const

double getUpperBound () const

int getLowerFermionicMatsubaraEnergyIndex () const

int getUpperFermionicMatsubaraEnergyIndex () const

int getLowerBosonicMatsubaraEnergyIndex () const

int getUpperBosonicMatsubaraEnergyIndex () const

double getEnergyInfinitesimal () const

template<typename DataType >
void calculate (void(*callback)(PropertyExtractor *cb_this, Property::Property &property, const Index &index, int offset, Information &information), Property::AbstractProperty< DataType > &property, Index pattern, const Index &ranges, int currentOffset, int offsetMultiplier, Information &information)

template<typename DataType >
void calculate (void(*callback)(PropertyExtractor *cb_this, Property::Property &property, const Index &index, int offset, Information &information), const IndexTree &allIndices, const IndexTree &memoryLayout, Property::AbstractProperty< DataType > &abstractProperty, Information &information)

void ensureCompliantRanges (const Index &pattern, Index &ranges)

std::vector< int > getLoopRanges (const Index &pattern, const Index &ranges)

IndexTree generateIndexTree (std::vector< Index > patterns, const HoppingAmplitudeSet &hoppingAmplitudeSet, bool keepSummationWildcards, bool keepSpinWildcards)

Detailed Description

Base class for PropertyExtractors.

A PropertyExtractor can be used to extract Properties from a Solver. The PropertyExtractor::PropertyExtractor is a base class for such PropertyExtractors, which each corresponds to a particular Solver. See the documentation for Diagonalizer, BlockDiagonalizer, ArnoldiIterator, and ChebyshevExpander for examples of specific production ready PropertyExtractors.

The PropertyExtractors provide a uniform interface to Solvers and allow for Properties to be extracted with limited knowledge about Solver specific details. The use of PropertyExtractors also makes it possible to switch between different Solvers with minimal changes to the code.

Example

#include "TBTK/TBTK.h"
using namespace TBTK;
int main(){
//Set the energy window for which to extract energy dependent
//Properties.
double lowerBound = -10;
double upperBound = -10;
double resolution = 1000;
propertyExtractor.setEnergyWindow(lowerBound, upperBound, resolution);
//Set the size of the imaginary infinitesimal to use in the denominator
//of the Green's function if it is used during the calculation.
propertyExtractor.setEnergyInfinitesimal(1e-10);
}

◆ EnergyType

 strongprotected

Energy type.

◆ PropertyExtractor()

 TBTK::PropertyExtractor::PropertyExtractor::PropertyExtractor ( )

◆ ~PropertyExtractor()

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

Destructor.

◆ calculate() [1/2]

template<typename DataType >
 void TBTK::PropertyExtractor::PropertyExtractor::calculate ( void(*)(PropertyExtractor *cb_this, Property::Property &property, const Index &index, int offset, Information &information) callback, Property::AbstractProperty< DataType > & property, Index pattern, const Index & ranges, int currentOffset, int offsetMultiplier, Information & information )
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
 callback A callback function that is called to perform the actual calculation for a given Index. property Reference to Property where the result is to be stored. pattern An Index specifying the pattern for which to perform the calculation. ranges The upper limit (exclusive) for which subindices with wildcard specifiers will be replaced. The lower limit is 0. currentOffset The memory offset calculated for the given pattern Index. Should be zero for the initial call to the function. offsetMultiplier Number 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. information Allows for custom information to be passed between the calculate-functions and the correpsonding callbacks.

◆ calculate() [2/2]

template<typename DataType >
 void TBTK::PropertyExtractor::PropertyExtractor::calculate ( void(*)(PropertyExtractor *cb_this, Property::Property &property, const Index &index, int offset, Information &information) callback, const IndexTree & allIndices, const IndexTree & memoryLayout, Property::AbstractProperty< DataType > & abstractProperty, Information & information )
protected

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

Parameters
 callback A callback function that is called to perform the actual calculation for a given Index. allIndices An IndexTree containing all the Indices for which the callback should be called. memoryLayout The memory layout used for the Property. abstractProperty The Property that is being calculated. information Allows for custom information to be passed between the calculate-functions and the correpsonding callbacks.

◆ calculateDensity() [1/2]

 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
 pattern Specifies 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. ranges Speifies 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, and TBTK::PropertyExtractor::ChebyshevExpander.

◆ calculateDensity() [2/2]

 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
 patterns A 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.

◆ calculateDOS()

 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.

◆ calculateEntropy()

 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.

◆ calculateExpectationValue()

 virtual std::complex 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
 to The Index on the left operator. from The index on the right operator.
Returns
The expectation value $$\langle c_{to}^{\dagger}c_{from}$$.

◆ calculateLDOS() [1/2]

 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
 pattern Specifies 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. ranges Speifies 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.

◆ calculateLDOS() [2/2]

 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
 patterns A 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.

◆ calculateMagnetization() [1/2]

 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
 pattern Specifies 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. ranges Speifies 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, and TBTK::PropertyExtractor::ChebyshevExpander.

◆ calculateMagnetization() [2/2]

 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
 patterns A 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.

◆ calculateSpinPolarizedLDOS() [1/2]

 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
 pattern Specifies 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. ranges Speifies 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) .$

◆ calculateSpinPolarizedLDOS() [2/2]

 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
 patterns A 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.

◆ ensureCompliantRanges()

 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
 pattern The pattern. ranges The ranges that will have its subindices set to one for every pattern subindex that is non negative.

◆ generateIndexTree()

 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
 patterns List of patterns to match against. The HoppingAmplitudeSet cntaining all the Indices that will be matched against the patterns. keepSummationWildcards If true, summation wildcards in the pattern will be preserved in the IndexTree. keepSpinWildcards If true, spin wildcards in the pattern will be preserved in the IndexTree.

◆ getEnergyResolution()

 int TBTK::PropertyExtractor::PropertyExtractor::getEnergyResolution ( ) const
inlineprotected

Get the energy resolution.

Returns
The energy resolution for the energy window.

◆ getEnergyType()

 PropertyExtractor::EnergyType TBTK::PropertyExtractor::PropertyExtractor::getEnergyType ( ) const
inlineprotected

Get the energy type.

Returns
The EnergyType for the energy window.

◆ getLoopRanges()

 std::vector TBTK::PropertyExtractor::PropertyExtractor::getLoopRanges ( const Index & pattern, const Index & ranges )
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
 pattern A pattern. ranges The ranges for the given pattern. loopDimensions Pointer to int that will hold the number of loop dimensions after the call has completed.
Returns
A vector that contains the ranges for the loop subindices.

◆ getLowerBosonicMatsubaraEnergyIndex()

 int TBTK::PropertyExtractor::PropertyExtractor::getLowerBosonicMatsubaraEnergyIndex ( ) const
inlineprotected

Get the lower Bosonic Matsubara energy index.

Returns
The lower Bosonic Matsubara energy index.

◆ getLowerBound()

 double TBTK::PropertyExtractor::PropertyExtractor::getLowerBound ( ) const
inlineprotected

Get lower bound for the energy window.

Returns
The lower bound for the energy window.

◆ getLowerFermionicMatsubaraEnergyIndex()

 int TBTK::PropertyExtractor::PropertyExtractor::getLowerFermionicMatsubaraEnergyIndex ( ) const
inlineprotected

Get the lower Fermionic Matsubara energy index.

Returns
The lower Fermionic Matsubara energy index.

◆ getUpperBosonicMatsubaraEnergyIndex()

 int TBTK::PropertyExtractor::PropertyExtractor::getUpperBosonicMatsubaraEnergyIndex ( ) const
inlineprotected

Get the upper Bosonic Matsubara energy index.

Returns
The upper Bosonic Matsubara energy index.

◆ getUpperBound()

 double TBTK::PropertyExtractor::PropertyExtractor::getUpperBound ( ) const
inlineprotected

Get the upper bound for the energy window.

Returns
The upper bound for the energy window.

◆ getUpperFermionicMatsubaraEnergyIndex()

 int TBTK::PropertyExtractor::PropertyExtractor::getUpperFermionicMatsubaraEnergyIndex ( ) const
inlineprotected

Get the upper Fermionic Matsubara energy index.

Returns
The upper Fermionic Matsubara energy index.

◆ sampleDOS()

 virtual Property::DOS TBTK::PropertyExtractor::PropertyExtractor::sampleDOS ( unsigned int numSamples, const std::vector< Index > & patterns = {}, unsigned int seed = time(nullptr) )
virtual

Sample the DOS by averaging over the LDOS for multiple random Indices. The resulting DOS is normalized to integrate to the total number of states in the sample space covered by the patterns Indices.

Parameters
 numSamples The number of samples to use. patterns A list of patterns to randomize over. If the list is empty (default value), all Indices are randomized over. seed Seed to use for randomization.
Returns
A Property::DOS containing the sampled DOS.

◆ setEnergyInfinitesimal()

 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
 energyInfinitesimal The energy infinitesimal $$\delta$$.

◆ setEnergyWindow() [1/2]

 virtual void TBTK::PropertyExtractor::PropertyExtractor::setEnergyWindow ( double lowerBound, double upperBound, int energyResolution )
virtual

Set the energy window used for energy dependent quantities. The energy window is set to be real.

Parameters
 lowerBound The lower bound for the energy window. upperBound The upper bound for the energy window. energyResolution The number of energy points used to resolve the energy window.

Reimplemented in TBTK::PropertyExtractor::ChebyshevExpander.

◆ setEnergyWindow() [2/2]

 virtual void TBTK::PropertyExtractor::PropertyExtractor::setEnergyWindow ( int lowerFermionicMatsubaraEnergyIndex, int upperFermionicMatsubaraEnergyIndex, int lowerBosonicMatsubaraEnergyIndex, int upperBosonicMatsubaraEnergyIndex )
virtual

Set the energy window used for energy dependent quantities. The energy window is set to consist of Matsubara energies.

Parameters
 lowerFermionicMatsubaraEnergyIndex The lower Fermionic Matsubara energy index. upperFermionicMatsubaraEnergyIndex The upper Fermionic Matsubara energy index. lowerBosonicMatsubaraEnergyIndex The lower Bosonic Matsubara energy index. upperBosonicMatsubaraEnergyIndex The upper Bosonic Matsubara energy index.

The documentation for this class was generated from the following file:
• /home/kristofer.bjornson/SecondQuantizationCom/TBTK/Lib/include/TBTK/PropertyExtractor/PropertyExtractor.h