Skip to content

Commit 7fc1419

Browse files
committed
Fix: stress of nonlocal
1 parent fd46e86 commit 7fc1419

1 file changed

Lines changed: 31 additions & 2 deletions

File tree

source/source_lcao/module_operator_lcao/nonlocal_force_stress.hpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,37 @@ void Nonlocal<OperatorLCAO<TK, TR>>::cal_force_stress(const bool cal_force,
182182
}
183183
}
184184

185-
// Finalize with MPI reduction and post-processing
186-
OperatorForceStress::finalize_force_stress(cal_force, cal_stress, this->ucell, stress_tmp, force, stress, 2.0, 2.0);
185+
if (cal_force)
186+
{
187+
#ifdef __MPI
188+
// sum up the occupation matrix
189+
Parallel_Reduce::reduce_all(force.c, force.nr * force.nc);
190+
#endif
191+
for (int i = 0; i < force.nr * force.nc; i++)
192+
{
193+
force.c[i] *= 2.0;
194+
}
195+
}
196+
197+
// stress renormalization
198+
if (cal_stress)
199+
{
200+
#ifdef __MPI
201+
// sum up the occupation matrix
202+
Parallel_Reduce::reduce_all(stress_tmp.data(), 6);
203+
#endif
204+
const double weight = this->ucell->lat0 / this->ucell->omega;
205+
for (int i = 0; i < 6; i++)
206+
{
207+
stress.c[i] = stress_tmp[i] * weight;
208+
}
209+
stress.c[8] = stress.c[5]; // stress(2,2)
210+
stress.c[7] = stress.c[4]; // stress(2,1)
211+
stress.c[6] = stress.c[2]; // stress(2,0)
212+
stress.c[5] = stress.c[4]; // stress(1,2)
213+
stress.c[4] = stress.c[3]; // stress(1,1)
214+
stress.c[3] = stress.c[1]; // stress(1,0)
215+
}
187216

188217
ModuleBase::timer::tick("Nonlocal", "cal_force_stress");
189218
}

0 commit comments

Comments
 (0)