-
Notifications
You must be signed in to change notification settings - Fork 0
/
gauged.c
126 lines (89 loc) · 2.4 KB
/
gauged.c
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#define MAIN
#include "worldline.h"
/* Gauge field */
double ***A;
double g;
double gauge_action(){
double S = 0;
for( int t=0;t<NT;t++) for( int x=0;x<NX;x++) for( int dir=0; dir<ND; dir++ ) {
S+= 1.-cos(A[t][x][dir]);
}
return S/(g*g);
}
void update_gauge(){
for( int t=0;t<NT;t++) for( int x=0;x<NX;x++) for( int dir=0; dir<ND; dir++ ) {
double s1 = -cos(A[t][x][dir])/(g*g);
double old = A[t][x][dir];
A[t][x][dir] = 2*M_PI*mersenne()-M_PI;
double s2 = -cos(A[t][x][dir])/(g*g);
double edS = exp(-s2+s1);
if( mersenne() > edS )
A[t][x][dir] = old;
}
}
double gauge_phase(){
double phase = 0;
for( int t=0;t<NT;t++) for( int x=0;x<NX;x++) {
int dir = diraclink[t][x];
if( dir < ND ){
phase += A[t][x][dir];
} else {
int tA = tdir(t,dir), xA = xdir(x,dir);
dir = opp_dir(dir);
phase -= A[tA][xA][dir];
}
}
return phase;
}
int main(void){
#ifdef DEBUG
feenableexcept(FE_INVALID | FE_OVERFLOW);
#endif
int i,n_loops,n_measure,n_average;
/* Read in the input */
setup_lattice();
/* Read in the input */
get_int("Number of updates", &n_loops);
get_int("Updates / measurement", &n_measure);
get_int("Updates between saves", &n_average);
printf("\n %d updates per measurements\n", n_measure );
get_double("mass", &m);
get_double("g", &g);
get_double("mu", &mu);
U=0; // Need a better way to disable dimers?
printf("\n m %f \n", m);
printf(" G %f \n", g);
printf(" mu %f \n", mu);
printf(" %d updates per measurements\n", n_measure );
A = malloc( NT*sizeof(int **) );
for (int t=0; t<NT; t++){
A[t] = malloc( NX*sizeof(int*) );
for (int x=0; x<NX+1; x++) {
A[t][x] = malloc( 2*sizeof(int) );
}
}
double gauge_action_sum = 0;
for (int i=0; i<100; i++){
update_gauge();
}
for (int i=1; i<n_loops+1; i++) {
double phase;
struct timeval start, end;
double updatetime;
for(int n=0; n<n_measure; n++){
update_gauge();
update_config(1);
}
gauge_action_sum += gauge_action();
phase = gauge_phase();
int sector = negative_loops();
phase += M_PI*sector;
printf("Sector %d\n", sector);
printf("Phase %g\n", phase);
if(i%n_average==0){
printf("Gauge action %g \n", gauge_action_sum/n_average);
gauge_action_sum = 0;
}
}
return 0;
}