Add check for zero-length active stages
Add geometry checks to stage separation Add branch name to simulation exception dialog
This commit is contained in:
parent
022a986130
commit
4c136441ff
@ -571,9 +571,11 @@ SimuRunDlg.lbl.Altitude = Altitude:
|
|||||||
SimuRunDlg.lbl.Velocity = Velocity:
|
SimuRunDlg.lbl.Velocity = Velocity:
|
||||||
SimuRunDlg.msg.Unabletosim = Unable to simulate:
|
SimuRunDlg.msg.Unabletosim = Unable to simulate:
|
||||||
SimuRunDlg.msg.errorOccurred = An error occurred during the simulation:
|
SimuRunDlg.msg.errorOccurred = An error occurred during the simulation:
|
||||||
|
SimuRunDlg.msg.branchErrorOccurred = An error occurred during simulation branch
|
||||||
|
|
||||||
BasicEventSimulationEngine.error.noMotorsDefined = No motors defined in the simulation.
|
BasicEventSimulationEngine.error.noMotorsDefined = No motors defined in the simulation.
|
||||||
BasicEventSimulationEngine.error.cantCalculateStability = Can't calculate rocket stability.
|
BasicEventSimulationEngine.error.activeLengthZero = Active airframe has length 0
|
||||||
|
BasicEventSimulationEngine.error.cantCalculateStability = Can't calculate stability
|
||||||
BasicEventSimulationEngine.error.earlyMotorBurnout = Motor burnout without liftoff.
|
BasicEventSimulationEngine.error.earlyMotorBurnout = Motor burnout without liftoff.
|
||||||
BasicEventSimulationEngine.error.noConfiguredIgnition = No motors configured to ignite at liftoff
|
BasicEventSimulationEngine.error.noConfiguredIgnition = No motors configured to ignite at liftoff
|
||||||
BasicEventSimulationEngine.error.noIgnition = No motors ignited.
|
BasicEventSimulationEngine.error.noIgnition = No motors ignited.
|
||||||
|
@ -86,13 +86,6 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
|||||||
throw new MotorIgnitionException(trans.get("BasicEventSimulationEngine.error.noMotorsDefined"));
|
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
|
// Problems that let us simulate, but result is likely bad
|
||||||
|
|
||||||
// No recovery device
|
// No recovery device
|
||||||
@ -157,6 +150,8 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
|||||||
Coordinate originVelocity = currentStatus.getRocketVelocity();
|
Coordinate originVelocity = currentStatus.getRocketVelocity();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
checkGeometry(currentStatus);
|
||||||
|
|
||||||
// Start the simulation
|
// Start the simulation
|
||||||
while (handleEvents()) {
|
while (handleEvents()) {
|
||||||
@ -284,6 +279,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
|||||||
flightData.getWarningSet().addAll(currentStatus.getWarnings());
|
flightData.getWarningSet().addAll(currentStatus.getWarnings());
|
||||||
|
|
||||||
e.setFlightData(flightData);
|
e.setFlightData(flightData);
|
||||||
|
e.setFlightDataBranch(currentStatus.getFlightData());
|
||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
@ -504,6 +500,10 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
|||||||
boosterStatus.getConfiguration().clearStagesAbove(stageNumber);
|
boosterStatus.getConfiguration().clearStagesAbove(stageNumber);
|
||||||
|
|
||||||
toSimulate.push(boosterStatus);
|
toSimulate.push(boosterStatus);
|
||||||
|
|
||||||
|
// Make sure upper stages can still be simulated
|
||||||
|
checkGeometry(currentStatus);
|
||||||
|
|
||||||
log.info(String.format("==>> @ %g; from Branch: %s ---- Branching: %s ---- \n",
|
log.info(String.format("==>> @ %g; from Branch: %s ---- Branching: %s ---- \n",
|
||||||
currentStatus.getSimulationTime(),
|
currentStatus.getSimulationTime(),
|
||||||
currentStatus.getFlightData().getBranchName(), boosterStatus.getFlightData().getBranchName()));
|
currentStatus.getFlightData().getBranchName(), boosterStatus.getFlightData().getBranchName()));
|
||||||
@ -665,8 +665,24 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we need to check geometry to make sure we can simulation the active
|
||||||
|
// stages in a simulation branch when the branch starts executing, and
|
||||||
|
// whenever a stage separation occurs
|
||||||
|
private void checkGeometry(SimulationStatus currentStatus) throws SimulationException {
|
||||||
|
|
||||||
|
// Active stages have total length of 0.
|
||||||
|
if (currentStatus.getConfiguration().getLengthAerodynamic() < MathUtil.EPSILON) {
|
||||||
|
throw new SimulationException(trans.get("BasicEventSimulationEngine.error.activeLengthZero"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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"));
|
||||||
|
}
|
||||||
|
|
||||||
private void checkNaN() throws SimulationException {
|
private void checkNaN() throws SimulationException {
|
||||||
double d = 0;
|
double d = 0;
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package net.sf.openrocket.simulation.exception;
|
package net.sf.openrocket.simulation.exception;
|
||||||
|
|
||||||
import net.sf.openrocket.simulation.FlightData;
|
import net.sf.openrocket.simulation.FlightData;
|
||||||
|
import net.sf.openrocket.simulation.FlightDataBranch;
|
||||||
|
|
||||||
public class SimulationException extends Exception {
|
public class SimulationException extends Exception {
|
||||||
|
|
||||||
private FlightData flightData = null;
|
private FlightData flightData = null;
|
||||||
|
private FlightDataBranch flightDataBranch = null;
|
||||||
|
|
||||||
public SimulationException() {
|
public SimulationException() {
|
||||||
|
|
||||||
@ -29,4 +31,13 @@ public class SimulationException extends Exception {
|
|||||||
public FlightData getFlightData() {
|
public FlightData getFlightData() {
|
||||||
return flightData;
|
return flightData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFlightDataBranch(FlightDataBranch f) {
|
||||||
|
flightDataBranch = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FlightDataBranch getFlightDataBranch() {
|
||||||
|
return flightDataBranch;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ import net.sf.openrocket.l10n.Translator;
|
|||||||
import net.sf.openrocket.motor.IgnitionEvent;
|
import net.sf.openrocket.motor.IgnitionEvent;
|
||||||
import net.sf.openrocket.motor.MotorConfiguration;
|
import net.sf.openrocket.motor.MotorConfiguration;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||||
|
import net.sf.openrocket.simulation.FlightDataBranch;
|
||||||
import net.sf.openrocket.simulation.FlightEvent;
|
import net.sf.openrocket.simulation.FlightEvent;
|
||||||
import net.sf.openrocket.simulation.SimulationStatus;
|
import net.sf.openrocket.simulation.SimulationStatus;
|
||||||
import net.sf.openrocket.simulation.customexpression.CustomExpression;
|
import net.sf.openrocket.simulation.customexpression.CustomExpression;
|
||||||
@ -433,12 +434,20 @@ public class SimulationRunDialog extends JDialog {
|
|||||||
null, simulation.getName(), JOptionPane.ERROR_MESSAGE);
|
null, simulation.getName(), JOptionPane.ERROR_MESSAGE);
|
||||||
|
|
||||||
} else if (t instanceof SimulationException) {
|
} else if (t instanceof SimulationException) {
|
||||||
|
String title = simulation.getName();
|
||||||
|
FlightDataBranch dataBranch = ((SimulationException) t).getFlightDataBranch();
|
||||||
|
|
||||||
|
String message;
|
||||||
|
if (dataBranch != null) {
|
||||||
|
message = trans.get("SimuRunDlg.msg.branchErrorOccurred") + "\"" + dataBranch.getBranchName() + "\"";
|
||||||
|
} else {
|
||||||
|
message = trans.get("SimuRunDlg.msg.errorOccurred");
|
||||||
|
}
|
||||||
DetailDialog.showDetailedMessageDialog(SimulationRunDialog.this,
|
DetailDialog.showDetailedMessageDialog(SimulationRunDialog.this,
|
||||||
new Object[] {
|
new Object[] {
|
||||||
//// A error occurred during the simulation:
|
//// A error occurred during the simulation:
|
||||||
trans.get("SimuRunDlg.msg.errorOccurred"), t.getMessage() },
|
message, t.getMessage() },
|
||||||
null, simulation.getName(), JOptionPane.ERROR_MESSAGE);
|
null, simulation.getName(), JOptionPane.ERROR_MESSAGE);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user