@@ -157,7 +157,7 @@ void ESolver_KS_LCAO_TDDFT<TR, Device>::runner(UnitCell& ucell, const int istep)
157157 this ->hamilt2rho (ucell, totstep, iter, this ->diag_ethr ); // From ESolver_KS
158158
159159 // 5) Finish SCF iterations
160- this ->iter_finish (ucell, totstep, iter, conv_esolver);
160+ this ->iter_finish (ucell, totstep, estep, estep_max, iter, conv_esolver);
161161
162162 // 6) Check convergence
163163 if (conv_esolver || this ->oscillate_esolver )
@@ -283,7 +283,12 @@ void ESolver_KS_LCAO_TDDFT<TR, Device>::hamilt2rho_single(UnitCell& ucell,
283283}
284284
285285template <typename TR, typename Device>
286- void ESolver_KS_LCAO_TDDFT<TR, Device>::iter_finish(UnitCell& ucell, const int istep, int & iter, bool & conv_esolver)
286+ void ESolver_KS_LCAO_TDDFT<TR, Device>::iter_finish(UnitCell& ucell,
287+ const int istep,
288+ const int estep,
289+ const int estep_max,
290+ int & iter,
291+ bool & conv_esolver)
287292{
288293 // Print occupation of each band
289294 if (iter == 1 && istep <= 2 )
@@ -307,6 +312,13 @@ void ESolver_KS_LCAO_TDDFT<TR, Device>::iter_finish(UnitCell& ucell, const int i
307312
308313 // Store wave function, Hamiltonian and Overlap matrix, to be used in next time step
309314 this ->store_h_s_psi (ucell, istep, iter, conv_esolver);
315+
316+ // Calculate energy-density matrix for RT-TDDFT
317+ if (conv_esolver && estep == estep_max - 1 && istep >= (PARAM.inp .init_wfc == " file" ? 0 : 1 )
318+ && PARAM.inp .td_edm == 0 )
319+ {
320+ elecstate::cal_edm_tddft (this ->pv , this ->pelec , this ->kv , this ->p_hamilt );
321+ }
310322}
311323
312324template <typename TR, typename Device>
@@ -421,12 +433,6 @@ void ESolver_KS_LCAO_TDDFT<TR, Device>::store_h_s_psi(UnitCell& ucell,
421433 1 );
422434 }
423435 }
424-
425- // Calculate energy-density matrix for RT-TDDFT
426- if (istep >= (PARAM.inp .init_wfc == " file" ? 0 : 1 ) && PARAM.inp .td_edm == 0 )
427- {
428- elecstate::cal_edm_tddft (this ->pv , this ->pelec , this ->kv , this ->p_hamilt );
429- }
430436 }
431437}
432438
0 commit comments