From e174e4f0f634d1dcbe1b74593a21fff6a1f6e7ff Mon Sep 17 00:00:00 2001 From: Kevin Ruland Date: Sat, 16 Jan 2016 22:14:09 -0600 Subject: [PATCH] Fixes to make simulations finally work again. --- .../net/sf/openrocket/motor/MotorConfiguration.java | 5 ++--- .../sf/openrocket/motor/ThrustCurveMotorState.java | 12 +++++++++++- .../simulation/AbstractSimulationStepper.java | 3 +++ .../src/net/sf/openrocket/simulation/MotorState.java | 5 ++++- .../openrocket/simulation/RK4SimulationStepper.java | 1 + 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/core/src/net/sf/openrocket/motor/MotorConfiguration.java b/core/src/net/sf/openrocket/motor/MotorConfiguration.java index c1d2e4351..ea79e0d51 100644 --- a/core/src/net/sf/openrocket/motor/MotorConfiguration.java +++ b/core/src/net/sf/openrocket/motor/MotorConfiguration.java @@ -43,15 +43,14 @@ public class MotorConfiguration implements FlightConfigurableParameter activeMotorList = status.getActiveMotors(); for (MotorState currentMotorInstance : activeMotorList ) { + if ( !stepMotors ) { + currentMotorInstance = currentMotorInstance.clone(); + } // old: transplanted from MotorInstanceConfiguration double instanceTime = currentTime - currentMotorInstance.getIgnitionTime(); if (instanceTime >= 0) { diff --git a/core/src/net/sf/openrocket/simulation/MotorState.java b/core/src/net/sf/openrocket/simulation/MotorState.java index a1bde98d0..53df42cbf 100644 --- a/core/src/net/sf/openrocket/simulation/MotorState.java +++ b/core/src/net/sf/openrocket/simulation/MotorState.java @@ -5,7 +5,7 @@ import net.sf.openrocket.motor.MotorInstanceId; import net.sf.openrocket.rocketcomponent.IgnitionEvent; import net.sf.openrocket.rocketcomponent.MotorMount; -public interface MotorState { +public interface MotorState extends Cloneable { public void step(double nextTime, double acceleration, AtmosphericConditions cond); public double getThrust(); @@ -28,4 +28,7 @@ public interface MotorState { public double getEjectionDelay(); public void setEjectionDelay( double delay); + + public MotorState clone(); + } diff --git a/core/src/net/sf/openrocket/simulation/RK4SimulationStepper.java b/core/src/net/sf/openrocket/simulation/RK4SimulationStepper.java index 1200f331c..0a4d9ec58 100644 --- a/core/src/net/sf/openrocket/simulation/RK4SimulationStepper.java +++ b/core/src/net/sf/openrocket/simulation/RK4SimulationStepper.java @@ -182,6 +182,7 @@ public class RK4SimulationStepper extends AbstractSimulationStepper { double thrustEstimate = store.thrustForce; store.thrustForce = calculateThrust(status, store.timestep, store.longitudinalAcceleration, store.atmosphericConditions, true); + log.trace("Thrust at time " + store.timestep + " thrustForce = " + store.thrustForce); double thrustDiff = Math.abs(store.thrustForce - thrustEstimate); // Log if difference over 1%, recompute if over 10% if (thrustDiff > 0.01 * thrustEstimate) {