@@ -84,7 +84,7 @@ void ESolver_DoubleXC<TK, TR>::before_all_runners(UnitCell& ucell, const Input_p
8484 }
8585
8686 // 6) initialize the density matrix
87- dynamic_cast <elecstate::ElecStateLCAO<TK>*>( this ->pelec_base )-> init_DM (&this ->kv , &( this ->pv ) , PARAM.inp .nspin );
87+ this ->dmat_base . allocate_dm (&this ->kv , &this ->pv , PARAM.inp .nspin );
8888
8989 // 10) inititlize the charge density
9090 this ->chr_base .allocate (PARAM.inp .nspin );
@@ -138,8 +138,6 @@ void ESolver_DoubleXC<TK, TR>::before_scf(UnitCell& ucell, const int istep)
138138 }
139139 if (this ->p_hamilt_base == nullptr )
140140 {
141- elecstate::DensityMatrix<TK, double >* DM = dynamic_cast <elecstate::ElecStateLCAO<TK>*>(this ->pelec_base )->get_DM ();
142-
143141 this ->p_hamilt_base = new hamilt::HamiltLCAO<TK, TR>(
144142 ucell,
145143 this ->gd ,
@@ -148,7 +146,7 @@ void ESolver_DoubleXC<TK, TR>::before_scf(UnitCell& ucell, const int istep)
148146 this ->kv ,
149147 this ->two_center_bundle_ ,
150148 this ->orb_ ,
151- DM ,
149+ this -> dmat_base . dm ,
152150 this ->deepks ,
153151 istep,
154152 this ->exx_nao );
@@ -159,13 +157,11 @@ void ESolver_DoubleXC<TK, TR>::before_scf(UnitCell& ucell, const int istep)
159157 XC_Functional::set_xc_type (ucell.atoms [0 ].ncpp .xc_func );
160158
161159 // DMR should be same size with Hamiltonian(R)
162- dynamic_cast <elecstate::ElecStateLCAO<TK>*>(this ->pelec_base )
163- ->get_DM ()
164- ->init_DMR (*(dynamic_cast <hamilt::HamiltLCAO<TK, TR>*>(this ->p_hamilt_base )->getHR ()));
160+ this ->dmat_base .dm ->init_DMR (*(dynamic_cast <hamilt::HamiltLCAO<TK, TR>*>(this ->p_hamilt_base )->getHR ()));
165161
166162 if (istep > 0 )
167163 {
168- dynamic_cast <elecstate::ElecStateLCAO<TK>*>( this ->pelec_base )-> get_DM () ->cal_DMR ();
164+ this ->dmat_base . dm ->cal_DMR ();
169165 }
170166
171167 ModuleBase::timer::tick (" ESolver_DoubleXC" , " before_scf" );
@@ -226,23 +222,23 @@ void ESolver_DoubleXC<TK, TR>::iter_finish(UnitCell& ucell, const int istep, int
226222 std::shared_ptr<LCAO_Deepks<TK>> ld_shared_ptr (&this ->deepks .ld , [](LCAO_Deepks<TK>*) {});
227223 LCAO_Deepks_Interface<TK, TR> deepks_interface (ld_shared_ptr);
228224
229- deepks_interface.out_deepks_labels (this ->pelec ->f_en .etot ,
230- this ->kv .get_nks (),
231- ucell.nat ,
232- PARAM.globalv .nlocal ,
233- this ->pelec ->ekb ,
234- this ->kv .kvec_d ,
235- ucell,
236- this ->orb_ ,
237- this ->gd ,
238- &(this ->pv ),
239- *(this ->psi ),
240- dynamic_cast < const elecstate::ElecStateLCAO<TK>*>( this ->pelec )-> get_DM () ,
241- p_ham_deepks,
242- iter,
243- conv_esolver,
244- GlobalV::MY_RANK,
245- GlobalV::ofs_running);
225+ deepks_interface.out_deepks_labels (this ->pelec ->f_en .etot ,
226+ this ->kv .get_nks (),
227+ ucell.nat ,
228+ PARAM.globalv .nlocal ,
229+ this ->pelec ->ekb ,
230+ this ->kv .kvec_d ,
231+ ucell,
232+ this ->orb_ ,
233+ this ->gd ,
234+ &(this ->pv ),
235+ *(this ->psi ),
236+ this ->dmat . dm ,
237+ p_ham_deepks,
238+ iter,
239+ conv_esolver,
240+ GlobalV::MY_RANK,
241+ GlobalV::ofs_running);
246242#endif
247243
248244 // restore to density after charge mixing
@@ -352,9 +348,12 @@ void ESolver_DoubleXC<TK, TR>::iter_finish(UnitCell& ucell, const int istep, int
352348 auto _pes_lcao = dynamic_cast <elecstate::ElecStateLCAO<TK>*>(this ->pelec );
353349 for (int ik = 0 ; ik < nks; ik++)
354350 {
355- _pes_lcao_base->get_DM ()->set_DMK_pointer (ik, _pes_lcao->get_DM ()->get_DMK_pointer (ik));
351+ // mohan update 2025-11-03
352+ this ->dmat_base .dm ->set_DMK_pointer (ik, this ->dmat .dm ->get_DMK_pointer (ik));
353+ // _pes_lcao_base->get_DM()->set_DMK_pointer(ik, _pes_lcao->get_DM()->get_DMK_pointer(ik));
356354 }
357- _pes_lcao_base->get_DM ()->cal_DMR ();
355+ this ->dmat_base .dm ->cal_DMR ();
356+ // _pes_lcao_base->get_DM()->cal_DMR();
358357 _pes_lcao_base->ekb = _pes_lcao->ekb ;
359358 _pes_lcao_base->wg = _pes_lcao->wg ;
360359 }
@@ -386,6 +385,7 @@ void ESolver_DoubleXC<TK, TR>::cal_force(UnitCell& ucell, ModuleBase::matrix& fo
386385 this ->gd ,
387386 this ->pv ,
388387 this ->pelec_base ,
388+ this ->dmat_base , // mohan add 2025-11-03
389389 this ->psi ,
390390 this ->two_center_bundle_ ,
391391 this ->orb_ ,
0 commit comments