Skip to content

Commit 062ea9b

Browse files
committed
delete use_paw
1 parent 49ea9c9 commit 062ea9b

File tree

16 files changed

+97
-275
lines changed

16 files changed

+97
-275
lines changed

source/module_cell/cal_atoms_info.h

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,28 @@ class CalAtomsInfo
3030
GlobalV::ofs_running << " The readin total magnetization is " << para.inp.nupdown << std::endl;
3131
}
3232

33-
if (!para.inp.use_paw)
33+
34+
// decide whether to be USPP
35+
for (int it = 0; it < ntype; ++it)
3436
{
35-
// decide whether to be USPP
36-
for (int it = 0; it < ntype; ++it)
37+
if (atoms[it].ncpp.tvanp)
3738
{
38-
if (atoms[it].ncpp.tvanp)
39-
{
40-
para.sys.use_uspp = true;
41-
}
39+
para.sys.use_uspp = true;
4240
}
43-
44-
// calculate the total number of local basis
45-
para.sys.nlocal = 0;
46-
for (int it = 0; it < ntype; ++it)
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)
4749
{
48-
const int nlocal_it = atoms[it].nw * atoms[it].na;
49-
if (para.inp.nspin != 4)
50-
{
51-
para.sys.nlocal += nlocal_it;
52-
}
53-
else
54-
{
55-
para.sys.nlocal += nlocal_it * 2; // zhengdy-soc
56-
}
50+
para.sys.nlocal += nlocal_it;
51+
}
52+
else
53+
{
54+
para.sys.nlocal += nlocal_it * 2; // zhengdy-soc
5755
}
5856
}
5957

source/module_cell/read_atom_species.cpp

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -34,47 +34,44 @@ bool read_atom_species(std::ifstream& ifa,
3434
ucell.pseudo_fn[i] = "auto";
3535
ucell.pseudo_type[i] = "auto";
3636

37-
if(!PARAM.inp.use_paw)
37+
bool end = false;
38+
if (ss >> one_string)
3839
{
39-
bool end = false;
40-
if (ss >> one_string)
40+
if (one_string[0] != '#')
4141
{
42-
if (one_string[0] != '#')
43-
{
44-
ucell.pseudo_fn[i] = one_string;
45-
}
46-
else
47-
{
48-
end = true;
49-
}
42+
ucell.pseudo_fn[i] = one_string;
5043
}
51-
52-
if (!end && ss >> one_string && one_string[0] != '#')
44+
else
5345
{
54-
if (one_string == "auto" || one_string == "upf"
55-
|| one_string == "vwr" || one_string == "upf201" || one_string == "blps")
56-
{
57-
ucell.pseudo_type[i] = one_string;
58-
}
59-
else if (one_string == "1/r")
60-
{
61-
ucell.atoms[i].coulomb_potential = true;
62-
}
63-
else
64-
{
65-
GlobalV::ofs_warning << "unrecognized pseudopotential type: "
66-
<< one_string << ", check your STRU file." << std::endl;
67-
ModuleBase::WARNING_QUIT("read_atom_species", "unrecognized pseudopotential type.");
68-
}
46+
end = true;
6947
}
48+
}
7049

71-
// Peize Lin test for bsse 2021.04.07
72-
const std::string bsse_label = "empty";
73-
ucell.atoms[i].flag_empty_element =
74-
(search( ucell.atom_label[i].begin(), ucell.atom_label[i].end(),
75-
bsse_label.begin(), bsse_label.end() ) != ucell.atom_label[i].end())
76-
? true : false;
50+
if (!end && ss >> one_string && one_string[0] != '#')
51+
{
52+
if (one_string == "auto" || one_string == "upf"
53+
|| one_string == "vwr" || one_string == "upf201" || one_string == "blps")
54+
{
55+
ucell.pseudo_type[i] = one_string;
56+
}
57+
else if (one_string == "1/r")
58+
{
59+
ucell.atoms[i].coulomb_potential = true;
60+
}
61+
else
62+
{
63+
GlobalV::ofs_warning << "unrecognized pseudopotential type: "
64+
<< one_string << ", check your STRU file." << std::endl;
65+
ModuleBase::WARNING_QUIT("read_atom_species", "unrecognized pseudopotential type.");
66+
}
7767
}
68+
69+
// Peize Lin test for bsse 2021.04.07
70+
const std::string bsse_label = "empty";
71+
ucell.atoms[i].flag_empty_element =
72+
(search( ucell.atom_label[i].begin(), ucell.atom_label[i].end(),
73+
bsse_label.begin(), bsse_label.end() ) != ucell.atom_label[i].end())
74+
? true : false;
7875
}
7976
}
8077

