FlightDataType.TYPE_PITCH_RATE = Pitch rate
FlightDataType.TYPE_YAW_RATE = Yaw rate
FlightDataType.TYPE_MASS = Mass
+FlightDataType.TYPE_PROPELLANT_MASS = Propellant mass
FlightDataType.TYPE_LONGITUDINAL_INERTIA = Longitudinal moment of inertia
FlightDataType.TYPE_ROTATIONAL_INERTIA = Rotational moment of inertia
FlightDataType.TYPE_CP_LOCATION = CP location
FlightDataType.TYPE_LATITUDE = Latitude
FlightDataType.TYPE_LONGITUDE = Longitude
FlightDataType.TYPE_CORIOLIS_ACCELERATION = Coriolis acceleration
+FlightDataType.TYPE_GRAVITY = Gravitational acceleration
! PlotConfiguration
PlotConfiguration.Verticalmotion = Vertical motion vs. time
import static net.sf.openrocket.util.MathUtil.pow2;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import net.sf.openrocket.motor.Motor;
* Return the CG of the rocket with the specified motor status (no motors,
* ignition, burnout).
*/
+ @Override
public Coordinate getCG(Configuration configuration, MassCalcType type) {
checkCache(configuration);
calculateStageCache(configuration);
/**
* Return the CG of the rocket with the provided motor configuration.
*/
+ @Override
public Coordinate getCG(Configuration configuration, MotorInstanceConfiguration motors) {
checkCache(configuration);
calculateStageCache(configuration);
return totalCG;
}
-
/**
* Return the longitudinal inertia of the rocket with the specified motor instance
* configuration.
* @param configuration the current motor instance configuration
* @return the longitudinal inertia of the rocket
*/
+ @Override
public double getLongitudinalInertia(Configuration configuration, MotorInstanceConfiguration motors) {
checkCache(configuration);
calculateStageCache(configuration);
* @param configuration the current motor instance configuration
* @return the rotational inertia of the rocket
*/
+ @Override
public double getRotationalInertia(Configuration configuration, MotorInstanceConfiguration motors) {
checkCache(configuration);
calculateStageCache(configuration);
return totalInertia;
}
+ /**
+ * Return the total mass of the motors
+ *
+ * @param configuration the current motor instance configuration
+ * @return the total mass of all motors
+ */
+ @Override
+ public double getPropellantMass(Configuration configuration, MotorInstanceConfiguration motors){
+ double mass = 0;
+
+ // add up the masses of all motors in the rocket
+ if (motors != null) {
+ for (MotorId id : motors.getMotorIDs()) {
+ MotorInstance motor = motors.getMotorInstance(id);
+ mass = mass + motor.getCG().weight - motor.getParentMotor().getEmptyCG().weight;
+ }
+ }
+ return mass;
+ }
-
@Override
public Map<RocketComponent, Coordinate> getCGAnalysis(Configuration configuration, MassCalcType type) {
checkCache(configuration);
*/
public double getRotationalInertia(Configuration configuration, MotorInstanceConfiguration motors);
+ /**
+ * Return the total mass of the motors
+ *
+ * @param motors the motor configuration
+ * @param configuration the current motor instance configuration
+ * @return the total mass of all motors
+ */
+ public double getPropellantMass(Configuration configuration, MotorInstanceConfiguration motors);
/**
* Compute an analysis of the per-component CG's of the provided configuration.
* identical to this instance and can be used independently from this one.
*/
public MotorInstance clone();
+
+
+ public Motor getParentMotor();
}
private final double unitRotationalInertia;
private final double unitLongitudinalInertia;
+ private final Motor parentMotor;
private int modID = 0;
stepCG = cg[0];
unitRotationalInertia = Inertia.filledCylinderRotational(getDiameter() / 2);
unitLongitudinalInertia = Inertia.filledCylinderLongitudinal(getDiameter() / 2, getLength());
+ parentMotor = ThrustCurveMotor.this;
+ }
+
+ @Override
+ public Motor getParentMotor(){
+ return parentMotor;
}
@Override
protected MassData calculateMassData(SimulationStatus status) throws SimulationException {
MassData mass;
Coordinate cg;
- double longitudinalInertia, rotationalInertia;
+ double longitudinalInertia, rotationalInertia, propellantMass;
// Call pre-listener
mass = SimulationListenerHelper.firePreMassCalculation(status);
cg = calc.getCG(status.getConfiguration(), status.getMotorConfiguration());
longitudinalInertia = calc.getLongitudinalInertia(status.getConfiguration(), status.getMotorConfiguration());
rotationalInertia = calc.getRotationalInertia(status.getConfiguration(), status.getMotorConfiguration());
- mass = new MassData(cg, longitudinalInertia, rotationalInertia);
+ propellantMass = calc.getPropellantMass(status.getConfiguration(), status.getMotorConfiguration());
+ mass = new MassData(cg, longitudinalInertia, rotationalInertia, propellantMass);
// Call post-listener
mass = SimulationListenerHelper.firePostMassCalculation(status, mass);
checkNaN(mass.getCG());
checkNaN(mass.getLongitudinalInertia());
checkNaN(mass.getRotationalInertia());
+ checkNaN(mass.getPropellantMass());
return mass;
}
data.setValue(FlightDataType.TYPE_LATITUDE, status.getRocketWorldPosition().getLatitudeRad());
data.setValue(FlightDataType.TYPE_LONGITUDE, status.getRocketWorldPosition().getLongitudeRad());
+ data.setValue(FlightDataType.TYPE_GRAVITY, gravity);
+
if (status.getSimulationConditions().getGeodeticComputation() != GeodeticComputationStrategy.FLAT) {
data.setValue(FlightDataType.TYPE_CORIOLIS_ACCELERATION, coriolisAcceleration.length());
}
data.setValue(FlightDataType.TYPE_MACH_NUMBER, mach);
data.setValue(FlightDataType.TYPE_MASS, mass);
+ data.setValue(FlightDataType.TYPE_PROPELLANT_MASS, 0.0); // Is this a reasonable assumption? Probably.
data.setValue(FlightDataType.TYPE_THRUST_FORCE, 0);
data.setValue(FlightDataType.TYPE_DRAG_FORCE, dragForce);
//// Longitude
public static final FlightDataType TYPE_LONGITUDE = newType(trans.get("FlightDataType.TYPE_LONGITUDE"), "\u03bb", UnitGroup.UNITS_ANGLE, 37);
+ //// Gravity
+ public static final FlightDataType TYPE_GRAVITY = newType(trans.get("FlightDataType.TYPE_GRAVITY"), "g", UnitGroup.UNITS_ACCELERATION, 38);
+
//// Angular motion
//// Angle of attack
public static final FlightDataType TYPE_AOA = newType(trans.get("FlightDataType.TYPE_AOA"), "\u03b1", UnitGroup.UNITS_ANGLE, 40);
//// Stability information
//// Mass
public static final FlightDataType TYPE_MASS = newType(trans.get("FlightDataType.TYPE_MASS"), "m", UnitGroup.UNITS_MASS, 50);
+ //// Propellant mass
+ public static final FlightDataType TYPE_PROPELLANT_MASS = newType(trans.get("FlightDataType.TYPE_PROPELLANT_MASS"), "mp", UnitGroup.UNITS_MASS, 51);
//// Longitudinal moment of inertia
- public static final FlightDataType TYPE_LONGITUDINAL_INERTIA = newType(trans.get("FlightDataType.TYPE_LONGITUDINAL_INERTIA"), "Il", UnitGroup.UNITS_INERTIA, 51);
+ public static final FlightDataType TYPE_LONGITUDINAL_INERTIA = newType(trans.get("FlightDataType.TYPE_LONGITUDINAL_INERTIA"), "Il", UnitGroup.UNITS_INERTIA, 52);
//// Rotational moment of inertia
- public static final FlightDataType TYPE_ROTATIONAL_INERTIA = newType(trans.get("FlightDataType.TYPE_ROTATIONAL_INERTIA"), "Ir", UnitGroup.UNITS_INERTIA, 52);
+ public static final FlightDataType TYPE_ROTATIONAL_INERTIA = newType(trans.get("FlightDataType.TYPE_ROTATIONAL_INERTIA"), "Ir", UnitGroup.UNITS_INERTIA, 53);
//// CP location
- public static final FlightDataType TYPE_CP_LOCATION = newType(trans.get("FlightDataType.TYPE_CP_LOCATION"), "Cp", UnitGroup.UNITS_LENGTH, 53);
+ public static final FlightDataType TYPE_CP_LOCATION = newType(trans.get("FlightDataType.TYPE_CP_LOCATION"), "Cp", UnitGroup.UNITS_LENGTH, 54);
//// CG location
- public static final FlightDataType TYPE_CG_LOCATION = newType(trans.get("FlightDataType.TYPE_CG_LOCATION"), "Cg", UnitGroup.UNITS_LENGTH, 54);
+ public static final FlightDataType TYPE_CG_LOCATION = newType(trans.get("FlightDataType.TYPE_CG_LOCATION"), "Cg", UnitGroup.UNITS_LENGTH, 55);
//// Stability margin calibers
- public static final FlightDataType TYPE_STABILITY = newType(trans.get("FlightDataType.TYPE_STABILITY"), "S", UnitGroup.UNITS_COEFFICIENT, 55);
+ public static final FlightDataType TYPE_STABILITY = newType(trans.get("FlightDataType.TYPE_STABILITY"), "S", UnitGroup.UNITS_COEFFICIENT, 56);
//// Characteristic numbers
TYPE_VELOCITY_XY,
TYPE_ACCELERATION_XY,
TYPE_LATITUDE,
- TYPE_LONGITUDE,
+ TYPE_LONGITUDE,
+ TYPE_GRAVITY,
TYPE_AOA,
TYPE_ROLL_RATE,
TYPE_PITCH_RATE,
TYPE_YAW_RATE,
TYPE_MASS,
+ TYPE_PROPELLANT_MASS,
TYPE_LONGITUDINAL_INERTIA,
TYPE_ROTATIONAL_INERTIA,
TYPE_CP_LOCATION,
private final Coordinate cg;
private final double longitudinalInertia;
private final double rotationalInertia;
+ private final double propellantMass;
- public MassData(Coordinate cg, double longitudinalInertia, double rotationalInertia) {
+ public MassData(Coordinate cg, double longitudinalInertia, double rotationalInertia, double propellantMass) {
if (cg == null) {
throw new IllegalArgumentException("cg is null");
}
this.cg = cg;
this.longitudinalInertia = longitudinalInertia;
this.rotationalInertia = rotationalInertia;
+ this.propellantMass = propellantMass;
}
return rotationalInertia;
}
+ public double getPropellantMass() {
+ return propellantMass;
+ }
@Override
MassData other = (MassData) obj;
return (this.cg.equals(other.cg) && MathUtil.equals(this.longitudinalInertia, other.longitudinalInertia) &&
- MathUtil.equals(this.rotationalInertia, other.rotationalInertia));
+ MathUtil.equals(this.rotationalInertia, other.rotationalInertia)) && MathUtil.equals(this.propellantMass, other.propellantMass) ;
}
@Override
public int hashCode() {
- return (int) (cg.hashCode() ^ Double.doubleToLongBits(longitudinalInertia) ^ Double.doubleToLongBits(rotationalInertia));
+ return (int) (cg.hashCode() ^ Double.doubleToLongBits(longitudinalInertia) ^ Double.doubleToLongBits(rotationalInertia) ^ Double.doubleToLongBits(propellantMass) );
}
@Override
public String toString() {
return "MassData [cg=" + cg + ", longitudinalInertia=" + longitudinalInertia
- + ", rotationalInertia=" + rotationalInertia + "]";
+ + ", rotationalInertia=" + rotationalInertia + ", propellantMass="+propellantMass + "]";
}
}
}
if (store.massData != null) {
data.setValue(FlightDataType.TYPE_MASS, store.massData.getCG().weight);
+ data.setValue(FlightDataType.TYPE_PROPELLANT_MASS, store.massData.getPropellantMass());
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);
data.setValue(FlightDataType.TYPE_DRAG_FORCE, store.dragForce);
+ data.setValue(FlightDataType.TYPE_GRAVITY, store.gravity);
if (status.isLaunchRodCleared() && store.forces != null) {
if (store.massData != null && store.flightConditions != null) {