1+ #ifndef EXX_LRI_INTERFACE_HPP
2+ #define EXX_LRI_INTERFACE_HPP
3+
14#include " Exx_LRI_interface.h"
25#include " module_ri/exx_abfs-jle.h"
36#include " module_ri/exx_opt_orb.h"
47#include " module_hamilt_lcao/hamilt_lcaodft/hamilt_lcao.h"
58#include " module_hamilt_lcao/hamilt_lcaodft/operator_lcao/op_exx_lcao.h"
69
10+ #include < sys/time.h>
11+
712template <typename T, typename Tdata>
813void Exx_LRI_Interface<T, Tdata>::write_Hexxs(const std::string& file_name) const
914{
@@ -32,13 +37,9 @@ void Exx_LRI_Interface<T, Tdata>::exx_beforescf(const K_Vectors& kv, const Charg
3237 if ( GlobalC::exx_info.info_global .cal_exx )
3338 {
3439 if (GlobalC::ucell.atoms [0 ].ncpp .xc_func == " HF" || GlobalC::ucell.atoms [0 ].ncpp .xc_func == " PBE0" || GlobalC::ucell.atoms [0 ].ncpp .xc_func == " HSE" )
35- {
3640 XC_Functional::set_xc_type (" pbe" );
37- }
3841 else if (GlobalC::ucell.atoms [0 ].ncpp .xc_func == " SCAN0" )
39- {
4042 XC_Functional::set_xc_type (" scan" );
41- }
4243
4344 this ->exx_ptr ->cal_exx_ions ();
4445 }
@@ -57,13 +58,9 @@ void Exx_LRI_Interface<T, Tdata>::exx_beforescf(const K_Vectors& kv, const Charg
5758 {
5859 this ->mix_DMk_2D .set_nks (kv.nks , GlobalV::GAMMA_ONLY_LOCAL);
5960 if (GlobalC::exx_info.info_global .separate_loop )
60- {
6161 this ->mix_DMk_2D .set_mixing (nullptr );
62- }
6362 else
64- {
6563 this ->mix_DMk_2D .set_mixing (chgmix.mixing );
66- }
6764 }
6865 // for exx two_level scf
6966 this ->two_level_step = 0 ;
@@ -139,25 +136,28 @@ bool Exx_LRI_Interface<T, Tdata>::exx_after_converge(
139136 }
140137 else
141138 {
142- hamilt::Operator<std::complex <double >>* exx;
143139 if (GlobalV::NSPIN < 4 )
144140 {
145- hamilt::HamiltLCAO<std::complex <double >, double >* hamilt_lcao =
146- dynamic_cast <hamilt::HamiltLCAO<std::complex <double >, double >*>(&hamilt);
147- exx = new hamilt::OperatorEXX<hamilt::OperatorLCAO<std::complex <double >, double >>(&lm,
148- hamilt_lcao->getHR (),
149- &(hamilt_lcao->getHk (&lm)),
150- kv);
141+ hamilt::HamiltLCAO<std::complex <double >, double >* hamilt_lcao
142+ = dynamic_cast <hamilt::HamiltLCAO<std::complex <double >, double >*>(&hamilt);
143+ hamilt::Operator<std::complex <double >>* exx
144+ = new hamilt::OperatorEXX<hamilt::OperatorLCAO<std::complex <double >, double >>(
145+ &lm,
146+ hamilt_lcao->getHR (),
147+ &(hamilt_lcao->getHk (&lm)),
148+ kv);
151149 hamilt_lcao->getOperator ()->add (exx);
152150 }
153151 else
154152 {
155- hamilt::HamiltLCAO<std::complex <double >, std::complex <double >>* hamilt_lcao =
156- dynamic_cast <hamilt::HamiltLCAO<std::complex <double >, std::complex <double >>*>(&hamilt);
157- exx = new hamilt::OperatorEXX<hamilt::OperatorLCAO<std::complex <double >, std::complex <double >>>(&lm,
158- hamilt_lcao->getHR (),
159- &(hamilt_lcao->getHk (&lm)),
160- kv);
153+ hamilt::HamiltLCAO<std::complex <double >, std::complex <double >>* hamilt_lcao
154+ = dynamic_cast <hamilt::HamiltLCAO<std::complex <double >, std::complex <double >>*>(&hamilt);
155+ hamilt::Operator<std::complex <double >>* exx
156+ = new hamilt::OperatorEXX<hamilt::OperatorLCAO<std::complex <double >, std::complex <double >>>(
157+ &lm,
158+ hamilt_lcao->getHR (),
159+ &(hamilt_lcao->getHk (&lm)),
160+ kv);
161161 hamilt_lcao->getOperator ()->add (exx);
162162 }
163163 }
@@ -207,6 +207,9 @@ bool Exx_LRI_Interface<T, Tdata>::exx_after_converge(
207207 XC_Functional::set_xc_type (GlobalC::ucell.atoms [0 ].ncpp .xc_func );
208208 }
209209
210+ std::cout << " Updating EXX " << std::flush;
211+ timeval t_start; gettimeofday (&t_start, NULL );
212+
210213 const bool flag_restart = (this ->two_level_step == 0 ) ? true : false ;
211214 this ->mix_DMk_2D .mix (dm.get_DMK_vector (), flag_restart);
212215
@@ -217,10 +220,20 @@ bool Exx_LRI_Interface<T, Tdata>::exx_after_converge(
217220 : RI_2D_Comm::split_m2D_ktoR<Tdata>(*this ->exx_ptr ->p_kv , this ->mix_DMk_2D .get_DMk_k_out (), *dm.get_paraV_pointer ());
218221 this ->exx_ptr ->cal_exx_elec (Ds, *dm.get_paraV_pointer ());
219222 iter = 0 ;
220- std::cout << " Updating EXX and rerun SCF" << std::endl;
221223 this ->two_level_step ++;
224+
225+ timeval t_end; gettimeofday (&t_end, NULL );
226+ std::cout << " and rerun SCF\t "
227+ << std::setprecision (3 ) << std::setiosflags (std::ios::scientific)
228+ << (double )(t_end.tv_sec -t_start.tv_sec ) + (double )(t_end.tv_usec -t_start.tv_usec )/1000000.0
229+ << std::defaultfloat << " (s)" << std::endl;
222230 return false ;
223231 }
224232 }
225- return true ;
226- }
233+ else
234+ {
235+ return true ;
236+ }
237+ }
238+
239+ #endif
0 commit comments