From 372bcae9a7f62f30de75cb958cbca8c5c803d2e4 Mon Sep 17 00:00:00 2001 From: kruland2607 Date: Fri, 5 Oct 2012 16:01:17 -0500 Subject: [PATCH] If the user selected a really small (0) timestep, the simulation gets into an infinite loop. Don't use a user selected timestep smaller than MIN_TIME_STEP. --- .../net/sf/openrocket/simulation/RK4SimulationStepper.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/net/sf/openrocket/simulation/RK4SimulationStepper.java b/core/src/net/sf/openrocket/simulation/RK4SimulationStepper.java index 8548ec91e..fdc4ba626 100644 --- a/core/src/net/sf/openrocket/simulation/RK4SimulationStepper.java +++ b/core/src/net/sf/openrocket/simulation/RK4SimulationStepper.java @@ -138,8 +138,9 @@ public class RK4SimulationStepper extends AbstractSimulationStepper { */ double[] dt = new double[8]; Arrays.fill(dt, Double.MAX_VALUE); - - dt[0] = status.getSimulationConditions().getTimeStep(); + + // If the user selected a really small timestep, use MIN_TIME_STEP instead. + dt[0] = MathUtil.max(status.getSimulationConditions().getTimeStep(),MIN_TIME_STEP); dt[1] = maxTimeStep; dt[2] = status.getSimulationConditions().getMaximumAngleStep() / store.lateralPitchRate; dt[3] = Math.abs(MAX_ROLL_STEP_ANGLE / store.flightConditions.getRollRate()); @@ -159,7 +160,7 @@ public class RK4SimulationStepper extends AbstractSimulationStepper { limitingValue = i; } } - + double minTimeStep = status.getSimulationConditions().getTimeStep() / 20; if (store.timestep < minTimeStep) { log.verbose("Too small time step " + store.timestep + " (limiting factor " + limitingValue + "), using " +