source/module_elecstate/elecstate.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,7 @@ void ElecState::init_scf(const int istep,
3636
const void* wfcpw)
3737
{
3838
//! core correction potential.
39-
if (!PARAM.inp.use_paw)
40-
{
41-
this->charge->set_rho_core(ucell,strucfac, numeric);
42-
}
43-
else
44-
{
45-
this->charge->set_rho_core_paw();
46-
}
39+
this->charge->set_rho_core(ucell,strucfac, numeric);
4740

4841
//! other effective potentials need charge density,
4942
// choose charge density from ionic step 0.

source/module_elecstate/elecstate_energy.cpp

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -101,55 +101,52 @@ double ElecState::cal_delta_eband(const UnitCell& ucell) const
101101
const double* v_ofk = nullptr;
102102
const bool v_ofk_flag = (XC_Functional::get_ked_flag());
103103

104-
if (!PARAM.inp.use_paw)
104+
for (int ir = 0; ir < this->charge->rhopw->nrxx; ir++)
105+
{
106+
deband_aux -= this->charge->rho[0][ir] * (v_eff[ir] - v_fixed[ir]);
107+
}
108+
if (v_ofk_flag)
105109
{
110+
v_ofk = this->pot->get_effective_vofk(0);
111+
// cause in the get_effective_vofk, the func will return nullptr
112+
if (v_ofk == nullptr && this->charge->rhopw->nrxx > 0)
113+
{
114+
ModuleBase::WARNING_QUIT("ElecState::cal_delta_eband", "v_ofk is nullptr");
115+
}
106116
for (int ir = 0; ir < this->charge->rhopw->nrxx; ir++)
107117
{
108-
deband_aux -= this->charge->rho[0][ir] * (v_eff[ir] - v_fixed[ir]);
118+
deband_aux -= this->charge->kin_r[0][ir] * v_ofk[ir];
119+
}
120+
}
121+
122+
if (PARAM.inp.nspin == 2)
123+
{
124+
v_eff = this->pot->get_effective_v(1);
125+
for (int ir = 0; ir < this->charge->rhopw->nrxx; ir++)
126+
{
127+
deband_aux -= this->charge->rho[1][ir] * (v_eff[ir] - v_fixed[ir]);
109128
}
110129
if (v_ofk_flag)
111130
{
112-
v_ofk = this->pot->get_effective_vofk(0);
113-
// cause in the get_effective_vofk, the func will return nullptr
131+
v_ofk = this->pot->get_effective_vofk(1);
114132
if (v_ofk == nullptr && this->charge->rhopw->nrxx > 0)
115133
{
116134
ModuleBase::WARNING_QUIT("ElecState::cal_delta_eband", "v_ofk is nullptr");
117135
}
118136
for (int ir = 0; ir < this->charge->rhopw->nrxx; ir++)
119137
{
120-
deband_aux -= this->charge->kin_r[0][ir] * v_ofk[ir];
138+
deband_aux -= this->charge->kin_r[1][ir] * v_ofk[ir];
121139
}
122140
}
123-
124-
if (PARAM.inp.nspin == 2)
141+
}
142+
else if (PARAM.inp.nspin == 4)
143+
{
144+
for (int is = 1; is < 4; is++)
125145
{
126-
v_eff = this->pot->get_effective_v(1);
146+
v_eff = this->pot->get_effective_v(is);
127147
for (int ir = 0; ir < this->charge->rhopw->nrxx; ir++)
128148
{
129-
deband_aux -= this->charge->rho[1][ir] * (v_eff[ir] - v_fixed[ir]);
130-
}
131-
if (v_ofk_flag)
132-
{
133-
v_ofk = this->pot->get_effective_vofk(1);
134-
if (v_ofk == nullptr && this->charge->rhopw->nrxx > 0)
135-
{
136-
ModuleBase::WARNING_QUIT("ElecState::cal_delta_eband", "v_ofk is nullptr");
137-
}
138-
for (int ir = 0; ir < this->charge->rhopw->nrxx; ir++)
139-
{
140-
deband_aux -= this->charge->kin_r[1][ir] * v_ofk[ir];
141-
}
142-
}
143-
}
144-
else if (PARAM.inp.nspin == 4)
145-
{
146-
for (int is = 1; is < 4; is++)
147-
{
148-
v_eff = this->pot->get_effective_v(is);
149-
for (int ir = 0; ir < this->charge->rhopw->nrxx; ir++)
150-
{
151-
deband_aux -= this->charge->rho[is][ir] * v_eff[ir];
152-
}
149+
deband_aux -= this->charge->rho[is][ir] * v_eff[ir];
153150
}
154151
}
155152
}

source/module_elecstate/fp_energy.cpp

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,16 @@ namespace elecstate
1515
/// @brief calculate etot
1616
double fenergy::calculate_etot()
1717
{
18-
if (PARAM.inp.use_paw)
19-
{
20-
etot = eband + deband + etxc + ewald_energy - hartree_energy + demet + descf + exx + efield + gatefield + evdw
21-
+ esol_el + esol_cav + edftu + edeepks_scf;
22-
}
23-
else
24-
{
25-
etot = eband + deband + (etxc - etxcc) + ewald_energy + hartree_energy + demet + descf + exx + efield
26-
+ gatefield + evdw + esol_el + esol_cav + edftu + edeepks_scf + escon;
27-
}
18+
etot = eband + deband + (etxc - etxcc) + ewald_energy + hartree_energy + demet + descf + exx + efield
19+
+ gatefield + evdw + esol_el + esol_cav + edftu + edeepks_scf + escon;
2820
return etot;
2921
}
3022

3123
/// @brief calculate etot_harris
3224
double fenergy::calculate_harris()
3325
{
34-
if (PARAM.inp.use_paw)
35-
{
36-
etot_harris = eband + deband_harris + etxc + ewald_energy - hartree_energy + demet + descf + exx + efield
37-
+ gatefield + evdw + esol_el + esol_cav + edftu + edeepks_scf;
38-
}
39-
else
40-
{
41-
etot_harris = eband + deband_harris + (etxc - etxcc) + ewald_energy + hartree_energy + demet + descf + exx
42-
+ efield + gatefield + evdw + esol_el + esol_cav + edftu + edeepks_scf + escon;
43-
}
26+
etot_harris = eband + deband_harris + (etxc - etxcc) + ewald_energy + hartree_energy + demet + descf + exx
27+
+ efield + gatefield + evdw + esol_el + esol_cav + edftu + edeepks_scf + escon;
4428
return etot_harris;
4529
}
4630

source/module_elecstate/module_charge/charge.cpp

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,6 @@ void Charge::destroy()
5757
{
5858
if (allocate_rho || allocate_rho_final_scf) // LiuXh add 20180619
5959
{
60-
for (int i = 0; i < PARAM.inp.nspin; i++)
61-
{
62-
if(PARAM.inp.use_paw)
63-
{
64-
delete[] nhat[i];
65-
delete[] nhat_save[i];
66-
}
67-
}
6860
delete[] rho;
6961
delete[] rhog;
7062
delete[] rho_save;
@@ -82,11 +74,6 @@ void Charge::destroy()
8274
delete[] kin_r;
8375
delete[] kin_r_save;
8476
}
85-
if(PARAM.inp.use_paw)
86-
{
87-
delete[] nhat;
88-
delete[] nhat_save;
89-
}
9077
}
9178
}
9279

