TBTK
TBTK::Solver::BlockDiagonalizer Class Reference

Solves a block diagonal Model using diagonalization. More...

#include <BlockDiagonalizer.h>

Inheritance diagram for TBTK::Solver::BlockDiagonalizer:
TBTK::Solver::Solver TBTK::Communicator

Public Member Functions

 BlockDiagonalizer ()
 
virtual ~BlockDiagonalizer ()
 
void setSelfConsistencyCallback (bool(*selfConsistencyCallback)(BlockDiagonalizer &blockDiagonalizer))
 
void setMaxIterations (int maxIterations)
 
void run ()
 
const double getEigenValue (int state)
 
const double getEigenValue (const Index &blockIndex, int state)
 
const std::complex< double > getAmplitude (int state, const Index &index)
 
const std::complex< double > getAmplitude (const Index &blockIndex, int state, const Index &intraBlockIndex)
 
unsigned int getFirstStateInBlock (const Index &index) const
 
unsigned int getLastStateInBlock (const Index &index) const
 
void setParallelExecution (bool parallelExecution)
 
- Public Member Functions inherited from TBTK::Solver::Solver
 Solver ()
 
virtual ~Solver ()
 
virtual void setModel (Model &model)
 
ModelgetModel ()
 
const ModelgetModel () const
 
- Public Member Functions inherited from TBTK::Communicator
 Communicator (bool verbose)
 
void setVerbose (bool verbose)
 
bool getVerbose () const
 

Additional Inherited Members

- Static Public Member Functions inherited from TBTK::Communicator
static void setGlobalVerbose (bool globalVerbose)
 
static bool getGlobalVerbose ()
 

Detailed Description

Solves a block diagonal Model using diagonalization.

Solves a given model by Diagonalizing the Hamiltonian. The eigenvalues and eigenvectors can then either be directly extracted and used to calculate custom physical quantities, or the PropertyExtractor can be used to extract common properties. Scales as \(O(n^3)\) with the dimension of the Hilbert space.

Constructor & Destructor Documentation

TBTK::Solver::BlockDiagonalizer::BlockDiagonalizer ( )

Constructs a Solver::Diagonalizer.

virtual TBTK::Solver::BlockDiagonalizer::~BlockDiagonalizer ( )
virtual

Destructor.

Member Function Documentation

const std::complex< double > TBTK::Solver::BlockDiagonalizer::getAmplitude ( int  state,
const Index index 
)
inline

Get amplitude for given eigenvector \(n\) and physical index \(x\): \(\Psi_{n}(x)\).

Parameters
stateEigenstate number \(n\).
indexPhysical index \(x\).
Returns
The amplitude \(\Psi_{n}(\mathbf{x})\).
const std::complex< double > TBTK::Solver::BlockDiagonalizer::getAmplitude ( const Index blockIndex,
int  state,
const Index intraBlockIndex 
)
inline

Get amplitude for given eigenvector \(n\), block index \(b\), and physical index \(x\): \(\Psi_{nb}(x)\).

Parameters
blockIndexBlock index \(b\)
stateEigenstate number \(n\) relative to the given block.
indexPhysical index \(x\).
Returns
The amplitude \(\Psi_{nb}(\mathbf{x})\).
const double TBTK::Solver::BlockDiagonalizer::getEigenValue ( int  state)
inline

Get eigenvalue. The eigenvalues are ordered first by block, and then in accending order. This means that eigenvalues for blocks with smaller Indices comes before eigenvalues for blocks with larger Indices , while inside each block the eigenvalues are in accending order.

Parameters
stateThe state number.
Returns
The eigenvalue for the given state.
const double TBTK::Solver::BlockDiagonalizer::getEigenValue ( const Index blockIndex,
int  state 
)
inline

Get eigenvalue for specific block. Note that in contrast to getEigenValue(int state), 'state' here is relative to the first state of the block.

Parameters
blockIndexBlock index to get the eigenvalue for.
stateState index relative to the block in accending order.
Returns
The eigenvalue for the given state in the given block.
unsigned int TBTK::Solver::BlockDiagonalizer::getFirstStateInBlock ( const Index index) const
inline

Get first state in the block corresponding to the given Index.

Parameters
indexA physical Index.
Returns
The global state index for the first state that belongs to the block for which the given Index is part of the basis.
unsigned int TBTK::Solver::BlockDiagonalizer::getLastStateInBlock ( const Index index) const
inline

Get last state in the block corresponding to the given Index.

Parameters
indexA physical Index.
Returns
The global state index for the last state that belongs to the block for which the given Index is part of the basis.
void TBTK::Solver::BlockDiagonalizer::run ( )

Run calculations. Diagonalizes ones if no self-consistency callback have been set, or otherwise multiple times until slef-consistencey or maximum number of iterations has been reached.

void TBTK::Solver::BlockDiagonalizer::setMaxIterations ( int  maxIterations)
inline

Set maximum number of iterations for the self-consistency loop. Only used if BlockDiagonalizer::setSelfConsistencyCallback() has been called with a non-nullptr argument. If the self-consistency callback does not return true, maxIterations determine the maximum number of times it is called.

Parameters
maxIterationsMaximum number of iterations to use in a self-consistent calculation.
void TBTK::Solver::BlockDiagonalizer::setParallelExecution ( bool  parallelExecution)
inline

Set whether parallel execution is enabled or not. Parallel execution is only possible if OpenMP is available.

parallelExecution True to enable parallel execution.

void TBTK::Solver::BlockDiagonalizer::setSelfConsistencyCallback ( bool(*)(BlockDiagonalizer &blockDiagonalizer)  selfConsistencyCallback)
inline

Set self-consistency callback. If set to nullptr or never called, the self-consistency loop will not be run.

Parameters
selfConsistencyCallbackA callback function that will be called after the Model has been diagonalized. The function should calculate relevant quantities, modify the Model if necessary, and return false if further iteration is necessary. If true is returned, self-consistency is considered to be reached and the iteration stops.

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