Skip to content

Commit

Permalink
updated examples.
Browse files Browse the repository at this point in the history
wztzjhn committed Sep 17, 2017
1 parent b6daa83 commit cd0fbe7
Showing 7 changed files with 366 additions and 16 deletions.
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -3,16 +3,21 @@ Basis of condensed matter quantum lattice problems, for usage in exact diagonali

## Examples
To learn how to use this library to design ED code for your own models, please refer to the folder "examples":
- Heisenberg spin-1/2 chain
- Heisenberg spin-1 chain
- Heisenberg spin-1/2 triangular lattice
- Heisenberg spin-1/2 kagome lattice
- Spinless fermion on honeycomb lattice
- Fermi-Hubbard Model on square lattice
- Bose-Hubbard Model on square lattice
- Kondo Lattice Model on a chain
- tJ Model on chain lattice (E0 checked, but E1 inconsistent with ALPS)
- tJ Model on kagome lattice (E0 checked, but E1 inconsistent with ALPS)
- Chain
- Heisenberg spin-1/2
- Heisenberg spin-1
- Kondo Lattice model
- t-J model
- Honeycomb lattice
- Spinless fermion
- Kagome lattice
- Heisenberg spin-1/2
- t-J model
- Square lattice
- Bose-Hubbard model
- Fermi-Hubbard model
- Triangular lattice
- Heisenberg spin-1/2

