-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·72 lines (62 loc) · 1.9 KB
/
main.cpp
File metadata and controls
executable file
·72 lines (62 loc) · 1.9 KB
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 "main.h"
using namespace std;
int main(int argc,char** argv)
{
int X=20,Y=20,T_INIT=5,N_INIT=100000;
int MODE,default_args;
double Steps;
cout<<"Please Key In The Mode You Choose(1 or 0)"<<endl;
cin>>MODE;
if (MODE){cout<<"You Choose IsingModel\n\n";Steps=1000;}
else {cout<<"You Choose MagnetModel\n\n";Steps=0.0005;}
cout<<"Using Default Args?(1 or 0)"<<endl;
cin>>default_args;
if (!default_args){
cout<<"Please Configurate The Args:X Y T N Steps"<<endl;
cin>>X>>Y>>T_INIT>>N_INIT>>Steps;
}else{
cout<<"Using Default Configuration"<<endl;
}
if (MODE){
char filename[]="dataIsing";
IsingModel MyModel(X,Y,T_INIT,N_INIT);
ofstream fout(filename);
for (int i=0;i<Steps;i++){
double ARG=i*0.05;
MyModel.ChangeT(ARG);
MyModel.StartCal();
fout<<ARG<<" "<<MyModel.getAver()<<endl;
cout<<"Step: "<<i<<"/"<<Steps<<"\t\tT: "<<ARG<<"\t\tP: "<<MyModel.getAver()<<endl;
MyModel.ResetS();
}
}else{
char filename[]="dataMagnet";
IsingModel MyModel(X,Y,T_INIT,N_INIT);
ofstream fout(filename);
double ARG=0;
fout<<ARG<<" "<<0<<endl;
for (int i=0;ARG<1e-22;i++){
ARG=i*1e-22*Steps;
MyModel.ChangeH(ARG);
MyModel.StartCal();
fout<<ARG<<" "<<MyModel.getAver()<<endl;
cout<<"Step: "<<i<<"/"<<1/Steps<<"\t\tH: "<<ARG<<"\t\tP: "<<MyModel.getAver()<<endl;
}
for (int i=0;ARG>-1e-22;i++){
ARG=-i*1e-22*Steps+1e-22;
MyModel.ChangeH(ARG);
MyModel.StartCal();
fout<<ARG<<" "<<MyModel.getAver()<<endl;
cout<<"Step: "<<2/Steps-i<<"/"<<2/Steps<<"\t\tH: "<<ARG<<"\t\tP: "<<MyModel.getAver()<<endl;
}
for (int i=0;ARG<1e-22;i++){
ARG=i*1e-22*Steps-1e-22;
MyModel.ChangeH(ARG);
MyModel.StartCal();
fout<<ARG<<" "<<MyModel.getAver()<<endl;
cout<<"Step: "<<i<<"/"<<2/Steps<<"\t\tH: "<<ARG<<"\t\tP: "<<MyModel.getAver()<<endl;
}
}
system("python isingplot.py");
return 0;
}