Skip to content

Commit 4070dd0

Browse files
committed
fix bug about p_hamilt and fix setup_exx
1 parent 8adda0c commit 4070dd0

File tree

14 files changed

+84
-62
lines changed

14 files changed

+84
-62
lines changed

examples/relax/lcao_output/INPUT

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,3 @@ out_band 0
4040
out_stru 0
4141
out_app_flag 0
4242

43-
out_interval 1

source/source_esolver/esolver_double_xc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ void ESolver_DoubleXC<TK, TR>::before_scf(UnitCell& ucell, const int istep)
162162
#ifdef __EXX
163163
,
164164
istep,
165-
GlobalC::exx_info.info_ri.real_number ? &this->exd->two_level_step : &this->exc->two_level_step,
166-
GlobalC::exx_info.info_ri.real_number ? &this->exd->get_Hexxs() : nullptr,
167-
GlobalC::exx_info.info_ri.real_number ? nullptr : &this->exc->get_Hexxs()
165+
GlobalC::exx_info.info_ri.real_number ? &this->exx_nao.exd->two_level_step : &this->exx_nao.exc->two_level_step,
166+
GlobalC::exx_info.info_ri.real_number ? &this->exx_nao.exd->get_Hexxs() : nullptr,
167+
GlobalC::exx_info.info_ri.real_number ? nullptr : &this->exx_nao.exc->get_Hexxs()
168168
#endif
169169
);
170170
}

source/source_esolver/esolver_ks_lcao.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
122122
dynamic_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec)->init_DM(&this->kv, &(this->pv), inp.nspin);
123123

124124
// 8) init exact exchange calculations
125-
this->exx_nao.before_runner();
125+
this->exx_nao.before_runner(ucell, this->kv, this->orb_, this->pv, PARAM.inp);
126126

127127
// 9) initialize DFT+U
128128
if (inp.dft_plus_u)
@@ -307,8 +307,8 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
307307
this->orb_, this->pw_rho, this->pw_rhod,
308308
this->sf, this->locpp.vloc,
309309
#ifdef __EXX
310-
this->exd,
311-
this->exc,
310+
this->exx_nao.exd,
311+
this->exx_nao.exc,
312312
#endif
313313
this->solvent);
314314

@@ -347,7 +347,7 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(UnitCell& ucell, const int istep, const
347347
{
348348
// the following steps are only needed in the first outer exx loop
349349
exx_two_level_step
350-
= GlobalC::exx_info.info_ri.real_number ? this->exd->two_level_step : this->exc->two_level_step;
350+
= GlobalC::exx_info.info_ri.real_number ? this->exx_nao.exd->two_level_step : this->exx_nao.exc->two_level_step;
351351
}
352352
#endif
353353
// elecstate::setup_dm<TK>(ucell, estate, this->psi, this->chr, iter, exx_two_level_step);
@@ -395,11 +395,11 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(UnitCell& ucell, const int istep, const
395395
{
396396
if (GlobalC::exx_info.info_ri.real_number)
397397
{
398-
this->exd->exx_eachiterinit(istep, ucell, *dm, this->kv, iter);
398+
this->exx_nao.exd->exx_eachiterinit(istep, ucell, *dm, this->kv, iter);
399399
}
400400
else
401401
{
402-
this->exc->exx_eachiterinit(istep, ucell, *dm, this->kv, iter);
402+
this->exx_nao.exc->exx_eachiterinit(istep, ucell, *dm, this->kv, iter);
403403
}
404404
}
405405
#endif
@@ -486,11 +486,11 @@ void ESolver_KS_LCAO<TK, TR>::hamilt2rho_single(UnitCell& ucell, int istep, int
486486
{
487487
if (GlobalC::exx_info.info_ri.real_number)
488488
{
489-
this->exd->exx_hamilt2rho(*this->pelec, this->pv, iter);
489+
this->exx_nao.exd->exx_hamilt2rho(*this->pelec, this->pv, iter);
490490
}
491491
else
492492
{
493-
this->exc->exx_hamilt2rho(*this->pelec, this->pv, iter);
493+
this->exx_nao.exc->exx_hamilt2rho(*this->pelec, this->pv, iter);
494494
}
495495
}
496496
#endif
@@ -609,8 +609,8 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(UnitCell& ucell, const int istep, int&
609609
this->ld,
610610
#endif
611611
#ifdef __EXX
612-
*this->exd,
613-
*this->exc,
612+
*this->exx_nao.exd,
613+
*this->exx_nao.exc,
614614
#endif
615615
iter, istep, conv_esolver, this->scf_ene_thr);
616616

source/source_esolver/esolver_ks_lcao.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class ESolver_KS_LCAO : public ESolver_KS<TK>
103103
LCAO_Deepks<TK> ld;
104104
#endif
105105

106-
Exx_NAO exx_nao;
106+
Exx_NAO<TK> exx_nao;
107107

108108
friend class LR::ESolver_LR<double, double>;
109109
friend class LR::ESolver_LR<std::complex<double>, double>;

source/source_esolver/lcao_after_scf.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep, const
6565
this->ld,
6666
#endif
6767
#ifdef __EXX
68-
*this->exd,
69-
*this->exc,
68+
*this->exx_nao.exd,
69+
*this->exx_nao.exc,
7070
#endif
7171
istep);
7272
}

source/source_esolver/lcao_before_scf.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,11 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
2828
ESolver_KS<TK>::before_scf(ucell, istep);
2929

3030
auto* estate = dynamic_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec);
31-
auto* hamilt_lcao = dynamic_cast<hamilt::HamiltLCAO<TK, TR>*>(this->p_hamilt);
32-
3331
if(!estate)
3432
{
3533
ModuleBase::WARNING_QUIT("ESolver_KS_LCAO::before_scf","pelec does not exist");
3634
}
3735

