@@ -62,9 +62,7 @@ void Exx_LRI_Interface<T, Tdata>::cal_exx_ions(const UnitCell& ucell, const bool
6262 ModuleBase::TITLE (" Exx_LRI_Interface" ," cal_exx_ions" );
6363 if (!this ->flag_finish .init )
6464 { throw std::runtime_error (" Exx init unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
65-
6665 this ->exx_ptr ->cal_exx_ions (ucell, write_cv);
67-
6866 this ->flag_finish .ions = true ;
6967}
7068
@@ -79,7 +77,6 @@ void Exx_LRI_Interface<T, Tdata>::cal_exx_elec(const std::vector<std::map<TA, st
7977 { throw std::runtime_error (" Exx init unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
8078
8179 this ->exx_ptr ->cal_exx_elec (Ds, ucell, pv, p_symrot);
82-
8380 this ->flag_finish .elec = true ;
8481}
8582
@@ -93,7 +90,6 @@ void Exx_LRI_Interface<T, Tdata>::cal_exx_force(const int& nat)
9390 { throw std::runtime_error (" Exx Hamiltonian unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
9491
9592 this ->exx_ptr ->cal_exx_force (nat);
96-
9793 this ->flag_finish .force = true ;
9894}
9995
@@ -107,12 +103,14 @@ void Exx_LRI_Interface<T, Tdata>::cal_exx_stress(const double& omega, const doub
107103 { throw std::runtime_error (" Exx Hamiltonian unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
108104
109105 this ->exx_ptr ->cal_exx_stress (omega, lat0);
110-
111106 this ->flag_finish .stress = true ;
112107}
113108
114109template <typename T, typename Tdata>
115- void Exx_LRI_Interface<T, Tdata>::exx_before_all_runners(const K_Vectors& kv, const UnitCell& ucell, const Parallel_2D& pv)
110+ void Exx_LRI_Interface<T, Tdata>::exx_before_all_runners(
111+ const K_Vectors& kv,
112+ const UnitCell& ucell,
113+ const Parallel_2D& pv)
116114{
117115 ModuleBase::TITLE (" Exx_LRI_Interface" ," exx_before_all_runners" );
118116 // initialize the rotation matrix in AO representation
@@ -166,14 +164,15 @@ void Exx_LRI_Interface<T, Tdata>::exx_beforescf(const int istep,
166164 if (GlobalC::exx_info.info_global .cal_exx )
167165 {
168166 if (this ->exx_spacegroup_symmetry )
169- {this ->mix_DMk_2D .set_nks (kv.get_nkstot_full () * (PARAM .inp .nspin == 2 ? 2 : 1 ), PARAM . globalv . gamma_only_local ); }
167+ { this ->mix_DMk_2D .set_nks (kv.get_nkstot_full () * (PARAM .inp .nspin == 2 ? 2 : 1 )); }
170168 else
171- {this ->mix_DMk_2D .set_nks (kv.get_nks (), PARAM . globalv . gamma_only_local ); }
169+ { this ->mix_DMk_2D .set_nks (kv.get_nks ()); }
172170
173- if (GlobalC::exx_info.info_global .separate_loop )
174- { this ->mix_DMk_2D .set_mixing ( nullptr ); }
171+ if (GlobalC::exx_info.info_global .separate_loop )
172+ { this ->mix_DMk_2D .set_mixing_plain (GlobalC::exx_info. info_global . mixing_beta_for_loop1 ); }
175173 else
176174 { this ->mix_DMk_2D .set_mixing (chgmix.get_mixing ()); }
175+
177176 // for exx two_level scf
178177 this ->two_level_step = 0 ;
179178 }
@@ -190,40 +189,39 @@ void Exx_LRI_Interface<T, Tdata>::exx_eachiterinit(const int istep,
190189 ModuleBase::TITLE (" Exx_LRI_Interface" ," exx_eachiterinit" );
191190 if (GlobalC::exx_info.info_global .cal_exx )
192191 {
193- if (!GlobalC::exx_info.info_global .separate_loop && (this ->two_level_step || istep > 0 || PARAM .inp .init_wfc == " file" ) // non separate loop case
194- || (GlobalC::exx_info.info_global .separate_loop && PARAM .inp .init_wfc == " file" && this ->two_level_step == 0 && iter == 1 )) // the first iter in separate loop case
192+ if (!GlobalC::exx_info.info_global .separate_loop
193+ && (this ->two_level_step
194+ || istep > 0
195+ || PARAM .inp .init_wfc == " file" ) // non separate loop case
196+ || (GlobalC::exx_info.info_global .separate_loop
197+ && PARAM .inp .init_wfc == " file"
198+ && this ->two_level_step == 0
199+ && iter == 1 )
200+ ) // the first iter in separate loop case
195201 {
196202 const bool flag_restart = (iter == 1 ) ? true : false ;
197203 auto cal = [this , &ucell,&kv, &flag_restart](const elecstate::DensityMatrix<T, double >& dm_in)
198204 {
199205 if (this ->exx_spacegroup_symmetry )
200- { this ->mix_DMk_2D .mix (symrot_.restore_dm (kv,dm_in.get_DMK_vector (), *dm_in.get_paraV_pointer ()), flag_restart); }
206+ { this ->mix_DMk_2D .mix (symrot_.restore_dm (kv, dm_in.get_DMK_vector (), *dm_in.get_paraV_pointer ()), flag_restart); }
201207 else
202208 { this ->mix_DMk_2D .mix (dm_in.get_DMK_vector (), flag_restart); }
203- const std::vector<std::map<TA , std::map<TAC , RI ::Tensor<Tdata>>>>
204- Ds = PARAM .globalv .gamma_only_local
205- ? RI_2D_Comm::split_m2D_ktoR<Tdata>(
206- ucell,
207- *this ->exx_ptr ->p_kv ,
208- this ->mix_DMk_2D .get_DMk_gamma_out (),
209- *dm_in.get_paraV_pointer (),
210- PARAM .inp .nspin )
211- : RI_2D_Comm::split_m2D_ktoR<Tdata>(
212- ucell,
213- *this ->exx_ptr ->p_kv ,
214- this ->mix_DMk_2D .get_DMk_k_out (),
215- *dm_in.get_paraV_pointer (),
216- PARAM .inp .nspin ,
217- this ->exx_spacegroup_symmetry );
218-
219- if (this ->exx_spacegroup_symmetry && GlobalC::exx_info.info_global .exx_symmetry_realspace )
209+ const std::vector<std::map<TA , std::map<TAC , RI ::Tensor<Tdata>>>> Ds =
210+ RI_2D_Comm::split_m2D_ktoR<Tdata>(
211+ ucell,
212+ *this ->exx_ptr ->p_kv ,
213+ this ->mix_DMk_2D .get_DMk_out (),
214+ *dm_in.get_paraV_pointer (),
215+ PARAM .inp .nspin ,
216+ this ->exx_spacegroup_symmetry );
217+ if (this ->exx_spacegroup_symmetry && GlobalC::exx_info.info_global .exx_symmetry_realspace )
220218 { this ->cal_exx_elec (Ds, ucell,*dm_in.get_paraV_pointer (), &this ->symrot_ ); }
221219 else
222220 { this ->cal_exx_elec (Ds, ucell,*dm_in.get_paraV_pointer ()); }
223221 };
224222
225223 if (istep > 0 && flag_restart)
226- { cal (*dm_last_step); }
224+ { cal (*this -> dm_last_step ); }
227225 else
228226 { cal (dm); }
229227 }
@@ -396,21 +394,23 @@ bool Exx_LRI_Interface<T, Tdata>::exx_after_converge(
396394 // if init_wfc == "file", DM is calculated in the 1st iter of the 1st two-level step, so we mix it here
397395 const bool flag_restart = (this ->two_level_step == 0 && PARAM .inp .init_wfc != " file" ) ? true : false ;
398396
399- if (this ->exx_spacegroup_symmetry )
400- {this ->mix_DMk_2D .mix (symrot_.restore_dm (kv, dm.get_DMK_vector (), *dm.get_paraV_pointer ()), flag_restart);}
397+ if (this ->exx_spacegroup_symmetry )
398+ { this ->mix_DMk_2D .mix (symrot_.restore_dm (kv, dm.get_DMK_vector (), *dm.get_paraV_pointer ()), flag_restart); }
401399 else
402- {this ->mix_DMk_2D .mix (dm.get_DMK_vector (), flag_restart);}
403-
404- // GlobalC::exx_lcao.cal_exx_elec(p_esolver->LOC, p_esolver->LOWF.wfc_k_grid);
405- const std::vector<std::map<int , std::map<std::pair<int , std::array<int , 3 >>, RI ::Tensor<Tdata>>>>
406- Ds = std::is_same<T, double >::value // gamma_only_local
407- ? RI_2D_Comm::split_m2D_ktoR<Tdata>(ucell,*this ->exx_ptr ->p_kv , this ->mix_DMk_2D .get_DMk_gamma_out (), *dm.get_paraV_pointer (), nspin)
408- : RI_2D_Comm::split_m2D_ktoR<Tdata>(ucell,*this ->exx_ptr ->p_kv , this ->mix_DMk_2D .get_DMk_k_out (), *dm.get_paraV_pointer (), nspin, this ->exx_spacegroup_symmetry );
409-
410- if (this ->exx_spacegroup_symmetry && GlobalC::exx_info.info_global .exx_symmetry_realspace )
400+ { this ->mix_DMk_2D .mix (dm.get_DMK_vector (), flag_restart); }
401+ const std::vector<std::map<TA , std::map<TAC , RI ::Tensor<Tdata>>>> Ds =
402+ RI_2D_Comm::split_m2D_ktoR<Tdata>(
403+ ucell,
404+ *this ->exx_ptr ->p_kv ,
405+ this ->mix_DMk_2D .get_DMk_out (),
406+ *dm.get_paraV_pointer (),
407+ nspin,
408+ this ->exx_spacegroup_symmetry );
409+ if (this ->exx_spacegroup_symmetry && GlobalC::exx_info.info_global .exx_symmetry_realspace )
411410 { this ->cal_exx_elec (Ds, ucell, *dm.get_paraV_pointer (), &this ->symrot_ ); }
412411 else
413412 { this ->cal_exx_elec (Ds, ucell, *dm.get_paraV_pointer ()); } // restore DM but not Hexx
413+
414414 iter = 0 ;
415415 this ->two_level_step ++;
416416
0 commit comments