Update stage logic for DesignReport
Stages need to be activated correctly in order to properly calculate the mass for all components that contribute to the current launch scenario. This change ensures that all of the stages from the top-most stage to the currently active stage are set as activated when stage mass is being calculated. Signed-off-by: Billy Olsen <billy.olsen@gmail.com>
This commit is contained in:
parent
94534ee8f8
commit
5bf8a7af15
@ -105,7 +105,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
||||
this._setAllStages(true);
|
||||
this.updateMotors();
|
||||
}
|
||||
|
||||
|
||||
private void _setAllStages(final boolean _active) {
|
||||
for (StageFlags cur : stages.values()) {
|
||||
cur.active = _active;
|
||||
@ -126,6 +126,32 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
||||
_setStageActive( stageNumber, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Activates all stages as active starting from the specified component
|
||||
* to the top-most stage in the rocket. Active stages are those stages
|
||||
* which contribute to the mass of the rocket. Given a rocket with the
|
||||
* following stages:
|
||||
*
|
||||
* <ul>
|
||||
* <li>StageA - top most stage, containing nose cone etc.</li>
|
||||
* <li>StageB - middle stage</li>
|
||||
* <li>StageC - bottom stage</li>
|
||||
* </ul>
|
||||
*
|
||||
* invoking <code>FlightConfiguration.activateStagesThrough(StageB)</code>
|
||||
* will cause both StageA and StageB to be marked as active, and StageC
|
||||
* will be marked as inactive.
|
||||
*
|
||||
* @param stage the AxialStage to activate all stages up to (inclusive)
|
||||
*/
|
||||
public void activateStagesThrough(final AxialStage stage) {
|
||||
clearAllStages();
|
||||
for (int i=0; i <= stage.getStageNumber(); i++) {
|
||||
_setStageActive(i, true);
|
||||
}
|
||||
updateMotors();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method flags the specified stage as active, and all other stages as inactive.
|
||||
*
|
||||
|
@ -294,6 +294,21 @@ public class FlightConfigurationTest extends BaseTestCase {
|
||||
|
||||
config.toggleStage(0);
|
||||
assertThat(" toggle stage #0: ", config.isStageActive(0), equalTo(false));
|
||||
|
||||
AxialStage sustainer = rkt.getTopmostStage();
|
||||
AxialStage booster = rkt.getBottomCoreStage();
|
||||
assertThat(" sustainer stage is stage #0: ", sustainer.getStageNumber(), equalTo(0));
|
||||
assertThat(" booster stage is stage #1: ", booster.getStageNumber(), equalTo(1));
|
||||
|
||||
config.clearAllStages();
|
||||
config.activateStagesThrough(sustainer);
|
||||
assertThat(" sustainer stage is active: ", config.isStageActive(sustainer.getStageNumber()), equalTo(true));
|
||||
assertThat(" booster stage is inactive: ", config.isStageActive(booster.getStageNumber()), equalTo(false));
|
||||
|
||||
config.clearAllStages();
|
||||
config.activateStagesThrough(booster);
|
||||
assertThat(" sustainer stage is active: ", config.isStageActive(sustainer.getStageNumber()), equalTo(true));
|
||||
assertThat(" booster stage is active: ", config.isStageActive(booster.getStageNumber()), equalTo(true));
|
||||
|
||||
}
|
||||
|
||||
|
@ -341,16 +341,13 @@ public class DesignReport {
|
||||
double totalImpulse = 0;
|
||||
double totalTTW = 0;
|
||||
|
||||
int stage = 0;
|
||||
double stageMass = 0;
|
||||
|
||||
boolean topBorder = false;
|
||||
for (RocketComponent c : rocket) {
|
||||
|
||||
if (c instanceof AxialStage) {
|
||||
config.clearAllStages();
|
||||
config.setOnlyStage(stage);
|
||||
stage++;
|
||||
config.activateStagesThrough((AxialStage) c);
|
||||
RigidBody launchInfo = MassCalculator.calculateLaunch(config);
|
||||
stageMass = launchInfo.getMass();
|
||||
// Calculate total thrust-to-weight from only lowest stage motors
|
||||
|
Loading…
x
Reference in New Issue
Block a user