@@ -188,6 +188,7 @@ void Force_LCAO<double>::ftable(const bool isforce,
188188 ModuleBase::matrix& svnl_dbeta,
189189 ModuleBase::matrix& svl_dphi,
190190#ifdef __DEEPKS
191+ ModuleBase::matrix& fvnl_dalpha,
191192 ModuleBase::matrix& svnl_dalpha,
192193#endif
193194 TGint<double >::type& gint,
@@ -246,15 +247,13 @@ void Force_LCAO<double>::ftable(const bool isforce,
246247 false /* reset dm to gint*/ );
247248
248249#ifdef __DEEPKS
250+ const std::vector<std::vector<double >>& dm_gamma = dm->get_DMK_vector ();
249251 if (PARAM.inp .deepks_scf )
250252 {
251- const std::vector<std::vector<double >>& dm_gamma = dm->get_DMK_vector ();
252-
253253 // when deepks_scf is on, the init pdm should be same as the out pdm, so we should not recalculate the pdm
254254 // GlobalC::ld.cal_projected_DM(dm, ucell, orb, gd);
255255
256256 GlobalC::ld.cal_descriptor (ucell.nat );
257-
258257 GlobalC::ld.cal_gedm (ucell.nat );
259258
260259 const int nks = 1 ;
@@ -269,40 +268,9 @@ void Force_LCAO<double>::ftable(const bool isforce,
269268 GlobalC::ld.phialpha ,
270269 GlobalC::ld.gedm ,
271270 GlobalC::ld.inl_index ,
272- GlobalC::ld. F_delta ,
271+ fvnl_dalpha ,
273272 isstress,
274273 svnl_dalpha);
275-
276- #ifdef __MPI
277- Parallel_Reduce::reduce_all (GlobalC::ld.F_delta .c , GlobalC::ld.F_delta .nr * GlobalC::ld.F_delta .nc );
278-
279- if (isstress)
280- {
281- Parallel_Reduce::reduce_pool (svnl_dalpha.c , svnl_dalpha.nr * svnl_dalpha.nc );
282- }
283- #endif
284-
285- if (PARAM.inp .deepks_out_unittest )
286- {
287- const int nks = 1 ; // 1 for gamma-only
288- LCAO_deepks_io::print_dm (nks, PARAM.globalv .nlocal , this ->ParaV ->nrow , dm_gamma);
289-
290- GlobalC::ld.check_projected_dm ();
291-
292- GlobalC::ld.check_descriptor (ucell, PARAM.globalv .global_out_dir );
293-
294- GlobalC::ld.check_gedm ();
295-
296- GlobalC::ld.cal_e_delta_band (dm_gamma, nks);
297-
298- std::ofstream ofs (" E_delta_bands.dat" );
299- ofs << std::setprecision (10 ) << GlobalC::ld.e_delta_band ;
300-
301- std::ofstream ofs1 (" E_delta.dat" );
302- ofs1 << std::setprecision (10 ) << GlobalC::ld.E_delta ;
303-
304- DeePKS_domain::check_f_delta (ucell.nat , GlobalC::ld.F_delta , svnl_dalpha);
305- }
306274 }
307275#endif
308276
@@ -312,14 +280,46 @@ void Force_LCAO<double>::ftable(const bool isforce,
312280 Parallel_Reduce::reduce_pool (ftvnl_dphi.c , ftvnl_dphi.nr * ftvnl_dphi.nc );
313281 Parallel_Reduce::reduce_pool (fvnl_dbeta.c , fvnl_dbeta.nr * fvnl_dbeta.nc );
314282 Parallel_Reduce::reduce_pool (fvl_dphi.c , fvl_dphi.nr * fvl_dphi.nc );
283+ #ifdef __DEEPKS
284+ Parallel_Reduce::reduce_pool (fvnl_dalpha.c , fvnl_dalpha.nr * fvnl_dalpha.nc );
285+ #endif
315286 }
316287 if (isstress)
317288 {
318289 Parallel_Reduce::reduce_pool (soverlap.c , soverlap.nr * soverlap.nc );
319290 Parallel_Reduce::reduce_pool (stvnl_dphi.c , stvnl_dphi.nr * stvnl_dphi.nc );
320291 Parallel_Reduce::reduce_pool (svnl_dbeta.c , svnl_dbeta.nr * svnl_dbeta.nc );
321292 Parallel_Reduce::reduce_pool (svl_dphi.c , svl_dphi.nr * svl_dphi.nc );
293+ #ifdef __DEEPKS
294+ Parallel_Reduce::reduce_pool (svnl_dalpha.c , svnl_dalpha.nr * svnl_dalpha.nc );
295+ #endif
296+ }
297+
298+ #ifdef __DEEPKS
299+ // It seems these test should not all be here, should be moved in the future
300+ // Also, these test are not in multi-k case now
301+ if (PARAM.inp .deepks_scf && PARAM.inp .deepks_out_unittest )
302+ {
303+ const int nks = 1 ; // 1 for gamma-only
304+ LCAO_deepks_io::print_dm (nks, PARAM.globalv .nlocal , this ->ParaV ->nrow , dm_gamma);
305+
306+ GlobalC::ld.check_projected_dm ();
307+
308+ GlobalC::ld.check_descriptor (ucell, PARAM.globalv .global_out_dir );
309+
310+ GlobalC::ld.check_gedm ();
311+
312+ GlobalC::ld.cal_e_delta_band (dm_gamma, nks);
313+
314+ std::ofstream ofs (" E_delta_bands.dat" );
315+ ofs << std::setprecision (10 ) << GlobalC::ld.e_delta_band ;
316+
317+ std::ofstream ofs1 (" E_delta.dat" );
318+ ofs1 << std::setprecision (10 ) << GlobalC::ld.E_delta ;
319+
320+ DeePKS_domain::check_f_delta (ucell.nat , fvnl_dalpha, svnl_dalpha);
322321 }
322+ #endif
323323
324324 // delete DSloc_x, DSloc_y, DSloc_z
325325 // delete DHloc_fixed_x, DHloc_fixed_y, DHloc_fixed_z
0 commit comments