@@ -35,22 +35,7 @@ ESolver_KS_LCAO<TK, TR>::ESolver_KS_LCAO()
3535{
3636 this ->classname = " ESolver_KS_LCAO" ;
3737 this ->basisname = " LCAO" ;
38-
39- #ifdef __EXX
40- // 1. currently this initialization must be put in constructor rather than `before_all_runners()`
41- // because the latter is not reused by ESolver_LCAO_TDDFT,
42- // which cause the failure of the subsequent procedure reused by ESolver_LCAO_TDDFT
43- // 2. always construct but only initialize when if(cal_exx) is true
44- // because some members like two_level_step are used outside if(cal_exx)
45- if (GlobalC::exx_info.info_ri .real_number )
46- {
47- this ->exd = std::make_shared<Exx_LRI_Interface<TK, double >>(GlobalC::exx_info.info_ri );
48- }
49- else
50- {
51- this ->exc = std::make_shared<Exx_LRI_Interface<TK, std::complex <double >>>(GlobalC::exx_info.info_ri );
52- }
53- #endif
38+ this ->exx_nao .init (); // mohan add 20251008
5439}
5540
5641template <typename TK, typename TR>
@@ -137,31 +122,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
137122 dynamic_cast <elecstate::ElecStateLCAO<TK>*>(this ->pelec )->init_DM (&this ->kv , &(this ->pv ), inp.nspin );
138123
139124 // 8) init exact exchange calculations
140- #ifdef __EXX
141- if (inp.calculation == " scf" || inp.calculation == " relax" || inp.calculation == " cell-relax"
142- || inp.calculation == " md" )
143- {
144- if (GlobalC::exx_info.info_global .cal_exx )
145- {
146- if (inp.init_wfc != " file" )
147- { // if init_wfc==file, directly enter the EXX loop
148- XC_Functional::set_xc_first_loop (ucell);
149- }
150-
151- // initialize 2-center radial tables for EXX-LRI
152- if (GlobalC::exx_info.info_ri .real_number )
153- {
154- this ->exd ->init (MPI_COMM_WORLD, ucell, this ->kv , orb_);
155- this ->exd ->exx_before_all_runners (this ->kv , ucell, this ->pv );
156- }
157- else
158- {
159- this ->exc ->init (MPI_COMM_WORLD, ucell, this ->kv , orb_);
160- this ->exc ->exx_before_all_runners (this ->kv , ucell, this ->pv );
161- }
162- }
163- }
164- #endif
125+ this ->exx_nao .before_runner (ucell, this ->kv , this ->orb_ , this ->pv , PARAM.inp );
165126
166127 // 9) initialize DFT+U
167128 if (inp.dft_plus_u )
@@ -280,10 +241,7 @@ void ESolver_KS_LCAO<TK, TR>::cal_force(UnitCell& ucell, ModuleBase::matrix& for
280241 this ->ld ,
281242 " tot" ,
282243#endif
283- #ifdef __EXX
284- *this ->exd ,
285- *this ->exc ,
286- #endif
244+ this ->exx_nao ,
287245 &ucell.symm );
288246
289247 // delete RA after cal_force
@@ -349,8 +307,8 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
349307 this ->orb_ , this ->pw_rho , this ->pw_rhod ,
350308 this ->sf , this ->locpp .vloc ,
351309#ifdef __EXX
352- this ->exd ,
353- this ->exc ,
310+ this ->exx_nao . exd ,
311+ this ->exx_nao . exc ,
354312#endif
355313 this ->solvent );
356314
@@ -389,7 +347,7 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(UnitCell& ucell, const int istep, const
389347 {
390348 // the following steps are only needed in the first outer exx loop
391349 exx_two_level_step
392- = 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 ;
393351 }
394352#endif
395353// elecstate::setup_dm<TK>(ucell, estate, this->psi, this->chr, iter, exx_two_level_step);
@@ -437,11 +395,11 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(UnitCell& ucell, const int istep, const
437395 {
438396 if (GlobalC::exx_info.info_ri .real_number )
439397 {
440- this ->exd ->exx_eachiterinit (istep, ucell, *dm, this ->kv , iter);
398+ this ->exx_nao . exd ->exx_eachiterinit (istep, ucell, *dm, this ->kv , iter);
441399 }
442400 else
443401 {
444- this ->exc ->exx_eachiterinit (istep, ucell, *dm, this ->kv , iter);
402+ this ->exx_nao . exc ->exx_eachiterinit (istep, ucell, *dm, this ->kv , iter);
445403 }
446404 }
447405#endif
@@ -528,11 +486,11 @@ void ESolver_KS_LCAO<TK, TR>::hamilt2rho_single(UnitCell& ucell, int istep, int
528486 {
529487 if (GlobalC::exx_info.info_ri .real_number )
530488 {
531- this ->exd ->exx_hamilt2rho (*this ->pelec , this ->pv , iter);
489+ this ->exx_nao . exd ->exx_hamilt2rho (*this ->pelec , this ->pv , iter);
532490 }
533491 else
534492 {
535- this ->exc ->exx_hamilt2rho (*this ->pelec , this ->pv , iter);
493+ this ->exx_nao . exc ->exx_hamilt2rho (*this ->pelec , this ->pv , iter);
536494 }
537495 }
538496#endif
@@ -651,8 +609,8 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(UnitCell& ucell, const int istep, int&
651609 this ->ld ,
652610#endif
653611#ifdef __EXX
654- *this ->exd ,
655- *this ->exc ,
612+ *this ->exx_nao . exd ,
613+ *this ->exx_nao . exc ,
656614#endif
657615 iter, istep, conv_esolver, this ->scf_ene_thr );
658616
0 commit comments