@@ -51,6 +51,61 @@ void Exx_LRI_Interface<T, Tdata>::init(const MPI_Comm &mpi_comm,
5151 this ->flag_finish .init = true ;
5252}
5353
54+ template <typename T, typename Tdata>
55+ void Exx_LRI_Interface<T, Tdata>::cal_exx_ions(const UnitCell& ucell, const bool write_cv)
56+ {
57+ ModuleBase::TITLE (" Exx_LRI_Interface" ," cal_exx_ions" );
58+ if (!this ->flag_finish .init )
59+ { throw std::runtime_error (" Exx init unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
60+
61+ this ->exx_ptr ->cal_exx_ions (ucell, write_cv);
62+
63+ this ->flag_finish .ions = true ;
64+ }
65+
66+ template <typename T, typename Tdata>
67+ void Exx_LRI_Interface<T, Tdata>::cal_exx_elec(const std::vector<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>>& Ds,
68+ const UnitCell& ucell,
69+ const Parallel_Orbitals& pv,
70+ const ModuleSymmetry::Symmetry_rotation* p_symrot)
71+ {
72+ ModuleBase::TITLE (" Exx_LRI_Interface" ," cal_exx_elec" );
73+ if (!this ->flag_finish .init || !this ->flag_finish .ions )
74+ { throw std::runtime_error (" Exx init unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
75+
76+ this ->exx_ptr ->cal_exx_elec (Ds, ucell, pv, p_symrot);
77+
78+ this ->flag_finish .elec = true ;
79+ }
80+
81+ template <typename T, typename Tdata>
82+ void Exx_LRI_Interface<T, Tdata>::cal_exx_force(const int & nat)
83+ {
84+ ModuleBase::TITLE (" Exx_LRI_Interface" ," cal_exx_force" );
85+ if (!this ->flag_finish .init || !this ->flag_finish .ions )
86+ { throw std::runtime_error (" Exx init unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
87+ if (!this ->flag_finish .elec )
88+ { throw std::runtime_error (" Exx Hamiltonian unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
89+
90+ this ->exx_ptr ->cal_exx_force (nat);
91+
92+ this ->flag_finish .force = true ;
93+ }
94+
95+ template <typename T, typename Tdata>
96+ void Exx_LRI_Interface<T, Tdata>::cal_exx_stress(const double & omega, const double & lat0)
97+ {
98+ ModuleBase::TITLE (" Exx_LRI_Interface" ," cal_exx_stress" );
99+ if (!this ->flag_finish .init || !this ->flag_finish .ions )
100+ { throw std::runtime_error (" Exx init unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
101+ if (!this ->flag_finish .elec )
102+ { throw std::runtime_error (" Exx Hamiltonian unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
103+
104+ this ->exx_ptr ->cal_exx_stress (omega, lat0);
105+
106+ this ->flag_finish .stress = true ;
107+ }
108+
54109template <typename T, typename Tdata>
55110void Exx_LRI_Interface<T, Tdata>::exx_before_all_runners(const K_Vectors& kv, const UnitCell& ucell, const Parallel_2D& pv)
56111{
@@ -102,10 +157,7 @@ void Exx_LRI_Interface<T, Tdata>::exx_beforescf(const int istep,
102157 }
103158 }
104159
105- if (!this ->flag_finish .init )
106- { throw std::runtime_error (" Exx init unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
107- this ->exx_ptr ->cal_exx_ions (ucell,PARAM.inp .out_ri_cv );
108- this ->flag_finish .ions = true ;
160+ this ->cal_exx_ions (ucell,PARAM.inp .out_ri_cv );
109161 }
110162
111163 if (Exx_Abfs::Jle::generate_matrix)
@@ -124,11 +176,11 @@ void Exx_LRI_Interface<T, Tdata>::exx_beforescf(const int istep,
124176 {this ->mix_DMk_2D .set_nks (kv.get_nkstot_full () * (PARAM.inp .nspin == 2 ? 2 : 1 ), PARAM.globalv .gamma_only_local );}
125177 else
126178 {this ->mix_DMk_2D .set_nks (kv.get_nks (), PARAM.globalv .gamma_only_local );}
127- if (GlobalC::exx_info. info_global . separate_loop ) {
128- this -> mix_DMk_2D . set_mixing ( nullptr );
129- } else {
130- this -> mix_DMk_2D . set_mixing (chgmix. get_mixing ());
131- }
179+
180+ if (GlobalC::exx_info. info_global . separate_loop )
181+ { this -> mix_DMk_2D . set_mixing ( nullptr ); }
182+ else
183+ { this -> mix_DMk_2D . set_mixing (chgmix. get_mixing ()); }
132184 // for exx two_level scf
133185 this ->two_level_step = 0 ;
134186 }
@@ -151,24 +203,19 @@ void Exx_LRI_Interface<T, Tdata>::exx_eachiterinit(const int istep,
151203 const bool flag_restart = (iter == 1 ) ? true : false ;
152204 auto cal = [this , &ucell,&kv, &flag_restart](const elecstate::DensityMatrix<T, double >& dm_in)
153205 {
154- if (!this ->flag_finish .init || !this ->flag_finish .ions )
155- { throw std::runtime_error (" Exx init unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
156-
157206 if (this ->exx_spacegroup_symmetry )
158207 { this ->mix_DMk_2D .mix (symrot_.restore_dm (kv,dm_in.get_DMK_vector (), *dm_in.get_paraV_pointer ()), flag_restart); }
159208 else
160209 { this ->mix_DMk_2D .mix (dm_in.get_DMK_vector (), flag_restart); }
161- const std::vector<std::map<int , std::map<std::pair< int , std::array< int , 3 >>, RI::Tensor<Tdata>>>>
210+ const std::vector<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>>
162211 Ds = PARAM.globalv .gamma_only_local
163212 ? RI_2D_Comm::split_m2D_ktoR<Tdata>(ucell,*this ->exx_ptr ->p_kv , this ->mix_DMk_2D .get_DMk_gamma_out (), *dm_in.get_paraV_pointer (), PARAM.inp .nspin )
164213 : RI_2D_Comm::split_m2D_ktoR<Tdata>(ucell,*this ->exx_ptr ->p_kv , this ->mix_DMk_2D .get_DMk_k_out (), *dm_in.get_paraV_pointer (), PARAM.inp .nspin , this ->exx_spacegroup_symmetry );
165214
166215 if (this ->exx_spacegroup_symmetry && GlobalC::exx_info.info_global .exx_symmetry_realspace )
167- { this ->exx_ptr -> cal_exx_elec (Ds, ucell,*dm_in.get_paraV_pointer (), &this ->symrot_ ); }
216+ { this ->cal_exx_elec (Ds, ucell,*dm_in.get_paraV_pointer (), &this ->symrot_ ); }
168217 else
169- { this ->exx_ptr ->cal_exx_elec (Ds, ucell,*dm_in.get_paraV_pointer ()); }
170-
171- this ->flag_finish .elec = true ;
218+ { this ->cal_exx_elec (Ds, ucell,*dm_in.get_paraV_pointer ()); }
172219 };
173220
174221 if (istep > 0 && flag_restart)
@@ -335,9 +382,6 @@ bool Exx_LRI_Interface<T, Tdata>::exx_after_converge(
335382 }
336383 else
337384 {
338- if (!this ->flag_finish .init || !this ->flag_finish .ions )
339- { throw std::runtime_error (" Exx init unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
340-
341385 this ->etot_last_outer_loop = etot;
342386 // update exx and redo scf
343387 if (this ->two_level_step == 0 )
@@ -361,16 +405,11 @@ bool Exx_LRI_Interface<T, Tdata>::exx_after_converge(
361405 : 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 );
362406
363407 if (this ->exx_spacegroup_symmetry && GlobalC::exx_info.info_global .exx_symmetry_realspace )
364- {
365- this ->exx_ptr ->cal_exx_elec (Ds, ucell, *dm.get_paraV_pointer (), &this ->symrot_ );
366- }
408+ { this ->cal_exx_elec (Ds, ucell, *dm.get_paraV_pointer (), &this ->symrot_ ); }
367409 else
368- {
369- this ->exx_ptr ->cal_exx_elec (Ds, ucell, *dm.get_paraV_pointer ()); // restore DM but not Hexx
370- }
410+ { this ->cal_exx_elec (Ds, ucell, *dm.get_paraV_pointer ()); } // restore DM but not Hexx
371411 iter = 0 ;
372412 this ->two_level_step ++;
373- this ->flag_finish .elec = true ;
374413
375414 timeval t_end; gettimeofday (&t_end, nullptr );
376415 std::cout << " and rerun SCF\t "
@@ -384,32 +423,4 @@ bool Exx_LRI_Interface<T, Tdata>::exx_after_converge(
384423 return true ;
385424}
386425
387- template <typename T, typename Tdata>
388- void Exx_LRI_Interface<T, Tdata>::cal_exx_force(const int & nat)
389- {
390- ModuleBase::TITLE (" Exx_LRI_Interface" ," cal_exx_force" );
391- if (!this ->flag_finish .init || !this ->flag_finish .ions )
392- { throw std::runtime_error (" Exx init unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
393- if (!this ->flag_finish .elec )
394- { throw std::runtime_error (" Exx Hamiltonian unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
395-
396- this ->exx_ptr ->cal_exx_force (nat);
397-
398- this ->flag_finish .force = true ;
399- }
400-
401- template <typename T, typename Tdata>
402- void Exx_LRI_Interface<T, Tdata>::cal_exx_stress(const double & omega, const double & lat0)
403- {
404- ModuleBase::TITLE (" Exx_LRI_Interface" ," cal_exx_stress" );
405- if (!this ->flag_finish .init || !this ->flag_finish .ions )
406- { throw std::runtime_error (" Exx init unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
407- if (!this ->flag_finish .elec )
408- { throw std::runtime_error (" Exx Hamiltonian unfinished when " +std::string (__FILE__)+" line " +std::to_string (__LINE__)); }
409-
410- this ->exx_ptr ->cal_exx_stress (omega, lat0);
411-
412- this ->flag_finish .stress = true ;
413- }
414-
415426#endif
0 commit comments