package cn.icer.simulation.InterfaceAdapter;
/**
* 火箭
* @author icer
* @date:2013-12-27
*
*/
public interface SkyRocket {
/**
*
* @return 燃料的剩余量
*/
public abstract double getMass();
/**
*
* @return 产生的推力
*/
public abstract double getThrust();
/**
*
* @param time 燃烧时间
*/
public abstract void setSimTime(double time);
}
package cn.icer.simulation.InterfaceAdapter;
/**
* 火箭
* @author icer
* @date 2013-12-27
*
*/
public class PhysicalRocket {
private double burnArea; //燃烧面积
private double burnRate; //燃烧率
private double initFuelMass; //燃料
private double totalMass; //燃料总量
private double totalBurnTime; //总燃烧时间
//重力加速度
private static double SPECIFIC_IMPULSE = 620; // Newtons/Kg
//燃料密度
private static double FUEL_DENSITY = 1800; // Kg / M**3
public PhysicalRocket(double burnArea, double burnRate, double fuelMass, double totalMass) {
this.burnArea = burnArea;
this.burnRate = burnRate;
this.initFuelMass = fuelMass;
this.totalMass = totalMass;
double initialFuelVolume = fuelMass / FUEL_DENSITY;
this.totalBurnTime = initialFuelVolume / (burnArea * burnRate);
}
/**
*
* @return 燃烧时间
*/
public double getBurnTime()
{
return totalBurnTime;
}
/**
*
* @param time 燃烧时间
* @return 现在剩余的燃料
*/
public double getMass(double time)
{
if ( time > totalBurnTime)
return totalMass - initFuelMass;
double burntFuelVolume = burnArea * burnRate * time;
return totalMass - burntFuelVolume * FUEL_DENSITY;
}
/**
*
* @param time 燃烧时间
* @return 点火以来产生的总推力
*/
public double getThrust(double time)
{
if (time > totalBurnTime)
return 0;
return FUEL_DENSITY * SPECIFIC_IMPULSE * burnArea * burnRate;
}
}
package cn.icer.simulation.InterfaceAdapter;
/**
* 火箭
* @author icer
* @date 2013-12-27
*
*/
public class IcerRocket extends PhysicalRocket implements SkyRocket {
private double time;
public IcerRocket(double burnArea, double burnRate, double fuelMass,
double totalMass) {
super(burnArea, burnRate, fuelMass, totalMass);
}
@Override
public double getMass() {
return getMass(time);
}
@Override
public double getThrust() {
return getThrust(time);
}
@Override
public void setSimTime(double time) {
this.time = time;
}
}