@@ -635,19 +635,22 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(const int istep, const int iter)
635635
636636#ifdef __EXX
637637 // calculate exact-exchange
638- if (GlobalC::exx_info.info_ri .real_number )
639- {
640- this ->exd ->exx_eachiterinit (istep,
641- *dynamic_cast <const elecstate::ElecStateLCAO<TK>*>(this ->pelec )->get_DM (),
642- this ->kv ,
643- iter);
644- }
645- else
638+ if (PARAM.inp .calculation != " nscf" )
646639 {
647- this ->exc ->exx_eachiterinit (istep,
648- *dynamic_cast <const elecstate::ElecStateLCAO<TK>*>(this ->pelec )->get_DM (),
649- this ->kv ,
650- iter);
640+ if (GlobalC::exx_info.info_ri .real_number )
641+ {
642+ this ->exd ->exx_eachiterinit (istep,
643+ *dynamic_cast <const elecstate::ElecStateLCAO<TK>*>(this ->pelec )->get_DM (),
644+ this ->kv ,
645+ iter);
646+ }
647+ else
648+ {
649+ this ->exc ->exx_eachiterinit (istep,
650+ *dynamic_cast <const elecstate::ElecStateLCAO<TK>*>(this ->pelec )->get_DM (),
651+ this ->kv ,
652+ iter);
653+ }
651654 }
652655#endif
653656
@@ -729,13 +732,16 @@ void ESolver_KS_LCAO<TK, TR>::hamilt2density_single(int istep, int iter, double
729732
730733 // 5) what's the exd used for?
731734#ifdef __EXX
732- if (GlobalC::exx_info. info_ri . real_number )
735+ if (PARAM. inp . calculation != " nscf " )
733736 {
734- this ->exd ->exx_hamilt2density (*this ->pelec , this ->pv , iter);
735- }
736- else
737- {
738- this ->exc ->exx_hamilt2density (*this ->pelec , this ->pv , iter);
737+ if (GlobalC::exx_info.info_ri .real_number )
738+ {
739+ this ->exd ->exx_hamilt2density (*this ->pelec , this ->pv , iter);
740+ }
741+ else
742+ {
743+ this ->exc ->exx_hamilt2density (*this ->pelec , this ->pv , iter);
744+ }
739745 }
740746#endif
741747
@@ -922,11 +928,29 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(const int istep, int& iter)
922928
923929#ifdef __EXX
924930 // 3) save exx matrix
925- if (GlobalC::exx_info. info_global . cal_exx )
931+ if (PARAM. inp . calculation != " nscf " )
926932 {
927- GlobalC::exx_info.info_ri .real_number ?
928- this ->exd ->exx_iter_finish (this ->kv , GlobalC::ucell, *this ->p_hamilt , *this ->pelec , *this ->p_chgmix , this ->scf_ene_thr , iter, istep, this ->conv_esolver ) :
929- this ->exc ->exx_iter_finish (this ->kv , GlobalC::ucell, *this ->p_hamilt , *this ->pelec , *this ->p_chgmix , this ->scf_ene_thr , iter, istep, this ->conv_esolver );
933+ if (GlobalC::exx_info.info_global .cal_exx )
934+ {
935+ GlobalC::exx_info.info_ri .real_number ? this ->exd ->exx_iter_finish (this ->kv ,
936+ GlobalC::ucell,
937+ *this ->p_hamilt ,
938+ *this ->pelec ,
939+ *this ->p_chgmix ,
940+ this ->scf_ene_thr ,
941+ iter,
942+ istep,
943+ this ->conv_esolver )
944+ : this ->exc ->exx_iter_finish (this ->kv ,
945+ GlobalC::ucell,
946+ *this ->p_hamilt ,
947+ *this ->pelec ,
948+ *this ->p_chgmix ,
949+ this ->scf_ene_thr ,
950+ iter,
951+ istep,
952+ this ->conv_esolver );
953+ }
930954 }
931955#endif
932956
@@ -1041,17 +1065,20 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(const int istep)
10411065
10421066#ifdef __EXX
10431067 // 5) write Hexx matrix for NSCF (see `out_chg` in docs/advanced/input_files/input-main.md)
1044- if (GlobalC::exx_info.info_global .cal_exx && PARAM.inp .out_chg [0 ]
1045- && istep % PARAM.inp .out_interval == 0 ) // Peize Lin add if 2022.11.14
1068+ if (PARAM.inp .calculation != " nscf" )
10461069 {
1047- const std::string file_name_exx = PARAM.globalv . global_out_dir + " HexxR " + std::to_string (GlobalV::MY_RANK);
1048- if (GlobalC::exx_info. info_ri . real_number )
1070+ if (GlobalC::exx_info. info_global . cal_exx && PARAM.inp . out_chg [ 0 ]
1071+ && istep % PARAM. inp . out_interval == 0 ) // Peize Lin add if 2022.11.14
10491072 {
1050- ModuleIO::write_Hexxs_csr (file_name_exx, GlobalC::ucell, this ->exd ->get_Hexxs ());
1051- }
1052- else
1053- {
1054- ModuleIO::write_Hexxs_csr (file_name_exx, GlobalC::ucell, this ->exc ->get_Hexxs ());
1073+ const std::string file_name_exx = PARAM.globalv .global_out_dir + " HexxR" + std::to_string (GlobalV::MY_RANK);
1074+ if (GlobalC::exx_info.info_ri .real_number )
1075+ {
1076+ ModuleIO::write_Hexxs_csr (file_name_exx, GlobalC::ucell, this ->exd ->get_Hexxs ());
1077+ }
1078+ else
1079+ {
1080+ ModuleIO::write_Hexxs_csr (file_name_exx, GlobalC::ucell, this ->exc ->get_Hexxs ());
1081+ }
10551082 }
10561083 }
10571084#endif
0 commit comments