HubbardGPU
Hubbard diagonalisation on the GPU (and CPU)
|
#include <bare-ham.h>
Public Member Functions | |
BareHamiltonian (int L, int Nu, int Nd, double J, double U) | |
virtual | ~BareHamiltonian () |
std::string | print_bin (myint num) const |
virtual void | BuildBase () |
virtual void | BuildFullHam ()=0 |
virtual void | BuildHam () |
int | getL () const |
int | getNu () const |
int | getNd () const |
int | getDim () const |
double | getJ () const |
double | getU () const |
void | setU (double) |
myint | getBaseUp (unsigned int i) const |
myint | getBaseDown (unsigned int i) const |
virtual std::vector< double > | ExactDiagonalizeFull (bool calc_eigenvectors=false) |
virtual double | LanczosDiagonalize (int m=0) |
virtual double | arpackDiagonalize () |
void | Print (bool list=false) const |
void | PrintBase () const |
void | PrintGroundstateVector () const |
virtual void | mvprod (double *x, double *y, double alpha) const =0 |
double | MemoryNeededFull () const |
double | MemoryNeededLanczos () const |
double | MemoryNeededArpack () const |
virtual void | SaveToFile (const std::string filename) const |
Static Public Member Functions | |
static int | CalcDim (int L, int N) |
static int | CountBits (myint bits) |
static std::string | print_bin (myint num, int bitcount) |
Protected Member Functions | |
int | CalcSign (int i, int j, myint a) const |
void | SaveToFile (const std::string filename, double *data, int dim) const |
Static Protected Member Functions | |
static void | Diagonalize (int dim, double *mat, double *eigs, bool calc_eigenvectors) |
Protected Attributes | |
int | L |
Number of sites. More... | |
int | Nu |
Number of up electrons. More... | |
int | Nd |
Number of down electrons. More... | |
double | J |
Hopping strength. More... | |
double | U |
On site interaction strength. More... | |
double * | ham |
Storage for the BareHamiltonian matrix. More... | |
int | dim |
Dimension of the BareHamiltonian matrix. More... | |
myint | Hb |
Hightest bit used. More... | |
int | Hbc |
the location of the highest bit More... | |
std::vector< myint > | baseUp |
vector to hold all bases ket's for up electrons More... | |
std::vector< myint > | baseDown |
vector to hold all bases ket's for down electrons More... | |
The is a pure virtual basic hamiltonian class. It's the base class for both the sites basis and the momentum basis
Definition at line 55 of file bare-ham.h.
BareHamiltonian::BareHamiltonian | ( | int | L, |
int | Nu, | ||
int | Nd, | ||
double | J, | ||
double | U | ||
) |
Constructor of the BareHamiltonian class
L | Number of lattice sites |
Nu | Number of Up Electrons |
Nd | Number of Down Electrons |
J | The hopping strengh |
U | The onsite interaction strength |
Definition at line 43 of file bare-ham.cpp.
|
virtual |
Destructor of the BareHamiltonian class
Definition at line 68 of file bare-ham.cpp.
|
virtual |
Definition at line 436 of file bare-ham.cpp.
|
virtual |
Builds all the up and down base kets
Reimplemented in SpinHamiltonian, and MomHamiltonian.
Definition at line 146 of file bare-ham.cpp.
|
pure virtual |
Implemented in SpinHamiltonian, MomHamiltonian, HubHam2D, and Hamiltonian.
|
virtual |
This method is always present and should build the Hamiltonian, either full or sparse
Definition at line 165 of file bare-ham.cpp.
|
static |
Calculates the dimension for the up or down electron space. Basically, it calculates the N-combination out of L. This algorithm is not perfect, overflow can occur but should be no problem for our small problems.
L | number of lattice sites |
N | number of up or down electrons |
Definition at line 83 of file bare-ham.cpp.
|
protected |
Calculates the sign of the hop between site i and site j on ket a. Make sure that i < j!
i | the first sp |
j | the second sp |
a | the ket to use |
Definition at line 178 of file bare-ham.cpp.
|
static |
Counts the number of bits set. It uses the builtin gcc function __buildtin_popcount. You must compile with -march=native and it will then generate a POPCNT instruction on platforms that support it. Otherwise it will be slow. Consider using a different method here if you don't have the POPCNT instruction: there are fast SSSE3 and SSE2 ways to do this(google is your friend).
bits | the myint of which to count the number of bits set |
Definition at line 106 of file bare-ham.cpp.
|
staticprotected |
Helper for exact diagonalization: diagonalize the matrix given in mat with dimension dim, stores the eigenvalues in eigs and optionally the eigenvectors in mat
dim | the dimension of the matrix |
mat | the actual matrix (size: dim*dim) |
eigs | array of size dim to store eigenvalues |
calc_eigenvectors | whether or not the calculate the eigenvectors |
Definition at line 681 of file bare-ham.cpp.
|
virtual |
Exactly calculates the eigenvalues of the BareHamiltonian matrix. Needs lapack.
Reimplemented in SpinHamiltonian, and MomHamiltonian.
Definition at line 280 of file bare-ham.cpp.
myint BareHamiltonian::getBaseDown | ( | unsigned int | i | ) | const |
Getter for the i base down ket
i | the number of the base ket |
Definition at line 270 of file bare-ham.cpp.
myint BareHamiltonian::getBaseUp | ( | unsigned int | i | ) | const |
Getter for the i base up ket
i | the number of the base ket |
Definition at line 260 of file bare-ham.cpp.
int BareHamiltonian::getDim | ( | ) | const |
Getter for the dimension of the BareHamiltonian matrix
Definition at line 223 of file bare-ham.cpp.
double BareHamiltonian::getJ | ( | ) | const |
Getter for the hopping strength
Definition at line 232 of file bare-ham.cpp.
int BareHamiltonian::getL | ( | ) | const |
Getter for the number of lattice sites
Definition at line 196 of file bare-ham.cpp.
int BareHamiltonian::getNd | ( | ) | const |
Getter for the number of down electrons
Definition at line 214 of file bare-ham.cpp.
int BareHamiltonian::getNu | ( | ) | const |
Getter for the number of up electrons
Definition at line 205 of file bare-ham.cpp.
double BareHamiltonian::getU | ( | ) | const |
Getter for the onsite interaction strength
Definition at line 241 of file bare-ham.cpp.
|
virtual |
Calculates the lowest eigenvalue of the BareHamiltonian matrix using the lanczos algorithm. Needs lapack.
m | an optional estimate for the lanczos space size |
Definition at line 313 of file bare-ham.cpp.
double BareHamiltonian::MemoryNeededArpack | ( | ) | const |
Calculates the amount of memory needed for the calculation if we use the arpack. It doesn't include the program code and stuff.
Definition at line 643 of file bare-ham.cpp.
double BareHamiltonian::MemoryNeededFull | ( | ) | const |
Calculates the amount of memory needed for the calculation of all eigenvalues using the exact method. It doesn't include the program code and stuff.
Definition at line 591 of file bare-ham.cpp.
double BareHamiltonian::MemoryNeededLanczos | ( | ) | const |
Calculates the amount of memory needed for the calculation if we use the lanczos method. It doesn't include the program code and stuff.
Definition at line 617 of file bare-ham.cpp.
|
pure virtual |
Implemented in SpinHamiltonian, MomHamiltonian, SparseHamiltonian2D_CSR, SparseHamiltonian2D, and Hamiltonian.
void BareHamiltonian::Print | ( | bool | list = false | ) | const |
Prints the full BareHamiltonian matrix to stdout
Definition at line 410 of file bare-ham.cpp.
std::string BareHamiltonian::print_bin | ( | myint | num | ) | const |
Print a int in binary form to a string. Prints a much as needed to represent the current system.
num | the myint to print in binary form |
Definition at line 138 of file bare-ham.cpp.
|
static |
Print a int in binary form to a string. It only prints the bitcount least significant bits
num | the myint to print in binary form |
bitcount | the number of bits to print (starting from the LSB) |
Definition at line 118 of file bare-ham.cpp.
void BareHamiltonian::PrintBase | ( | ) | const |
Print the basis set used.
Definition at line 429 of file bare-ham.cpp.
void BareHamiltonian::PrintGroundstateVector | ( | ) | const |
Prints the groundstate in function of the basis vectors Only gives meanfull output after running BareHamiltonian::ExactDiagonalizeFull(true)
Definition at line 295 of file bare-ham.cpp.
|
virtual |
Save the hamiltonian matrix to a file in the HDF5 format
filename | the name of the file to write to |
Definition at line 727 of file bare-ham.cpp.
|
protected |
Save a array to a file in the HDF5 format
filename | the name of the file to write to |
data | a pointer to the array to write to a file |
dim | the size of the array |
Definition at line 741 of file bare-ham.cpp.
void BareHamiltonian::setU | ( | double | myU | ) |
Set the value of U
myU | the value of U |
Definition at line 250 of file bare-ham.cpp.
|
protected |
vector to hold all bases ket's for down electrons
Definition at line 138 of file bare-ham.h.
|
protected |
vector to hold all bases ket's for up electrons
Definition at line 136 of file bare-ham.h.
|
protected |
Dimension of the BareHamiltonian matrix.
Definition at line 128 of file bare-ham.h.
|
protected |
Storage for the BareHamiltonian matrix.
Definition at line 126 of file bare-ham.h.
|
protected |
Hightest bit used.
Definition at line 131 of file bare-ham.h.
|
protected |
the location of the highest bit
Definition at line 133 of file bare-ham.h.
|
protected |
Hopping strength.
Definition at line 122 of file bare-ham.h.
|
protected |
Number of sites.
Definition at line 116 of file bare-ham.h.
|
protected |
Number of down electrons.
Definition at line 120 of file bare-ham.h.
|
protected |
Number of up electrons.
Definition at line 118 of file bare-ham.h.
|
protected |
On site interaction strength.
Definition at line 124 of file bare-ham.h.