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

Container of Model related information. More...

#include <Model.h>

Inheritance diagram for TBTK::Model:
TBTK::Serializable TBTK::Communicator TBTK::Streamable TBTK::Models::SquareLattice

Public Member Functions

 Model ()
 
 Model (const std::vector< unsigned int > &capacity)
 
 Model (const Model &model)
 
 Model (Model &&model)
 
 Model (const std::string &serialization, Mode mode)
 
virtual ~Model ()
 
Modeloperator= (const Model &rhs)
 
Modeloperator= (Model &&rhs)
 
void add (HoppingAmplitude ha)
 
void addModel (const Model &model, const Index &subsytemIndex)
 
int getBasisIndex (const Index &index) const
 
int getBasisSize () const
 
void generateHoppingAmplitudeSet (const HoppingAmplitude::AmplitudeCallback &hoppingAmplitudeCallback)
 
void generateOverlapAmplitudeSet (const OverlapAmplitude::AmplitudeCallback &overlapAmplitudeCallback)
 
void construct ()
 
bool getIsConstructed ()
 
void setTemperature (double temperature)
 
double getTemperature () const
 
void setChemicalPotential (double chemicalPotential)
 
double getChemicalPotential () const
 
void setStatistics (Statistics statistics)
 
Statistics getStatistics () const
 
const BasisStateSet & getBasisStateSet () const
 
const HoppingAmplitudeSetgetHoppingAmplitudeSet () const
 
const SourceAmplitudeSetgetSourceAmplitudeSet () const
 
const OverlapAmplitudeSetgetOverlapAmplitudeSet () const
 
GeometrygetGeometry ()
 
const GeometrygetGeometry () const
 
void createManyParticleContext ()
 
ManyParticleContext * getManyParticleContext ()
 
void setFilter (const AbstractHoppingAmplitudeFilter &hoppingAmplitudeFilter)
 
void setFilter (const AbstractIndexFilter &indexFilter)
 
Modeloperator<< (const AbstractState &basisState)
 
Modeloperator<< (const HoppingAmplitude &hoppingAmplitude)
 
Modeloperator<< (const std::tuple< HoppingAmplitude, HoppingAmplitude > &hoppingAmplitudes)
 
Modeloperator<< (const HoppingAmplitudeList &hoppingAmplitudeList)
 
Modeloperator<< (const SourceAmplitude &sourceAmplitude)
 
Modeloperator<< (const OverlapAmplitude &overlapAmplitudeSet)
 
virtual std::string toString () const
 
std::string serialize (Mode mode) const
 
- Public Member Functions inherited from TBTK::Serializable
template<>
std::string serialize (const bool &data, Mode mode)
 
template<>
std::string serialize (const double &data, Mode mode)
 
template<>
std::string serialize (const std::complex< double > &data, Mode mode)
 
template<>
std::string serialize (const int &data, Mode mode)
 
template<>
std::string serialize (const unsigned int &data, Mode mode)
 
template<>
std::string serialize (const SpinMatrix &data, Mode mode)
 
template<>
std::string serialize (const Statistics &data, Mode mode)
 
template<>
std::string serialize (const std::vector< std::complex< double >> &data, Mode mode)
 
template<>
int deserialize (const std::string &serialization, Mode mode)
 
- Public Member Functions inherited from TBTK::Communicator
 Communicator (bool verbose)
 
void setVerbose (bool verbose)
 
bool getVerbose () const
 

Friends

class FileReader
 

Additional Inherited Members

- Public Types inherited from TBTK::Serializable
enum  Mode { Debug, Binary, XML, JSON }
 
- Static Public Member Functions inherited from TBTK::Serializable
static bool hasID (const std::string &serialization, Mode mode)
 
static std::string getID (const std::string &serialization, Mode mode)
 
static std::string extractComponent (const std::string &serialization, const std::string &containerID, const std::string &componentID, const std::string &componentName, Mode mode)
 
- Static Public Member Functions inherited from TBTK::Communicator
static void setGlobalVerbose (bool globalVerbose)
 