38-
if(!hamilt_lcao)
39-
{
40-
ModuleBase::WARNING_QUIT("ESolver_KS_LCAO::before_scf","p_hamilt does not exist");
41-
}
4236

4337
//! 2) find search radius
4438
double search_radius = atom_arrange::set_sr_NL(GlobalV::ofs_running,
@@ -143,9 +137,9 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
143137
#ifdef __EXX
144138
,
145139
istep,
146-
GlobalC::exx_info.info_ri.real_number ? &this->exd->two_level_step : &this->exc->two_level_step,
147-
GlobalC::exx_info.info_ri.real_number ? &this->exd->get_Hexxs() : nullptr,
148-
GlobalC::exx_info.info_ri.real_number ? nullptr : &this->exc->get_Hexxs()
140+
GlobalC::exx_info.info_ri.real_number ? &this->exx_nao.exd->two_level_step : &this->exx_nao.exc->two_level_step,
141+
GlobalC::exx_info.info_ri.real_number ? &this->exx_nao.exd->get_Hexxs() : nullptr,
142+
GlobalC::exx_info.info_ri.real_number ? nullptr : &this->exx_nao.exc->get_Hexxs()
149143
#endif
150144
);
151145
}
@@ -185,11 +179,11 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
185179
{
186180
if (GlobalC::exx_info.info_ri.real_number)
187181
{
188-
this->exd->exx_beforescf(istep, this->kv, *this->p_chgmix, ucell, orb_);
182+
this->exx_nao.exd->exx_beforescf(istep, this->kv, *this->p_chgmix, ucell, orb_);
189183
}
190184
else
191185
{
192-
this->exc->exx_beforescf(istep, this->kv, *this->p_chgmix, ucell, orb_);
186+
this->exx_nao.exc->exx_beforescf(istep, this->kv, *this->p_chgmix, ucell, orb_);
193187
}
194188
}
195189
#endif
@@ -199,6 +193,11 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
199193

200194
// 13) initalize DMR
201195
// DMR should be same size with Hamiltonian(R)
196+
auto* hamilt_lcao = dynamic_cast<hamilt::HamiltLCAO<TK, TR>*>(this->p_hamilt);
197+
if(!hamilt_lcao)
198+
{
199+
ModuleBase::WARNING_QUIT("ESolver_KS_LCAO::before_scf","p_hamilt does not exist");
200+
}
202201
estate->get_DM()->init_DMR(*hamilt_lcao->getHR());
203202

204203
#ifdef __MLALGO