## Dependencies:
- [Boost](http://www.boost.org/)
7 changes: 3 additions & 4 deletions examples/trans_absent/latt_chain/chain_tJ.cc
Original file line number Diff line number Diff line change
@@ -3,10 +3,8 @@
#include "qbasis.h"

// tJ model on chain lattice
// E0 checked. Excitations seems not correct.
int main() {
qbasis::enable_ckpt = true;
std::cout << "ground state energy checked correct. 1st excited state inconsistent with ALPS!" << std::endl;
std::cout << std::setprecision(10);
// parameters
double t = 1.0;
@@ -93,10 +91,11 @@ int main() {


// obtaining the eigenvals of the matrix
tJ.locate_E0_lanczos(0);
tJ.locate_E0_full(4,8);
std::cout << std::endl;


// for the parameters considered, we should obtain:
//assert(std::abs(tJ.eigenvals_full[0] + 15.41931496) < 1e-8);
assert(std::abs(tJ.eigenvals_full[0] + 9.762087307) < 1e-8);
assert(std::abs(tJ.eigenvals_full[1] + 9.762087307) < 1e-8);
}
2 changes: 0 additions & 2 deletions examples/trans_absent/latt_kagome/kagome_tJ.cc
Original file line number Diff line number Diff line change
@@ -3,10 +3,8 @@
#include "qbasis.h"

// tJ model on kagome lattice
// Ground state energy consistent with ALPS, 1st excitation NOT agree. NEED further check.
int main() {
qbasis::enable_ckpt = true;
std::cout << "ground state energy checked correct. 1st excited state inconsistent with ALPS!" << std::endl;
std::cout << std::setprecision(10);
// parameters
double t = 1.0;
107 changes: 107 additions & 0 deletions examples/trans_symmetric/latt_chain/chain_tJ.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#include <iostream>
#include <iomanip>
#include "qbasis.h"

// tJ model on chain lattice
int main() {
qbasis::enable_ckpt = false;
std::cout << std::setprecision(10);
// parameters
double t = 1.0;
double J = 1.0;
int Lx = 12;
double N_total_val = 8;
double Sz_total_val = 0;

std::cout << "Lx = " << Lx << std::endl;
std::cout << "t = " << t << std::endl;
std::cout << "J = " << J << std::endl;
std::cout << "N = " << N_total_val << std::endl;
std::cout << "Sz = " << Sz_total_val << std::endl << std::endl;


// lattice object
std::vector<std::string> bc{"pbc"};
qbasis::lattice lattice("chain",std::vector<uint32_t>{static_cast<uint32_t>(Lx)},bc);


// local matrix representation
auto c_up = std::vector<std::vector<std::complex<double>>>(3,std::vector<std::complex<double>>(3, 0.0));
auto c_dn = std::vector<std::vector<std::complex<double>>>(3,std::vector<std::complex<double>>(3, 0.0));
c_up[0][1] = std::complex<double>(1.0,0.0);
c_dn[0][2] = std::complex<double>(1.0,0.0);


// constructing the Hamiltonian in operator representation
qbasis::model<std::complex<double>> tJ;
tJ.add_orbital(lattice.total_sites(), "tJ");
qbasis::mopr<std::complex<double>> Sz_total; // operators representating total Sz
qbasis::mopr<std::complex<double>> N_total; // operators representating total N

for (int m = 0; m < Lx; m++) {
uint32_t site_i, site_j;
std::vector<int> work(lattice.dimension());
lattice.coor2site(std::vector<int>{m}, 0, site_i, work); // obtain site label of (x,y)
lattice.coor2site(std::vector<int>{m+1}, 0, site_j, work);
// construct operators on each site
auto c_up_i = qbasis::opr<std::complex<double>>(site_i,0,true,c_up);
auto c_dn_i = qbasis::opr<std::complex<double>>(site_i,0,true,c_dn);
auto c_up_dg_i = c_up_i; c_up_dg_i.dagger();
auto c_dn_dg_i = c_dn_i; c_dn_dg_i.dagger();
auto Splus_i = c_up_dg_i * c_dn_i;
auto Sminus_i = c_dn_dg_i * c_up_i;
auto Sz_i = std::complex<double>(0.5,0.0) * (c_up_dg_i * c_up_i - c_dn_dg_i * c_dn_i);
auto N_i = (c_up_dg_i * c_up_i + c_dn_dg_i * c_dn_i);

auto c_up_j = qbasis::opr<std::complex<double>>(site_j,0,true,c_up);
auto c_dn_j = qbasis::opr<std::complex<double>>(site_j,0,true,c_dn);
auto c_up_dg_j = c_up_j; c_up_dg_j.dagger();
auto c_dn_dg_j = c_dn_j; c_dn_dg_j.dagger();
auto Splus_j = c_up_dg_j * c_dn_j;
auto Sminus_j = c_dn_dg_j * c_up_j;
auto Sz_j = std::complex<double>(0.5,0.0) * (c_up_dg_j * c_up_j - c_dn_dg_j * c_dn_j);
auto N_j = (c_up_dg_j * c_up_j + c_dn_dg_j * c_dn_j);

if (bc[0] == "pbc" || (bc[0] == "obc" && m < Lx - 1)) {
tJ.add_offdiagonal_Ham(std::complex<double>(-t,0.0) * ( c_up_dg_i * c_up_j ));
tJ.add_offdiagonal_Ham(std::complex<double>(-t,0.0) * ( c_up_dg_j * c_up_i ));
tJ.add_offdiagonal_Ham(std::complex<double>(-t,0.0) * ( c_dn_dg_i * c_dn_j ));
tJ.add_offdiagonal_Ham(std::complex<double>(-t,0.0) * ( c_dn_dg_j * c_dn_i ));
tJ.add_offdiagonal_Ham(std::complex<double>(0.5*J,0.0) * (Splus_i * Sminus_j + Sminus_i * Splus_j));
tJ.add_diagonal_Ham(std::complex<double>(J,0.0) * ( Sz_i * Sz_j ));
tJ.add_diagonal_Ham(std::complex<double>(-0.25*J,0.0) * ( N_i * N_j ));
}


// total Sz operator
Sz_total += Sz_i;
// total N operator
N_total += N_i;

}

// to use translational symmetry, we first fill the Weisse tables
tJ.fill_Weisse_table(lattice);

std::vector<double> E0_list;
for (int momentum = 0; momentum < Lx; momentum++) {
// constructing the Hilbert space basis
tJ.enumerate_basis_repr({momentum}, {Sz_total, N_total}, {Sz_total_val, N_total_val});

// optional in future, will use more memory and give higher speed
// generating matrix of the Hamiltonian in the full Hilbert space
tJ.generate_Ham_sparse_repr();
std::cout << std::endl;

// obtaining the eigenvals of the matrix
tJ.locate_E0_lanczos(1);
std::cout << std::endl;

E0_list.push_back(tJ.eigenvals_repr[0]);

}

for (int momentum = 0; momentum < Lx; momentum++) {
std::cout << "E0(k=" << momentum << ")=\t" << E0_list[momentum] << std::endl;
}
}
Loading

0 comments on commit cd0fbe7

Please sign in to comment.