Repository navigation
Expand file tree
/
Copy pathread_input_item_other.cpp
More file actions
550 lines (542 loc) · 19.8 KB
/
Copy pathread_input_item_other.cpp
File metadata and controls
550 lines (542 loc) · 19.8 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
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
#include "source_base/global_function.h"
#include "source_base/tool_quit.h"
#include "read_input.h"
#include "read_input_tool.h"
#include <algorithm>
#include <cstring>
#include <iostream>
namespace ModuleIO
{
void ReadInput::item_others()
{
// non-collinear spin-constrained
{
Input_Item item("sc_mag_switch");
item.annotation = "switch to control spin-constrained DFT";
read_sync_bool(input.sc_mag_switch);
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.sc_mag_switch)
{
ModuleBase::WARNING_QUIT("ReadInput",
"This feature is not stable yet and might lead to "
"erroneous results.\n"
" Please wait for the official release version.");
// if (para.input.nspin != 4 && para.input.nspin != 2)
// {
// ModuleBase::WARNING_QUIT("ReadInput", "nspin must be 2 or
// 4 when sc_mag_switch > 0");
// }
// if (para.input.calculation != "scf")
// {
// ModuleBase::WARNING_QUIT("ReadInput", "calculation must
// be scf when sc_mag_switch > 0");
// }
// if (para.input.nupdown > 0.0)
// {
// ModuleBase::WARNING_QUIT("ReadInput", "nupdown should not
// be set when sc_mag_switch > 0");
// }
}
};
this->add_item(item);
}
{
Input_Item item("decay_grad_switch");
item.annotation = "switch to control gradient break condition";
read_sync_bool(input.decay_grad_switch);
this->add_item(item);
}
{
Input_Item item("sc_thr");
item.annotation = "Convergence criterion of spin-constrained iteration (RMS) in uB";
read_sync_double(input.sc_thr);
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.sc_thr < 0)
{
ModuleBase::WARNING_QUIT("ReadInput", "sc_thr must >= 0");
}
};
this->add_item(item);
}
{
Input_Item item("nsc");
item.annotation = "Maximal number of spin-constrained iteration";
read_sync_int(input.nsc);
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.nsc <= 0)
{
ModuleBase::WARNING_QUIT("ReadInput", "nsc must > 0");
}
};
this->add_item(item);
}
{
Input_Item item("nsc_min");
item.annotation = "Minimum number of spin-constrained iteration";
read_sync_int(input.nsc_min);
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.nsc_min <= 0)
{
ModuleBase::WARNING_QUIT("ReadInput", "nsc_min must > 0");
}
};
this->add_item(item);
}
{
Input_Item item("sc_scf_nmin");
item.annotation = "Minimum number of outer scf loop before "
"initializing lambda loop";
read_sync_int(input.sc_scf_nmin);
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.sc_scf_nmin < 2)
{
ModuleBase::WARNING_QUIT("ReadInput", "sc_scf_nmin must >= 2");
}
};
this->add_item(item);
}
{
Input_Item item("alpha_trial");
item.annotation = "Initial trial step size for lambda in eV/uB^2";
read_sync_double(input.alpha_trial);
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.alpha_trial <= 0)
{
ModuleBase::WARNING_QUIT("ReadInput", "alpha_trial must > 0");
}
};
this->add_item(item);
}
{
Input_Item item("sccut");
item.annotation = "Maximal step size for lambda in eV/uB";
read_sync_double(input.sccut);
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.sccut <= 0)
{
ModuleBase::WARNING_QUIT("ReadInput", "sccut must > 0");
}
};
this->add_item(item);
}
{
Input_Item item("sc_drop_thr");
item.annotation = "Convergence criterion ratio of lambda iteration in Spin-constrained DFT";
read_sync_double(input.sc_drop_thr);
this->add_item(item);
}
{
Input_Item item("sc_scf_thr");
item.annotation = "Density error threshold for inner loop of spin-constrained SCF";
read_sync_double(input.sc_scf_thr);
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.sc_scf_thr <= 0.0)
{
ModuleBase::WARNING_QUIT("ReadInput", "sc_scf_thr must > 0.0");
}
};
this->add_item(item);
}
// Quasiatomic Orbital analysis
{
Input_Item item("qo_switch");
item.annotation = "switch to control quasiatomic orbital analysis";
read_sync_bool(input.qo_switch);
this->add_item(item);
}
{
Input_Item item("qo_basis");
item.annotation = "type of QO basis function: hydrogen: hydrogen-like "
"basis, pswfc: read basis from pseudopotential";
read_sync_string(input.qo_basis);
this->add_item(item);
}
{
Input_Item item("qo_thr");
item.annotation = "accuracy for evaluating cutoff radius of QO basis function";
read_sync_double(input.qo_thr);
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.qo_thr > 1e-6)
{
ModuleBase::WARNING("ReadInput",
"too high the convergence threshold might "
"yield unacceptable result");
}
};
this->add_item(item);
}
{
Input_Item item("qo_strategy");
item.annotation = "strategy to generate generate radial orbitals";
item.read_value = [](const Input_Item& item, Parameter& para) {
size_t count = item.get_size();
for (int i = 0; i < count; i++)
{
para.input.qo_strategy.push_back(item.str_values[i]);
}
};
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.qo_strategy.size() != para.input.ntype)
{
if (para.input.qo_strategy.size() == 1)
{
para.input.qo_strategy.resize(para.input.ntype, para.input.qo_strategy[0]);
}
else
{
std::string default_strategy;
if (para.input.qo_basis == "hydrogen")
{
default_strategy = "energy-valence";
}
else if ((para.input.qo_basis == "pswfc") || (para.input.qo_basis == "szv"))
{
default_strategy = "all";
}
else
{
ModuleBase::WARNING_QUIT("ReadInput",
"When setting default values for qo_strategy, "
"unexpected/unknown "
"qo_basis is found. Please check it.");
}
para.input.qo_strategy.resize(para.input.ntype, default_strategy);
}
}
};
sync_stringvec(input.qo_strategy, para.input.ntype, "all");
this->add_item(item);
}
{
Input_Item item("qo_screening_coeff");
item.annotation = "rescale the shape of radial orbitals";
item.read_value = [](const Input_Item& item, Parameter& para) {
size_t count = item.get_size();
for (int i = 0; i < count; i++)
{
para.input.qo_screening_coeff.push_back(std::stod(item.str_values[i]));
}
};
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (!item.is_read())
{
return;
}
if (para.input.qo_screening_coeff.size() != para.input.ntype)
{
if (para.input.qo_basis == "pswfc")
{
double default_screening_coeff
= (para.input.qo_screening_coeff.size() == 1) ? para.input.qo_screening_coeff[0] : 0.1;
para.input.qo_screening_coeff.resize(para.input.ntype, default_screening_coeff);
}
else
{
ModuleBase::WARNING_QUIT("ReadInput",
"qo_screening_coeff should have the same number of "
"elements as ntype");
}
}
};
item.check_value = [](const Input_Item& item, const Parameter& para) {
for (auto screen_coeff: para.input.qo_screening_coeff)
{
if (screen_coeff < 0)
{
ModuleBase::WARNING_QUIT("ReadInput",
"screening coefficient must >= 0 "
"to tune the pswfc decay");
}
if (std::fabs(screen_coeff) < 1e-6)
{
ModuleBase::WARNING_QUIT("ReadInput",
"every low screening coefficient might yield very high "
"computational cost");
}
}
};
sync_doublevec(input.qo_screening_coeff, para.input.ntype, 0.1);
this->add_item(item);
}
// PEXSI
{
Input_Item item("pexsi_npole");
item.annotation = "Number of poles in expansion";
read_sync_int(input.pexsi_npole);
this->add_item(item);
}
{
Input_Item item("pexsi_inertia");
item.annotation = "Whether inertia counting is used at the very "
"beginning of PEXSI process";
read_sync_bool(input.pexsi_inertia);
this->add_item(item);
}
{
Input_Item item("pexsi_nmax");
item.annotation = "Maximum number of PEXSI iterations after each "
"inertia counting procedure";
read_sync_int(input.pexsi_nmax);
this->add_item(item);
}
{
Input_Item item("pexsi_comm");
item.annotation = "Whether to construct PSelInv communication pattern";
read_sync_bool(input.pexsi_comm);
this->add_item(item);
}
{
Input_Item item("pexsi_storage");
item.annotation = "Storage space used by the Selected Inversion "
"algorithm for symmetric matrices";
read_sync_bool(input.pexsi_storage);
this->add_item(item);
}
{
Input_Item item("pexsi_ordering");
item.annotation = "Ordering strategy for factorization and selected inversion";
read_sync_int(input.pexsi_ordering);
this->add_item(item);
}
{
Input_Item item("pexsi_row_ordering");
item.annotation = "Row permutation strategy for factorization and "
"selected inversion, 0: NoRowPerm, 1: LargeDiag";
read_sync_int(input.pexsi_row_ordering);
this->add_item(item);
}
{
Input_Item item("pexsi_nproc");
item.annotation = "Number of processors for parmetis";
read_sync_int(input.pexsi_nproc);
this->add_item(item);
}
{
Input_Item item("pexsi_symm");
item.annotation = "Matrix symmetry";
read_sync_bool(input.pexsi_symm);
this->add_item(item);
}
{
Input_Item item("pexsi_trans");
item.annotation = "Whether to transpose";
read_sync_bool(input.pexsi_trans);
this->add_item(item);
}
{
Input_Item item("pexsi_method");
item.annotation = "pole expansion method, 1: Cauchy Contour Integral, "
"2: Moussa optimized method";
read_sync_int(input.pexsi_method);
this->add_item(item);
}
{
Input_Item item("pexsi_nproc_pole");
item.annotation = "Number of processes used by each pole";
read_sync_int(input.pexsi_nproc_pole);
this->add_item(item);
}
{
Input_Item item("pexsi_temp");
item.annotation = "Temperature, in the same unit as H";
read_sync_double(input.pexsi_temp);
this->add_item(item);
}
{
Input_Item item("pexsi_gap");
item.annotation = "Spectral gap";
read_sync_double(input.pexsi_gap);
this->add_item(item);
}
{
Input_Item item("pexsi_delta_e");
item.annotation = "An upper bound for the spectral radius of S^{-1} H";
read_sync_double(input.pexsi_delta_e);
this->add_item(item);
}
{
Input_Item item("pexsi_mu_lower");
item.annotation = "Initial guess of lower bound for mu";
read_sync_double(input.pexsi_mu_lower);
this->add_item(item);
}
{
Input_Item item("pexsi_mu_upper");
item.annotation = "Initial guess of upper bound for mu";
read_sync_double(input.pexsi_mu_upper);
this->add_item(item);
}
{
Input_Item item("pexsi_mu");
item.annotation = "Initial guess for mu (for the solver)";
read_sync_double(input.pexsi_mu);
this->add_item(item);
}
{
Input_Item item("pexsi_mu_thr");
item.annotation = "Stopping criterion in terms of the chemical "
"potential for the inertia counting procedure";
read_sync_double(input.pexsi_mu_thr);
this->add_item(item);
}
{
Input_Item item("pexsi_mu_expand");
item.annotation = "If the chemical potential is not in the initial "
"interval, the interval is expanded by "
"muInertiaExpansion";
read_sync_double(input.pexsi_mu_expand);
this->add_item(item);
}
{
Input_Item item("pexsi_mu_guard");
item.annotation = "Safe guard criterion in terms of the chemical potential to "
"reinvoke the inertia counting procedure";
read_sync_double(input.pexsi_mu_guard);
this->add_item(item);
}
{
Input_Item item("pexsi_elec_thr");
item.annotation = "Stopping criterion of the PEXSI iteration in terms "
"of the number of electrons compared to "
"numElectronExact";
read_sync_double(input.pexsi_elec_thr);
this->add_item(item);
}
{
Input_Item item("pexsi_zero_thr");
item.annotation = "if the absolute value of matrix element is less "
"than ZERO_Limit, it will be considered as 0";
read_sync_double(input.pexsi_zero_thr);
this->add_item(item);
}
// Only for Test
{
Input_Item item("out_alllog");
item.annotation = "output information for each processor, when parallel";
read_sync_bool(input.out_alllog);
this->add_item(item);
}
{
Input_Item item("nurse");
item.annotation = "for coders";
read_sync_int(input.nurse);
this->add_item(item);
}
{
Input_Item item("t_in_h");
item.annotation = "calculate the kinetic energy or not";
read_sync_bool(input.t_in_h);
this->add_item(item);
}
{
Input_Item item("vl_in_h");
item.annotation = "calculate the local potential or not";
read_sync_bool(input.vl_in_h);
this->add_item(item);
}
{
Input_Item item("vnl_in_h");
item.annotation = "calculate the nonlocal potential or not";
read_sync_bool(input.vnl_in_h);
this->add_item(item);
}
{
Input_Item item("vh_in_h");
item.annotation = "calculate the hartree potential or not";
read_sync_bool(input.vh_in_h);
this->add_item(item);
}
{
Input_Item item("vion_in_h");
item.annotation = "calculate the local ionic potential or not";
read_sync_bool(input.vion_in_h);
this->add_item(item);
}
{
Input_Item item("test_force");
item.annotation = "test the force";
read_sync_bool(input.test_force);
this->add_item(item);
}
{
Input_Item item("test_stress");
item.annotation = "test the stress";
read_sync_bool(input.test_stress);
this->add_item(item);
}
{
Input_Item item("test_skip_ewald");
item.annotation = "whether to skip ewald";
read_sync_bool(input.test_skip_ewald);
this->add_item(item);
}
{
Input_Item item("ri_hartree_benchmark");
item.annotation = "whether to use the RI approximation for the Hartree term in LR-TDDFT for benchmark (with FHI-aims/ABACUS read-in style)";
read_sync_string(input.ri_hartree_benchmark);
this->add_item(item);
}
{
Input_Item item("aims_nbasis");
item.annotation = "the number of basis functions for each atom type used in FHI-aims (for benchmark)";
item.read_value = [](const Input_Item& item, Parameter& para) {
size_t count = item.get_size();
for (int i = 0; i < count; i++)
{
para.input.aims_nbasis.push_back(std::stod(item.str_values[i]));
}
};
sync_intvec(input.aims_nbasis, para.input.aims_nbasis.size(), 0);
this->add_item(item);
}
// RDMFT, added by jghan, 2024-10-16
{
Input_Item item("rdmft");
item.annotation = "whether to perform rdmft calculation, default is false";
read_sync_bool(input.rdmft);
this->add_item(item);
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.rdmft && para.input.nspin == 4)
{
ModuleBase::WARNING_QUIT("ReadInput", "rdmft is not available for nspin = 4");
}
};
}
{
Input_Item item("rdmft_power_alpha");
item.annotation = "the alpha parameter of power-functional, g(occ_number) = occ_number^alpha"
" used in exx-type functionals such as muller and power";
read_sync_double(input.rdmft_power_alpha);
item.reset_value = [](const Input_Item& item, Parameter& para) {
if( para.input.dft_functional == "hf" || para.input.dft_functional == "pbe0" )
{
para.input.rdmft_power_alpha = 1.0;
}
else if( para.input.dft_functional == "muller" )
{
para.input.rdmft_power_alpha = 0.5;
}
};
item.check_value = [](const Input_Item& item, const Parameter& para) {
if( (para.input.rdmft_power_alpha < 0) || (para.input.rdmft_power_alpha > 1) )
{
ModuleBase::WARNING_QUIT("ReadInput", "rdmft_power_alpha should be greater than 0.0 and less than 1.0");
}
};
this->add_item(item);
}
// EXX PW by rhx0820, 2025-03-10
{
Input_Item item("exxace");
item.annotation = "whether to perform ace calculation in exxpw";
read_sync_bool(input.exxace);
this->add_item(item);
}
{
Input_Item item("exx_gamma_extrapolation");
item.annotation = "whether to perform gamma extrapolation in exxpw";
read_sync_bool(input.exx_gamma_extrapolation);
this->add_item(item);
}
}
} // namespace ModuleIO