TBTK
Need a break? Support the development by playing Polarity Puzzles
BlockDiagonalizer

Hamiltonian

\(H = -\mu\sum_{\mathbf{i}}c_{\mathbf{i}}^{\dagger}c_{\mathbf{i}} + t\sum_{\langle \mathbf{i}\mathbf{j}\rangle}c_{\mathbf{i}}^{\dagger}c_{\mathbf{j}}\)

Code

#include "TBTK/Model.h"
#include "TBTK/Range.h"
#include "TBTK/Smooth.h"
#include "TBTK/Solver/BlockDiagonalizer.h"
#include "TBTK/Streams.h"
#include "TBTK/TBTK.h"
#include <complex>
#include <cmath>
using namespace std;
using namespace TBTK;
using namespace Visualization::MatPlotLib;
int main(){
//Initialize TBTK.
//Parameters.
const int NUM_K_POINTS = 10000;
double a = 1;
//Set up the Model.
Model model;
Range K(0, 2*M_PI, NUM_K_POINTS);
for(int k = 0; k < NUM_K_POINTS; k++)
model << HoppingAmplitude(cos(K[k]*a), {k, 0}, {k, 1}) + HC;
model.setChemicalPotential(-0.5);
model.setTemperature(300);
model.construct();
//Set up the Solver.
solver.setModel(model);
solver.run();
//Set up the PropertyExtractor.
const double LOWER_BOUND = -2;
const double UPPER_BOUND = 2;
const int RESOLUTION = 200;
PropertyExtractor::BlockDiagonalizer propertyExtractor(solver);
propertyExtractor.setEnergyWindow(
LOWER_BOUND,
UPPER_BOUND,
RESOLUTION
);
//Calculate the density of states (DOS).
Property::DOS dos = propertyExtractor.calculateDOS();
//Smooth the DOS
const double SMOOTHING_SIGMA = 0.01;
const unsigned int SMOOTHING_WINDOW = 51;
dos = Smooth::gaussian(dos, SMOOTHING_SIGMA, SMOOTHING_WINDOW);
//Plot the DOS.
Plotter plotter;
plotter.plot(dos);
plotter.save("figures/DOS.png");
//Caluclate the density (momentum space density).
Property::Density density = propertyExtractor.calculateDensity({
//All k-points, summing over the second subindex.
{_a_, IDX_SUM_ALL}
});
//Plot the Density.
plotter.clear();
plotter.setAxes({{0, {0, 2*M_PI}}});
plotter.plot({_a_, IDX_SUM_ALL}, density);
plotter.setLabelX("k");
plotter.save("figures/Density.png");
}

Output

Plotter.h
Plots data.
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
Model.h
Container of Model related information.
Streams.h
Streams for TBTK output.
TBTK::PropertyExtractor::BlockDiagonalizer
Extracts physical properties from the Solver::BlockDiagonalizer.
Definition: BlockDiagonalizer.h:54
TBTK::Solver::BlockDiagonalizer
Solves a block diagonal Model using diagonalization.
Definition: BlockDiagonalizer.h:68
TBTK::Range
One-dimensional range.
Definition: Range.h:52
TBTK::Model::setChemicalPotential
void setChemicalPotential(double chemicalPotential)
Definition: Model.h:347
TBTK::Initialize
void Initialize()
TBTK::Solver::Solver::setModel
virtual void setModel(Model &model)
Definition: Solver.h:69
Range.h
Helper class for flattening nested looping.
TBTK::Property::Density
Property container for density.
Definition: Density.h:43
TBTK::Model::setTemperature
void setTemperature(double temperature)
Definition: Model.h:339
TBTK::Math::cos
Array< DataType > cos(const Array< DataType > &array)
Definition: ArrayAlgorithms.h:606
TBTK::HoppingAmplitude
Hopping amplitude from state 'from' to state 'to'.
Definition: HoppingAmplitude.h:53
TBTK::Solver::BlockDiagonalizer::run
void run()
BlockDiagonalizer.h
Extracts physical properties from the Solver::BlockDiagonalizer.
TBTK.h
TBTK initialization.
Smooth.h
Collection of functions for smoothing data.
TBTK::Model::construct
void construct()