static bool getGlobalVerbose ()
 
- Static Protected Member Functions inherited from TBTK::Serializable
static bool validate (const std::string &serialization, const std::string &id, Mode mode)
 
static std::string getContent (const std::string &serialization, Mode mode)
 
static std::vector< std::string > split (const std::string &content, Mode mode)
 
template<typename DataType >
static std::enable_if<!std::is_pointer< DataType >::value, std::string >::type serialize (const DataType &data, Mode mode)
 
template<typename DataType >
static std::enable_if< std::is_pointer< DataType >::value, std::string >::type serialize (const DataType &data, Mode mode)
 
template<typename DataType >
static DataType deserialize (const std::string &serialization, Mode mode)
 
static std::string extract (const std::string &serialization, Mode mode, std::string component)
 

Detailed Description

Container of Model related information.

The Model contains all model related information such as the Hamiltonian, temperature, and chemical potential.

Example

#include "TBTK/Model.h"
#include "TBTK/Streams.h"
#include "TBTK/TBTK.h"
#include <complex>
using namespace std;
using namespace TBTK;
//Create a 2D-lattice with on-site potential U, nearest neighbor hopping
//amplitude t, chemical potential mu, temperature T, and Fermi-Dirac
//statistics.
int main(){
//Parameters.
complex<double> U = 1;
complex<double> t = 1;
double mu = -1;
double T = 300;
unsigned int SIZE_X = 10;
unsigned int SIZE_Y = 10;
//Model specification.
Model model;
for(unsigned int x = 0; x < SIZE_X; x++){
for(unsigned int y = 0; y < SIZE_Y; y++){
for(unsigned int spin = 0; spin < 2; spin++){
model << HoppingAmplitude(
U,
{x, y, spin},
{x, y, spin}
);
if(x+1 < SIZE_X){
model << HoppingAmplitude(
-t,
{x+1, y, spin},
{x, y, spin}
) + HC;
}
if(y+1 < SIZE_Y){
model << HoppingAmplitude(
-t,
{x, y+1, spin},
{x, y, spin}
) + HC;
}
}
}
}
model.setTemperature(T);
model.setStatistics(Statistics::FermiDirac);
//Construct a mapping from the Physical Indices to a linear Hilbert
//space basis.
model.construct();
Streams::out << model << "\n";
}

Output

Temperature: 300K (300 n.u.)
Chemical potential: -1eV (-1 n.u.)
Statistics: Fermi-Dirac
Basis size: 200

Constructor & Destructor Documentation

◆ Model() [1/5]

TBTK::Model::Model ( )

Constructor.

◆ Model() [2/5]

TBTK::Model::Model ( const std::vector< unsigned int > &  capacity)

Constructs a Model with a preallocated storage structure such that the addition of HoppingAmplitudes with indices that have the same subindex structure as 'capacity', but with smaller subindices will not cause reallocation for the main storage structure. Internal containers for HoppingAmplitudes may still be reallocated.

Parameters
capacityThe 'Index capacity'.

◆ Model() [3/5]

TBTK::Model::Model ( const Model model)

Copy constructor.

Parameters
modelModel to copy.

◆ Model() [4/5]

TBTK::Model::Model ( Model &&  model)

Move constructor.

Parameters
modelModel to move.

◆ Model() [5/5]

TBTK::Model::Model ( const std::string &  serialization,
Mode  mode 
)

Constructor. Constructs the Model from a serialization string. Note that the ManyParticleContext is not yet serialized.

Parameters
serializationSerialization string from which to construct the Model.
modeMode with which the string has been serialized.

◆ ~Model()

virtual TBTK::Model::~Model ( )
virtual

Destructor.

Member Function Documentation

◆ add()

void TBTK::Model::add ( HoppingAmplitude  ha)
inline

Add a HoppingAmplitude.

Parameters
haHoppingAmplitude to add.

◆ addModel()

void TBTK::Model::addModel ( const Model model,
const Index subsytemIndex 
)

Add a Model as a subsystem.

Parameters
modelModel to include as subsystem.
subsystemIndexIndex that will be prepended to each Index in the model.

