1 package com.billkuker.rocketry.motorsim.fuel;
\r
3 import javax.measure.quantity.Pressure;
\r
4 import javax.measure.quantity.Velocity;
\r
5 import javax.measure.quantity.VolumetricDensity;
\r
6 import javax.measure.unit.NonSI;
\r
7 import javax.measure.unit.Unit;
\r
9 import org.jscience.physics.amount.Amount;
\r
11 import com.billkuker.rocketry.motorsim.Fuel;
\r
12 import com.billkuker.rocketry.motorsim.RocketScience;
\r
14 public abstract class SaintRobertFuel implements Fuel {
\r
16 public static enum Type{
\r
18 javax.measure.unit.SI.MILLIMETER.divide(javax.measure.unit.SI.SECOND).asType(Velocity.class),
\r
19 javax.measure.unit.SI.MEGA(javax.measure.unit.SI.PASCAL).asType(Pressure.class)),
\r
21 NonSI.INCH.divide(javax.measure.unit.SI.SECOND).asType(Velocity.class),
\r
25 private final Unit<Velocity> v;
\r
26 private final Unit<Pressure> p;
\r
28 Type( Unit<Velocity> v, Unit<Pressure> p){
\r
34 private Type t = Type.SI;
\r
36 public SaintRobertFuel(Type t){
\r
38 throw new IllegalArgumentException("Type must be non-null");
\r
42 public Type getType(){
\r
46 protected void setType(final Type t){
\r
50 public Amount<Velocity> burnRate(Amount<Pressure> pressure) {
\r
53 double p = pressure.doubleValue(getType().p);
\r
54 double a = burnrateCoefficient(pressure);
\r
55 double n = burnrateExponent(pressure);
\r
57 return burnrateConstant().plus(Amount.valueOf( a*Math.pow(p,n), getType().v ));
\r
60 protected abstract double burnrateCoefficient(Amount<Pressure> pressure);
\r
62 protected abstract double burnrateExponent(Amount<Pressure> pressure);
\r
64 protected Amount<Velocity> burnrateConstant(){
\r
65 return Amount.valueOf(0, Velocity.UNIT);
\r
68 public abstract Amount<VolumetricDensity> getIdealDensity();
\r
70 public String getName(){
\r
71 return this.getClass().getSimpleName();
\r
74 public String toString(){
\r