From 18763d6fdd3409f0f714d4804fd5150cef7dc329 Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Sat, 24 Dec 2022 11:36:41 -0700 Subject: [PATCH] Throw exception at simulation startup if CP can't be calculated. Exception says "Can't calculate rocket stability." --- core/resources/l10n/messages.properties | 5 ++--- .../simulation/BasicEventSimulationEngine.java | 9 +++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index a8c1cb10f..78e9e6a9c 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -562,6 +562,7 @@ SimuRunDlg.msg.Unabletosim = Unable to simulate: SimuRunDlg.msg.errorOccurred = An error occurred during the simulation: BasicEventSimulationEngine.error.noMotorsDefined = No motors defined in the simulation. +BasicEventSimulationEngine.error.cantCalculateStability = Can't calculate rocket stability. BasicEventSimulationEngine.error.earlyMotorBurnout = Motor burnout without liftoff. BasicEventSimulationEngine.error.noConfiguredIgnition = No motors configured to ignite at liftoff BasicEventSimulationEngine.error.noIgnition = No motors ignited. @@ -1148,8 +1149,6 @@ NoseConeCfg.tab.General = General NoseConeCfg.tab.ttip.General = General properties NoseConeCfg.tab.Shoulder = Shoulder NoseConeCfg.tab.ttip.Shoulder = Shoulder properties -NoseConeCfg.checkbox.Flip = Flip to tail cone -NoseConeCfg.checkbox.Flip.ttip = Flips the nose cone direction to a tail cone. ! ParachuteConfig Parachute.Parachute = Parachute @@ -1364,7 +1363,7 @@ TCMotorSelPan.lbl.Datapoints = Data points: TCMotorSelPan.lbl.Digest = Digest: TCMotorSelPan.title.Thrustcurve = Thrust curve: TCMotorSelPan.title.Thrust = Thrust -TCMotorSelPan.delayBox.None = Plugged (none) +TCMotorSelPan.delayBox.None = None TCMotorSelPan.noDescription = No description available. TCMotorSelPan.btn.checkAll = Select All TCMotorSelPan.btn.checkNone = Clear All diff --git a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java index 513190b8b..e31fa4a98 100644 --- a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java +++ b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java @@ -7,7 +7,9 @@ import java.util.Deque; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import net.sf.openrocket.aerodynamics.FlightConditions; import net.sf.openrocket.aerodynamics.Warning; +import net.sf.openrocket.aerodynamics.WarningSet; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.motor.IgnitionEvent; import net.sf.openrocket.motor.MotorConfiguration; @@ -84,6 +86,13 @@ public class BasicEventSimulationEngine implements SimulationEngine { throw new MotorIgnitionException(trans.get("BasicEventSimulationEngine.error.noMotorsDefined")); } + // Can't calculate stability + if (currentStatus.getSimulationConditions().getAerodynamicCalculator() + .getCP(currentStatus.getConfiguration(), + new FlightConditions(currentStatus.getConfiguration()), + new WarningSet()).weight < MathUtil.EPSILON) + throw new SimulationException(trans.get("BasicEventSimulationEngine.error.cantCalculateStability")); + // Problems that let us simulate, but result is likely bad // No recovery device