forked from abacusmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 236
Expand file tree
/
Copy pathread_input_item_system.cpp
More file actions
1316 lines (1301 loc) · 60.4 KB
/
Copy pathread_input_item_system.cpp
File metadata and controls
1316 lines (1301 loc) · 60.4 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
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "source_base/global_function.h"
#include "source_base/tool_quit.h"
#include "read_input.h"
#include "read_input_tool.h"
#include "source_base/module_device/device.h"
#include <unistd.h>
#include <algorithm>
namespace ModuleIO
{
// There are some examples:
// Generallly:
// {
// Input_Item item("suffix");
// item.annotation = "the name of main output directory";
// read_sync_string(input.suffix);
// this->add_item(item);
// }
//
// Specially:
// {
// Input_Item item("kspacing");
// item.annotation = "unit in 1/bohr, should be > 0, default is 0 which
// means read KPT file";
//
// item.read_value = [](const Input_Item& item, Parameter& para) {
// para.input.kspacing[0] = std::stod(item.str_values[0]);
// para.input.kspacing[1] = std::stod(item.str_values[1]);
// para.input.kspacing[2] = std::stod(item.str_values[2]);
// };
//
// item.reset_value = [](const Input_Item& item, Parameter& para) {
// if(para.input.kspacing[0] <= 0) para.input.kspacing[0] = 1;
// };
//
// item.check_value = [](const Input_Item& item, const Parameter& para)
// {assert(para.input.kspacing[0]>0);};
//
// item.get_final_value = [](Input_Item& item, const Parameter& para) {
// item.final_value << para.input.kspacing[0] << " " <<
// para.input.kspacing[1] << " " << para.input.kspacing[2];
// };
//
// add_doublevec_bcast(&Parameter::PARAMETER, N);
// this->add_item(item);
// }
void ReadInput::item_system()
{
// NOTE: The order of add_item() calls below determines the parameter order
// in the generated documentation (docs/advanced/input_files/input-main.md).
// Please preserve this ordering when adding new parameters.
{
Input_Item item("suffix");
item.annotation = "the name of main output directory";
item.category = "System variables";
item.type = "String";
item.description = "In each run, ABACUS will generate a subdirectory in the working directory. "
"This subdirectory contains all the information of the run. "
"The subdirectory name has the format: OUT.suffix, where the suffix is the name you can pick up for your convenience.";
item.default_value = "ABACUS";
read_sync_string(input.suffix);
this->add_item(item);
}
{
Input_Item item("ntype");
item.annotation = "atom species number";
item.category = "System variables";
item.type = "Integer";
item.description = "Number of different atom species in the calculation.";
item.default_value = "0";
// check of ntype is done in check_ntype
read_sync_int(input.ntype);
this->add_item(item);
}
{
Input_Item item("calculation");
item.annotation = "scf; relax; md; socket; cell-relax; nscf; get_s; get_wf; get_pchg; gen_bessel; gen_opt_abfs; test_memory; test_neighbour";
item.category = "System variables";
item.type = "String";
item.description = R"(Specify the type of calculation.
* scf: perform self-consistent electronic structure calculations
* nscf: perform non-self-consistent electronic structure calculations. A charge density file is required
* relax: perform structure relaxation calculations, the relax_nmax parameter depicts the maximal number of ionic iterations
* cell-relax: perform cell relaxation calculations
* md: perform molecular dynamics simulations
* socket: run as a socket client for external drivers using the i-PI protocol
* get_pchg: obtain partial (band-decomposed) charge densities (for LCAO basis only). See out_pchg for more information
* get_wf: obtain real space wave functions (for LCAO basis only). See out_wfc_norm and out_wfc_re_im for more information
* get_s: obtain the overlap matrix formed by localized orbitals (for LCAO basis with multiple k points). the file name is SR.csr with file format being the same as that generated by out_mat_hs2
* gen_bessel: generates projectors, i.e., a series of Bessel functions, for the DeePKS method (for LCAO basis only)
* gen_opt_abfs: generate opt-ABFs as discussed in this article
* test_memory: obtain a rough estimation of memory consumption for the calculation
* test_neighbour: obtain information of neighboring atoms (for LCAO basis only), please specify a positive search_radius manually)";
item.default_value = "scf";
item.read_value = [](const Input_Item& item, Parameter& para) {
para.input.calculation = strvalue;
std::string& calculation = para.input.calculation;
};
item.check_value = [](const Input_Item& item, const Parameter& para) {
const std::string& calculation = para.input.calculation;
std::vector<std::string> callist = {"scf",
"relax",
"md",
"socket",
"cell-relax",
"nscf",
"get_s",
"get_wf",
"get_pchg",
"gen_bessel",
"gen_opt_abfs",
"test_memory",
"test_neighbour"};
if (std::find(callist.begin(), callist.end(), calculation) == callist.end())
{
const std::string warningstr = nofound_str(callist, "calculation");
ModuleBase::WARNING_QUIT("ReadInput", warningstr);
}
if (calculation == "get_pchg" || calculation == "get_wf")
{
if (para.input.basis_type == "pw") // xiaohui add 2013-09-01
{
ModuleBase::WARNING_QUIT("ReadInput",
"calculate = get_pchg or get_wf "
"is only availble for LCAO.");
}
}
else if (calculation == "gen_bessel")
{
if (para.input.basis_type != "pw")
{
ModuleBase::WARNING_QUIT("ReadInput", "to generate descriptors, please use pw basis");
}
}
};
sync_string(input.calculation);
this->add_item(item);
}
{
Input_Item item("esolver_type");
item.annotation = "the energy solver: ksdft, sdft, ofdft, tdofdft, tddft, lj, dp, ks-lr, lr";
item.category = "System variables";
item.type = "String";
item.description = R"(Choose the energy solver.
* ksdft: Kohn-Sham density functional theory
* ofdft: orbital-free density functional theory
* tdofdft: time-dependent orbital-free density functional theory
* sdft: stochastic density functional theory
* tddft: real-time time-dependent density functional theory (RT-TDDFT)
* lj: Leonard Jones potential
* dp: DeeP potential
* nep: Neuroevolution Potential
* ks-lr: Kohn-Sham density functional theory + LR-TDDFT (Under Development Feature)
* lr: LR-TDDFT with given KS orbitals (Under Development Feature))";
item.default_value = "ksdft";
read_sync_string(input.esolver_type);
item.check_value = [](const Input_Item& item, const Parameter& para) {
const std::vector<std::string> esolver_types = { "ksdft", "sdft", "ofdft", "tdofdft", "tddft", "lj", "dp", "nep", "lr", "ks-lr" };
if (std::find(esolver_types.begin(), esolver_types.end(), para.input.esolver_type) == esolver_types.end())
{
const std::string warningstr = nofound_str(esolver_types, "esolver_type");
ModuleBase::WARNING_QUIT("ReadInput", warningstr);
}
if (para.input.esolver_type == "dp" || para.input.esolver_type == "nep")
{
if (access(para.input.mdp.pot_file.c_str(), 0) == -1)
{
ModuleBase::WARNING_QUIT("ReadInput", "Can not find `pot_file` !");
}
}
};
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.esolver_type == "lr" && para.input.calculation == "scf")
{ // for LR-only calculation based on the ground-state, set calculation to "nscf"
para.input.calculation = "nscf";
}
};
this->add_item(item);
}
{
Input_Item item("symmetry");
item.annotation = "the control of symmetry";
item.category = "System variables";
item.type = "String";
item.description = R"(Takes value 1, 0 or -1.
* -1: No symmetry will be considered. It is recommended to set -1 for non-colinear + soc calculations, where time reversal symmetry is broken sometimes.
* 0: Only time reversal symmetry would be considered in symmetry operations, which implied k point and -k point would be treated as a single k point with twice the weight.
* 1: Symmetry analysis will be performed to determine the type of Bravais lattice and associated symmetry operations. (point groups, space groups, primitive cells, and irreducible k-points)
[NOTE] When symmetry is enabled (value 1), k-points are reduced to the irreducible Brillouin zone (IBZ). For explicit k-point lists with custom weights (see KPT file), the custom weights are preserved during symmetry reduction. For Monkhorst-Pack grids, uniform weights are used.)";
item.default_value = "default";
read_sync_string(input.symmetry);
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.symmetry == "default")
{
if (para.input.gamma_only || para.input.calculation == "nscf" || para.input.calculation == "get_s"
|| para.input.calculation == "get_pchg" || para.input.calculation == "get_wf")
{
para.input.symmetry = "0"; // if md or exx, symmetry will be
// force-set to 0 or -1 later
}
else
{
para.input.symmetry = "1";
}
}
if (para.input.calculation == "md")
{
para.input.symmetry = "0";
}
if (para.input.efield_flag)
{
para.input.symmetry = "0";
}
if (para.input.esolver_type == "tddft")
{
para.input.symmetry = "-1";
}
if (para.input.qo_switch)
{
para.input.symmetry = "-1"; // disable kpoint reduce
}
if (para.input.berry_phase)
{
para.input.symmetry = "-1"; // disable kpoint reduce
}
};
this->add_item(item);
}
{
Input_Item item("symmetry_prec");
item.annotation = "accuracy for symmetry";
item.category = "System variables";
item.type = "Real";
item.description = "The accuracy for symmetry analysis. Typically, the default value is good enough, "
"but if the lattice parameters or atom positions in STRU file are not accurate enough, "
"this value should be enlarged.\n"
"[NOTE] Note: if calculation==cell_relax, this value can be dynamically changed "
"corresponding to the variation of accuracy of the lattice parameters and atom positions "
"during the relaxation.";
item.default_value = "1.0e-6";
item.unit = "Bohr";
read_sync_double(input.symmetry_prec);
this->add_item(item);
}
{
Input_Item item("symmetry_autoclose");
item.annotation = "whether to close symmetry automatically when error "
"occurs in symmetry analysis";
item.category = "System variables";
item.type = "Boolean";
item.description = "Control how to deal with error in symmetry analysis due to inaccurate lattice parameters "
"or atom positions in STRU file, especially useful when calculation==cell-relax\n"
"* False: quit with an error message\n"
"* True: automatically set symmetry to 0 and continue running without symmetry analysis";
item.default_value = "True";
item.availability = "symmetry==1";
read_sync_bool(input.symmetry_autoclose);
this->add_item(item);
}
{
Input_Item item("cal_force");
item.annotation = "if calculate the force at the end of the electronic iteration";
item.category = "System variables";
item.type = "Boolean";
item.description = "If set to True, calculate the force at the end of the electronic iteration.";
item.default_value = "False";
item.reset_value = [](const Input_Item& item, Parameter& para) {
std::vector<std::string> use_force = {"cell-relax", "relax", "md", "socket"};
std::vector<std::string> not_use_force = {"get_wf", "get_pchg", "get_s"};
if (std::find(use_force.begin(), use_force.end(), para.input.calculation) != use_force.end())
{
if (!para.input.cal_force)
{
ModuleBase::GlobalFunc::AUTO_SET("cal_force", "true");
}
para.input.cal_force = true;
}
else if (std::find(not_use_force.begin(), not_use_force.end(), para.input.calculation) != not_use_force.end())
{
if (para.input.cal_force)
{
ModuleBase::GlobalFunc::AUTO_SET("cal_force", "false");
}
para.input.cal_force = false;
}
};
read_sync_bool(input.cal_force);
this->add_item(item);
}
{
Input_Item item("kpar");
item.annotation = "devide all processors into kpar groups and k points "
"will be distributed among";
item.category = "System variables";
item.type = "Integer";
item.description = "Divide all processors into kpar groups, and k points will be distributed among each group. "
"The value taken should be less than or equal to the number of k points as well as the number of MPI processes.";
item.default_value = "1";
read_sync_int(input.kpar);
item.reset_value = [](const Input_Item& item, Parameter& para) {
#ifdef __LCAO
if (para.inp.basis_type == "lcao")
{
para.sys.kpar_lcao = para.inp.kpar;
para.input.kpar = 1;
}
#endif
// GPU + PW: validate kpar against total processors
// Moved from base_device::information::get_device_kpar()
#if defined(__CUDA) || defined(__ROCM)
if (para.input.device == "gpu" && para.input.basis_type == "pw")
{
if (GlobalV::NPROC != para.input.kpar * para.input.bndpar)
{
para.input.kpar = GlobalV::NPROC / para.input.bndpar;
ModuleBase::WARNING("ReadInput",
"kpar is not compatible with the number of processors, auto set kpar value.");
}
}
#endif
};
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.basis_type == "lcao" && para.input.kpar > 1)
{
ModuleBase::WARNING("ReadInput", "kpar > 1 has not been supported for lcao calculation.");
}
};
this->add_item(item);
add_int_bcast(sys.kpar_lcao);
}
{
Input_Item item("bndpar");
item.annotation = "devide all processors into bndpar groups and bands "
"will be distributed among each group";
item.category = "System variables";
item.type = "Integer";
item.description = "Divide all processors into bndpar groups, and bands (only stochastic orbitals now) "
"will be distributed among each group. It should be larger than 0.";
item.default_value = "1";
read_sync_int(input.bndpar);
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.esolver_type != "sdft" && para.input.ks_solver != "bpcg")
{
para.input.bndpar = 1;
}
if (para.input.bndpar > GlobalV::NPROC)
{
para.input.bndpar = GlobalV::NPROC;
}
};
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (GlobalV::NPROC % para.input.bndpar != 0)
{
ModuleBase::WARNING_QUIT("ReadInput", "The number of processors can not be divided by bndpar");
}
};
this->add_item(item);
}
{
Input_Item item("latname");
item.annotation = "the name of lattice name";
item.category = "System variables";
item.type = "String";
item.description = R"(Specifies the type of Bravias lattice. When set to none, the three lattice vectors are supplied explicitly in STRU file.
Available options are:
* none: free structure
* sc: simple cubic
* fcc: face-centered cubic
* bcc: body-centered cubic
* hexagonal: hexagonal
* trigonal: trigonal
* st: simple tetragonal
* bct: body-centered tetragonal
* so: orthorhombic
* baco: base-centered orthorhombic
* fco: face-centered orthorhombic
* bco: body-centered orthorhombic
* sm: simple monoclinic
* bacm: base-centered monoclinic
* triclinic: triclinic)";
item.default_value = "none";
read_sync_string(input.latname);
this->add_item(item);
}
{
Input_Item item("assume_isolated");
item.annotation = "isolated-system electrostatic correction";
item.category = "System variables";
item.type = "String";
item.description = R"(Used to perform a calculation assuming an isolated system in a 3D supercell.
Available options are:
* none: regular periodic calculation without isolated-system correction.
* makov-payne, m-p, mp: compute the Makov-Payne correction to the total energy and estimate a corrected vacuum level for eigenvalue alignment. This option is available only for cubic lattices (latname = sc, fcc, or bcc).
Theory: G. Makov and M. C. Payne, Phys. Rev. B 51, 4014 (1995).)";
item.default_value = "none";
read_sync_string(input.assume_isolated);
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.assume_isolated == "m-p" || para.input.assume_isolated == "mp")
{
para.input.assume_isolated = "makov-payne";
}
};
item.check_value = [](const Input_Item& item, const Parameter& para) {
const std::vector<std::string> allowed = {"none", "makov-payne", "m-p", "mp"};
if (std::find(allowed.begin(), allowed.end(), para.input.assume_isolated) == allowed.end())
{
ModuleBase::WARNING_QUIT("ReadInput", nofound_str(allowed, "assume_isolated"));
}
if ((para.input.assume_isolated == "makov-payne" || para.input.assume_isolated == "m-p"
|| para.input.assume_isolated == "mp")
&& para.input.latname != "sc" && para.input.latname != "fcc" && para.input.latname != "bcc")
{
ModuleBase::WARNING_QUIT("ReadInput",
"Makov-Payne correction is available only for cubic lattices: latname = sc, fcc, or bcc.");
}
};
this->add_item(item);
}
{
Input_Item item("init_wfc");
item.annotation = "start wave functions are from 'atomic', "
"'atomic+random', 'random' or";
item.category = "System variables";
item.type = "String";
item.description = R"(The type of the starting wave functions.
Available options are:
* atomic: from atomic pseudo wave functions. If they are not enough, other wave functions are initialized with random numbers.
* atomic+random: add small random numbers on atomic pseudo-wavefunctions
* file: from binary files wf*.dat, which are output by setting out_wfc_pw to 2.
* random: random numbers
* nao: from numerical atomic orbitals. If they are not enough, other wave functions are initialized with random numbers.
* nao+random: add small random numbers on numerical atomic orbitals
[NOTE] Only the file option is useful for the lcao basis set, which is mostly used when calculation is set to get_wf and get_pchg.)";
item.default_value = "atomic";
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.calculation == "get_pchg" || para.input.calculation == "get_wf")
{
para.input.init_wfc = "file";
}
if (para.input.basis_type == "lcao_in_pw")
{
if (para.input.init_wfc != "nao")
{
para.input.init_wfc = "nao";
GlobalV::ofs_warning << "init_wfc is set to nao when "
"basis_type is lcao_in_pw"
<< std::endl;
}
}
};
read_sync_string(input.init_wfc);
this->add_item(item);
}
{
Input_Item item("init_chg");
item.annotation = "start charge is from 'atomic' or file";
item.category = "System variables";
item.type = "String";
item.description = R"(This variable is used for both plane wave set and localized orbitals set. It indicates the type of starting density.
* atomic: the density is starting from the summation of the atomic density of single atoms.
* file: the density will be read in from a binary file charge-density.dat first. If it does not exist, the charge density will be read in from cube files.
* wfc: the density will be calculated by wavefunctions and occupations.
* dm: the density will be calculated by real space density matrix(DMR) of LCAO base.
* dm_no_renormalize: same as dm, but the charge density is not renormalized to the number of electrons.
* hr: the real space Hamiltonian matrix(HR) will be read in from file hrs1_nao.csr in directory read_file_dir.
* auto: Abacus first attempts to read the density from a file; if not found, it defaults to using atomic density.)";
item.default_value = "atomic";
read_sync_string(input.init_chg);
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.calculation == "get_pchg" || para.input.calculation == "get_wf")
{
para.input.init_chg = "atomic";
}
if (para.input.calculation == "nscf" || para.input.calculation == "get_s")
{
// dm and hr are valid options for nscf calculation (e.g., band structure, wannier90)
if (para.input.init_chg != "file" &&
para.input.init_chg != "dm" &&
para.input.init_chg != "dm_no_renormalize" &&
para.input.init_chg != "hr")
{
ModuleBase::GlobalFunc::AUTO_SET("init_chg", para.input.init_chg);
para.input.init_chg = "file";
}
}
};
item.check_value = [](const Input_Item& item, const Parameter& para) {
const std::vector<std::string> init_chgs = {"atomic", "file", "wfc", "auto", "dm", "dm_no_renormalize", "hr"};
if (std::find(init_chgs.begin(), init_chgs.end(), para.input.init_chg) == init_chgs.end())
{
const std::string warningstr = nofound_str(init_chgs, "init_chg");
ModuleBase::WARNING_QUIT("ReadInput", warningstr);
}
};
this->add_item(item);
}
{
Input_Item item("init_vel");
item.annotation = "read velocity from STRU or not";
item.category = "System variables";
item.type = "Boolean";
item.description = R"(* True: read the atom velocity (atomic unit : 1 a.u. = 21.877 Angstrom/fs) from the atom file (STRU) and determine the initial temperature md_tfirst. If md_tfirst is unset or less than zero, init_vel is autoset to be true.
* False: assign value to atom velocity using Gaussian distributed random numbers.)";
item.default_value = "False";
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.calculation == "md")
{
if (para.input.mdp.md_tfirst < 0 || para.input.mdp.md_restart)
{
para.input.init_vel = true;
}
}
};
read_sync_bool(input.init_vel);
this->add_item(item);
}
{
Input_Item item("mem_saver");
item.annotation = "Only for nscf calculations. if set to 1, then a "
"memory saving technique will be used for "
"many k point calculations.";
item.category = "System variables";
item.type = "Integer";
item.description = R"(Save memory when performing nscf calculations.
* 0: no memory saving techniques are used.
* 1: a memory saving technique will be used for many k point calculations.)";
item.default_value = "0";
item.availability = "Used only for nscf calculations with plane wave basis set.";
read_sync_int(input.mem_saver);
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.mem_saver == 1)
{
if (para.input.calculation == "scf" || para.input.calculation == "relax")
{
para.input.mem_saver = 0;
ModuleBase::GlobalFunc::AUTO_SET("mem_saver", "0");
}
}
};
this->add_item(item);
}
{
Input_Item item("cal_stress");
item.annotation = "calculate the stress or not";
item.category = "System variables";
item.type = "Boolean";
item.description = "If set to True, calculate the stress at the end of the electronic iteration.";
item.default_value = "False";
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.calculation == "md")
{
if (para.input.esolver_type == "lj" || para.input.esolver_type == "dp"
|| para.input.mdp.md_type == "msst" || para.input.mdp.md_type == "npt")
{
para.input.cal_stress = true;
}
}
else if (para.input.calculation == "cell-relax")
{
para.input.cal_stress = true;
}
};
read_sync_bool(input.cal_stress);
this->add_item(item);
}
{
Input_Item item("diago_proc");
item.annotation = "the number of procs used to do diagonalization";
item.category = "System variables";
item.type = "Integer";
item.description = R"(* 0: it will be set to the number of MPI processes.
* >0: it specifies the number of processes used for carrying out diagonalization. Must be less than or equal to total number of MPI processes.)";
item.default_value = "0";
item.availability = "Used only for plane wave basis set.";
read_sync_int(input.diago_proc);
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.diago_proc > GlobalV::NPROC || para.input.diago_proc <= 0)
{
para.input.diago_proc = GlobalV::NPROC;
}
};
this->add_item(item);
}
{
Input_Item item("nbspline");
item.annotation = "the order of B-spline basis";
item.category = "System variables";
item.type = "Integer";
item.description = "If set to a natural number, a Cardinal B-spline interpolation will be used to calculate "
"Structure Factor. nbspline represents the order of B-spline basis and a larger one can get "
"more accurate results but cost more. It is turned off by default.";
item.default_value = "-1";
read_sync_int(input.nbspline);
this->add_item(item);
}
{
Input_Item item("kspacing");
item.annotation = "unit in 1/bohr, should be > 0, default is 0 which "
"means read KPT file";
item.category = "System variables";
item.type = "Vector of Real (1 or 3 values)";
item.description = "Set the smallest allowed spacing between k points, unit in 1/bohr. It should be larger than 0.0, "
"and suggest smaller than 0.25. When you have set this value > 0.0, then the KPT file is unnecessary. "
"The default value 0.0 means that ABACUS will read the applied KPT file."
"\n\n[NOTE] If gamma_only is set to be true, kspacing is invalid.";
item.default_value = "0.0";
item.read_value = [](const Input_Item& item, Parameter& para) {
size_t count = item.get_size();
if (count == 1)
{
para.input.kspacing[0] = para.input.kspacing[1] = para.input.kspacing[2] = doublevalue;
}
else if (count == 3)
{
para.input.kspacing[0] = std::stod(item.str_values[0]);
para.input.kspacing[1] = std::stod(item.str_values[1]);
para.input.kspacing[2] = std::stod(item.str_values[2]);
}
else
{
ModuleBase::WARNING_QUIT("ReadInput", "kspacing can only accept one or three values.");
}
};
sync_doublevec(input.kspacing, 3, 0.0);
item.check_value = [](const Input_Item& item, const Parameter& para) {
int kspacing_zero_num = 0;
const std::vector<double>& kspacing = para.input.kspacing;
for (int i = 0; i < 3; i++)
{
if (kspacing[i] < 0.0)
{
ModuleBase::WARNING_QUIT("ReadInput", "kspacing must > 0");
}
else if (kspacing[i] == 0.0)
{
kspacing_zero_num++;
}
}
if (kspacing_zero_num > 0 && kspacing_zero_num < 3)
{
std::cout << "kspacing: " << kspacing[0] << " " << kspacing[1] << " " << kspacing[2] << std::endl;
ModuleBase::WARNING_QUIT("ReadInput", "kspacing must > 0");
}
};
this->add_item(item);
}
{
Input_Item item("koffset");
item.annotation = "offset for kspacing-generated automatic k-point mesh";
item.category = "System variables";
item.type = "Vector of Real (3 values)";
item.description = "Set offsets for automatic k-point mesh generated by kspacing, in each reciprocal direction. "
"This parameter is only effective when kspacing > 0.0 and gamma_only is false.";
item.default_value = "0.0 0.0 0.0";
item.read_value = [](const Input_Item& item, Parameter& para) {
if (item.get_size() != 3)
{
ModuleBase::WARNING_QUIT("ReadInput", "koffset must provide three values.");
}
para.input.koffset[0] = std::stod(item.str_values[0]);
para.input.koffset[1] = std::stod(item.str_values[1]);
para.input.koffset[2] = std::stod(item.str_values[2]);
};
sync_doublevec(input.koffset, 3, 0.0);
this->add_item(item);
}
{
Input_Item item("kmesh_type");
item.annotation = "mesh type for kspacing-generated automatic k-point mesh";
item.category = "System variables";
item.type = "String";
item.description = "Set mesh type used for automatic k-point mesh generated by kspacing. "
"Available options are gamma and mp. This parameter is only effective when kspacing > 0.0 "
"and gamma_only is false.";
item.default_value = "gamma";
item.read_value = [](const Input_Item& item, Parameter& para) {
para.input.kmesh_type = strvalue;
std::transform(para.input.kmesh_type.begin(),
para.input.kmesh_type.end(),
para.input.kmesh_type.begin(),
::tolower);
};
sync_string(input.kmesh_type);
item.check_value = [](const Input_Item& item, const Parameter& para) {
std::vector<std::string> avail_list = {"gamma", "mp"};
if (std::find(avail_list.begin(), avail_list.end(), para.input.kmesh_type) == avail_list.end())
{
const std::string warningstr = nofound_str(avail_list, "kmesh_type");
ModuleBase::WARNING_QUIT("ReadInput", warningstr);
}
};
this->add_item(item);
}
{
Input_Item item("min_dist_coef");
item.annotation = "factor related to the allowed minimum distance "
"between two atoms";
item.category = "System variables";
item.type = "Real";
item.description = "A factor related to the allowed minimum distance between two atoms. At the beginning, "
"ABACUS will check the structure, and if the distance of two atoms is shorter than "
"min_dist_coef*(standard covalent bond length), we think this structure is unreasonable.";
item.default_value = "0.2";
read_sync_double(input.min_dist_coef);
this->add_item(item);
}
{
Input_Item item("device");
item.annotation = "the computing device for ABACUS";
item.category = "System variables";
item.type = "String";
item.description = R"(Specifies the computing device for ABACUS.
Available options are:
* cpu: for CPUs via Intel, AMD, or Other supported CPU devices
* gpu: for GPUs via CUDA or ROCm.
[NOTE] ks_solver must also be set to the algorithms supported. lcao_in_pw currently does not support gpu.)";
item.default_value = "cpu";
read_sync_string(input.device);
item.reset_value = [](const Input_Item& item, Parameter& para) {
para.input.device=base_device::information::get_device_flag(
para.inp.device, para.inp.basis_type);
};
item.check_value = [](const Input_Item& item, const Parameter& para) {
std::vector<std::string> avail_list = {"cpu", "gpu"};
if (std::find(avail_list.begin(), avail_list.end(), para.input.device) == avail_list.end())
{
const std::string warningstr = nofound_str(avail_list, "device");
ModuleBase::WARNING_QUIT("ReadInput", warningstr);
}
};
this->add_item(item);
}
{
Input_Item item("precision");
item.annotation = "the computing precision for ABACUS";
item.category = "System variables";
item.type = "String";
item.description = R"(Specifies the precision when performing scf calculation.
* single: single precision
* double: double precision)";
item.default_value = "double";
item.availability = "Used only for plane wave basis set.";
read_sync_string(input.precision);
item.check_value = [](const Input_Item& item, const Parameter& para) {
std::vector<std::string> avail_list = {"single", "double"};
if (std::find(avail_list.begin(), avail_list.end(), para.input.precision) == avail_list.end())
{
const std::string warningstr = nofound_str(avail_list, "precision");
ModuleBase::WARNING_QUIT("ReadInput", warningstr);
}
if (para.inp.precision == "single" && para.inp.basis_type == "lcao")
{
ModuleBase::WARNING_QUIT(
"ReadInput",
"Single precision is not supported for NAO basis,\nPlease use double precision for NAO basis.\n");
}
// cpu single precision is not supported while float_fftw lib is not available
if (para.inp.device == "cpu" && para.inp.precision == "single")
{
#ifndef __ENABLE_FLOAT_FFTW
ModuleBase::WARNING_QUIT(
"ReadInput",
"Single precision with cpu is not supported while float_fftw lib is not available; \
\n Please recompile with cmake flag \"-DENABLE_FLOAT_FFTW=ON\".\n");
#endif
}
};
this->add_item(item);
}
{
Input_Item item("gint_precision");
item.annotation = "the computing precision for LCAO grid integral";
item.category = "System variables";
item.type = "String";
item.description = R"(Specifies the precision when performing grid integral in LCAO calculations.
* single: single precision
* double: double precision
* mix: mixed precision, starting from single precision and switching to double precision when the SCF residual becomes small enough)";
item.default_value = "double";
item.availability = "Used only for LCAO basis set.";
read_sync_string(input.gint_precision);
item.check_value = [](const Input_Item& item, const Parameter& para) {
std::vector<std::string> avail_list = {"single", "double", "mix"};
if (std::find(avail_list.begin(), avail_list.end(), para.input.gint_precision) == avail_list.end())
{
const std::string warningstr = nofound_str(avail_list, "gint_precision");
ModuleBase::WARNING_QUIT("ReadInput", warningstr);
}
if (para.inp.gint_precision != "double" && para.inp.basis_type != "lcao")
{
ModuleBase::WARNING_QUIT(
"ReadInput",
"gint_precision = single or mix is currently supported only for LCAO calculations.\n");
}
if (para.inp.gint_precision != "double" && para.inp.nspin == 4)
{
ModuleBase::WARNING_QUIT(
"ReadInput",
"gint_precision = single or mix is not supported for nspin = 4 (noncollinear/SOC) calculations.\n");
}
};
this->add_item(item);
}
{
Input_Item item("timer_enable_nvtx");
item.annotation = "enable NVTX labeling for profiling or not";
item.category = "System variables";
item.type = "Boolean";
item.description = R"(Controls whether NVTX profiling labels are emitted by the timer. This feature is only effective on CUDA platforms.
* True: Enable NVTX profiling labels in the timer.
* False: Disable NVTX profiling labels in the timer.)";
item.default_value = "False";
read_sync_bool(input.timer_enable_nvtx);
this->add_item(item);
}
{
Input_Item item("cell_factor");
item.annotation = "used in the construction of the pseudopotential tables";
item.category = "System variables";
item.type = "Real";
item.description = "Used in the construction of the pseudopotential tables. "
"For cell-relax calculations, this is automatically set to 2.0.";
item.default_value = "1.2";
read_sync_double(input.cell_factor);
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.calculation == "cell-relax" && para.input.cell_factor < 2.0)
{
para.input.cell_factor = 2.0; // follows QE
}
};
this->add_item(item);
}
{
Input_Item item("dm_to_rho");
item.annotation = "reads dmr in npz format and calculates electron density";
item.category = "System variables";
item.type = "Boolean";
item.description = "Reads density matrix in npz format and calculates electron density.";
item.default_value = "False";
read_sync_bool(input.dm_to_rho);
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.dm_to_rho && GlobalV::NPROC > 1)
{
ModuleBase::WARNING_QUIT("ReadInput", "dm_to_rho is not available for parallel calculations");
}
if (para.input.dm_to_rho && para.inp.gamma_only)
{
ModuleBase::WARNING_QUIT("ReadInput", "dm_to_rho is not available for gamma_only calculations");
}
if (para.input.dm_to_rho)
{
#ifndef __USECNPY
ModuleBase::WARNING_QUIT("ReadInput",
"to write in npz format, please "
"recompile with -DENABLE_CNPY=1");
#endif
}
};
this->add_item(item);
}
{
Input_Item item("chg_extrap");
item.annotation = "atomic; first-order; second-order; dm:coefficients of SIA";
item.category = "System variables";
item.type = "String";
item.description = R"(Charge extrapolation method for MD, relaxation, and socket-driven calculations.
When set to default, ABACUS chooses second-order for md, first-order for
relax/cell-relax/socket, and atomic for other calculations. Socket-driven
molecular dynamics can explicitly set second-order if the external driver
updates structures smoothly enough for second-order extrapolation.)";
item.default_value = "default";
read_sync_string(input.chg_extrap);
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.chg_extrap == "default" && para.input.calculation == "md")
{
para.input.chg_extrap = "second-order";
}
else if (para.input.chg_extrap == "default"
&& (para.input.calculation == "relax" || para.input.calculation == "cell-relax" || para.input.calculation == "socket"))
{
para.input.chg_extrap = "first-order";
}
else if (para.input.chg_extrap == "default")
{
para.input.chg_extrap = "atomic";
}
if (para.input.calculation == "get_wf" || para.input.calculation == "get_pchg")
{
para.input.chg_extrap = "atomic";
}
};
this->add_item(item);
}
{
Input_Item item("ecutwfc");
item.annotation = "energy cutoff for wave functions";
item.category = "Plane wave related variables";
item.type = "Real";
item.description = "Energy cutoff for plane wave functions. Note that even for localized orbitals basis, "
"you still need to setup an energy cutoff for this system. Because our local pseudopotential parts "
"and the related force are calculated from plane wave basis set.\n"
"[NOTE] ecutwfc and ecutrho can be set simultaneously. If only one parameter is set, "
"abacus will automatically set another parameter based on the 4-time relationship.";
item.default_value = "50 for PW basis, 100 for LCAO basis";
item.unit = "Ry";
read_sync_double(input.ecutwfc);
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.ecutwfc == 0)
{ // 0 means no input value
if (para.input.ecutrho > 0)
{
para.input.ecutwfc = para.input.ecutrho / 4.0;
}
else if (para.input.basis_type == "lcao")
{
para.input.ecutwfc = 100;
}
else
{
para.input.ecutwfc = 50;
}
}
};
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.ecutwfc <= 0)
{
ModuleBase::WARNING_QUIT("ReadInput", "ecutwfc should be positive");
}
};
this->add_item(item);
}
{
Input_Item item("ecutrho");
item.annotation = "energy cutoff for charge density and potential";
item.category = "Plane wave related variables";
item.type = "Real";
item.description = "Energy cutoff for charge density and potential. For norm-conserving pseudopotential "
"you should stick to the default value, you can reduce it by a little but it will introduce noise "
"especially on forces and stress.";
item.default_value = "4*ecutwfc";
item.unit = "Ry";
read_sync_double(input.ecutrho);
item.reset_value = [](const Input_Item& item, Parameter& para) {
Input_para& input = para.input;
if (input.ecutrho <= 0.0)
{
input.ecutrho = 4.0 * input.ecutwfc;
}
if (input.nx * input.ny * input.nz == 0 && input.ecutrho / input.ecutwfc > 4 + 1e-8)
{
para.sys.double_grid = true;
}
};
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.ecutrho / para.input.ecutwfc < 4 - 1e-8)
{
ModuleBase::WARNING_QUIT("ReadInput", "ecutrho/ecutwfc must >= 4");
}
if (para.sys.double_grid == true && para.input.basis_type == "lcao")
{
ModuleBase::WARNING_QUIT("ReadInput", "ecutrho/ecutwfc must = 4 for lcao calculation");
}
};
this->add_item(item);
}
{
Input_Item item("nx");
item.annotation = "number of points along x axis for FFT grid";
item.category = "Plane wave related variables";
item.type = "Integer";
item.description = "If set to a positive number, specifies the number of FFT grid points in x direction. "
"If set to 0, the number will be calculated from ecutrho."
"\n\n[NOTE] You must specify all three dimensions (nx, ny, nz) for this setting to be used.";
item.default_value = "0";
item.read_value = [](const Input_Item& item, Parameter& para) {
para.input.nx = intvalue;
};
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.nx * para.input.ny * para.input.nz == 0 && para.input.nx != 0)
{
ModuleBase::WARNING_QUIT("ReadInput", "nx, ny, nz should be all set to non-zero");
}
};
sync_int(input.nx);
this->add_item(item);
}
{