@@ -35,9 +35,7 @@ void Exx_LRI_Interface<T, Tdata>::cal_exx_ions(const UnitCell& ucell, const bool
3535 ModuleBase::TITLE (" Exx_LRI_Interface" ," cal_exx_ions" );
3636 if (!this ->flag_finish .init )
3737 { throw std::runtime_error (" Exx init unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
38-
3938 this ->exx_ptr ->cal_exx_ions (ucell, write_cv);
40-
4139 this ->flag_finish .ions = true ;
4240}
4341
@@ -49,13 +47,9 @@ void Exx_LRI_Interface<T, Tdata>::cal_exx_elec(const std::vector<std::map<TA, st
4947{
5048 ModuleBase::TITLE (" Exx_LRI_Interface" ," cal_exx_elec" );
5149 if (!this ->flag_finish .init || !this ->flag_finish .ions )
52- {
53- throw std::runtime_error (" Exx init unfinished when "
54- +std::string (__FILE__)+" line " +std::to_string (__LINE__));
55- }
50+ { throw std::runtime_error (" Exx init unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
5651
5752 this ->exx_ptr ->cal_exx_elec (Ds, ucell, pv, p_symrot);
58-
5953 this ->flag_finish .elec = true ;
6054}
6155
@@ -64,17 +58,11 @@ void Exx_LRI_Interface<T, Tdata>::cal_exx_force(const int& nat)
6458{
6559 ModuleBase::TITLE (" Exx_LRI_Interface" ," cal_exx_force" );
6660 if (!this ->flag_finish .init || !this ->flag_finish .ions )
67- {
68- throw std::runtime_error (" Exx init unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__));
69- }
61+ { throw std::runtime_error (" Exx init unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
7062 if (!this ->flag_finish .elec )
71- {
72- throw std::runtime_error (" Exx Hamiltonian unfinished when " +std::string (__FILE__)
73- +" line " +std::to_string (__LINE__));
74- }
63+ { throw std::runtime_error (" Exx Hamiltonian unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
7564
7665 this ->exx_ptr ->cal_exx_force (nat);
77-
7866 this ->flag_finish .force = true ;
7967}
8068
@@ -83,24 +71,17 @@ void Exx_LRI_Interface<T, Tdata>::cal_exx_stress(const double& omega, const doub
8371{
8472 ModuleBase::TITLE (" Exx_LRI_Interface" ," cal_exx_stress" );
8573 if (!this ->flag_finish .init || !this ->flag_finish .ions )
86- {
87- throw std::runtime_error (" Exx init unfinished when "
88- +std::string (__FILE__)+" line " +std::to_string (__LINE__));
89- }
74+ { throw std::runtime_error (" Exx init unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
9075 if (!this ->flag_finish .elec )
91- {
92- throw std::runtime_error (" Exx Hamiltonian unfinished when "
93- +std::string (__FILE__)+" line " +std::to_string (__LINE__));
94- }
76+ { throw std::runtime_error (" Exx Hamiltonian unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
9577
9678 this ->exx_ptr ->cal_exx_stress (omega, lat0);
97-
9879 this ->flag_finish .stress = true ;
9980}
10081
10182template <typename T, typename Tdata>
10283void Exx_LRI_Interface<T, Tdata>::exx_before_all_runners(
103- const K_Vectors& kv,
84+ const K_Vectors& kv,
10485 const UnitCell& ucell,
10586 const Parallel_2D& pv)
10687{
@@ -147,14 +128,15 @@ void Exx_LRI_Interface<T, Tdata>::exx_beforescf(const int istep,
147128 if (GlobalC::exx_info.info_global .cal_exx )
148129 {
149130 if (this ->exx_spacegroup_symmetry )
150- {this ->mix_DMk_2D .set_nks (kv.get_nkstot_full () * (PARAM .inp .nspin == 2 ? 2 : 1 ), PARAM . globalv . gamma_only_local ); }
131+ { this ->mix_DMk_2D .set_nks (kv.get_nkstot_full () * (PARAM .inp .nspin == 2 ? 2 : 1 )); }
151132 else
152- {this ->mix_DMk_2D .set_nks (kv.get_nks (), PARAM . globalv . gamma_only_local ); }
133+ { this ->mix_DMk_2D .set_nks (kv.get_nks ()); }
153134
154- if (GlobalC::exx_info.info_global .separate_loop )
155- { this ->mix_DMk_2D .set_mixing ( nullptr ); }
135+ if (GlobalC::exx_info.info_global .separate_loop )
136+ { this ->mix_DMk_2D .set_mixing_plain (GlobalC::exx_info. info_global . mixing_beta_for_loop1 ); }
156137 else
157138 { this ->mix_DMk_2D .set_mixing (chgmix.get_mixing ()); }
139+
158140 // for exx two_level scf
159141 this ->two_level_step = 0 ;
160142 }
@@ -171,13 +153,13 @@ void Exx_LRI_Interface<T, Tdata>::exx_eachiterinit(const int istep,
171153 ModuleBase::TITLE (" Exx_LRI_Interface" ," exx_eachiterinit" );
172154 if (GlobalC::exx_info.info_global .cal_exx )
173155 {
174- if (!GlobalC::exx_info.info_global .separate_loop
175- && (this ->two_level_step
176- || istep > 0
156+ if (!GlobalC::exx_info.info_global .separate_loop
157+ && (this ->two_level_step
158+ || istep > 0
177159 || PARAM .inp .init_wfc == " file" ) // non separate loop case
178- || (GlobalC::exx_info.info_global .separate_loop
179- && PARAM .inp .init_wfc == " file"
180- && this ->two_level_step == 0
160+ || (GlobalC::exx_info.info_global .separate_loop
161+ && PARAM .inp .init_wfc == " file"
162+ && this ->two_level_step == 0
181163 && iter == 1 )
182164 ) // the first iter in separate loop case
183165 {
@@ -186,33 +168,25 @@ void Exx_LRI_Interface<T, Tdata>::exx_eachiterinit(const int istep,
186168 auto cal = [this , &ucell,&kv, &flag_restart](const elecstate::DensityMatrix<T, double >& dm_in)
187169 {
188170 if (this ->exx_spacegroup_symmetry )
189- { this ->mix_DMk_2D .mix (symrot_.restore_dm (kv,dm_in.get_DMK_vector (), *dm_in.get_paraV_pointer ()), flag_restart); }
171+ { this ->mix_DMk_2D .mix (symrot_.restore_dm (kv, dm_in.get_DMK_vector (), *dm_in.get_paraV_pointer ()), flag_restart); }
190172 else
191173 { this ->mix_DMk_2D .mix (dm_in.get_DMK_vector (), flag_restart); }
192- const std::vector<std::map<TA , std::map<TAC , RI ::Tensor<Tdata>>>>
193- Ds = PARAM .globalv .gamma_only_local
194- ? RI_2D_Comm::split_m2D_ktoR<Tdata>(
195- ucell,
196- *this ->exx_ptr ->p_kv ,
197- this ->mix_DMk_2D .get_DMk_gamma_out (),
198- *dm_in.get_paraV_pointer (),
199- PARAM .inp .nspin )
200- : RI_2D_Comm::split_m2D_ktoR<Tdata>(
201- ucell,
202- *this ->exx_ptr ->p_kv ,
203- this ->mix_DMk_2D .get_DMk_k_out (),
204- *dm_in.get_paraV_pointer (),
205- PARAM .inp .nspin ,
206- this ->exx_spacegroup_symmetry );
207-
208- if (this ->exx_spacegroup_symmetry && GlobalC::exx_info.info_ri .exx_symmetry_realspace )
174+ const std::vector<std::map<TA , std::map<TAC , RI ::Tensor<Tdata>>>> Ds =
175+ RI_2D_Comm::split_m2D_ktoR<Tdata>(
176+ ucell,
177+ *this ->exx_ptr ->p_kv ,
178+ this ->mix_DMk_2D .get_DMk_out (),
179+ *dm_in.get_paraV_pointer (),
180+ PARAM .inp .nspin ,
181+ this ->exx_spacegroup_symmetry );
182+ if (this ->exx_spacegroup_symmetry && GlobalC::exx_info.info_ri .exx_symmetry_realspace )
209183 { this ->cal_exx_elec (Ds, ucell,*dm_in.get_paraV_pointer (), &this ->symrot_ ); }
210184 else
211185 { this ->cal_exx_elec (Ds, ucell,*dm_in.get_paraV_pointer ()); }
212186 };
213187
214188 if (istep > 0 && flag_restart)
215- { cal (*dm_last_step); }
189+ { cal (*this -> dm_last_step ); }
216190 else
217191 { cal (dm); }
218192 }
@@ -387,21 +361,23 @@ bool Exx_LRI_Interface<T, Tdata>::exx_after_converge(
387361 // if init_wfc == "file", DM is calculated in the 1st iter of the 1st two-level step, so we mix it here
388362 const bool flag_restart = (this ->two_level_step == 0 && PARAM .inp .init_wfc != " file" ) ? true : false ;
389363
390- if (this ->exx_spacegroup_symmetry )
391- {this ->mix_DMk_2D .mix (symrot_.restore_dm (kv, dm.get_DMK_vector (), *dm.get_paraV_pointer ()), flag_restart);}
364+ if (this ->exx_spacegroup_symmetry )
365+ { this ->mix_DMk_2D .mix (symrot_.restore_dm (kv, dm.get_DMK_vector (), *dm.get_paraV_pointer ()), flag_restart); }
392366 else
393- {this ->mix_DMk_2D .mix (dm.get_DMK_vector (), flag_restart);}
394-
395- // GlobalC::exx_lcao.cal_exx_elec(p_esolver->LOC, p_esolver->LOWF.wfc_k_grid);
396- const std::vector<std::map<int , std::map<std::pair<int , std::array<int , 3 >>, RI ::Tensor<Tdata>>>>
397- Ds = std::is_same<T, double >::value // gamma_only_local
398- ? 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)
399- : 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 );
400-
401- if (this ->exx_spacegroup_symmetry && GlobalC::exx_info.info_ri .exx_symmetry_realspace )
367+ { this ->mix_DMk_2D .mix (dm.get_DMK_vector (), flag_restart); }
368+ const std::vector<std::map<TA , std::map<TAC , RI ::Tensor<Tdata>>>> Ds =
369+ RI_2D_Comm::split_m2D_ktoR<Tdata>(
370+ ucell,
371+ *this ->exx_ptr ->p_kv ,
372+ this ->mix_DMk_2D .get_DMk_out (),
373+ *dm.get_paraV_pointer (),
374+ nspin,
375+ this ->exx_spacegroup_symmetry );
376+ if (this ->exx_spacegroup_symmetry && GlobalC::exx_info.info_ri .exx_symmetry_realspace )
402377 { this ->cal_exx_elec (Ds, ucell, *dm.get_paraV_pointer (), &this ->symrot_ ); }
403378 else
404379 { this ->cal_exx_elec (Ds, ucell, *dm.get_paraV_pointer ()); } // restore DM but not Hexx
380+
405381 iter = 0 ;
406382 this ->two_level_step ++;
407383
0 commit comments