@@ -69,6 +69,7 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
6969 Gint_Tools::init_orb (dr_uniform, rcuts, ucell, orb_, psi_u, dpsi_u, d2psi_u);
7070
7171 // ! 5) set periodic boundary conditions
72+ #ifndef __NEW_GINT
7273 this ->GridT .set_pbc_grid (this ->pw_rho ->nx ,
7374 this ->pw_rho ->ny ,
7475 this ->pw_rho ->nz ,
@@ -92,9 +93,17 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
9293 dpsi_u,
9394 d2psi_u,
9495 PARAM.inp .nstream );
96+
97+ psi_u.clear ();
98+ psi_u.shrink_to_fit ();
99+ dpsi_u.clear ();
100+ dpsi_u.shrink_to_fit ();
101+ d2psi_u.clear ();
102+ d2psi_u.shrink_to_fit ();
103+ LCAO_domain::grid_prepare (this ->GridT , this ->GG , this ->GK , ucell, orb_, *this ->pw_rho , *this ->pw_big );
95104
96105 // ! 6) prepare grid integral
97- #ifdef __NEW_GINT
106+ #else
98107 auto gint_info = std::make_shared<ModuleGint::GintInfo>(
99108 this ->pw_big ->nbx ,
100109 this ->pw_big ->nby ,
@@ -114,22 +123,12 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
114123 ModuleGint::Gint::set_gint_info (gint_info);
115124#endif
116125
117- psi_u.clear ();
118- psi_u.shrink_to_fit ();
119- dpsi_u.clear ();
120- dpsi_u.shrink_to_fit ();
121- d2psi_u.clear ();
122- d2psi_u.shrink_to_fit ();
123-
124126 // 7) For each atom, calculate the adjacent atoms in different cells
125127 // and allocate the space for H(R) and S(R).
126128 // If k point is used here, allocate HlocR after atom_arrange.
127129 this ->RA .for_2d (ucell, this ->gd , this ->pv , PARAM.globalv .gamma_only_local , orb_.cutoffs ());
128130
129- // 8) after ions move, prepare grid in Gint
130- LCAO_domain::grid_prepare (this ->GridT , this ->GG , this ->GK , ucell, orb_, *this ->pw_rho , *this ->pw_big );
131-
132- // 9) initialize the Hamiltonian operators
131+ // 8) initialize the Hamiltonian operators
133132 // if atom moves, then delete old pointer and add a new one
134133 if (this ->p_hamilt != nullptr )
135134 {
@@ -169,7 +168,7 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
169168
170169
171170#ifdef __MLALGO
172- // 10 ) for each ionic step, the overlap <phi|alpha> must be rebuilt
171+ // 9 ) for each ionic step, the overlap <phi|alpha> must be rebuilt
173172 // since it depends on ionic positions
174173 if (PARAM.globalv .deepks_setorb )
175174 {
@@ -198,7 +197,7 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
198197 }
199198#endif
200199
201- // 11 ) prepare sc calculation
200+ // 10 ) prepare sc calculation
202201 if (PARAM.inp .sc_mag_switch )
203202 {
204203 spinconstrain::SpinConstrain<TK>& sc = spinconstrain::SpinConstrain<TK>::getScInstance ();
@@ -217,7 +216,7 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
217216 this ->pelec );
218217 }
219218
220- // 12 ) set xc type before the first cal of xc in pelec->init_scf
219+ // 11 ) set xc type before the first cal of xc in pelec->init_scf
221220 // Peize Lin add 2016-12-03
222221#ifdef __EXX
223222 if (PARAM.inp .calculation != " nscf" )
@@ -233,10 +232,10 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
233232 }
234233#endif
235234
236- // 13 ) init_scf, should be before_scf? mohan add 2025-03-10
235+ // 12 ) init_scf, should be before_scf? mohan add 2025-03-10
237236 this ->pelec ->init_scf (istep, ucell, this ->Pgrid , this ->sf .strucFac , this ->locpp .numeric , ucell.symm );
238237
239- // 14 ) initalize DMR
238+ // 13 ) initalize DMR
240239 // DMR should be same size with Hamiltonian(R)
241240 dynamic_cast <elecstate::ElecStateLCAO<TK>*>(this ->pelec )
242241 ->get_DM ()
@@ -247,26 +246,26 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
247246 this ->ld .init_DMR (ucell, orb_, this ->pv , this ->gd );
248247#endif
249248
250- // 15 ) two cases are considered:
249+ // 14 ) two cases are considered:
251250 // 1. DMK in DensityMatrix is not empty (istep > 0), then DMR is initialized by DMK
252251 // 2. DMK in DensityMatrix is empty (istep == 0), then DMR is initialized by zeros
253252 if (istep > 0 )
254253 {
255254 dynamic_cast <elecstate::ElecStateLCAO<TK>*>(this ->pelec )->get_DM ()->cal_DMR ();
256255 }
257256
258- // 16 ) the electron charge density should be symmetrized,
257+ // 15 ) the electron charge density should be symmetrized,
259258 // here is the initialization
260259 Symmetry_rho srho;
261260 for (int is = 0 ; is < PARAM.inp .nspin ; is++)
262261 {
263262 srho.begin (is, this ->chr , this ->pw_rho , ucell.symm );
264263 }
265264
266- // 17 ) why we need to set this sentence? mohan add 2025-03-10
265+ // 16 ) why we need to set this sentence? mohan add 2025-03-10
267266 this ->p_hamilt ->non_first_scf = istep;
268267
269- // 18 ) update of RDMFT, added by jghan
268+ // 17 ) update of RDMFT, added by jghan
270269 if (PARAM.inp .rdmft == true )
271270 {
272271 // necessary operation of these parameters have be done with p_esolver->Init() in source/driver_run.cpp
0 commit comments