23 #include <boost/timer.hpp>
33 int main(
int argc,
char **argv)
44 bool momentum =
false;
45 bool nonperiodic =
false;
48 struct option long_options[] =
50 {
"up", required_argument, 0,
'u'},
51 {
"down", required_argument, 0,
'd'},
52 {
"sites", required_argument, 0,
's'},
53 {
"interaction", required_argument, 0,
'U'},
54 {
"hopping", required_argument, 0,
'J'},
55 {
"exact", no_argument, 0,
'e'},
56 {
"lanczos", no_argument, 0,
'l'},
57 {
"momentum", no_argument, 0,
'p'},
58 {
"nonperiodic", no_argument, 0,
'n'},
59 {
"symspin", no_argument, 0,
'z'},
60 {
"spin", required_argument, 0,
'S'},
61 {
"help", no_argument, 0,
'h'},
66 while( (j = getopt_long (argc, argv,
"hu:d:s:U:J:elpnzS:", long_options, &i)) != -1)
71 cout <<
"Usage: " << argv[0] <<
" [OPTIONS]\n"
73 " -s --sites=L The number of sites\n"
74 " -u --up=Nu The number of up electrons\n"
75 " -d --down=Nd The number of down electrons\n"
76 " -U --interaction=U The onsite interaction strength\n"
77 " -J --hopping=J The hopping strength\n"
78 " -e --exact Solve with exact diagonalisation\n"
79 " -l --lanczos Solve with Lanczos algorithm\n"
80 " -p --momentum Solve in the momentum basis\n"
81 " -n --nonperiodic Use non periodic boundary conditions\n"
82 " -z --symspin Use spin symmetry\n"
83 " -S --spin=S Limit to spin=S\n"
84 " -h, --help Display this help\n"
116 whichS = atoi(optarg);
123 cout <<
"L = " << L <<
"; Nu = " << Nu <<
"; Nd = " << Nd <<
"; J = " << J <<
"; U = " << U <<
";" << endl;
126 cout <<
"Limiting to S=" << whichS << endl;
128 if(whichS!=-1 && !spin)
130 cerr <<
"Need to use spin symmetry to select a spin!" << endl;
134 if(momentum && nonperiodic)
136 cerr <<
"Cannot use non periodic boundary conditions in the momentum base" << endl;
149 std::unique_ptr<BareHamiltonian> ham;
162 cout <<
"Memory needed: " << ham->MemoryNeededFull()*1.0/1024*1.0/1024 <<
" MB" << endl;
163 cout <<
"Building base..." << endl;
165 cout <<
"Building hamiltonian..." << endl;
169 cout <<
"Dim: " << ham->getDim() << endl;
171 double Egroundstate = 0;
178 cout <<
"Building hamiltonian..." << endl;
181 hampje->BuildHamWithS(whichS);
183 hampje->BuildFullHam();
185 auto E = hampje->ExactSpinDiagonalizeFull(
false);
186 Egroundstate = std::get<2>(E[0]);
188 cout <<
"K\tS\tE" << endl;
190 cout << std::get<0>(p) <<
"\t" << std::get<1>(p) <<
"\t" << std::get<2>(p) << endl;
196 auto E = (
static_cast<MomHamiltonian *
>(ham.get()))->ExactMomDiagonalizeFull(
false);
198 cout <<
"Energy levels: " << endl;
200 cout << p.second <<
"\t" << p.first << endl;
202 Egroundstate = E[0].second;
208 auto E = ham->ExactDiagonalizeFull(
true);
210 name <<
"results-" << L <<
"-" << Nu <<
"-" << Nd <<
"-" << U <<
".h5";
211 ham->SaveToFile(name.str());
213 ham->PrintGroundstateVector();
214 cout <<
"Energy levels: " << endl;
222 cout <<
"lowest E = " << Egroundstate << endl;
224 cout <<
"Time: " << tijd.elapsed() <<
" s" << endl;
231 std::unique_ptr<BareHamiltonian> sham;
238 cout <<
"Memory needed: " << sham->MemoryNeededArpack()*1.0/1024*1.0/1024 <<
" MB" << endl;
243 cout <<
"Dim: " << sham->getDim() << endl;
245 double E = sham->arpackDiagonalize();
246 cout <<
"E = " << E << endl;
248 cout <<
"Time: " << tijd.elapsed() <<
" s" << endl;