-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
154 lines (131 loc) · 4.15 KB
/
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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#include <iostream>
#include "head.h"
#include <functional>
#include <stdlib.h>
#include <string>
#include <fstream>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
std::ofstream file;
std::string slabel;
std::string name1="All_";
double JT;
int name_q;
if(argc==3){
slabel=argv[1];
name1=name1+slabel+".txt";
file.open(name1.c_str());
JT=atof(argv[2]);
}
else{
std::cin>>JT>>slabel;
name1=name1+slabel+".txt";
file.open(name1.c_str());
}
long long int N=1e9;
long int block_N=0;
long int block_L=N/20;
long int block_n=0;
long long int i;
long long int l;
long long int j,k,i1;
int k1=0,k2=0,k3=0;
// long long int Out_P=1000000000;
int label;
double Z0=0;
double total[3];
double sum=0;
Spin spgp[NN][NN];
for(i=0;i<100000000;i++){ //Thermalization
k1=int(RNG()*NN);
k2=int(RNG()*NN);
k3=int(RNG()*Sub);
Spin::Interaction(k1,k2,k3,spgp,total);
// printf("%f %f %f \n",total[0],total[1],total[2]);
Update(total,spgp[k1][k2].vector[k3],JT);
// printf("%f %f %f\n",spgp[k1][k2].vector[k3][0],spgp[k1][k2].vector[k3][1],spgp[k1][k2].vector[k3][2]);
}
for(i=0;i<NN;i++){
for(j=0;j<NN;j++){
for(k=0;k<Sub;k++){
spgp[i][j].cor[k]=0;
spgp[i][j].ZC[k]=0;
spgp[i][j].IP[k]=Inner(spgp[0][0].vector[0], spgp[i][j].vector[k]);
}
}
}
for(l=0;l<N;l++){
k1=int(RNG()*NN);
k2=int(RNG()*NN);
k3=int(RNG()*Sub);
Spin::Interaction(k1,k2,k3,spgp,total);
// printf("%f %f %f \n",total[0],total[1],total[2]);
Update(total,spgp[k1][k2].vector[k3],JT);
Z0++;
if(k1==0&&k2==0&&k3==0){
for(i=0;i<NN;i++){
for(j=0;j<NN;j++){
for(k=0;k<Sub;k++){
spgp[i][j].cor[k]=spgp[i][j].cor[k]+spgp[i][j].IP[k]*(Z0-spgp[i][j].ZC[k]);
spgp[i][j].ZC[k]=Z0;
spgp[i][j].IP[k]=Inner(spgp[0][0].vector[0], spgp[i][j].vector[k]);
}
}
}
}
else {
spgp[k1][k2].cor[k3]=spgp[k1][k2].cor[k3]+spgp[k1][k2].IP[k3]*(Z0-spgp[k1][k2].ZC[k3]);
spgp[k1][k2].ZC[k3]=Z0;
spgp[k1][k2].IP[k3]=Inner(spgp[0][0].vector[0], spgp[k1][k2].vector[k3]);
// printf("%f\n",spgp[k1][k2].IP[k3]);
}
if((l+1)%block_L==0){
block_n=(l+1)/block_L-1;
for(i=0;i<NN;i++){
for(j=0;j<NN;j++){
for(k=0;k<Sub;k++){
spgp[i][j].block[block_n][k]=spgp[i][j].cor[k]+spgp[i][j].IP[k]*(Z0-spgp[i][j].ZC[k]);
}
}
}
}
}
for(i=0;i<NN;i++){
for(j=0;j<NN;j++){
file<<i<<"\t"<<j<<"\t";
for(k=0;k<Sub;k++){
spgp[i][j].cor[k]=spgp[i][j].cor[k]+spgp[i][j].IP[k]*(Z0-spgp[i][j].ZC[k]); for(l=19;l>0;l--){
spgp[i][j].block[l][k]=(spgp[i][j].block[l][k]-spgp[i][j].block[l-1][k])/block_L;
sum=sum+(spgp[i][j].block[l][k]-spgp[i][j].cor[k]/Z0)*(spgp[i][j].block[l][k]-spgp[i][j].cor[k]/Z0);
}
spgp[i][j].block[0][k]/=block_L;
sum=sum+(spgp[i][j].block[0][k]-spgp[i][j].cor[k]/Z0)*(spgp[i][j].block[0][k]-spgp[i][j].cor[k]/Z0);
sum=sqrt(sum/20);
file<<spgp[i][j].cor[k]/Z0<<"\t"<<sum<<((k==Sub-1)?"\n":"\t");
sum=0;
}
}
}
/* fprintf(fp2,"%lf\n",spgp[0][0].cor[2]/Z0);
fprintf(fp2,"%lf\n",spgp[0][1].cor[0]/Z0);
fprintf(fp2,"%lf\n",spgp[0][1].cor[1]/Z0);
fprintf(fp2,"%lf\n",spgp[1][1].cor[1]/Z0);
fprintf(fp2,"%lf\n",spgp[1][1].cor[2]/Z0);
fprintf(fp2,"%lf\n",spgp[0][1].cor[2]/Z0);
fprintf(fp2,"%lf\n",spgp[NN-1][1].cor[1]/Z0);
fprintf(fp2,"%lf\n",spgp[0][2].cor[0]/Z0);
fprintf(fp2,"%lf\n",spgp[1][2].cor[1]/Z0);
fprintf(fp2,"%lf\n",spgp[2][2].cor[1]/Z0);
fprintf(fp2,"%lf\n",spgp[0][2].cor[1]/Z0);
fprintf(fp2,"%lf\n",spgp[1][2].cor[2]/Z0);
fprintf(fp2,"%lf\n",spgp[2][2].cor[2]/Z0); */
/* for(i=0;i<NN;i++){
for(j=0;j<NN;j++){
printf("%f ",spgp[i][j].vector[0]);
}
printf("\n");
} */
file.close();
return 0;
}