private static final LogHelper log = Application.getLogger();
+ /** Random value with which to XOR the random seed value */
+ private static final int SEED_RANDOMIZATION = 0x23E3A01F;
+
/**
* A recommended reasonably accurate time step.
private static final double MIN_TIME_STEP = 0.001;
-
- private final Random random = new Random();
+ private Random random;
@Override
public RK4SimulationStatus initialize(SimulationStatus original) {
- log.info("Performing RK4SimulationStepper initialization");
-
RK4SimulationStatus status = new RK4SimulationStatus();
status.copyFrom(original);
Math.cos(sim.getLaunchRodAngle())
));
+ this.random = new Random(original.getSimulationConditions().getRandomSeed() ^ SEED_RANDOMIZATION);
+
return status;
}
double minTimeStep = status.getSimulationConditions().getTimeStep() / 20;
if (store.timestep < minTimeStep) {
- log.debug("Too small time step " + store.timestep + " (limiting factor " + limitingValue + "), using " +
+ log.verbose("Too small time step " + store.timestep + " (limiting factor " + limitingValue + "), using " +
minTimeStep + " instead.");
store.timestep = minTimeStep;
} else {
- log.debug("Selected time step " + store.timestep + " (limiting factor " + limitingValue + ")");
+ log.verbose("Selected time step " + store.timestep + " (limiting factor " + limitingValue + ")");
}
checkNaN(store.timestep);
* diminished by it affecting only 1/6th of the total, so it's an acceptable error.
*/
double thrustEstimate = store.thrustForce;
- store.thrustForce = calculateThrust(status, store.timestep, store.longitudalAcceleration,
+ store.thrustForce = calculateThrust(status, store.timestep, store.longitudinalAcceleration,
store.atmosphericConditions, true);
double thrustDiff = Math.abs(store.thrustForce - thrustEstimate);
// Log if difference over 1%, recompute if over 10%
if (thrustDiff > 0.01 * thrustEstimate) {
if (thrustDiff > 0.1 * thrustEstimate + 0.001) {
- log.info("Thrust estimate differs from correct value by " +
+ log.debug("Thrust estimate differs from correct value by " +
(Math.rint(1000 * (thrustDiff + 0.000001) / thrustEstimate) / 10.0) + "%," +
" estimate=" + thrustEstimate +
" correct=" + store.thrustForce +
", recomputing k1 parameters");
k1 = computeParameters(status, store);
} else {
- log.debug("Thrust estimate differs from correct value by " +
+ log.verbose("Thrust estimate differs from correct value by " +
(Math.rint(1000 * (thrustDiff + 0.000001) / thrustEstimate) / 10.0) + "%," +
" estimate=" + thrustEstimate +
" correct=" + store.thrustForce +
double momZ = store.forces.getCroll() * dynP * refArea * refLength;
// Compute acceleration in rocket coordinates
- store.angularAcceleration = new Coordinate(momX / store.massData.getLongitudalInertia(),
- momY / store.massData.getLongitudalInertia(), momZ / store.massData.getRotationalInertia());
+ store.angularAcceleration = new Coordinate(momX / store.massData.getLongitudinalInertia(),
+ momY / store.massData.getLongitudinalInertia(), momZ / store.massData.getRotationalInertia());
store.rollAcceleration = store.angularAcceleration.z;
// TODO: LOW: This should be hypot, but does it matter?
}
if (store.flightConditions != null) {
- data.setValue(FlightDataType.TYPE_VELOCITY_TOTAL, store.flightConditions.getVelocity());
+ data.setValue(FlightDataType.TYPE_VELOCITY_TOTAL, status.getRocketVelocity().length());
data.setValue(FlightDataType.TYPE_MACH_NUMBER, store.flightConditions.getMach());
}
}
if (store.massData != null) {
data.setValue(FlightDataType.TYPE_MASS, store.massData.getCG().weight);
+ data.setValue(FlightDataType.TYPE_LONGITUDINAL_INERTIA, store.massData.getLongitudinalInertia());
+ data.setValue(FlightDataType.TYPE_ROTATIONAL_INERTIA, store.massData.getRotationalInertia());
}
data.setValue(FlightDataType.TYPE_THRUST_FORCE, store.thrustForce);
public FlightConditions flightConditions;
- public double longitudalAcceleration = Double.NaN;
+ public double longitudinalAcceleration = Double.NaN;
public MassData massData;