in floating point math a*b may be zero even if both a>0 and b>0

This commit is contained in:
Axel Kohlmeyer
2021-09-24 16:43:07 -04:00
parent 4d9cef823d
commit b3a8a7bf6f

View File

@ -171,7 +171,7 @@ void FixDtReset::end_of_step()
if (vsq > 0.0) dtv = xmax / sqrt(vsq);
if (fsq > 0.0) dtf = sqrt(2.0 * xmax / (ftm2v * sqrt(fsq) * massinv));
dt = MIN(dtv, dtf);
if (emax > 0.0 && vsq > 0.0 && fsq > 0.0) {
if ((emax > 0.0) && (fsq * vsq > 0.0)) {
dte = emax / sqrt(fsq * vsq) / sqrt(ftm2v * mvv2e);
dt = MIN(dt, dte);
}