|
18 | 18 | #include "module_base/memory.h" |
19 | 19 | #include "module_base/module_device/device.h" |
20 | 20 | #include "module_elecstate/elecstate_pw.h" |
| 21 | +#include "module_elecstate/elecstate_pw_sdft.h" |
21 | 22 | #include "module_hamilt_general/module_vdw/vdw.h" |
22 | 23 | #include "module_hamilt_pw/hamilt_pwdft/elecond.h" |
23 | 24 | #include "module_hamilt_pw/hamilt_pwdft/hamilt_pw.h" |
@@ -136,14 +137,29 @@ void ESolver_KS_PW<T, Device>::before_all_runners(const Input_para& inp, UnitCel |
136 | 137 | // 3) initialize ElecState, |
137 | 138 | if (this->pelec == nullptr) |
138 | 139 | { |
139 | | - this->pelec = new elecstate::ElecStatePW<T, Device>(this->pw_wfc, |
140 | | - &(this->chr), |
141 | | - &(this->kv), |
142 | | - &ucell, |
143 | | - &GlobalC::ppcell, |
144 | | - this->pw_rhod, |
145 | | - this->pw_rho, |
146 | | - this->pw_big); |
| 140 | + if (inp.esolver_type == "sdft") |
| 141 | + { |
| 142 | + //! SDFT only supports double precision currently |
| 143 | + this->pelec = new elecstate::ElecStatePW_SDFT<std::complex<double>, Device>(this->pw_wfc, |
| 144 | + &(this->chr), |
| 145 | + &(this->kv), |
| 146 | + &ucell, |
| 147 | + &(GlobalC::ppcell), |
| 148 | + this->pw_rhod, |
| 149 | + this->pw_rho, |
| 150 | + this->pw_big); |
| 151 | + } |
| 152 | + else |
| 153 | + { |
| 154 | + this->pelec = new elecstate::ElecStatePW<T, Device>(this->pw_wfc, |
| 155 | + &(this->chr), |
| 156 | + &(this->kv), |
| 157 | + &ucell, |
| 158 | + &GlobalC::ppcell, |
| 159 | + this->pw_rhod, |
| 160 | + this->pw_rho, |
| 161 | + this->pw_big); |
| 162 | + } |
147 | 163 | } |
148 | 164 |
|
149 | 165 | //! 4) inititlize the charge density. |
@@ -180,8 +196,39 @@ void ESolver_KS_PW<T, Device>::before_all_runners(const Input_para& inp, UnitCel |
180 | 196 | #endif |
181 | 197 | &GlobalC::ppcell); |
182 | 198 |
|
183 | | - //! 8) setup global classes |
184 | | - this->Init_GlobalC(inp, ucell, GlobalC::ppcell); |
| 199 | + if (this->psi != nullptr) |
| 200 | + { |
| 201 | + delete this->psi; |
| 202 | + } |
| 203 | + |
| 204 | + //! init pseudopotential |
| 205 | + GlobalC::ppcell.init(ucell.ntype, &this->sf, this->pw_wfc); |
| 206 | + |
| 207 | + //! initalize local pseudopotential |
| 208 | + GlobalC::ppcell.init_vloc(GlobalC::ppcell.vloc, this->pw_rhod); |
| 209 | + ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "LOCAL POTENTIAL"); |
| 210 | + |
| 211 | + //! Initalize non-local pseudopotential |
| 212 | + GlobalC::ppcell.init_vnl(ucell, this->pw_rhod); |
| 213 | + ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "NON-LOCAL POTENTIAL"); |
| 214 | + |
| 215 | + //! Allocate psi |
| 216 | + this->p_wf_init->allocate_psi(this->psi, |
| 217 | + this->kv.get_nkstot(), |
| 218 | + this->kv.get_nks(), |
| 219 | + this->kv.ngk.data(), |
| 220 | + this->pw_wfc->npwk_max, |
| 221 | + &(this->sf)); |
| 222 | + |
| 223 | + this->kspw_psi = PARAM.inp.device == "gpu" || PARAM.inp.precision == "single" |
| 224 | + ? new psi::Psi<T, Device>(this->psi[0]) |
| 225 | + : reinterpret_cast<psi::Psi<T, Device>*>(this->psi); |
| 226 | + |
| 227 | + if (PARAM.inp.precision == "single") |
| 228 | + { |
| 229 | + ModuleBase::Memory::record("Psi_single", sizeof(T) * this->psi[0].size()); |
| 230 | + } |
| 231 | + ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT BASIS"); |
185 | 232 |
|
186 | 233 | //! 9) setup occupations |
187 | 234 | if (PARAM.inp.ocp) |
|
0 commit comments