Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
wsttiger committed Sep 28, 2015
1 parent b23e336 commit 3383a10
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 28 deletions.
26 changes: 13 additions & 13 deletions heisen.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using std::vector;
using std::complex;
using std::ifstream;

#define NSIZE 4
#define NSIZE 24

typedef bitset<NSIZE> ketT;

Expand Down Expand Up @@ -63,7 +63,6 @@ class States {
States(int nup, int nsites)
: nsites(nsites), nup(nup) {

printf("states constructor ... begin\n");
int tnstates = 1 << nsites;

// create states for up and down spins
Expand All @@ -82,7 +81,6 @@ class States {
}

nst= states.size();
printf("states constructor ... end\n");
}

int get_nst() const {return nst;}
Expand Down Expand Up @@ -335,32 +333,34 @@ class HeisenCalculation {
}

void create_ring(int sites) {
// double J = 1.0;
// for (int i = 0; i < sites-1; i++) {
// lattice.push_back(Bond(i,i+1,J));
// }
// lattice.push_back(Bond(sites-1,0,J));
// sectors.push_back(Sector(lattice,sites,-1));

double J = 1.0;
for (int i = 0; i < sites-1; i++) {
lattice.push_back(Bond(i,i+1,J));
}
lattice.push_back(Bond(sites-1,0,J));
for (int i = 0; i < sites; i++) {
sectors.push_back(Sector(lattice,sites,i));
}
sectors.push_back(Sector(lattice,sites,1));

// double J = 1.0;
// for (int i = 0; i < sites-1; i++) {
// lattice.push_back(Bond(i,i+1,J));
// }
// lattice.push_back(Bond(sites-1,0,J));
// for (int i = 0; i < sites; i++) {
// sectors.push_back(Sector(lattice,sites,i));
// }
}

vector<double> eigenvalues() {
vector<double> e;
for (unsigned int is = 0; is < sectors.size(); is++) {
printf("sector: %d\n", is);
Sector s = sectors[is];
int nst = s.get_nst();
vector<double> mat = s.make_matrix();
vector<double> es(nst,0.0);
vector<double> ev(nst*nst,0.0);
diag_matrix(mat,nst,es,ev);
print_matrix(mat,nst,nst);
std::copy(es.begin(),es.end(),std::back_inserter(e));
}
std::sort(e.begin(),e.end(),[](const double& a, const double& b) {return a < b;});
Expand Down
16 changes: 1 addition & 15 deletions test_heisen.cc
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
#include "heisen.h"

int main(int argc, char** argv) {
// // for (int i = 0; i <= 4; i++) {
// { int i = -1;
// printf("%d\n", i);
// HeisenCalculation calc(12,i);
// vector<double> mat = calc.make_matrix();
// int n = calc.get_nstates();
// vector<double> e(n,0.0);
// vector<double> ev(n*n, 0.0);
// printf("\n");
// print_matrix(mat,n,n);
// diag_matrix(mat,n,e,ev);
// print_vector(e);
// // printf("Lanczos: lowest eigenvalue is %15.8f\n\n", e[0]);
// }
HeisenCalculation calc(12);
HeisenCalculation calc(4);
vector<double> e = calc.eigenvalues();
print_vector(e);
return 0;
Expand Down

0 comments on commit 3383a10

Please sign in to comment.