Skip to content

Commit c341a0f

Browse files
author
abacus_fixer
committed
clean exx_info_
1 parent b06e263 commit c341a0f

8 files changed

Lines changed: 41 additions & 44 deletions

File tree

source/source_esolver/esolver_double_xc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void ESolver_DoubleXC<TK, TR>::before_scf(UnitCell& ucell, const int istep)
152152
this->deepks,
153153
istep,
154154
this->exx_nao,
155-
*this->exx_info_);
155+
this->exx_info_);
156156
}
157157

158158
XC_Functional::set_xc_type(PARAM.inp.deepks_out_base);
@@ -417,7 +417,7 @@ void ESolver_DoubleXC<TK, TR>::cal_force(BaseCell& basecell, ModuleBase::matrix&
417417
this->deepks,
418418
this->exx_nao,
419419
&ucell.symm,
420-
*this->exx_info_);
420+
this->exx_info_);
421421

422422
// restore to original xc
423423
XC_Functional::set_xc_type(ucell.atoms[0].ncpp.xc_func);

source/source_esolver/esolver_ks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void ESolver_KS::before_all_runners(BaseCell& basecell, const Input_para& inp)
4747
ESolver_FP::before_all_runners(ucell, inp);
4848

4949
//! 2) initialize Exx_Info from input parameters
50-
init_exx_info(exx_info_obj_, inp);
50+
init_exx_info(exx_info_, inp);
5151

5252
//! 3) setup some parameters
5353
classname = "ESolver_KS";

source/source_esolver/esolver_ks.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ class ESolver_KS : public ESolver_FP
7676
bool scf_nmax_flag = false; // whether scf has reached nmax, mohan add 20250921
7777

7878
/// EXX info owned by ESolver, initialized from input parameters.
79-
Exx_Info exx_info_obj_;
80-
81-
/// Pointer to the owned Exx_Info object, for uniform access pattern.
82-
Exx_Info* exx_info_ = &exx_info_obj_;
79+
Exx_Info exx_info_;
8380
};
8481
} // namespace ModuleESolver
8582
#endif

source/source_esolver/esolver_ks_lcao.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(BaseCell& basecell, const Input
5555
ModuleBase::TITLE("ESolver_KS_LCAO", "before_all_runners");
5656
ModuleBase::timer::start("ESolver_KS_LCAO", "before_all_runners");
5757

58-
// 0) init EXX - moved from constructor to ensure exx_info_->info_global is already set
59-
this->exx_nao.init(ucell, *this->exx_info_);
58+
// 0) init EXX - moved from constructor to ensure exx_info_.info_global is already set
59+
this->exx_nao.init(ucell, this->exx_info_);
6060

6161
// 1) before_all_runners in ESolver_KS
6262
ESolver_KS::before_all_runners(ucell, inp);
@@ -78,7 +78,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(BaseCell& basecell, const Input
7878
{
7979
#ifdef __EXX
8080
Exx_Opt_Orb exx_opt_orb;
81-
exx_opt_orb.generate_matrix(exx_info_->info_opt_abfs, this->kv, ucell, this->orb_);
81+
exx_opt_orb.generate_matrix(exx_info_.info_opt_abfs, this->kv, ucell, this->orb_);
8282
#else
8383
ModuleBase::WARNING_QUIT("ESolver_KS_LCAO::before_all_runners", "calculation=gen_opt_abfs must compile __EXX");
8484
#endif
@@ -90,7 +90,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(BaseCell& basecell, const Input
9090

9191
LCAO_domain::set_pot<TK>(ucell, this->kv, this->sf, *this->pw_rho, *this->pw_rhod,
9292
this->pelec, this->orb_, this->pv, this->locpp, this->dftu,
93-
this->solvent, this->exx_nao, this->deepks, inp, *this->exx_info_);
93+
this->solvent, this->exx_nao, this->deepks, inp, this->exx_info_);
9494

9595
//! if kpar is not divisible by nks, print a warning
9696
ModuleIO::print_kpar(this->kv.get_nks(), PARAM.globalv.kpar_lcao);
@@ -100,7 +100,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(BaseCell& basecell, const Input
100100
{
101101
rdmft_solver.init(this->pv, ucell,
102102
this->gd, this->kv, *(this->pelec), this->orb_,
103-
two_center_bundle_, inp.dft_functional, inp.rdmft_power_alpha, *this->exx_info_);
103+
two_center_bundle_, inp.dft_functional, inp.rdmft_power_alpha, this->exx_info_);
104104
}
105105

106106
ModuleBase::timer::end("ESolver_KS_LCAO", "before_all_runners");
@@ -153,7 +153,7 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
153153
{
154154
this->p_hamilt = new hamilt::HamiltLCAO<TK, TR>(
155155
ucell, this->gd, &this->pv, this->pelec->pot, this->kv,
156-
two_center_bundle_, orb_, this->dmat.dm, &this->dftu, this->deepks, istep, exx_nao, *this->exx_info_);
156+
two_center_bundle_, orb_, this->dmat.dm, &this->dftu, this->deepks, istep, exx_nao, this->exx_info_);
157157
}
158158

159159
// 9) for each ionic step, the overlap <phi|alpha> must be rebuilt
@@ -170,7 +170,7 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
170170
init_deltaspin_lcao<TK>(ucell, PARAM.inp, &(this->pv), this->kv, this->p_hamilt, this->psi, this->dmat.dm, this->pelec);
171171

172172
// 11) set xc type before the first cal of xc in pelec->init_scf, Peize Lin add 2016-12-03
173-
this->exx_nao.before_scf(ucell, this->kv, orb_, this->p_chgmix, istep, PARAM.inp, *this->exx_info_);
173+
this->exx_nao.before_scf(ucell, this->kv, orb_, this->p_chgmix, istep, PARAM.inp, this->exx_info_);
174174

175175
// 12) initalize DM(R), which has the same size with Hamiltonian(R)
176176
auto* hamilt_lcao = dynamic_cast<hamilt::HamiltLCAO<TK, TR>*>(this->p_hamilt);
@@ -254,7 +254,7 @@ void ESolver_KS_LCAO<TK, TR>::cal_force(BaseCell& basecell, ModuleBase::matrix&
254254
two_center_bundle_, orb_, force, this->scs,
255255
this->locpp, this->sf, this->kv,
256256
this->pw_rho, this->solvent, this->dftu, this->deepks,
257-
this->exx_nao, &ucell.symm, *this->exx_info_, PARAM.inp.td_stype,
257+
this->exx_nao, &ucell.symm, this->exx_info_, PARAM.inp.td_stype,
258258
static_cast<hamilt::Hamilt<TK>*>(this->p_hamilt));
259259

260260
// delete RA after cal_force
@@ -309,7 +309,7 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(BaseCell& basecell)
309309
this->gd, this->psi, this->chr, hamilt_lcao,
310310
this->two_center_bundle_,
311311
this->orb_, this->pw_rho, this->pw_rhod,
312-
this->sf, this->locpp.vloc, this->exx_nao, *this->exx_info_, this->solvent);
312+
this->sf, this->locpp.vloc, this->exx_nao, this->exx_info_, this->solvent);
313313

