avoid memory corruption when using mliap unified with ghostneigh_flag == 1
This commit is contained in:
@ -245,15 +245,19 @@ MLIAPBuildUnified_t LAMMPS_NS::build_unified(char *unified_fname, MLIAPData *dat
|
|||||||
void LAMMPS_NS::update_pair_energy(MLIAPData *data, double *eij)
|
void LAMMPS_NS::update_pair_energy(MLIAPData *data, double *eij)
|
||||||
{
|
{
|
||||||
double e_total = 0;
|
double e_total = 0;
|
||||||
for (int ii = 0; ii < data->nlistatoms; ii++) data->eatoms[ii] = 0;
|
const auto nlistatoms = data->nlistatoms;
|
||||||
|
for (int ii = 0; ii < nlistatoms; ii++) data->eatoms[ii] = 0;
|
||||||
|
|
||||||
for (int ii = 0; ii < data->npairs; ii++) {
|
for (int ii = 0; ii < data->npairs; ii++) {
|
||||||
int i = data->pair_i[ii];
|
int i = data->pair_i[ii];
|
||||||
double e = 0.5 * eij[ii];
|
double e = 0.5 * eij[ii];
|
||||||
|
|
||||||
|
// TODO: the if avoids memory corruption with ghostneigh_flag = 1,
|
||||||
|
if (i < nlistatoms) {
|
||||||
data->eatoms[i] += e;
|
data->eatoms[i] += e;
|
||||||
e_total += e;
|
e_total += e;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
data->energy = e_total;
|
data->energy = e_total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user