Use current atmospheric conditions, not previous conditions, in calculating thrust.

This lets us get rid of previousAtmosphericConditions completely.

Note that while we pass acceleration and atmospheric conditions into calculateAverageThrust(), we don't actually do anything with them there. They appear to be passed in for some sort of eventual enhancements when we do things like altitude compensation for motors, or acceleration for hybrids or water rockets.

It also turned out that while we called getPreviousAtmosphericConditions() when call ing calculateAverageThrust(), setPreviousAtmosphericConditions() was never called.
This commit is contained in:
JoePfeiffer 2023-09-25 18:43:05 -06:00
parent 65b36af180
commit 7a2ede6e24
2 changed files with 8 additions and 16 deletions

View File

@ -8,7 +8,6 @@ public class RK4SimulationStatus extends SimulationStatus implements Cloneable {
private Coordinate launchRodDirection;
private double previousAcceleration = 0;
private AtmosphericConditions previousAtmosphericConditions;
// Used for determining when to store aerodynamic computation warnings:
private double maxZVelocity = 0;
@ -26,7 +25,6 @@ public class RK4SimulationStatus extends SimulationStatus implements Cloneable {
this.previousAcceleration = ((RK4SimulationStatus) other).previousAcceleration;
this.maxZVelocity = ((RK4SimulationStatus) other).maxZVelocity;
this.startWarningTime = ((RK4SimulationStatus) other).startWarningTime;
this.previousAtmosphericConditions = ((RK4SimulationStatus) other).previousAtmosphericConditions;
}
}
public void setLaunchRodDirection(Coordinate launchRodDirection) {
@ -49,18 +47,6 @@ public class RK4SimulationStatus extends SimulationStatus implements Cloneable {
this.previousAcceleration = previousAcceleration;
}
public AtmosphericConditions getPreviousAtmosphericConditions() {
return previousAtmosphericConditions;
}
public void setPreviousAtmosphericConditions(
AtmosphericConditions previousAtmosphericConditions) {
this.previousAtmosphericConditions = previousAtmosphericConditions;
}
public double getMaxZVelocity() {
return maxZVelocity;
}

View File

@ -102,11 +102,17 @@ public class RK4SimulationStepper extends AbstractSimulationStepper {
store.timestep = MathUtil.max(MathUtil.min(store.timestep, maxTimeStep), MIN_TIME_STEP);
checkNaN(store.timestep);
/*
* Get the current atmospheric conditions
*/
calculateFlightConditions(status, store);
store.atmosphericConditions = store.flightConditions.getAtmosphericConditions();
/*
* Compute the initial thrust estimate. This is used for the first time step computation.
*/
store.thrustForce = calculateAverageThrust(status, store.timestep, store.timestep,
status.getPreviousAtmosphericConditions(), false);
store.thrustForce = calculateAverageThrust(status, store.timestep, store.longitudinalAcceleration,
store.atmosphericConditions, false);
/*
* Perform RK4 integration. Decide the time step length after the first step.