314314

315315
#ifdef __MPI
@@ -358,11 +358,11 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(UnitCell& ucell, const int istep, const
358358
{
359359
int exx_two_level_step = 0;
360360
#ifdef __EXX
361-
if (exx_info_->info_global.cal_exx)
361+
if (exx_info_.info_global.cal_exx)
362362
{
363363
// the following steps are only needed in the first outer exx loop
364364
exx_two_level_step
365-
= exx_info_->info_ri.real_number ?
365+
= exx_info_.info_ri.real_number ?
366366
this->exx_nao.exd->two_level_step : this->exx_nao.exc->two_level_step;
367367
}
368368
#endif
@@ -373,7 +373,7 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(UnitCell& ucell, const int istep, const
373373
// calculate exact-exchange
374374
if (PARAM.inp.calculation != "nscf")
375375
{
376-
if (exx_info_->info_ri.real_number)
376+
if (exx_info_.info_ri.real_number)
377377
{
378378
this->exx_nao.exd->exx_eachiterinit(istep, ucell, *this->dmat.dm, this->kv, iter);
379379
}
@@ -467,7 +467,7 @@ void ESolver_KS_LCAO<TK, TR>::hamilt2rho_single(UnitCell& ucell, int istep, int
467467
#ifdef __EXX
468468
if (PARAM.inp.calculation != "nscf")
469469
{
470-
if (exx_info_->info_ri.real_number)
470+
if (exx_info_.info_ri.real_number)
471471
{
472472
this->exx_nao.exd->exx_hamilt2rho(*this->pelec, this->pv, iter);
473473
}
@@ -537,7 +537,7 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(UnitCell& ucell, const int istep, int&
537537
ModuleIO::ctrl_iter_lcao<TK, TR>(ucell, PARAM.inp, this->kv, this->pelec, *this->dmat.dm,
538538
this->pv, this->gd, this->psi, this->chr, this->p_chgmix,
539539
hamilt_lcao, this->orb_, this->deepks,
540-
this->exx_nao, *this->exx_info_, iter, istep, conv_esolver, this->scf_ene_thr);
540+
this->exx_nao, this->exx_info_, iter, istep, conv_esolver, this->scf_ene_thr);
541541
}
542542

543543
template <typename TK, typename TR>
@@ -567,7 +567,7 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep, const
567567
this->gd, this->psi, hamilt_lcao, this->dftu, this->two_center_bundle_,
568568
this->orb_, this->pw_wfc, this->pw_rho, this->pw_big, this->sf,
569569
this->pw_rhod, this->locpp.vloc, this->solvent,
570-
this->rdmft_solver, this->deepks, this->exx_nao, *this->exx_info_,
570+
this->rdmft_solver, this->deepks, this->exx_nao, this->exx_info_,
571571
this->conv_esolver, this->scf_nmax_flag, istep);
572572

573573
//! 3) Clean up RA, which is used to serach for adjacent atoms

source/source_esolver/esolver_ks_lcao_tddft.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ void ESolver_KS_LCAO_TDDFT<TR, Device>::runner(BaseCell& basecell, const int ist
203203
{
204204
this->CE.update_all_dis(ucell);
205205
this->CE.extrapolate_charge(&this->Pgrid, ucell, &this->chr, &this->sf, GlobalV::ofs_running, GlobalV::ofs_warning);
206-
this->exx_nao.before_scf(ucell, this->kv, this->orb_, this->p_chgmix, totstep, PARAM.inp, *this->exx_info_);
206+
this->exx_nao.before_scf(ucell, this->kv, this->orb_, this->p_chgmix, totstep, PARAM.inp, this->exx_info_);
207207
elecstate::init_scf(ucell,
208208
this->Pgrid,
209209
this->sf.strucFac,
@@ -378,7 +378,7 @@ void ESolver_KS_LCAO_TDDFT<TR, Device>::hamilt2rho_single(UnitCell& ucell, const
378378
Symmetry_rho::symmetrize_rho(PARAM.inp.nspin, this->chr, this->pw_rho, ucell.symm);
379379
}
380380
#ifdef __EXX
381-
if (this->exx_info_->info_ri.real_number)
381+
if (this->exx_info_.info_ri.real_number)
382382
this->exx_nao.exd->exx_hamilt2rho(*this->pelec, this->pv, iter);
383383
else
384384
this->exx_nao.exc->exx_hamilt2rho(*this->pelec, this->pv, iter);
@@ -581,7 +581,7 @@ void ESolver_KS_LCAO_TDDFT<TR, Device>::after_scf(UnitCell& ucell, const int ist
581581
this->RA,
582582
this->td_p,
583583
this->exx_nao,
584-
*this->exx_info_);
584+
this->exx_info_);
585585

586586
ModuleBase::timer::end(this->classname, "after_scf");
587587
}

source/source_esolver/esolver_ks_lcaopw.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ namespace ModuleESolver
8888
if (inp.calculation == "scf" || inp.calculation == "relax"
8989
|| inp.calculation == "cell-relax"
9090
|| inp.calculation == "md") {
91-
if (this->exx_info_->info_global.cal_exx)
91+
if (this->exx_info_.info_global.cal_exx)
9292
{
9393
XC_Functional::set_xc_first_loop(ucell);
94-
this->exx_lip = std::unique_ptr<Exx_Lip<T>>(new Exx_Lip<T>(this->exx_info_->info_lip,
94+
this->exx_lip = std::unique_ptr<Exx_Lip<T>>(new Exx_Lip<T>(this->exx_info_.info_lip,
9595
&this->kv,
9696
this->psi_local,
9797
this->stp.template get_psi_t<T, base_device::DEVICE_CPU>(),
@@ -109,7 +109,7 @@ namespace ModuleESolver
109109
{
110110
ESolver_KS_PW<T>::iter_init(ucell, istep, iter);
111111
#ifdef __EXX
112-
if (this->exx_info_->info_global.cal_exx && !this->exx_info_->info_global.separate_loop && this->two_level_step) {
112+
if (this->exx_info_.info_global.cal_exx && !this->exx_info_.info_global.separate_loop && this->two_level_step) {
113113
this->exx_lip->cal_exx();
114114
}
115115
#endif
@@ -138,12 +138,12 @@ namespace ModuleESolver
138138
PARAM.inp.basis_type,
139139
PARAM.inp.calculation);
140140
hsolver_lip_obj.solve(static_cast<hamilt::Hamilt<T>*>(this->p_hamilt), *this->stp.template get_psi_t<T, base_device::DEVICE_CPU>(), this->pelec,
141-
*this->psi_local, skip_charge,ucell.tpiba,ucell.nat, *this->exx_info_);
141+
*this->psi_local, skip_charge,ucell.tpiba,ucell.nat, this->exx_info_);
142142

143143
// add exx
144144
#ifdef __EXX
145-
bool cal_exx = this->exx_info_->info_global.cal_exx;
146-
double hybrid_alpha = this->exx_info_->info_global.hybrid_alpha;
145+
bool cal_exx = this->exx_info_.info_global.cal_exx;
146+
double hybrid_alpha = this->exx_info_.info_global.hybrid_alpha;
147147
if (cal_exx)
148148
{
149149
this->pelec->set_exx(this->exx_lip->get_exx_energy(), cal_exx, hybrid_alpha); // Peize Lin add 2019-03-09
@@ -166,12 +166,12 @@ namespace ModuleESolver
166166
ESolver_KS_PW<T>::iter_finish(ucell, istep, iter, conv_esolver);
167167

168168
#ifdef __EXX
169-
if (this->exx_info_->info_global.cal_exx && conv_esolver)
169+
if (this->exx_info_.info_global.cal_exx && conv_esolver)
170170
{
171171
// no separate_loop case
172-
if (!this->exx_info_->info_global.separate_loop)
172+
if (!this->exx_info_.info_global.separate_loop)
173173
{
174-
this->exx_info_->info_global.hybrid_step = 1;
174+
this->exx_info_.info_global.hybrid_step = 1;
175175

176176
// in no_separate_loop case, scf loop only did twice
177177
// in first scf loop, exx updated once in beginning,
@@ -189,7 +189,7 @@ namespace ModuleESolver
189189
}
190190
// has separate_loop case
191191
// exx converged or get max exx steps
192-
else if (this->two_level_step == this->exx_info_->info_global.hybrid_step
192+
else if (this->two_level_step == this->exx_info_.info_global.hybrid_step
193193
|| (iter == 1 && this->two_level_step != 0))
194194
{
195195
conv_esolver = true;
@@ -233,8 +233,8 @@ namespace ModuleESolver
233233
if (PARAM.inp.out_mat_xc)
234234
{
235235
#ifdef __EXX
236-
bool cal_exx = this->exx_info_->info_global.cal_exx;
237-
double hybrid_alpha = this->exx_info_->info_global.hybrid_alpha;
236+
bool cal_exx = this->exx_info_.info_global.cal_exx;
237+
double hybrid_alpha = this->exx_info_.info_global.hybrid_alpha;
238238
#else
239239
bool cal_exx = false;
240240
double hybrid_alpha = 0.0;

source/source_esolver/esolver_ks_pw.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void ESolver_KS_PW<T, Device>::allocate_hamilt(const UnitCell& ucell)
6666
&this->ppcell,
6767
&this->dftu,
6868
&ucell,
69-
this->exx_info_);
69+
&this->exx_info_);
7070
}
7171

7272
template <typename T, typename Device>
@@ -127,7 +127,7 @@ void ESolver_KS_PW<T, Device>::before_all_runners(BaseCell& basecell, const Inpu
127127
}
128128

129129
//! Initialize exx pw
130-
this->exx_helper->init(ucell, inp, this->pelec->wg, *this->exx_info_);
130+
this->exx_helper->init(ucell, inp, this->pelec->wg, this->exx_info_);
131131
}
132132

133133
template <typename T, typename Device>
@@ -183,7 +183,7 @@ void ESolver_KS_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)
183183
this->stp.init(this->p_hamilt);
184184

185185
//! Setup EXX helper for Hamiltonian and psi
186-
exx_helper->before_scf(this->p_hamilt, this->stp.template get_psi_t<T, Device>(), PARAM.inp, *this->exx_info_);
186+
exx_helper->before_scf(this->p_hamilt, this->stp.template get_psi_t<T, Device>(), PARAM.inp, this->exx_info_);
187187

188188
ModuleBase::timer::end("ESolver_KS_PW", "before_scf");
189189
}
@@ -269,8 +269,8 @@ template <typename T, typename Device>
269269
void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int& iter, bool& conv_esolver)
270270
{
271271
// Related to EXX
272-
bool cal_exx = exx_info_->info_global.cal_exx;
273-
double hybrid_alpha = exx_info_->info_global.hybrid_alpha;
272+
bool cal_exx = exx_info_.info_global.cal_exx;
273+
double hybrid_alpha = exx_info_.info_global.hybrid_alpha;
274274
if (cal_exx && !exx_helper->get_op_first_iter())
275275
{
276276
this->pelec->set_exx(exx_helper->cal_exx_energy(this->stp.template get_psi_t<T, Device>()),
@@ -398,7 +398,7 @@ void ESolver_KS_PW<T, Device>::cal_stress(BaseCell& basecell, ModuleBase::matrix
398398
&this->sf,
399399
&this->kv,
400400
this->pw_wfc,
401-
*this->exx_info_,
401+
this->exx_info_,
402402
this->stp.template get_psi_d<T, Device>());
403403

404404
// external stress

source/source_esolver/lcao_others.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ void ESolver_KS_LCAO<TK, TR>::others(BaseCell& basecell, const int istep)
140140
this->deepks,
141141
istep,
142142
this->exx_nao,
143-
*this->exx_info_);
143+
this->exx_info_);
144144
}
145145

146146
// for each ionic step, the overlap <phi|alpha> must be rebuilt

0 commit comments

Comments
 (0)