3030#include " module_io/write_wfc_nao.h"
3131#include " module_parameter/parameter.h"
3232
33- // be careful of hpp, there may be multiple definitions of functions, 20250302, mohan
33+ // be careful of hpp, there may be multiple definitions of functions, 20250302, mohan
34+ #include " module_hamilt_lcao/hamilt_lcaodft/hs_matrix_k.hpp"
3435#include " module_io/write_eband_terms.hpp"
3536#include " module_io/write_vxc.hpp"
3637#include " module_io/write_vxc_r.hpp"
37- #include " module_hamilt_lcao/hamilt_lcaodft/hs_matrix_k.hpp"
3838
3939// --------------temporary----------------------------
4040#include " module_base/global_function.h"
@@ -179,15 +179,13 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
179179
180180 // 7) initialize exact exchange calculations
181181#ifdef __EXX
182- if (PARAM.inp .calculation == " scf"
183- || PARAM.inp .calculation == " relax"
184- || PARAM.inp .calculation == " cell-relax"
182+ if (PARAM.inp .calculation == " scf" || PARAM.inp .calculation == " relax" || PARAM.inp .calculation == " cell-relax"
185183 || PARAM.inp .calculation == " md" )
186184 {
187185 if (GlobalC::exx_info.info_global .cal_exx )
188186 {
189187 if (PARAM.inp .init_wfc != " file" )
190- { // if init_wfc==file, directly enter the EXX loop
188+ { // if init_wfc==file, directly enter the EXX loop
191189 XC_Functional::set_xc_first_loop (ucell);
192190 }
193191
@@ -307,7 +305,6 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
307305 return ;
308306}
309307
310-
311308template <typename TK, typename TR>
312309double ESolver_KS_LCAO<TK, TR>::cal_energy()
313310{
@@ -316,7 +313,6 @@ double ESolver_KS_LCAO<TK, TR>::cal_energy()
316313 return this ->pelec ->f_en .etot ;
317314}
318315
319-
320316template <typename TK, typename TR>
321317void ESolver_KS_LCAO<TK, TR>::cal_force(UnitCell& ucell, ModuleBase::matrix& force)
322318{
@@ -460,7 +456,7 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
460456 this ->pelec ->ekb ,
461457 this ->kv );
462458 }
463- }
459+ }
464460
465461 // 4) write projected band structure by jiyy-2022-4-20
466462 if (PARAM.inp .out_proj_band )
@@ -489,49 +485,50 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
489485 if (PARAM.inp .out_mat_xc )
490486 {
491487 ModuleIO::write_Vxc<TK, TR>(PARAM.inp .nspin ,
492- PARAM.globalv .nlocal ,
493- GlobalV::DRANK,
494- &this ->pv ,
495- *this ->psi ,
496- ucell,
497- this ->sf ,
498- this ->solvent ,
499- *this ->pw_rho ,
500- *this ->pw_rhod ,
501- this ->locpp .vloc ,
502- this ->chr ,
503- this ->GG ,
504- this ->GK ,
505- this ->kv ,
506- orb_.cutoffs (),
507- this ->pelec ->wg ,
508- this ->gd
488+ PARAM.globalv .nlocal ,
489+ GlobalV::DRANK,
490+ &this ->pv ,
491+ *this ->psi ,
492+ ucell,
493+ this ->sf ,
494+ this ->solvent ,
495+ *this ->pw_rho ,
496+ *this ->pw_rhod ,
497+ this ->locpp .vloc ,
498+ this ->chr ,
499+ this ->GG ,
500+ this ->GK ,
501+ this ->kv ,
502+ orb_.cutoffs (),
503+ this ->pelec ->wg ,
504+ this ->gd
509505#ifdef __EXX
510- ,
511- this ->exx_lri_double ? &this ->exx_lri_double ->Hexxs : nullptr ,
512- this ->exx_lri_complex ? &this ->exx_lri_complex ->Hexxs : nullptr
506+ ,
507+ this ->exx_lri_double ? &this ->exx_lri_double ->Hexxs : nullptr ,
508+ this ->exx_lri_complex ? &this ->exx_lri_complex ->Hexxs : nullptr
513509#endif
514510 );
515511 }
516512 if (PARAM.inp .out_mat_xc2 )
517513 {
518514 ModuleIO::write_Vxc_R<TK, TR>(PARAM.inp .nspin ,
519- &this ->pv ,
520- ucell,
521- this ->sf ,
522- this ->solvent ,
523- *this ->pw_rho ,
524- *this ->pw_rhod ,
525- this ->locpp .vloc ,
526- this ->chr ,
527- this ->GG ,
528- this ->GK ,
529- this ->kv ,
530- orb_.cutoffs (),
531- this ->gd
515+ &this ->pv ,
516+ ucell,
517+ this ->sf ,
518+ this ->solvent ,
519+ *this ->pw_rho ,
520+ *this ->pw_rhod ,
521+ this ->locpp .vloc ,
522+ this ->chr ,
523+ this ->GG ,
524+ this ->GK ,
525+ this ->kv ,
526+ orb_.cutoffs (),
527+ this ->gd
532528#ifdef __EXX
533- , this ->exx_lri_double ? &this ->exx_lri_double ->Hexxs : nullptr ,
534- this ->exx_lri_complex ? &this ->exx_lri_complex ->Hexxs : nullptr
529+ ,
530+ this ->exx_lri_double ? &this ->exx_lri_double ->Hexxs : nullptr ,
531+ this ->exx_lri_complex ? &this ->exx_lri_complex ->Hexxs : nullptr
535532#endif
536533 );
537534 }
@@ -569,7 +566,6 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
569566 ModuleBase::timer::tick (" ESolver_KS_LCAO" , " after_all_runners" );
570567}
571568
572-
573569template <typename TK, typename TR>
574570void ESolver_KS_LCAO<TK, TR>::iter_init(UnitCell& ucell, const int istep, const int iter)
575571{
@@ -639,11 +635,10 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(UnitCell& ucell, const int istep, const
639635 if (GlobalC::exx_info.info_global .cal_exx )
640636 {
641637 // the following steps are only needed in the first outer exx loop
642- exx_two_level_step = GlobalC::exx_info.info_ri .real_number ?
643- this ->exd ->two_level_step
644- : this ->exc ->two_level_step ;
638+ exx_two_level_step
639+ = GlobalC::exx_info.info_ri .real_number ? this ->exd ->two_level_step : this ->exc ->two_level_step ;
645640 }
646- #endif
641+ #endif
647642 if (iter == 1 && exx_two_level_step == 0 )
648643 {
649644 std::cout << " WAVEFUN -> CHARGE " << std::endl;
@@ -742,6 +737,11 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(UnitCell& ucell, const int istep, const
742737 {
743738 this ->p_hamilt ->refresh ();
744739 }
740+ if (iter == 1 && istep == 0 )
741+ {
742+ // initialize DMR
743+ this ->ld .init_DMR (ucell, orb_, this ->pv , this ->gd );
744+ }
745745#endif
746746
747747 if (PARAM.inp .vl_in_h )
@@ -758,7 +758,6 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(UnitCell& ucell, const int istep, const
758758 }
759759}
760760
761-
762761template <typename TK, typename TR>
763762void ESolver_KS_LCAO<TK, TR>::hamilt2rho_single(UnitCell& ucell, int istep, int iter, double ethr)
764763{
@@ -822,7 +821,6 @@ void ESolver_KS_LCAO<TK, TR>::hamilt2rho_single(UnitCell& ucell, int istep, int
822821 this ->pelec ->f_en .deband = this ->pelec ->cal_delta_eband (ucell);
823822}
824823
825-
826824template <typename TK, typename TR>
827825void ESolver_KS_LCAO<TK, TR>::update_pot(UnitCell& ucell, const int istep, const int iter, const bool conv_esolver)
828826{
@@ -840,7 +838,6 @@ void ESolver_KS_LCAO<TK, TR>::update_pot(UnitCell& ucell, const int istep, const
840838 }
841839}
842840
843-
844841template <typename TK, typename TR>
845842void ESolver_KS_LCAO<TK, TR>::iter_finish(UnitCell& ucell, const int istep, int & iter, bool & conv_esolver)
846843{
@@ -878,6 +875,7 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(UnitCell& ucell, const int istep, int&
878875 = dynamic_cast <const elecstate::ElecStateLCAO<TK>*>(this ->pelec )->get_DM ()->get_DMK_vector ();
879876
880877 ld.dpks_cal_e_delta_band (dm, this ->kv .get_nks ());
878+ DeePKS_domain::update_dmr (this ->kv .kvec_d , dm, ucell, orb_, this ->pv , this ->gd , ld.dm_r );
881879 this ->pelec ->f_en .edeepks_scf = ld.E_delta - ld.e_delta_band ;
882880 this ->pelec ->f_en .edeepks_delta = ld.E_delta ;
883881 }
0 commit comments