@@ -132,12 +119,6 @@ void Charge::allocate(const int& nspin_in)
132119
kin_r = new double*[nspin];
133120
kin_r_save = new double*[nspin];
134121
}
135-
if(PARAM.inp.use_paw)
136-
{
137-
nhat = new double*[nspin];
138-
nhat_save = new double*[nspin];
139-
}
140-
141122
for (int is = 0; is < nspin; is++)
142123
{
143124
rho[is] = _space_rho + is * nrxx;
@@ -155,13 +136,6 @@ void Charge::allocate(const int& nspin_in)
155136
kin_r_save[is] = _space_kin_r_save + is * nrxx;
156137
ModuleBase::GlobalFunc::ZEROS(kin_r_save[is], nrxx);
157138
}
158-
if(PARAM.inp.use_paw)
159-
{
160-
nhat[is] = new double[nrxx];
161-
ModuleBase::GlobalFunc::ZEROS(nhat[is], nrxx);
162-
nhat_save[is] = new double[nrxx];
163-
ModuleBase::GlobalFunc::ZEROS(nhat_save[is], nrxx);
164-
}
165139
}
166140

167141
ModuleBase::Memory::record("Chg::rho", sizeof(double) * nspin * nrxx);
@@ -173,11 +147,6 @@ void Charge::allocate(const int& nspin_in)
173147
ModuleBase::Memory::record("Chg::kin_r", sizeof(double) * nspin * ngmc);
174148
ModuleBase::Memory::record("Chg::kin_r_save", sizeof(double) * nspin * ngmc);
175149
}
176-
if(PARAM.inp.use_paw)
177-
{
178-
ModuleBase::Memory::record("Chg::nhat", sizeof(double) * nspin * ngmc);
179-
ModuleBase::Memory::record("Chg::nhat_save", sizeof(double) * nspin * ngmc);
180-
}
181150

