Skip to content

Commit ceeefc3

Browse files
committed
fix a bug
1 parent 4799d5f commit ceeefc3

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

source/module_hamilt_lcao/module_deepks/deepks_force.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ void DeePKS_domain::cal_f_delta(const std::vector<std::vector<TK>>& dm,
3333

3434
#pragma omp parallel
3535
{
36-
ModuleBase::matrix svnl_dalpha_local(svnl_dalpha.nr, svnl_dalpha.nc);
3736
ModuleBase::matrix f_delta_local(f_delta.nr, f_delta.nc);
37+
if(isstress)
38+
{
39+
ModuleBase::matrix svnl_dalpha_local(svnl_dalpha.nr, svnl_dalpha.nc);
40+
}
3841
#pragma omp for schedule(dynamic)
3942
for (int iat = 0; iat < ucell.nat; iat++)
4043
{
@@ -299,13 +302,16 @@ void DeePKS_domain::cal_f_delta(const std::vector<std::vector<TK>>& dm,
299302
} // ad2
300303
} // ad1
301304
} // iat
302-
for (int ipol = 0; ipol < 3; ipol++)
305+
if(isstress)
303306
{
304-
for (int jpol = ipol; jpol < 3; jpol++)
307+
for (int ipol = 0; ipol < 3; ipol++)
305308
{
306-
#pragma omp atomic
307-
svnl_dalpha(ipol, jpol)
308-
+= svnl_dalpha_local(ipol, jpol);
309+
for (int jpol = ipol; jpol < 3; jpol++)
310+
{
311+
#pragma omp atomic
312+
svnl_dalpha(ipol, jpol)
313+
+= svnl_dalpha_local(ipol, jpol);
314+
}
309315
}
310316
}
311317
for (int iat = 0; iat < ucell.nat; iat++)

0 commit comments

Comments
 (0)