@@ -25,12 +25,11 @@ void DeePKS_domain::cal_f_delta(const std::vector<std::vector<TK>>& dm,
2525 ModuleBase::matrix& svnl_dalpha)
2626{
2727 ModuleBase::TITLE (" DeePKS_domain" , " cal_f_delta" );
28-
28+ ModuleBase::timer::tick ( " DeePKS_domain " , " cal_f_delta " );
2929 f_delta.zero_out ();
3030
3131 const double Rcut_Alpha = orb.Alpha [0 ].getRcut ();
3232 const int lmaxd = orb.get_lmax_d ();
33- const int nrow = pv.nrow ;
3433
3534 for (int T0 = 0 ; T0 < ucell.ntype ; T0++)
3635 {
@@ -146,6 +145,22 @@ void DeePKS_domain::cal_f_delta(const std::vector<std::vector<TK>>& dm,
146145 }
147146 }
148147
148+ hamilt::BaseMatrix<double >* overlap_1 = phialpha[0 ]->find_matrix (iat, ibt1, dR1);
149+ hamilt::BaseMatrix<double >* overlap_2 = phialpha[0 ]->find_matrix (iat, ibt2, dR2);
150+ if (overlap_1 == nullptr || overlap_2 == nullptr )
151+ {
152+ continue ;
153+ }
154+ std::vector<hamilt::BaseMatrix<double >*> grad_overlap_1 (3 );
155+ std::vector<hamilt::BaseMatrix<double >*> grad_overlap_2 (3 );
156+ for (int i = 0 ; i < 3 ; ++i)
157+ {
158+ grad_overlap_1[i] = phialpha[i + 1 ]->find_matrix (iat, ibt1, dR1);
159+ grad_overlap_2[i] = phialpha[i + 1 ]->find_matrix (iat, ibt2, dR2);
160+ }
161+
162+ assert (overlap_1->get_col_size () == overlap_2->get_col_size ());
163+
149164 const double * dm_current = dm_pair.get_pointer ();
150165
151166 for (int iw1 = 0 ; iw1 < row_indexes.size (); ++iw1)
@@ -155,18 +170,6 @@ void DeePKS_domain::cal_f_delta(const std::vector<std::vector<TK>>& dm,
155170 double nlm[3 ] = {0 , 0 , 0 };
156171 double nlm_t [3 ] = {0 , 0 , 0 }; // for stress
157172
158- hamilt::BaseMatrix<double >* overlap_1 = phialpha[0 ]->find_matrix (iat, ibt1, dR1);
159- hamilt::BaseMatrix<double >* overlap_2 = phialpha[0 ]->find_matrix (iat, ibt2, dR2);
160- std::vector<hamilt::BaseMatrix<double >*> grad_overlap_1 (3 );
161- std::vector<hamilt::BaseMatrix<double >*> grad_overlap_2 (3 );
162- for (int i = 0 ; i < 3 ; ++i)
163- {
164- grad_overlap_1[i] = phialpha[i + 1 ]->find_matrix (iat, ibt1, dR1);
165- grad_overlap_2[i] = phialpha[i + 1 ]->find_matrix (iat, ibt2, dR2);
166- }
167-
168- assert (overlap_1->get_col_size () == overlap_2->get_col_size ());
169-
170173 if (!PARAM.inp .deepks_equiv )
171174 {
172175 int ib = 0 ;
@@ -310,7 +313,7 @@ void DeePKS_domain::cal_f_delta(const std::vector<std::vector<TK>>& dm,
310313 }
311314 }
312315 }
313-
316+ ModuleBase::timer::tick ( " DeePKS_domain " , " cal_f_delta " );
314317 return ;
315318}
316319
0 commit comments