182151
this->rho_core = new double[nrxx]; // core charge in real space
183152
ModuleBase::GlobalFunc::ZEROS(rho_core, nrxx);
@@ -203,14 +172,7 @@ double Charge::sum_rho() const
203172
{
204173
for (int ir = 0; ir < nrxx; ir++)
205174
{
206-
if(PARAM.inp.use_paw)
207-
{
208-
sum_rho += this->rho[is][ir] + this->nhat[is][ir];
209-
}
210-
else
211-
{
212-
sum_rho += this->rho[is][ir];
213-
}
175+
sum_rho += this->rho[is][ir];
214176
}
215177
}
216178

source/module_elecstate/module_pot/H_Hartree_pw.cpp

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -103,30 +103,7 @@ PotHartree::PotHartree(const ModulePW::PW_Basis* rho_basis_in)
103103

104104
void PotHartree::cal_v_eff(const Charge*const chg, const UnitCell*const ucell, ModuleBase::matrix& v_eff)
105105
{
106-
if(PARAM.inp.use_paw)
107-
{
108-
double ** rho_tmp;
109-
rho_tmp = new double*[chg->nspin];
110-
for(int is = 0; is < chg->nspin; is++)
111-
{
112-
rho_tmp[is] = new double[rho_basis_->nrxx];
113-
for(int ir = 0; ir < rho_basis_->nrxx; ir++)
114-
{
115-
rho_tmp[is][ir] = chg->rho[is][ir] + chg->nhat[is][ir];
116-
}
117-
}
118-
v_eff += H_Hartree_pw::v_hartree(*ucell, const_cast<ModulePW::PW_Basis*>(this->rho_basis_), v_eff.nr, rho_tmp);
119-
120-
for(int is = 0; is < chg->nspin; is++)
121-
{
122-
delete[] rho_tmp[is];
123-
}
124-
delete[] rho_tmp;
125-
}
126-
else
127-
{
128-
v_eff += H_Hartree_pw::v_hartree(*ucell, const_cast<ModulePW::PW_Basis*>(this->rho_basis_), v_eff.nr, chg->rho);
129-
}
106+
v_eff += H_Hartree_pw::v_hartree(*ucell, const_cast<ModulePW::PW_Basis*>(this->rho_basis_), v_eff.nr, chg->rho);
130107
return;
131108
}
132109

source/module_elecstate/module_pot/potential_new.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,6 @@ void Potential::allocate()
112112
this->veff_smooth.create(PARAM.inp.nspin, nrxx_smooth);
113113
ModuleBase::Memory::record("Pot::veff_smooth", sizeof(double) * PARAM.inp.nspin * nrxx_smooth);
114114

115-
if(PARAM.inp.use_paw)
116-
{
117-
this->v_xc.create(PARAM.inp.nspin, nrxx);
118-
ModuleBase::Memory::record("Pot::vxc", sizeof(double) * PARAM.inp.nspin * nrxx);
119-
}
120-
121115
if (XC_Functional::get_ked_flag())
122116
{
123117
this->vofk_effective.create(PARAM.inp.nspin, nrxx);

0 commit comments

Comments
 (0)