Repository navigation
Expand file tree
/
Copy pathread_input_item_md.cpp
More file actions
413 lines (412 loc) · 14.9 KB
/
Copy pathread_input_item_md.cpp
File metadata and controls
413 lines (412 loc) · 14.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
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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
#include "source_base/tool_quit.h"
#include "read_input.h"
#include "read_input_tool.h"
namespace ModuleIO
{
void ReadInput::item_md()
{
// 9. Molecular dynamics
{
Input_Item item("md_type");
item.annotation = "choose ensemble";
read_sync_string(input.mdp.md_type);
this->add_item(item);
}
{
Input_Item item("md_thermostat");
item.annotation = "choose thermostat";
read_sync_string(input.mdp.md_thermostat);
this->add_item(item);
}
{
Input_Item item("md_nstep");
item.annotation = "md steps";
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.mdp.md_nstep == 0 && para.input.esolver_type != "tddft")
{
GlobalV::ofs_running << "md_nstep should be set. Autoset md_nstep to 50!" << std::endl;
para.input.mdp.md_nstep = 50;
}
};
read_sync_int(input.mdp.md_nstep);
this->add_item(item);
}
{
Input_Item item("md_dt");
item.annotation = "time step";
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.mdp.md_dt < 0) {
ModuleBase::WARNING_QUIT("ReadInput", "time interval of MD calculation should be positive");
}
};
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.td_dt != -1.0)
{
GlobalV::ofs_running << "td_dt exist, set md_dt with td_dt" << std::endl;
para.input.mdp.md_dt = para.input.td_dt * para.input.estep_per_md;
}
};
read_sync_double(input.mdp.md_dt);
this->add_item(item);
}
{
Input_Item item("md_tchain");
item.annotation = "number of Nose-Hoover chains";
read_sync_int(input.mdp.md_tchain);
this->add_item(item);
}
{
Input_Item item("md_tfirst");
item.annotation = "temperature first";
read_sync_double(input.mdp.md_tfirst);
this->add_item(item);
}
{
Input_Item item("md_tlast");
item.annotation = "temperature last";
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.mdp.md_tlast < 0)
{
para.input.mdp.md_tlast = para.mdp.md_tfirst;
}
};
read_sync_double(input.mdp.md_tlast);
this->add_item(item);
}
{
Input_Item item("md_dumpfreq");
item.annotation = "The period to dump MD information";
read_sync_int(input.mdp.md_dumpfreq);
this->add_item(item);
}
{
Input_Item item("md_restartfreq");
item.annotation = "The period to output MD restart information";
read_sync_int(input.mdp.md_restartfreq);
this->add_item(item);
}
{
Input_Item item("md_seed");
item.annotation = "random seed for MD";
read_sync_int(input.mdp.md_seed);
this->add_item(item);
}
{
Input_Item item("md_prec_level");
item.annotation = "precision level for vc-md";
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.calculation != "md")
{
para.input.mdp.md_prec_level = 0;
}
// md_prec_level only used in vc-md liuyu 2023-03-27
else if (para.input.mdp.md_type != "msst" && para.input.mdp.md_type != "npt")
{
para.input.mdp.md_prec_level = 0;
}
};
read_sync_int(input.mdp.md_prec_level);
this->add_item(item);
}
{
Input_Item item("ref_cell_factor");
item.annotation = "construct a reference cell bigger than the initial cell";
read_sync_double(input.ref_cell_factor);
this->add_item(item);
}
{
Input_Item item("md_restart");
item.annotation = "whether restart";
read_sync_bool(input.mdp.md_restart);
this->add_item(item);
}
{
Input_Item item("lj_rule");
item.annotation = "combination rules used to construct the parameter matrix for LJ potential";
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.esolver_type == "lj" && para.input.mdp.lj_rule != 1 && para.input.mdp.lj_rule != 2)
{
ModuleBase::WARNING_QUIT("ReadInput", "lj_rule must be 1 or 2");
}
};
read_sync_int(input.mdp.lj_rule);
this->add_item(item);
}
{
Input_Item item("lj_eshift");
item.annotation = "whether to use energy shift for LJ potential";
read_sync_bool(input.mdp.lj_eshift);
this->add_item(item);
}
{
Input_Item item("lj_rcut");
item.annotation = "cutoff radius of LJ potential";
item.read_value = [](const Input_Item& item, Parameter& para) {
size_t count = item.get_size();
para.input.mdp.lj_rcut.resize(count);
std::transform(begin(item.str_values),
end(item.str_values),
begin(para.input.mdp.lj_rcut),
[](std::string str) { return std::stod(str); });
};
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (!item.is_read()) {
return;
}
size_t n_ljrcut = para.input.mdp.lj_rcut.size();
if (n_ljrcut != 1 && n_ljrcut != para.input.ntype * (para.input.ntype + 1) / 2)
{
ModuleBase::WARNING_QUIT("ReadInput", " the number of lj_rcut should be 1 or ntype(ntype+1)/2 ");
}
for (auto rcut: para.input.mdp.lj_rcut)
{
if (rcut <= 0)
{
ModuleBase::WARNING_QUIT("ReadInput", "lj_rcut must > 0");
}
}
};
sync_doublevec(input.mdp.lj_rcut, para.input.mdp.lj_rcut.size(), 0.0);
this->add_item(item);
}
{
Input_Item item("lj_epsilon");
item.annotation = "the value of epsilon for LJ potential";
item.read_value = [](const Input_Item& item, Parameter& para) {
size_t count = item.get_size();
para.input.mdp.lj_epsilon.resize(count);
std::transform(begin(item.str_values),
end(item.str_values),
begin(para.input.mdp.lj_epsilon),
[](std::string str) { return std::stod(str); });
};
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (!item.is_read()) {
return;
}
size_t n_ljepsilon = para.input.mdp.lj_epsilon.size();
if (n_ljepsilon != para.input.ntype && n_ljepsilon != para.input.ntype * (para.input.ntype + 1) / 2)
{
ModuleBase::WARNING_QUIT("ReadInput", " the number of lj_epsilon should be ntype or ntype(ntype+1)/2 ");
}
};
sync_doublevec(input.mdp.lj_epsilon, para.input.mdp.lj_epsilon.size(), 0.0);
this->add_item(item);
}
{
Input_Item item("lj_sigma");
item.annotation = "the value of sigma for LJ potential";
item.read_value = [](const Input_Item& item, Parameter& para) {
size_t count = item.get_size();
para.input.mdp.lj_sigma.resize(count);
std::transform(begin(item.str_values),
end(item.str_values),
begin(para.input.mdp.lj_sigma),
[](std::string str) { return std::stod(str); });
};
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (!item.is_read()) {
return;
}
size_t n_ljsigma = para.input.mdp.lj_sigma.size();
if (n_ljsigma != para.input.ntype && n_ljsigma != para.input.ntype * (para.input.ntype + 1) / 2)
{
ModuleBase::WARNING_QUIT("ReadInput", " the number of lj_sigma should be ntype or ntype(ntype+1)/2 ");
}
};
sync_doublevec(input.mdp.lj_sigma, para.input.mdp.lj_sigma.size(), 0.0);
this->add_item(item);
}
{
Input_Item item("pot_file");
item.annotation = "the filename of potential files for CMD such as DP";
read_sync_string(input.mdp.pot_file);
this->add_item(item);
}
{
Input_Item item("dp_rescaling");
item.annotation = "rescaling factor for dp potential";
read_sync_double(input.mdp.dp_rescaling);
this->add_item(item);
}
{
Input_Item item("dp_fparam");
item.annotation = "the frame parameter for dp potential";
item.read_value = [](const Input_Item& item, Parameter& para) {
size_t count = item.get_size();
para.input.mdp.dp_fparam.resize(count);
std::transform(begin(item.str_values),
end(item.str_values),
begin(para.input.mdp.dp_fparam),
[](std::string str) { return std::stod(str); });
};
sync_doublevec(input.mdp.dp_fparam, para.input.mdp.dp_fparam.size(), 0.0);
this->add_item(item);
}
{
Input_Item item("dp_aparam");
item.annotation = "the atomic parameter for dp potential";
item.read_value = [](const Input_Item& item, Parameter& para) {
size_t count = item.get_size();
para.input.mdp.dp_aparam.resize(count);
std::transform(begin(item.str_values),
end(item.str_values),
begin(para.input.mdp.dp_aparam),
[](std::string str) { return std::stod(str); });
};
sync_doublevec(input.mdp.dp_aparam, para.input.mdp.dp_aparam.size(), 0.0);
this->add_item(item);
}
{
Input_Item item("msst_direction");
item.annotation = "the direction of shock wave";
read_sync_int(input.mdp.msst_direction);
this->add_item(item);
}
{
Input_Item item("msst_vel");
item.annotation = "the velocity of shock wave";
read_sync_double(input.mdp.msst_vel);
this->add_item(item);
}
{
Input_Item item("msst_vis");
item.annotation = "artificial viscosity";
read_sync_double(input.mdp.msst_vis);
this->add_item(item);
}
{
Input_Item item("msst_tscale");
item.annotation = "reduction in initial temperature";
read_sync_double(input.mdp.msst_tscale);
this->add_item(item);
}
{
Input_Item item("msst_qmass");
item.annotation = "mass of thermostat";
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.mdp.msst_qmass <= 0)
{
ModuleBase::WARNING_QUIT("ReadInput", "msst_qmass must be greater than 0!");
}
};
read_sync_double(input.mdp.msst_qmass);
this->add_item(item);
}
{
Input_Item item("md_tfreq");
item.annotation = "oscillation frequency, used to determine qmass of NHC";
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.mdp.md_tfreq == 0 && para.input.calculation == "md")
{
para.input.mdp.md_tfreq = 1.0 / 40 / para.input.mdp.md_dt;
}
};
read_sync_double(input.mdp.md_tfreq);
this->add_item(item);
}
{
Input_Item item("md_damp");
item.annotation = "damping parameter (time units) used to add force in "
"Langevin method";
read_sync_double(input.mdp.md_damp);
this->add_item(item);
}
{
Input_Item item("md_nraise");
item.annotation = "parameters used when md_type=nvt";
read_sync_int(input.mdp.md_nraise);
this->add_item(item);
}
{
Input_Item item("cal_syns");
item.annotation = "calculate asynchronous overlap matrix to output for Hefei-NAMD";
read_sync_bool(input.cal_syns);
this->add_item(item);
}
{
Input_Item item("dmax");
item.annotation = "maximum displacement of all atoms in one step (bohr)";
read_sync_double(input.dmax);
this->add_item(item);
}
{
Input_Item item("md_tolerance");
item.annotation = "tolerance for velocity rescaling (K)";
read_sync_double(input.mdp.md_tolerance);
this->add_item(item);
}
{
Input_Item item("md_pmode");
item.annotation = "NPT ensemble mode: iso, aniso, tri";
read_sync_string(input.mdp.md_pmode);
this->add_item(item);
}
{
Input_Item item("md_pcouple");
item.annotation = "whether couple different components: xyz, xy, yz, xz, none";
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.mdp.md_pmode == "iso")
{
para.input.mdp.md_pcouple = "xyz";
}
};
read_sync_string(input.mdp.md_pcouple);
this->add_item(item);
}
{
Input_Item item("md_pchain");
item.annotation = "num of thermostats coupled with barostat";
read_sync_int(input.mdp.md_pchain);
this->add_item(item);
}
{
Input_Item item("md_pfirst");
item.annotation = "initial target pressure";
read_sync_double(input.mdp.md_pfirst);
this->add_item(item);
}
{
Input_Item item("md_plast");
item.annotation = "final target pressure";
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (!item.is_read()) { // no md_plast in INPUT
para.input.mdp.md_plast = para.input.mdp.md_pfirst;
}
};
read_sync_double(input.mdp.md_plast);
this->add_item(item);
}
{
Input_Item item("md_pfreq");
item.annotation = "oscillation frequency, used to determine qmass of "
"thermostats coupled with barostat";
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.mdp.md_pfreq == 0 && para.input.calculation == "md")
{
para.input.mdp.md_pfreq = 1.0 / 400 / para.input.mdp.md_dt;
}
};
read_sync_double(input.mdp.md_pfreq);
this->add_item(item);
}
{
Input_Item item("dump_force");
item.annotation = "output atomic forces into the file MD_dump or not";
read_sync_bool(input.mdp.dump_force);
this->add_item(item);
}
{
Input_Item item("dump_vel");
item.annotation = "output atomic velocities into the file MD_dump or not";
read_sync_bool(input.mdp.dump_vel);
this->add_item(item);
}
{
Input_Item item("dump_virial");
item.annotation = "output lattice virial into the file MD_dump or not";
read_sync_bool(input.mdp.dump_virial);
this->add_item(item);
}
}
} // namespace ModuleIO