restrict choice of weight factors and guarantee that weights are >= 0.001

This commit is contained in:
Axel Kohlmeyer
2016-09-30 11:11:32 -04:00
parent f7b5afee82
commit d45e333f7c
5 changed files with 33 additions and 12 deletions

View File

@ -24,10 +24,11 @@
#include "update.h"
using namespace LAMMPS_NS;
#define SMALL 0.001
/* -------------------------------------------------------------------- */
ImbalanceVar::ImbalanceVar(LAMMPS *lmp) : Imbalance(lmp), name(0) {}
ImbalanceVar::ImbalanceVar(LAMMPS *lmp) : Imbalance(lmp), name(0), id(0) {}
/* -------------------------------------------------------------------- */
@ -75,7 +76,10 @@ void ImbalanceVar::compute(double *weight)
memory->create(values,nlocal,"imbalance:values");
input->variable->compute_atom(id,all,values,1,0);
for (int i = 0; i < nlocal; ++i) weight[i] *= values[i];
for (int i = 0; i < nlocal; ++i) {
weight[i] *= values[i];
if (weight[i] < SMALL) weight[i] = SMALL;
}
memory->destroy(values);
}