Skip to content

Commit aef0c12

Browse files
committed
clean esolver_ks_lcao
1 parent 4d2cf41 commit aef0c12

File tree

5 files changed

+17
-36
lines changed

5 files changed

+17
-36
lines changed

source/source_esolver/esolver_ks_lcao.cpp

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,7 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
211211
// 12) init_scf, should be before_scf? mohan add 2025-03-10
212212
this->pelec->init_scf(istep, ucell, this->Pgrid, this->sf.strucFac, this->locpp.numeric, ucell.symm);
213213

214-
// 13) initalize DMR
215-
// DMR should be same size with Hamiltonian(R)
214+
// 13) initalize DM(R), which has the same size with Hamiltonian(R)
216215
auto* hamilt_lcao = dynamic_cast<hamilt::HamiltLCAO<TK, TR>*>(this->p_hamilt);
217216
if(!hamilt_lcao)
218217
{
@@ -221,7 +220,7 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
221220
this->dmat.dm->init_DMR(*hamilt_lcao->getHR());
222221

223222
#ifdef __MLALGO
224-
// 14) initialize DMR of DeePKS
223+
// 14) initialize DM2(R) of DeePKS, the DM2(R) is different from DM(R)
225224
this->deepks.ld.init_DMR(ucell, orb_, this->pv, this->gd);
226225
#endif
227226

@@ -257,8 +256,6 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
257256
template <typename TK, typename TR>
258257
double ESolver_KS_LCAO<TK, TR>::cal_energy()
259258
{
260-
ModuleBase::TITLE("ESolver_KS_LCAO", "cal_energy");
261-
262259
return this->pelec->f_en.etot;
263260
}
264261

@@ -294,15 +291,13 @@ void ESolver_KS_LCAO<TK, TR>::cal_stress(UnitCell& ucell, ModuleBase::matrix& st
294291
ModuleBase::TITLE("ESolver_KS_LCAO", "cal_stress");
295292
ModuleBase::timer::tick("ESolver_KS_LCAO", "cal_stress");
296293

297-
// if the users do not want to calculate forces but want stress,
298-
// we call cal_force
299294
if (!this->have_force)
300295
{
301296
ModuleBase::matrix fcs;
302297
this->cal_force(ucell, fcs);
303298
}
304299

305-
// the 'scs' stress has already been calculated in 'cal_force'
300+
// the stress has been calculated in 'cal_force'
306301
stress = this->scs;
307302
this->have_force = false;
308303

@@ -319,21 +314,14 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
319314

320315
const int nspin0 = (PARAM.inp.nspin == 2) ? 2 : 1;
321316

322-
auto* estate = dynamic_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec);
323317
auto* hamilt_lcao = dynamic_cast<hamilt::HamiltLCAO<TK, TR>*>(this->p_hamilt);
324-
325-
if(!estate)
326-
{
327-
ModuleBase::WARNING_QUIT("ESolver_KS_LCAO::after_all_runners","pelec does not exist");
328-
}
329-
330318
if(!hamilt_lcao)
331319
{
332320
ModuleBase::WARNING_QUIT("ESolver_KS_LCAO::after_all_runners","p_hamilt does not exist");
333321
}
334322

335323
ModuleIO::ctrl_runner_lcao<TK, TR>(ucell,
336-
PARAM.inp, this->kv, estate, this->dmat, this->pv, this->Pgrid,
324+
PARAM.inp, this->kv, this->pelec, this->dmat, this->pv, this->Pgrid,
337325
this->gd, this->psi, this->chr, hamilt_lcao,
338326
this->two_center_bundle_,
339327
this->orb_, this->pw_rho, this->pw_rhod,
@@ -350,17 +338,10 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(UnitCell& ucell, const int istep, const
350338
// call iter_init() of ESolver_KS
351339
ESolver_KS<TK>::iter_init(ucell, istep, iter);
352340

353-
// cast pointers
354-
auto* estate = dynamic_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec);
355-
if(!estate)
356-
{
357-
ModuleBase::WARNING_QUIT("ESolver_KS_LCAO::iter_init","pelec does not exist");
358-
}
359-
360341
module_charge::chgmixing_ks_lcao(iter, this->p_chgmix, this->dmat.dm->get_DMR_pointer(1)->get_nnr(), PARAM.inp);
361342

362343
// mohan update 2012-06-05
363-
estate->f_en.deband_harris = estate->cal_delta_eband(ucell);
344+
this->pelec->f_en.deband_harris = this->pelec->cal_delta_eband(ucell);
364345

365346
if (istep == 0 && PARAM.inp.init_wfc == "file")
366347
{
@@ -374,7 +355,7 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(UnitCell& ucell, const int istep, const
374355
this->exx_nao.exd->two_level_step : this->exx_nao.exc->two_level_step;
375356
}
376357
#endif
377-
elecstate::init_dm<TK>(ucell, estate, this->dmat, this->psi, this->chr, iter, exx_two_level_step);
358+
elecstate::init_dm<TK>(ucell, this->pelec, this->dmat, this->psi, this->chr, iter, exx_two_level_step);
378359
}
379360

380361
#ifdef __EXX

source/source_estate/module_dm/init_dm.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
template <typename TK>
77
void elecstate::init_dm(UnitCell& ucell,
8-
elecstate::ElecStateLCAO<TK>* pelec,
8+
elecstate::ElecState* pelec,
99
LCAO_domain::Setup_DM<TK> &dmat,
1010
psi::Psi<TK>* psi,
1111
Charge &chr,
@@ -51,15 +51,15 @@ void elecstate::init_dm(UnitCell& ucell,
5151

5252

5353
template void elecstate::init_dm<double>(UnitCell& ucell,
54-
elecstate::ElecStateLCAO<double>* pelec,
54+
elecstate::ElecState* pelec,
5555
LCAO_domain::Setup_DM<double> &dmat,
5656
psi::Psi<double>* psi,
5757
Charge &chr,
5858
const int iter,
5959
const int exx_two_level_step);
6060

6161
template void elecstate::init_dm<std::complex<double>>(UnitCell& ucell,
62-
elecstate::ElecStateLCAO<std::complex<double>>* pelec,
62+
elecstate::ElecState* pelec,
6363
LCAO_domain::Setup_DM<std::complex<double>> &dmat,
6464
psi::Psi<std::complex<double>>* psi,
6565
Charge &chr,

source/source_estate/module_dm/init_dm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define INIT_DM_H
33

44
#include "source_cell/unitcell.h" // use unitcell
5-
#include "source_estate/elecstate_lcao.h"// use ElecStateLCAO
5+
#include "source_estate/elecstate.h"// use ElecState
66
#include "source_psi/psi.h" // use electronic wave functions
77
#include "source_estate/module_charge/charge.h" // use charge
88
#include "source_lcao/setup_dm.h" // define Setup_DM
@@ -12,7 +12,7 @@ namespace elecstate
1212

1313
template <typename TK>
1414
void init_dm(UnitCell& ucell,
15-
ElecStateLCAO<TK>* pelec,
15+
ElecState* pelec,
1616
LCAO_domain::Setup_DM<TK> &dmat,
1717
psi::Psi<TK>* psi,
1818
Charge &chr,

source/source_io/ctrl_runner_lcao.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ template <typename TK, typename TR>
1616
void ctrl_runner_lcao(UnitCell& ucell, // unitcell
1717
const Input_para &inp, // input
1818
K_Vectors &kv, // k-point
19-
elecstate::ElecStateLCAO<TK>* pelec,// electronic info
19+
elecstate::ElecState* pelec,// electronic info
2020
const LCAO_domain::Setup_DM<TK> &dmat, // mohan add 2025-11-02
2121
Parallel_Orbitals &pv, // orbital info
2222
Parallel_Grid &pgrid, // grid info
@@ -136,7 +136,7 @@ void ctrl_runner_lcao(UnitCell& ucell, // unitcell
136136
template void ModuleIO::ctrl_runner_lcao<double, double>(UnitCell& ucell, // unitcell
137137
const Input_para &inp, // input
138138
K_Vectors &kv, // k-point
139-
elecstate::ElecStateLCAO<double>* pelec,// electronic info
139+
elecstate::ElecState* pelec,// electronic info
140140
const LCAO_domain::Setup_DM<double> &dmat, // mohan add 2025-11-02
141141
Parallel_Orbitals &pv, // orbital info
142142
Parallel_Grid &pgrid, // grid info
@@ -157,7 +157,7 @@ template void ModuleIO::ctrl_runner_lcao<double, double>(UnitCell& ucell, /
157157
template void ctrl_runner_lcao<std::complex<double>, double>(UnitCell& ucell, // unitcell
158158
const Input_para &inp, // input
159159
K_Vectors &kv, // k-point
160-
elecstate::ElecStateLCAO<std::complex<double>>* pelec,// electronic info
160+
elecstate::ElecState* pelec,// electronic info
161161
const LCAO_domain::Setup_DM<std::complex<double>> &dmat, // mohan add 2025-11-02
162162
Parallel_Orbitals &pv, // orbital info
163163
Parallel_Grid &pgrid, // grid info
@@ -178,7 +178,7 @@ template void ctrl_runner_lcao<std::complex<double>, double>(UnitCell& ucell,
178178
template void ctrl_runner_lcao<std::complex<double>, std::complex<double>>(UnitCell& ucell, // unitcell
179179
const Input_para &inp, // input
180180
K_Vectors &kv, // k-point
181-
elecstate::ElecStateLCAO<std::complex<double>>* pelec,// electronic info
181+
elecstate::ElecState* pelec,// electronic info
182182
const LCAO_domain::Setup_DM<std::complex<double>> &dmat, // mohan add 2025-11-02
183183
Parallel_Orbitals &pv, // orbital info
184184
Parallel_Grid &pgrid, // grid info

source/source_io/ctrl_runner_lcao.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "source_cell/unitcell.h" // use UnitCell
55
#include "source_cell/klist.h" // use K_Vectors
6-
#include "source_estate/elecstate_lcao.h" // use elecstate::ElecStateLCAO<TK>
6+
#include "source_estate/elecstate.h" // use elecstate::ElecStateLCAO<TK>
77
#include "source_psi/psi.h" // use Psi<TK>
88
#include "source_lcao/hamilt_lcao.h" // use hamilt::HamiltLCAO<TK, TR>
99
#include "source_basis/module_nao/two_center_bundle.h" // use TwoCenterBundle
@@ -17,7 +17,7 @@ template <typename TK, typename TR>
1717
void ctrl_runner_lcao(UnitCell& ucell, // unitcell
1818
const Input_para &inp, // input
1919
K_Vectors &kv, // k-point
20-
elecstate::ElecStateLCAO<TK>* pelec,// electronic info
20+
elecstate::ElecState* pelec,// electronic info
2121
const LCAO_domain::Setup_DM<TK> &dmat, // mohan add 2025-11-02
2222
Parallel_Orbitals &pv, // orbital info
2323
Parallel_Grid &pgrid, // grid info

0 commit comments

Comments
 (0)