Added gravitational acceleration and propellant mass datatypes.

This commit is contained in:
Richard Graham 2012-09-05 05:14:10 +00:00
parent 4e272adb23
commit 1828f9d2fb
10 changed files with 76 additions and 14 deletions

View File

@ -1367,6 +1367,7 @@ FlightDataType.TYPE_ROLL_RATE = Roll rate
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
@ -1403,6 +1404,7 @@ FlightDataType.TYPE_COMPUTATION_TIME = Computation time
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

View File

@ -2,8 +2,10 @@ package net.sf.openrocket.masscalc;
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;
@ -38,6 +40,7 @@ public class BasicMassCalculator extends AbstractMassCalculator {
* 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);
@ -80,6 +83,7 @@ public class BasicMassCalculator extends AbstractMassCalculator {
/**
* Return the CG of the rocket with the provided motor configuration.
*/
@Override
public Coordinate getCG(Configuration configuration, MotorInstanceConfiguration motors) {
checkCache(configuration);
calculateStageCache(configuration);
@ -103,7 +107,6 @@ public class BasicMassCalculator extends AbstractMassCalculator {
return totalCG;
}
/**
* Return the longitudinal inertia of the rocket with the specified motor instance
* configuration.
@ -111,6 +114,7 @@ public class BasicMassCalculator extends AbstractMassCalculator {
* @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);
@ -154,6 +158,7 @@ public class BasicMassCalculator extends AbstractMassCalculator {
* @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);
@ -190,7 +195,25 @@ public class BasicMassCalculator extends AbstractMassCalculator {
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) {

View File

@ -70,6 +70,14 @@ public interface MassCalculator extends Monitorable {
*/
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.

View File

@ -57,4 +57,7 @@ public interface MotorInstance extends Cloneable, Monitorable {
*/
public MotorInstance clone();
public Motor getParentMotor();
}

View File

@ -424,6 +424,7 @@ public class ThrustCurveMotor implements Motor, Comparable<ThrustCurveMotor> {
private final double unitRotationalInertia;
private final double unitLongitudinalInertia;
private final Motor parentMotor;
private int modID = 0;
@ -437,6 +438,12 @@ public class ThrustCurveMotor implements Motor, Comparable<ThrustCurveMotor> {
stepCG = cg[0];
unitRotationalInertia = Inertia.filledCylinderRotational(getDiameter() / 2);
unitLongitudinalInertia = Inertia.filledCylinderLongitudinal(getDiameter() / 2, getLength());
parentMotor = ThrustCurveMotor.this;
}
@Override
public Motor getParentMotor(){
return parentMotor;
}
@Override

View File

@ -115,7 +115,7 @@ public abstract class AbstractSimulationStepper implements SimulationStepper {
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);
@ -127,7 +127,8 @@ public abstract class AbstractSimulationStepper implements SimulationStepper {
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);
@ -135,6 +136,7 @@ public abstract class AbstractSimulationStepper implements SimulationStepper {
checkNaN(mass.getCG());
checkNaN(mass.getLongitudinalInertia());
checkNaN(mass.getRotationalInertia());
checkNaN(mass.getPropellantMass());
return mass;
}

View File

@ -109,6 +109,8 @@ public class BasicLandingStepper extends AbstractSimulationStepper {
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());
}
@ -121,6 +123,7 @@ public class BasicLandingStepper extends AbstractSimulationStepper {
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);

View File

@ -71,6 +71,9 @@ public class FlightDataType implements Comparable<FlightDataType> {
//// 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);
@ -85,16 +88,18 @@ public class FlightDataType implements Comparable<FlightDataType> {
//// 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
@ -195,11 +200,13 @@ public class FlightDataType implements Comparable<FlightDataType> {
TYPE_ACCELERATION_XY,
TYPE_LATITUDE,
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,

View File

@ -13,15 +13,17 @@ public class MassData {
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;
}
@ -39,6 +41,9 @@ public class MassData {
return rotationalInertia;
}
public double getPropellantMass() {
return propellantMass;
}
@Override
@ -50,20 +55,20 @@ public class MassData {
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 + "]";
}
}

View File

@ -605,12 +605,14 @@ public class RK4SimulationStepper extends AbstractSimulationStepper {
}
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) {