◆ construct()

void TBTK::Model::construct ( )

Construct Hilbert space. No more HoppingAmplitudes should be added after this call.

◆ createManyParticleContext()

void TBTK::Model::createManyParticleContext ( )
inline

Create ManyParticleContext.

◆ generateHoppingAmplitudeSet()

void TBTK::Model::generateHoppingAmplitudeSet ( const HoppingAmplitude::AmplitudeCallback hoppingAmplitudeCallback)
inline

Generate HoppingAmplitudeSet from basis functions.

Parameters
hoppingAmplitudeCallbackCallback to use as argument for the HoppingAmplitudes.

◆ generateOverlapAmplitudeSet()

void TBTK::Model::generateOverlapAmplitudeSet ( const OverlapAmplitude::AmplitudeCallback overlapAmplitudeCallback)
inline

Generate OverlapAmplitudeSet from basis functions.

Parameters
overlapAmplitudeCallbackCallback to use as argument for the OverlapAmplitudes.

◆ getBasisIndex()

int TBTK::Model::getBasisIndex ( const Index index) const
inline

Get Hilbert space index corresponding to given 'from'-index.

Parameters
indexPhysical Index for which to obtain the Hilbert space index.
Returns
The Hilbert space index corresponding to the given Physical Index. Returns -1 if Model::construct() has not been called.

◆ getBasisSize()

int TBTK::Model::getBasisSize ( ) const
inline

Get size of Hilbert space.

Returns
The basis size if the basis has been constructed using the call to Model::construct(), otherwise -1.

◆ getBasisStateSet()

const BasisStateSet & TBTK::Model::getBasisStateSet ( ) const
inline

Get BasisStateSet.

Returns
Reference to the contained BasisStateSet.

◆ getChemicalPotential()

double TBTK::Model::getChemicalPotential ( ) const
inline

Get chemical potential.

Returns
The chemical potential.

◆ getGeometry() [1/2]

const Geometry & TBTK::Model::getGeometry ( )
inline

Get geometry.

Returns
Pointer to the contained Geometry.

◆ getGeometry() [2/2]

const Geometry& TBTK::Model::getGeometry ( ) const

Get geometry.

Returns
Pointer to the contained Geometry.

◆ getHoppingAmplitudeSet()

const HoppingAmplitudeSet & TBTK::Model::getHoppingAmplitudeSet ( ) const
inline

Get amplitude set.

Returns
Reference to the contained HoppingAmplitudeSet.

◆ getIsConstructed()

bool TBTK::Model::getIsConstructed ( )
inline

Check whether the Hilbert space basis has been constructed.

Returns
True if the Hilbert space basis has been constructed.

◆ getManyParticleContext()

ManyParticleContext * TBTK::Model::getManyParticleContext ( )
inline

Get ManyParticleContext.

Returns
Pointer to the contained ManyParticleContext.

◆ getOverlapAmplitudeSet()

const OverlapAmplitudeSet & TBTK::Model::getOverlapAmplitudeSet ( ) const
inline

Get OverlapAmplitudeSet.

Returns
Reference to the contained OverlapAmplitudeSet.

◆ getSourceAmplitudeSet()

const SourceAmplitudeSet & TBTK::Model::getSourceAmplitudeSet ( ) const
inline

Get SourceAmplitudeSet.

Returns
Reference to the contained SourceAmplitudeSet.

◆ getStatistics()

Statistics TBTK::Model::getStatistics ( ) const
inline

Get statistics.

Returns
The currently set Statistics.

◆ getTemperature()

double TBTK::Model::getTemperature ( ) const
inline

Get temperature.

Returns
The temperature.

◆ operator<<() [1/6]

Model & TBTK::Model::operator<< ( const AbstractState &  basisState)
inline

Operator<<.

◆ operator<<() [2/6]

Model & TBTK::Model::operator<< ( const HoppingAmplitude hoppingAmplitude)
inline

Operator<<.

◆ operator<<() [3/6]

Model & TBTK::Model::operator<< ( const HoppingAmplitudeList hoppingAmplitudeList)
inline

