-
Notifications
You must be signed in to change notification settings - Fork 0
/
recurssive_greens_func.cpp
57 lines (46 loc) · 1.39 KB
/
recurssive_greens_func.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
//----------------------------------------
//
// g++ filename.cpp -lgsl -lgslcblas -lm
//
//---------------------------------------
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <iterator>
#include <ctime>
#include <gsl/gsl_eigen.h>
#include <gsl/gsl_complex.h>
#include <gsl/gsl_complex_math.h>
using namespace std;
int main()
{
int N_SITES = 2;
double e1 = -2.0;
double e2 = 2.0;
// double t = 1.0;
double omega = -5.0;
int num_z_points = 1000;
double eta = 0.1;
double pi = acos(-1);
gsl_complex z, g11, g22, G11, G22, t;
GSL_SET_COMPLEX(&t, 1, 0);
ofstream outfile;
outfile.open("greens_func_2_site.dat");
for(int i = 0; i <= num_z_points; i++)
{
GSL_SET_COMPLEX(&z, omega, eta);
g11 = gsl_complex_inverse(gsl_complex_sub_real(z,e1));
g22 = gsl_complex_inverse(gsl_complex_sub_real(z,e2));
G11 = gsl_complex_inverse(gsl_complex_sub(gsl_complex_inverse(g11), gsl_complex_mul(gsl_complex_mul(gsl_complex_conjugate(t), g22), t)));
G22 = gsl_complex_inverse(gsl_complex_sub(gsl_complex_inverse(g22), gsl_complex_mul(gsl_complex_mul(gsl_complex_conjugate(t), g11), t)));
outfile << omega << '\t' << -GSL_IMAG(G11)/pi << '\t' << -GSL_IMAG(G22)/pi << endl;
// cout << GSL_REAL(z) << '\t' << GSL_IMAG(z) << endl;
omega = omega + 10.0/(double)num_z_points;
}
outfile.close();
return 0;
}