-
Notifications
You must be signed in to change notification settings - Fork 3
/
ed-main.cpp
66 lines (49 loc) · 1.79 KB
/
ed-main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <fstream>
#include "ed_library.h"
void check_consistency(void);
void check_tb_validity(void);
int main(int argc, char* argv[])
{
cout << "Enter lattice size and U: ";
cin >> size >> U; assert(size%2==0);
vector<basis> half_filling; select_half_filling(half_filling);
std::vector<basis> v_spin;
std::vector<double> eigenvalues;
int spin_limit = int(0.5*size);
for(int i= -spin_limit; i<=spin_limit; i++)
{
select_spin(half_filling, v_spin, i);
cout << "Spin: " << i << " sector\n----------------\nsize=" << v_spin.size() << endl;
MatrixXd Ht; construct_Ht(Ht,v_spin);
MatrixXd HU; construct_HU(HU,v_spin);
MatrixXd H=Ht+HU;
// cout << Ht << endl << endl;
std::vector<double> ith_spin_eivals; MatrixXd ith_eigenvectors;
diagonalize(H, ith_spin_eivals, ith_eigenvectors);
eigenvalues.insert(eigenvalues.end(),ith_spin_eivals.begin(),ith_spin_eivals.end());
v_spin.clear(); ith_spin_eivals.clear(); cout << endl;
}
sort(eigenvalues.begin(),eigenvalues.end());
filter(eigenvalues,1e-4);
ofstream fout; string filename;
filename = "data/eivals_size"+to_string(size)+"_U"+to_string(int(U))+".txt";
fout.open(filename);
for(auto it=eigenvalues.begin(); it!=eigenvalues.end(); it++) fout << *it << endl;
fout.close();
eigenvalues.clear();
check_consistency();
return 0;
}
void check_consistency(void)
{
if(size!=2) return;
cout << "-------------------------------------\n";
cout << "Theoretical result for eigenvalues: \n";
cout << U/2-sqrt(U*U/4+4*t*t) << endl << 0 << " (Triplet) " << endl << U << endl << U/2+sqrt(U*U/4+4*t*t)<< endl;
}
void check_tb_validity(void)
{
cout << "The eigenvalues obtained by theoretical TB model: \n";
for(int i=0; i<size; i++) cout << -2*t*cos(2*M_PI*i/double(size)) << ", ";
cout << endl;
}