HubbardGPU
Hubbard diagonalisation on the GPU (and CPU)
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Friends
Macros
main2D.cpp
Go to the documentation of this file.
1
/* Copyright (C) 2012 Ward Poelmans
2
3
This file is part of Hubbard-GPU.
4
5
Hubbard-GPU is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9
10
Hubbard-GPU is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with Hubbard-GPU. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
25
#include <iostream>
26
#include <boost/timer.hpp>
27
#include <getopt.h>
28
#include "
ham2D.h
"
29
#include "
hamsparse2D_CSR.h
"
30
#include "
hamsparse2D.h
"
31
32
using namespace
std;
33
34
int
main
(
int
argc,
char
**argv)
35
{
36
int
L = 3;
// The Length of the 2D grid
37
int
D = 3;
// The Depth of the 2D grid
38
int
Nu = 4;
// number of up electrons
39
int
Nd = 5;
// number of down electrons
40
double
J = 1.0;
// hopping term
41
double
U = 1.0;
// on-site interaction strength
42
43
bool
exact =
false
;
44
bool
lanczos =
false
;
45
46
struct
option long_options[] =
47
{
48
{
"up"
, required_argument, 0,
'u'
},
49
{
"down"
, required_argument, 0,
'd'
},
50
{
"length"
, required_argument, 0,
'L'
},
51
{
"depth"
, required_argument, 0,
'D'
},
52
{
"interaction"
, required_argument, 0,
'U'
},
53
{
"hopping"
, required_argument, 0,
'J'
},
54
{
"exact"
, no_argument, 0,
'e'
},
55
{
"lanczos"
, no_argument, 0,
'l'
},
56
{
"help"
, no_argument, 0,
'h'
},
57
{0, 0, 0, 0}
58
};
59
60
int
i,j;
61
while
( (j = getopt_long (argc, argv,
"hu:d:L:D:U:J:el"
, long_options, &i)) != -1)
62
switch
(j)
63
{
64
case
'h'
:
65
case
'?'
:
66
cout <<
"Usage: "
<< argv[0] <<
" [OPTIONS]\n"
67
"\n"
68
" -L --length=l The length of the 2D grid\n"
69
" -D --depth=d The depth of the 2D grid\n"
70
" -u --up=Nu The number of up electrons\n"
71
" -d --down=Nd The number of down electrons\n"
72
" -U --interaction=U The onsite interaction strength\n"
73
" -J --hopping=J The hopping strength\n"
74
" -e --exact Solve with exact diagonalisation\n"
75
" -l --lanczos Solve with Lanczos algorithm\n"
76
" -h, --help Display this help\n"
77
"\n"
;
78
return
0;
79
break
;
80
case
'u'
:
81
Nu = atoi(optarg);
82
break
;
83
case
'd'
:
84
Nd = atoi(optarg);
85
break
;
86
case
'L'
:
87
L = atoi(optarg);
88
break
;
89
case
'D'
:
90
D = atoi(optarg);
91
break
;
92
case
'U'
:
93
U = atof(optarg);
94
break
;
95
case
'J'
:
96
J = atof(optarg);
97
break
;
98
case
'l'
:
99
lanczos =
true
;
100
break
;
101
case
'e'
:
102
exact =
true
;
103
break
;
104
}
105
106
cout <<
"L = "
<< L <<
"; D = "
<< D <<
"; Nu = "
<< Nu <<
"; Nd = "
<< Nd <<
"; J = "
<< J <<
"; U = "
<< U <<
";"
<< endl;
107
108
cout.precision(10);
109
110
boost::timer tijd;
111
112
if
(exact)
113
{
114
tijd.restart();
115
116
HubHam2D
ham(L,D,Nu,Nd,J,U);
117
118
ham.
BuildBase
();
119
ham.
BuildFullHam
();
120
121
cout <<
"Dim: "
<< ham.
getDim
() << endl;
122
123
auto
E = ham.
ExactDiagonalizeFull
();
124
cout <<
"E = "
<< E[0] << endl;
125
126
cout <<
"Time: "
<< tijd.elapsed() <<
" s"
<< endl;
127
}
128
129
if
(lanczos)
130
{
131
tijd.restart();
132
133
SparseHamiltonian2D
sham(L,D,Nu,Nd,J,U);
134
135
sham.
BuildBase
();
136
sham.
BuildSparseHam
();
137
138
cout <<
"Dim: "
<< sham.
getDim
() << endl;
139
140
double
E = sham.
arpackDiagonalize
();
141
cout <<
"E = "
<< E << endl;
142
143
cout <<
"Time: "
<< tijd.elapsed() <<
" s"
<< endl;
144
}
145
146
return
0;
147
}
148
149
/* vim: set ts=8 sw=4 tw=0 expandtab :*/
main2D.cpp
Generated on Fri Mar 7 2014 14:52:13 for HubbardGPU by
1.8.3.1