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
7{
8 public:
11
19 void cal_atoms_info(const Atom* atoms, const int& ntype, Parameter& para)
20 {
21 // calculate initial total magnetization when NSPIN=2
22 if (para.inp.nspin == 2 && !para.globalv.two_fermi)
23 {
24 for (int it = 0; it < ntype; ++it)
25 {
26 for (int ia = 0; ia < atoms[it].na; ++ia)
27 {
28 para.input.nupdown += atoms[it].mag[ia];
29 }
30 }
31 GlobalV::ofs_running << std::endl;
32 ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "The readin total magnetization", para.inp.nupdown);
33 }
34
35
36 // decide whether to be USPP
37 for (int it = 0; it < ntype; ++it)
38 {
39 if (atoms[it].ncpp.tvanp)
40 {
41 para.sys.use_uspp = true;
42 }
43 }
44
45 // calculate the total number of local basis
46 para.sys.nlocal = 0;
47 for (int it = 0; it < ntype; ++it)
48 {
49 const int nlocal_it = atoms[it].nw * atoms[it].na;
50 if (para.inp.nspin != 4)
51 {
52 para.sys.nlocal += nlocal_it;
53 }
54 else
55 {
56 para.sys.nlocal += nlocal_it * 2; // zhengdy-soc
57 }
58 }
59
60 // calculate the total number of electrons
61 elecstate::cal_nelec(atoms, ntype, para.input.nelec);
62
63 // autoset and check GlobalV::NBANDS
64 std::vector<double> nelec_spin(2, 0.0);
65 if (para.inp.nspin == 2)
66 {
67 nelec_spin[0] = (para.inp.nelec + para.inp.nupdown ) / 2.0;
68 nelec_spin[1] = (para.inp.nelec - para.inp.nupdown ) / 2.0;
69 }
70 elecstate::cal_nbands(para.inp.nelec, para.sys.nlocal, nelec_spin, para.input.nbands);
71
72 // calculate the number of nbands_local
73 para.sys.nbands_l = para.inp.nbands;
74 if (para.inp.ks_solver == "bpcg") // only bpcg support band parallel
75 {
76 para.sys.nbands_l = para.inp.nbands / para.inp.bndpar;
77 if (GlobalV::MY_BNDGROUP < para.inp.nbands % para.inp.bndpar)
78 {
79 para.sys.nbands_l++;
80 }
81 }
82 // temporary code
83 if (GlobalV::MY_BNDGROUP == 0 || para.inp.ks_solver == "bpcg")
84 {
85 para.sys.ks_run = true;
86 }
87 return;
88 }
89};
90#endif
Definition atom_spec.h:6
int na
Definition atom_spec.h:27
int nw
Definition atom_spec.h:22
std::vector< double > mag
Definition atom_spec.h:45
Definition cal_atoms_info.h:7
CalAtomsInfo()
Definition cal_atoms_info.h:9
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:19
~CalAtomsInfo()
Definition cal_atoms_info.h:10
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 OUT(std::ofstream &ofs, const std::string &name)
Definition global_function.cpp:56
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:77
int bndpar
parallel for stochastic/deterministic bands
Definition input_parameter.h:34
int nspin
LDA ; LSDA ; non-linear spin.
Definition input_parameter.h:88
double nelec
total number of electrons
Definition input_parameter.h:80
int nbands
number of bands
Definition input_parameter.h:79
double nupdown
Definition input_parameter.h:82
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