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

Convert Properties to AnnotatedArrays. More...

#include <PropertyConverter.h>

Static Public Member Functions

template<typename DataType >
static AnnotatedArray< DataType, Subindexconvert (const Property::AbstractProperty< DataType > &abstractProperty)
 
template<typename DataType >
static AnnotatedArray< DataType, Subindexconvert (const Property::AbstractProperty< DataType > &abstractProperty, const Index &pattern)
 

Detailed Description

Convert Properties to AnnotatedArrays.

If the Property is on the format Index::Descriptor::Format::None or IndexDescriptor::Format::Ranges, it can be converted to an AnnotatedArray using

AnnotatedArray<DataType, Subindex> array

where DataType is the data type of the Propertys data elements. If the property has a block structure, the last array subindex corresponds to this block index. For example, for a Property::EnergyResolvedProperty, the last subindex corresponds to energy.

Similart to above, if the Property is on the format IndexDescriptor::Format::Custom, it can be converted to an AnnotatedArray using

AnnotatedArray<DataType, Subindex> array
= PropertyConverter::convert(property, pattern);

Here pattern is an Index that will be matched against every Index in the property to determine whether it should be included in the output or not. The resulting AnnotatedArray will have minimal possible ranges to conver all included Indices. The ranges for the AnnotatedArray start from zero, but the axes that can be obtained using

const std::vector<std::vector<Subindex>> &axes = array.getAxes();

contains information about which Subindex that corresponds to which array entry. The Subindices for the nth dimension is contained in axes[n].

Example

#include "TBTK/PropertyExtractor/Diagonalizer.h"
#include "TBTK/Streams.h"
#include "TBTK/TBTK.h"
#include <vector>
using namespace std;
using namespace TBTK;
int main(){
//Create Model.
const unsigned int SIZE_X = 2;
const unsigned int SIZE_Y = 3;
double t = 1;
Model model = Models::SquareLattice({SIZE_X, SIZE_Y}, {0, t});
model.construct();
//Set up and run the Solver.
solver.setModel(model);
solver.run();
//Set up the PropertyExtractor.
PropertyExtractor::Diagonalizer propertyExtractor(solver);
propertyExtractor.setEnergyWindow(-10, 10, 5);
//Calculate Properties.
Property::DOS dos = propertyExtractor.calculateDOS();
= propertyExtractor.calculateDensity({{_a_, _a_}});
Property::LDOS ldos = propertyExtractor.calculateLDOS({{_a_, _a_}});
//Convert the Properties to AnnotatedArrays.
= PropertyConverter::convert(density, {_a_, 1});
= PropertyConverter::convert(density, {_a_, _a_});
= PropertyConverter::convert(ldos, {_a_, 1});
//Print results.
Streams::out << "DOS:\n";
Streams::out << dosArray << "\n\n";
Streams::out << "Density 1D:\n";
Streams::out << densityArray1D << "\n\n";
Streams::out << "Density 2D:\n";
Streams::out << densityArray2D << "\n\n";
Streams::out << "LDOS:\n";
Streams::out << ldosArray << "\n\n";
}

Output

DOS:
[0, 0, 1.2, 0, 0]
Density 1D:
[0.5, 0.5]
Density 2D:
[[0.5, 0.5, 0.5]
[0.5, 0.5, 0.5]]
LDOS:
[[0, 0, 0.2, 0, 0]
[0, 0, 0.2, 0, 0]]

Member Function Documentation

◆ convert() [1/2]

template<typename DataType >
AnnotatedArray< DataType, Subindex > TBTK::PropertyConverter::convert ( const Property::AbstractProperty< DataType > &  abstractProperty)
static

Converts an AbstractProperty on the format IndexDescriptor::Format::None or IndexDescriptor::Format::Ranges to an AnnotatedArray.

Parameters
abstractPropertyThe property to convert.

◆ convert() [2/2]

template<typename DataType >
AnnotatedArray< DataType, Subindex > TBTK::PropertyConverter::convert ( const Property::AbstractProperty< DataType > &  abstractProperty,
const Index pattern 
)
static

Converts an AbstractProperty on the format IndexDescriptor::Format::Custom to an AnnotatedArray. The data for all points matching a given pattern Index will be extracted.

The dimension of the resulting AnnotatedArray will be equal to the number of wild cards (plus one if the block size is larger than one). The size of a given dimension is given by the difference between the largest and smallest Subindex for the corresponding Subindex position. For example, if the pattern is {a, 5, a} and the property contains data for {3, 5, 4}, {7, 5, 5}, {4, 5, 9}, the first dimension will range from 0 to 4 (= 7-3) and the second dimension will range from 0 to 6 (= 9-4). The corresponding axes will contain {3, 4, 5, 6, 7} and {4, 5, 6, 7, 8, 9}. If the property has a block size, the last dimension ranges from 0 to blockSize, with the corresponding axis containing {0, ..., blockSize-1}.

If the Indices are not dense, AnnotatedArray elements corresponding to "missing Indices" will be set to zero.

Parameters
abstractPropertyThe property to convert.
patternPattern that determines which points to extract the data for.

The documentation for this class was generated from the following file:
TBTK::AnnotatedArray
Array with additional information about its axes.
Definition: AnnotatedArray.h:41
TBTK::Model
Container of Model related information.
Definition: Model.h:57
TBTK::Property::DOS
Property container for density of states (DOS).
Definition: DOS.h:48
TBTK::Solver::Diagonalizer
Solves a Model using diagonalization.
Definition: Diagonalizer.h:52
Streams.h
Streams for TBTK output.
TBTK::Property::LDOS
Property container for the local density of states (LDOS).
Definition: LDOS.h:48
TBTK::PropertyExtractor::Diagonalizer
Extracts physical properties from the Solver::Diagonalizer.
Definition: Diagonalizer.h:55
TBTK::Solver::Diagonalizer::run
void run()
Diagonalizer.h
Solves a Model using diagonalization.
PropertyConverter.h
Converts Properties to AnnotatedArrays.
TBTK::Initialize
void Initialize()
TBTK::Solver::Solver::setModel
virtual void setModel(Model &model)
Definition: Solver.h:69
TBTK::Property::Density
Property container for density.
Definition: Density.h:43
SquareLattice.h
Square lattice model.
TBTK::Streams::out
static std::ostream out
Definition: Streams.h:70
TBTK::PropertyConverter::convert
static AnnotatedArray< DataType, Subindex > convert(const Property::AbstractProperty< DataType > &abstractProperty)
Definition: PropertyConverter.h:114
TBTK.h
TBTK initialization.
TBTK::Model::construct
void construct()
TBTK::Models::SquareLattice
Square lattice model.
Definition: SquareLattice.h:60