ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
cal_atoms_info.h
Go to the documentation of this file.
1#ifndef CAL_ATOMS_INFO_H
2#define CAL_ATOMS_INFO_H
6{
7 public:
10
18 void cal_atoms_info(const Atom* atoms, const int& ntype, Parameter& para)
19 {
20 // calculate initial total magnetization when NSPIN=2
21 if (para.inp.nspin == 2 && !para.globalv.two_fermi)
22 {
23 for (int it = 0; it < ntype; ++it)
24 {
25 for (int ia = 0; ia < atoms[it].na; ++ia)
26 {
27 para.input.nupdown += atoms[it].mag[ia];
28 }
29 }
30 GlobalV::ofs_running << " The readin total magnetization is " << para.inp.nupdown << std::endl;
31 }
32
33
34 // decide whether to be USPP
35 for (int it = 0; it < ntype; ++it)
36 {
37 if (atoms[it].ncpp.tvanp)
38 {
39 para.sys.use_uspp = true;
40 }
41 }
42
43 // calculate the total number of local basis
44 para.sys.nlocal = 0;
45 for (int it = 0; it < ntype; ++it)
46 {
47 const int nlocal_it = atoms[it].nw * atoms[it].na;
48 if (para.inp.nspin != 4)
49 {
50 para.sys.nlocal += nlocal_it;
51 }
52 else
53 {
54 para.sys.nlocal += nlocal_it * 2; // zhengdy-soc
55 }
56 }
57
58 // calculate the total number of electrons
59 elecstate::cal_nelec(atoms, ntype, para.input.nelec);
60
61 // autoset and check GlobalV::NBANDS
62 std::vector<double> nelec_spin(2, 0.0);
63 if (para.inp.nspin == 2)
64 {
65 nelec_spin[0] = (para.inp.nelec + para.inp.nupdown ) / 2.0;
66 nelec_spin[1] = (para.inp.nelec - para.inp.nupdown ) / 2.0;
67 }
68 elecstate::cal_nbands(para.inp.nelec, para.sys.nlocal, nelec_spin, para.input.nbands);
69
70 // calculate the number of nbands_local
71 para.sys.nbands_l = para.inp.nbands;
72 if (para.inp.ks_solver == "bpcg") // only bpcg support band parallel
73 {
74 para.sys.nbands_l = para.inp.nbands / para.inp.bndpar;
75 if (GlobalV::MY_BNDGROUP < para.inp.nbands % para.inp.bndpar)
76 {
77 para.sys.nbands_l++;
78 }
79 }
80 // temporary code
81 if (GlobalV::MY_BNDGROUP == 0 || para.inp.ks_solver == "bpcg")
82 {
83 para.sys.ks_run = true;
84 }
85 return;
86 }
87};
88#endif
Definition atom_spec.h:7
int na
Definition atom_spec.h:28
int nw
Definition atom_spec.h:23
std::vector< double > mag
Definition atom_spec.h:45
Definition cal_atoms_info.h:6
CalAtomsInfo()
Definition cal_atoms_info.h:8
void cal_atoms_info(const Atom *atoms, const int &ntype, Parameter &para)
Calculate the atom information from pseudopotential to set Parameter.
Definition cal_atoms_info.h:18
~CalAtomsInfo()
Definition cal_atoms_info.h:9
Definition parameter.h:13
Input_para input
Definition parameter.h:45
const Input_para & inp
Definition parameter.h:26
System_para sys
Definition parameter.h:47
const System_para & globalv
Definition parameter.h:30
std::ofstream ofs_running
Definition global_variable.cpp:38
int MY_BNDGROUP
Definition global_variable.cpp:23
void cal_nbands(const int &nelec, const int &nlocal, const std::vector< double > &nelec_spin, int &nbands)
Calculate the number of bands.
Definition cal_nelec_nband.cpp:39
void cal_nelec(const Atom *atoms, const int &ntype, double &nelec)
calculate the total number of electrons in system
Definition cal_nelec_nband.cpp:7
std::string ks_solver
xiaohui add 2013-09-01
Definition input_parameter.h:73
int bndpar
parallel for stochastic/deterministic bands
Definition input_parameter.h:34
int nspin
LDA ; LSDA ; non-linear spin.
Definition input_parameter.h:84
double nelec
total number of electrons
Definition input_parameter.h:76
int nbands
number of bands
Definition input_parameter.h:75
double nupdown
Definition input_parameter.h:78
bool two_fermi
true if "nupdown" is set
Definition system_parameter.h:24
int nbands_l
number of bands of each band parallel calculation, same to nbands when bndpar=1
Definition system_parameter.h:60
bool ks_run
true if current process runs KS calculation
Definition system_parameter.h:61
bool use_uspp
true if "uspp" is set
Definition system_parameter.h:25
int nlocal
total number of local basis.
Definition system_parameter.h:23