-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprogParams.cpp
More file actions
175 lines (146 loc) · 5.41 KB
/
Copy pathprogParams.cpp
File metadata and controls
175 lines (146 loc) · 5.41 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
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/// A class that will carry all my parameters
#include "progParams.h"
/*class programParams
* {
* public:
* programParams();
* int initialize(char *filename);
* int matrixsize;
* int stepnumber;
* char *finfile;
* char *outfile;
* int initialconfig;
* int measure;
* char *inifile;
* double gD2;
* double gD22;
* double gD4;
* double wmoveA;
* double wmoveM;
* int Type;
*
* }; */
programParams::programParams()
{
// some hardcoded default values, for lazy people
matrixsize = 2;
wmoveA = 1. / 6. / pow(matrixsize, 1.5);
stepnumber = 1000;
outfile = (char *) calloc(150, sizeof(char));
strcpy(outfile, "default_output.txt");
initialconfig = 1;
measure = 0;
Type = 13;
gD2 = 1;
gD22 = 0;
gD4 = 0;
moveT = 0;
inifile = (char *) calloc(150, sizeof(char));
finfile = (char *) calloc(150, sizeof(char));
strcpy(finfile, "default_finalmatrix.txt");
}
int programParams::initialize(char * filename)
{
FILE * fin;
int j, iniI = 0, buf;
char * value;
char buffer[150];
double p;
value = (char *) calloc(150, sizeof(char));
// buffer= (char*) calloc (30,sizeof(char));
fin = fopen(filename, "r");
if (!fin) {
printf("Sorry but your input file does not exist");
return 1;
}
// while there are more lines we keep going
while (j != -1) {
j = fscanf(fin, "%s %s \n", value, buffer);
if (strcmp(value, "matrixsize") == 0) {
buf = atoi(buffer);
matrixsize = buf;
wmoveA = 1. / 6. / pow(matrixsize, 1.5);
if (DEBUG) printf(" %d %s \n", buf, value);
} else if (strcmp(value, "Type") == 0) { /// I am assuming that the type is (p,q) written as pq.
/// this only works as long as p,q<10 but I think it's a safe bet
buf = atoi(buffer);
Type = buf;
if (DEBUG) printf(" %d %s \n", buf, value);
} else if (strcmp(value, "steps") == 0) {
buf = atoi(buffer);
stepnumber = buf;
if (DEBUG) printf(" %d %s \n", buf, value);
} else if (strcmp(value, "outputfile") == 0) {
strcpy(outfile, buffer);
if (DEBUG) printf(" %s %s \n", outfile, value);
} else if (strcmp(value, "initialconfig") == 0) {
buf = atoi(buffer);
initialconfig = buf;
if (DEBUG) printf(" %d %s \n", buf, value);
} else if (strcmp(value, "measurement") == 0) {
buf = atoi(buffer);
measure = buf;
if (DEBUG) printf(" %d %s \n", buf, value);
} else if (strcmp(value, "moveT") == 0) {
buf = atoi(buffer);
moveT = buf;
if (DEBUG) printf(" %d %s \n", buf, value);
} else if (strcmp(value, "initalfile") == 0) {
strcpy(inifile, buffer);
iniI = 1;
if (DEBUG) printf(" %s %s \n", inifile, value);
} else if (strcmp(value, "movesradiusA") == 0) {
p = atof(buffer);
wmoveA = p;
if (DEBUG) printf(" %e %s \n", p, value);
} else if (strcmp(value, "couplingD4") == 0) {
p = atof(buffer);
gD4 = p;
if (DEBUG) printf(" %e %s \n", p, value);
} else if (strcmp(value, "couplingD2") == 0) {
p = atof(buffer);
gD2 = p;
if (DEBUG) printf(" %e %s \n", p, value);
} else if (strcmp(value, "couplingD22") == 0) {
p = atof(buffer);
gD22 = p;
if (DEBUG) printf(" %e %s \n", p, value);
} else if (strcmp(value, "finalmatrixfile") == 0) {
strcpy(finfile, buffer);
iniI = 1;
if (DEBUG) printf(" %s %s \n", finfile, value);
} else {
printf("Are you sure %s is a valid option? \n", value);
}
}
if (iniI == 0 && initialconfig == 4) {
printf("You need to tell me an initial file.");
return 1;
}
fclose(fin);
free(value);
// free(buffer);
return 0;
} // programParams::initialize
void programParams::announce()
{
std::cout << "You are simulating a " << matrixsize << "x" << matrixsize << " matrix" << std::endl;
std::cout << "of type (p,q)=pq " << Type << " " << std::endl;
std::cout << "There will be " << stepnumber << " sweeps of " << matrixsize * 4 << " attempted MC moves"
<< std::endl;
std::cout << "The D^2 coupling is " << gD2 << ", the (Tr(D^2)^2 coupling is " << gD22
<< " and the D^4 coupling is " << gD4 << std::endl;
if (measure == 0) {
std::cout << "You are measuring set 0, that means only the action, kind of obsolete see action_monitor.txt"
<< std::endl;
} else if (measure == 1) {
std::cout << "You are measuring set 1, that means the action and the determinants for the mi" << std::endl;
} else if (measure == 2) {
std::cout << "You are measuring set 2, that means the eigenvalues of D" << std::endl;
} else if (measure == 3) {
std::cout << "You are measuring set 3, that means all elements of D" << std::endl;
}
if (wmoveA == 0.) std::cout << " The additive move distance will be determined dynamically" << std::endl;
else std::cout << "And additive move distance of " << wmoveA << std::endl;
std::cout << "And the resulting data will be gathered in " << outfile << std::endl;
}