Merge pull request #1924 from JoePfeiffer/fix-1898

Throw exception at simulation startup if CP can't be calculated.
This commit is contained in:
Sibo Van Gool 2022-12-27 20:13:06 +01:00 committed by GitHub
commit d417b179cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -563,6 +563,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.
@ -1149,8 +1150,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
@ -1365,7 +1364,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

View File

@ -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