avoid division by zero
This commit is contained in:
@ -243,7 +243,7 @@ void ComputeBasalAtom::compute_peratom()
|
||||
j1[1]=2;
|
||||
j1[2]=2;
|
||||
}
|
||||
xmean5 = ymean5 = zmean5 = xmean6 = ymean6 = zmean6 = xmean7 = ymean7 = zmean7 = 0;
|
||||
xmean5 = ymean5 = zmean5 = xmean6 = ymean6 = zmean6 = xmean7 = ymean7 = zmean7 = 0.0;
|
||||
for (j = 0; j < chi[0]; j++) {
|
||||
for (k = j+1; k < chi[0]; k++) {
|
||||
//get cross products
|
||||
@ -261,27 +261,29 @@ void ComputeBasalAtom::compute_peratom()
|
||||
y7[count] = y4[count]*copysign(1.0,z4[count]);
|
||||
z7[count] = z4[count]*copysign(1.0,z4[count]);
|
||||
//get average cross products
|
||||
xmean5 = xmean5 + x5[count];
|
||||
ymean5 = ymean5 + y5[count];
|
||||
zmean5 = zmean5 + z5[count];
|
||||
xmean6 = xmean6 + x6[count];
|
||||
ymean6 = ymean6 + y6[count];
|
||||
zmean6 = zmean6 + z6[count];
|
||||
xmean7 = xmean7 + x7[count];
|
||||
ymean7 = ymean7 + y7[count];
|
||||
zmean6 = zmean6 + z7[count];
|
||||
xmean5 += x5[count];
|
||||
ymean5 += y5[count];
|
||||
zmean5 += z5[count];
|
||||
xmean6 += x6[count];
|
||||
ymean6 += y6[count];
|
||||
zmean6 += z6[count];
|
||||
xmean7 += x7[count];
|
||||
ymean7 += y7[count];
|
||||
zmean6 += z7[count];
|
||||
count++;
|
||||
}
|
||||
}
|
||||
xmean5 = xmean5/count;
|
||||
xmean6 = xmean6/count;
|
||||
xmean7 = xmean7/count;
|
||||
ymean5 = ymean5/count;
|
||||
ymean6 = ymean6/count;
|
||||
ymean7 = ymean7/count;
|
||||
zmean5 = zmean5/count;
|
||||
zmean6 = zmean6/count;
|
||||
zmean7 = zmean7/count;
|
||||
if (count > 0) {
|
||||
xmean5 /= count;
|
||||
xmean6 /= count;
|
||||
xmean7 /= count;
|
||||
ymean5 /= count;
|
||||
ymean6 /= count;
|
||||
ymean7 /= count;
|
||||
zmean5 /= count;
|
||||
zmean6 /= count;
|
||||
zmean7 /= count;
|
||||
}
|
||||
var5 = var6 = var7 = 0.0;
|
||||
//find standard deviations
|
||||
for (j=0;j<count;j++){
|
||||
|
||||
@ -76,8 +76,8 @@ FixTISpring::FixTISpring(LAMMPS *lmp, int narg, char **arg) :
|
||||
t_switch = atoi(arg[4]); // Switching time.
|
||||
t_equil = atoi(arg[5]); // Equilibration time.
|
||||
t0 = update->ntimestep; // Initial time.
|
||||
if (t_switch < 0.0) error->all(FLERR,"Illegal fix ti/spring command");
|
||||
if (t_equil < 0.0) error->all(FLERR,"Illegal fix ti/spring command");
|
||||
if (t_switch <= 0.0) error->all(FLERR,"Illegal fix ti/spring command");
|
||||
if (t_equil <= 0.0) error->all(FLERR,"Illegal fix ti/spring command");
|
||||
|
||||
// Coupling parameter initialization.
|
||||
sf = 1;
|
||||
|
||||
@ -225,6 +225,10 @@ FixTTMMod::FixTTMMod(LAMMPS *lmp, int narg, char **arg) :
|
||||
t_surface_l = surface_l;
|
||||
mult_factor = intensity;
|
||||
duration = 0.0;
|
||||
v_0_sq = v_0*v_0;
|
||||
// error checks
|
||||
if (nxnodes <= 0 || nynodes <= 0 || nznodes <= 0)
|
||||
error->all(FLERR,"Fix ttm number of nodes must be > 0");
|
||||
surface_double = double(t_surface_l)*(domain->xprd/nxnodes);
|
||||
if ((C_limit+esheat_0) < 0.0)
|
||||
error->all(FLERR,"Fix ttm electronic_specific_heat must be >= 0.0");
|
||||
@ -234,10 +238,6 @@ FixTTMMod::FixTTMMod(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (gamma_s < 0.0) error->all(FLERR,"Fix ttm gamma_s must be >= 0.0");
|
||||
if (v_0 < 0.0) error->all(FLERR,"Fix ttm v_0 must be >= 0.0");
|
||||
if (ionic_density <= 0.0) error->all(FLERR,"Fix ttm ionic_density must be > 0.0");
|
||||
v_0_sq = v_0*v_0;
|
||||
// error check
|
||||
if (nxnodes <= 0 || nynodes <= 0 || nznodes <= 0)
|
||||
error->all(FLERR,"Fix ttm number of nodes must be > 0");
|
||||
if (seed <= 0) error->all(FLERR,"Invalid random number seed in fix ttm command");
|
||||
if (surface_l < 0) error->all(FLERR,"Surface coordinates must be >= 0");
|
||||
if (surface_l >= surface_r) error->all(FLERR, "Left surface coordinate must be less than right surface coordinate");
|
||||
|
||||
@ -330,6 +330,7 @@ void FixSMD_TLSPH_ReferenceConfiguration::setup(int vflag) {
|
||||
int nall, countall;
|
||||
MPI_Allreduce(&n, &nall, 1, MPI_INT, MPI_SUM, world);
|
||||
MPI_Allreduce(&count, &countall, 1, MPI_INT, MPI_SUM, world);
|
||||
if (countall < 1) countall = 1;
|
||||
|
||||
if (comm->me == 0) {
|
||||
if (screen) {
|
||||
|
||||
Reference in New Issue
Block a user