Operator<<.

◆ operator<<() [4/6]

Model & TBTK::Model::operator<< ( const OverlapAmplitude overlapAmplitudeSet)
inline

Operator<<.

◆ operator<<() [5/6]

Model & TBTK::Model::operator<< ( const SourceAmplitude sourceAmplitude)
inline

Operator<<.

◆ operator<<() [6/6]

Model & TBTK::Model::operator<< ( const std::tuple< HoppingAmplitude, HoppingAmplitude > &  hoppingAmplitudes)
inline

Operator<<.

◆ operator=() [1/2]

Model& TBTK::Model::operator= ( const Model rhs)

Assignment operator.

Parameters
rhsModel to assign to the left hand side.
Returns
Reference to the assigned Model.

◆ operator=() [2/2]

Model& TBTK::Model::operator= ( Model &&  rhs)

Move assignment operator.

Parameters
rhsModel to assign to the left hand side.
Returns
Reference to the assigned Model.

◆ serialize()

std::string TBTK::Model::serialize ( Mode  mode) const
virtual

Implements Serializable::serialize(). Note that the ManyParticleContext is not yet serialized.

Implements TBTK::Serializable.

◆ setChemicalPotential()

void TBTK::Model::setChemicalPotential ( double  chemicalPotential)
inline

Set chemical potential.

Parameters
chemicalPotentialThe chemical potential.

◆ setFilter() [1/2]

void TBTK::Model::setFilter ( const AbstractHoppingAmplitudeFilter hoppingAmplitudeFilter)
inline

Set a HoppingAmplitudeFilter. The HoppingAmplitudeFilter will be used by the Model to determine whether a given HoppingAmplitude that is passed to the Model actually should be added or not. If no HoppingAmplitudeFilter is set, all HoppingAmplitudes are added. But if a HoppingAmplitudeFilter is set, only those HoppingAmplitudes that the filter returns true for are added.

Parameters
hoppingAmplitudeFilterThe HoppingAmplitudeFilter to use.

◆ setFilter() [2/2]

void TBTK::Model::setFilter ( const AbstractIndexFilter indexFilter)
inline

Set an IndexFilter. The IndexFilter will be used by the Model to determine whether a given HoppingAmplitude that is passed to the Model actually should be added or not. If no IndexFilter is set, all HoppingAmplitudes are added. But if an IndexFilter is set, only those HoppingAmplitudes for which the filter returns true for both Indices are added.

Parameters
indexFilterThe IndexFilter to use.

◆ setStatistics()

void TBTK::Model::setStatistics ( Statistics  statistics)
inline

Set statistics.

Parameters
statisticsThe statistics to use.

◆ setTemperature()

void TBTK::Model::setTemperature ( double  temperature)
inline

Set temperature.

Parameters
temperatureThe temperature.

◆ toString()

virtual std::string TBTK::Model::toString ( ) const
virtual

Returns a string with characteristic information about the Model.

Returns
A string with characterstic information about the Model.

Implements TBTK::Streamable.

Friends And Related Function Documentation

◆ FileReader

friend class FileReader
friend

FileReader is a friend class to allow it to write Model data.


The documentation for this class was generated from the following file:
TBTK::Model
Container of Model related information.
Definition: Model.h:57
Model.h
Container of Model related information.
TBTK::Model::setStatistics
void setStatistics(Statistics statistics)
Definition: Model.h:355
Streams.h
Streams for TBTK output.
TBTK::Model::setChemicalPotential
void setChemicalPotential(double chemicalPotential)
Definition: Model.h:347
TBTK::Initialize
void Initialize()
TBTK::Model::Model
Model()
TBTK::Model::setTemperature
void setTemperature(double temperature)
Definition: Model.h:339
TBTK::HoppingAmplitude
Hopping amplitude from state 'from' to state 'to'.
Definition: HoppingAmplitude.h:53
TBTK::Streams::out
static std::ostream out
Definition: Streams.h:70
TBTK.h
TBTK initialization.
TBTK::Model::construct
void construct()