Check for active upper stage before dropping booster

If there are multiple independent motor clusters in a stage, each of them can attempt a separation event. When the second event happens, there is no longer an active upper stage, so the separation results in a simulation branch with no active stages.  This causes a NaN exception as the mass is 0.
This commit is contained in:
JoePfeiffer 2022-03-09 11:01:18 -07:00
parent f8f0e5d12c
commit 5ac829ea78

View File

@ -425,12 +425,13 @@ public class BasicEventSimulationEngine implements SimulationEngine {
} }
case STAGE_SEPARATION: { case STAGE_SEPARATION: {
// Record the event.
currentStatus.getFlightData().addEvent(event);
RocketComponent boosterStage = event.getSource(); RocketComponent boosterStage = event.getSource();
final int stageNumber = boosterStage.getStageNumber(); final int stageNumber = boosterStage.getStageNumber();
if (currentStatus.getConfiguration().isStageActive(stageNumber-1)) {
// Record the event.
currentStatus.getFlightData().addEvent(event);
// Mark the status as having dropped the booster // Mark the status as having dropped the booster
currentStatus.getConfiguration().clearStage( stageNumber); currentStatus.getConfiguration().clearStage( stageNumber);
@ -443,6 +444,9 @@ public class BasicEventSimulationEngine implements SimulationEngine {
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()));
} else {
log.debug("upper stage is not active; not performing separation");
}
break; break;
} }