source/source_esolver/lcao_others.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ void ESolver_KS_LCAO<TK, TR>::others(UnitCell& ucell, const int istep)
238238
#ifdef __EXX
239239
,
240240
istep,
241-
GlobalC::exx_info.info_ri.real_number ? &this->exd->two_level_step : &this->exc->two_level_step,
242-
GlobalC::exx_info.info_ri.real_number ? &this->exd->get_Hexxs() : nullptr,
243-
GlobalC::exx_info.info_ri.real_number ? nullptr : &this->exc->get_Hexxs()
241+
GlobalC::exx_info.info_ri.real_number ? &this->exx_nao.exd->two_level_step : &this->exx_nao.exc->two_level_step,
242+
GlobalC::exx_info.info_ri.real_number ? &this->exx_nao.exd->get_Hexxs() : nullptr,
243+
GlobalC::exx_info.info_ri.real_number ? nullptr : &this->exx_nao.exc->get_Hexxs()
244244
#endif
245245
);
246246
}

source/source_lcao/FORCE.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef W_ABACUS_DEVELOP_ABACUS_DEVELOP_SOURCE_MODULE_HAMILT_LCAO_HAMILT_LCAODFT_FORCE_H
2-
#define W_ABACUS_DEVELOP_ABACUS_DEVELOP_SOURCE_MODULE_HAMILT_LCAO_HAMILT_LCAODFT_FORCE_H
1+
#ifndef LCAO_FORCE_H
2+
#define LCAO_FORCE_H
33

44
#include "source_base/global_function.h"
55
#include "source_base/global_variable.h"

source/source_lcao/FORCE_STRESS.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void Force_Stress_LCAO<T>::getForceStress(UnitCell& ucell,
5555
LCAO_Deepks<T>& ld,
5656
const std::string& dpks_out_type,
5757
#endif
58-
Exx_NAO &exx_nao,
58+
Exx_NAO<T> &exx_nao,
5959
ModuleSymmetry::Symmetry* symm)
6060
{
6161
ModuleBase::TITLE("Force_Stress_LCAO", "getForceStress");
@@ -375,26 +375,26 @@ void Force_Stress_LCAO<T>::getForceStress(UnitCell& ucell,
375375
{
376376
if (GlobalC::exx_info.info_ri.real_number)
377377
{
378-
exx_nao.exd.cal_exx_force(ucell.nat);
379-
force_exx = GlobalC::exx_info.info_global.hybrid_alpha * exx_nao.exd.get_force();
378+
exx_nao.exd->cal_exx_force(ucell.nat);
379+
force_exx = GlobalC::exx_info.info_global.hybrid_alpha * exx_nao.exd->get_force();
380380
}
381381
else
382382
{
383-
exx_nao.exc.cal_exx_force(ucell.nat);
384-
force_exx = GlobalC::exx_info.info_global.hybrid_alpha * exx_nao.exc.get_force();
383+
exx_nao.exc->cal_exx_force(ucell.nat);
384+
force_exx = GlobalC::exx_info.info_global.hybrid_alpha * exx_nao.exc->get_force();
385385
}
386386
}
387387
if (isstress)
388388
{
389389
if (GlobalC::exx_info.info_ri.real_number)
390390
{
391-
exx_nao.exd.cal_exx_stress(ucell.omega, ucell.lat0);
392-
stress_exx = GlobalC::exx_info.info_global.hybrid_alpha * exx_nao.exd.get_stress();
391+
exx_nao.exd->cal_exx_stress(ucell.omega, ucell.lat0);
392+
stress_exx = GlobalC::exx_info.info_global.hybrid_alpha * exx_nao.exd->get_stress();
393393
}
394394
else
395395
{
396-
exx_nao.exc.cal_exx_stress(ucell.omega, ucell.lat0);
397-
stress_exx = GlobalC::exx_info.info_global.hybrid_alpha * exx_nao.exc.get_stress();
396+
exx_nao.exc->cal_exx_stress(ucell.omega, ucell.lat0);
397+
stress_exx = GlobalC::exx_info.info_global.hybrid_alpha * exx_nao.exc->get_stress();
398398
}
399399
}
400400
}

source/source_lcao/FORCE_STRESS.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Force_Stress_LCAO
5555
LCAO_Deepks<T>& ld,
5656
const std::string& dpks_out_type,
5757
#endif
58-
Exx_NAO &exx_nao,
58+
Exx_NAO<T> &exx_nao,
5959
ModuleSymmetry::Symmetry* symm);
6060

6161
private:

0 commit comments

Comments
 (0)