-
Notifications
You must be signed in to change notification settings - Fork 1
/
check_rpa_compare.cpp
72 lines (59 loc) · 2.17 KB
/
check_rpa_compare.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
67
68
69
70
71
72
#include "rpa.hpp"
#include <cstring>
#include <chrono>
#include <cstdlib>
double t=1;
double U_prime=2;
int L=4;
MatrixXcd U;
using namespace std::chrono;
void greens_sigma_generate(MatrixXi& suggested_sigma, int lattice_index, long & idum)
{
if(ran0(&idum)<=0.5) suggested_sigma(lattice_index,2) *= -1;
}
VectorXd inttobin(int theValue)
{
VectorXd v(L);
for (int i = 0; i < L; ++i) v(i) = theValue & (1 << i) ? 1 : 0;
return v;
}
VectorXd get_field(int i)
{
VectorXd raw = inttobin(i);
for(int i=0; i<raw.size(); i++) raw(i) = (raw(i)==0)?-1:1;
return raw;
}
int main(int argc, char* argv[])
{
if(argc!=4) {cerr << "Enter (1) lattice size, (2) U and (3) temperature.\n"; exit(1);}
L = atoi(argv[1]);
U_prime = atof(argv[2]);
double temperature = atof(argv[3]);
MatrixXd sigma = MatrixXd::Zero(L,3);
sigma.col(2) = VectorXd::Constant(L,1);
MatrixXcd H0 = construct_h0();
int i_min = 0, i_max = 0;
for(int it=0; it < L; it++) i_max += pow(2,it);
{
MatrixXcd H_spa = H0 - U_prime/2*matrixelement_sigmaz(sigma);
pair<MatrixXcd,VectorXd> spa_spectrum = Eigenspectrum(H_spa);
double free_energy = rpa_free_energy(spa_spectrum.second, spa_spectrum.first, temperature);
cout << "Ferro: " << free_energy/L << " " << " " << endl;
}
{
for(int i=0; i<L; i++) sigma(i,2) = pow(-1,i);
MatrixXcd H_spa = H0 - U_prime/2*matrixelement_sigmaz(sigma);
pair<MatrixXcd,VectorXd> spa_spectrum = Eigenspectrum(H_spa);
double free_energy = rpa_free_energy(spa_spectrum.second, spa_spectrum.first, temperature);
cout << "Antiferro: " << free_energy/L << " " << " " << endl;
}
// MatrixXcd H_rpa = construct_RPA(spa_spectrum.second, spa_spectrum.first, temperature);
// cout.precision(3);
// // for(int i=0; i<N*N/4; i++) cout << "(" <<
// cout << endl << H_rpa.unaryExpr(&filter).real() << endl << endl;
// MatrixXcd A = H_rpa.block(0, 0, H_rpa.rows()/2, H_rpa.cols()/2);
// MatrixXcd B = H_rpa.block(0, H_rpa.cols()/2, H_rpa.rows()/2, H_rpa.cols()/2);
// MatrixXcd D = (A+B)*(A-B);
// cout << Eigenvalues(D).unaryExpr(&squareroot).transpose() << endl << endl;
// cout << Eigenvalues(H_rpa, &zgeev_cpp).transpose() << endl << endl;
}