-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_input.cpp
More file actions
325 lines (259 loc) · 7.92 KB
/
Copy pathread_input.cpp
File metadata and controls
325 lines (259 loc) · 7.92 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
#include "globals.h"
#include <sstream>
#include <string>
void read_anneal( void ) ;
void set_defaults( void ) ;
void write_runtime_parameters( void ) ;
void allocate_gaussians( void ) ;
void allocate_gausserfcs( void ) ;
void allocate_erfc2s( void ) ;
void read_input( void ) {
int i,j;
double d1 ;
char tt[80] ;
Diff = ( double* ) calloc( ntypes , sizeof( double ) ) ;
set_defaults() ;
ifstream inp("mpi2.input") ;
string word, line ;
while ( getline(inp, line) ) {
// Blank or commented line
if ( line.length() == 0 || line.at(0) == '#' )
continue ;
istringstream iss(line) ;
// Loop over words in line
while ( iss >> word ) {
cout << "Read: " << word << endl;
if ( word == "Nx" ) {
string toint ;
iss >> toint ;
Nx[0] = stoi( toint ) ;
}
else if ( word == "Ny" ) {
string toint ;
iss >> toint ;
Nx[1] = stoi( toint ) ;
}
else if ( word == "Nz" ) {
if ( Dim == 2 ) {
cout << "Nz parameter ignored for 2D simulation!\n" ;
}
else {
string toint ;
iss >> toint ;
Nx[2] = stoi( toint ) ;
}
}
else if ( word == "delt" ) {
string todouble ;
iss >> todouble ;
delt = stod(todouble) ;
}
else if ( word == "pmeorder" ) {
string toint ;
iss >> toint ;
pmeorder = stoi( toint ) ;
}
else if ( word == "send_buff" ) {
string todouble ;
iss >> todouble ;
send_buff = stod(todouble) ;
}
else if ( word == "nsteps" ) {
string toint ;
iss >> toint ;
nsteps = stoi( toint ) ;
}
else if ( word == "print_freq" ) {
string toint ;
iss >> toint ;
print_freq = stoi( toint ) ;
}
else if ( word == "sample_wait" ) {
string toint ;
iss >> toint ;
sample_wait = stoi( toint ) ;
}
else if ( word == "sample_freq" ) {
string toint ;
iss >> toint ;
sample_freq = stoi( toint ) ;
}
else if ( word == "stress_freq" ) {
string toint ;
iss >> toint ;
stress_freq = stoi( toint ) ;
}
else if ( word == "frame_freq" ) {
string toint ;
iss >> toint ;
frame_freq = stoi( toint ) ;
}
else if ( word == "traj_freq" ) {
string toint ;
iss >> toint ;
traj_freq = stoi( toint ) ;
}
else if ( word == "init_flag" ) {
string toint ;
iss >> toint ;
init_flag = stoi( toint ) ;
}
else if ( word == "Diff" ) {
string todouble ;
for ( int j=0 ; j<ntypes ; j++ ) {
iss >> todouble ;
Diff[j] = stod( todouble ) ;
}
}
// Gaussian interactions //
else if ( word == "n_gaussians" ) {
string toint ;
iss >> toint ;
n_gaussian_pairstyles = stoi( toint ) ;
allocate_gaussians() ;
for ( i=0 ; i<n_gaussian_pairstyles; i++ ) {
getline( inp, line ) ;
istringstream iss2(line) ;
string convert ;
iss2 >> convert ;
if ( convert != "gaussian" ) {
cout << "Read: " << convert << " should be 'gaussian'\n" ;
die("Error in Gaussian stuff in input file!\n");
}
iss2 >> convert ;
gaussian_types[i][0] = stoi( convert ) - 1 ;
iss2 >> convert ;
gaussian_types[i][1] = stoi( convert ) - 1 ;
iss2 >> convert ;
gaussian_prefactor[i] = stod( convert ) ;
iss2 >> convert ;
gaussian_sigma[i] = stod( convert ) ;
}
}//n_gaussians
// Gaussian-erfc convolved interaction //
else if ( word == "n_gausserfcs") {
string toint ;
iss >> toint ;
n_gausserfc_pairstyles = stoi( toint ) ;
allocate_gausserfcs() ;
for ( i=0 ; i<n_gausserfc_pairstyles; i++ ) {
getline( inp, line ) ;
istringstream iss2(line) ;
string convert ;
iss2 >> convert ;
if ( convert != "gausserfc" ) {
cout << "Read: " << convert << " should be 'gausserfc'\n" ;
die("Error in GaussErfc stuff in input file!\n");
}
iss2 >> convert ;
gausserfc_types[i][0] = stoi( convert ) - 1 ;
iss2 >> convert ;
gausserfc_types[i][1] = stoi( convert ) - 1 ;
iss2 >> convert ;
gausserfc_prefactor[i] = stod( convert ) ;
iss2 >> convert ;
gausserfc_sigma[i] = stod( convert ) ;
iss2 >> convert ;
gausserfc_Rp[i] = stod( convert ) ;
iss2 >> convert ;
gausserfc_xi[i] = stod( convert ) ;
}
}
else if ( word == "n_erfc2" ) {
string toint ;
iss >> toint ;
n_erfc2_pairstyles = stoi( toint ) ;
allocate_erfc2s() ;
for ( i=0 ; i<n_erfc2_pairstyles ; i++ ) {
getline( inp, line ) ;
istringstream iss2(line) ;
string convert ;
iss2 >> convert ;
if ( convert != "erfc2" ) {
cout << "Read: " << convert << " should be 'erfc2'\n";
die("Error in Erfc2 stuff in input file!\n");
}
iss2 >> convert ;
erfc2_types[i][0] = stoi( convert ) - 1 ;
iss2 >> convert ;
erfc2_types[i][1] = stoi( convert ) - 1 ;
iss2 >> convert ;
erfc2_prefactor[i] = stod( convert ) ;
iss2 >> convert ;
erfc2_Rp[i] = stod( convert ) ;
iss2 >> convert ;
erfc2_xi[i] = stod( convert ) ;
}
}
else if ( word == "bond" ) {
string toint, todouble;
iss >> toint ;
int btype = stoi( toint ) ;
iss >> todouble ;
bond_coeff[ btype-1 ] = stod( todouble ) ;
iss >> todouble ;
bond_eq[ btype-1 ] = stod( todouble ) ;
}
}//line stream
}//getline()
inp.close() ;
write_runtime_parameters() ;
read_anneal() ;
}
void set_defaults() {
for (int j=0 ; j<Dim ; j++ ) {
Nx[j] = 35 ;
}
for ( int j=0 ; j<ntypes ; j++ )
Diff[j] = 1.0 / mass[j] ;
delt = 0.002 ;
pmeorder = 2 ;
send_buff = 2.5 ;
nsteps = 250000 ;
print_freq = 500 ;
sample_wait = nsteps + 1 ;
sample_freq = 5 ;
stress_freq = 0 ;
frame_freq = 0 ;
traj_freq = 1000 ;
init_flag = 0 ;
n_gausserfc_pairstyles = 0 ;
}
void write_runtime_parameters() {
ofstream otp ;
otp.open("tild_out.input" ) ;
otp << "Nx " << Nx[0] << endl;
otp << "Ny " << Nx[1] << endl;
if ( Dim == 3 ) {
otp << "Nz " << endl;
}
otp << "delt " << delt << endl;
otp << "pmeorder " << pmeorder << endl;
otp << "send_buff " << send_buff << endl;
otp << "nsteps " << nsteps << endl;
otp << "print_freq " << print_freq << endl;
otp << "sample_wait " << sample_wait << endl;
otp << "sample_freq " << sample_freq << endl;
otp << "stress_freq " << stress_freq << endl;
otp << "frame_freq " << frame_freq << endl;
otp << "traj_freq " << traj_freq << endl;
otp << "init_flag " << init_flag << endl;
otp << "Diff " ;
for ( int i=0 ; i<ntypes ; i++ )
otp << Diff[i] << " " ;
otp << endl;
otp << "n_gaussians " << n_gaussian_pairstyles << endl;
for ( int i=0 ; i<n_gaussian_pairstyles ; i++ ) {
otp << "gaussian " << gaussian_types[i][0] << " " << gaussian_types[i][1] \
<< " " << gaussian_prefactor[i] << " " << gaussian_sigma[i] << endl;
}
otp << "n_gausserfcs " << n_gausserfc_pairstyles << endl;
for ( int i=0 ; i<n_gausserfc_pairstyles ; i++ ) {
otp << "gausserfc " << gausserfc_types[i][0] << " " << gausserfc_types[i][1] \
<< " " << gausserfc_prefactor[i] << " " << gaussian_sigma[i] << " " \
<< gausserfc_Rp[i] << " " << gausserfc_xi[i] << endl;
}
for ( int i=0 ; i<nbond_types ; i++ )
otp << "bond " << i+1 << " " << bond_coeff[i] << " " << bond_eq[i] << endl;
otp.close() ;
}