FuelFlowRate = 0.0;
OxidizerFlowRate = 0.0;
SLOxiFlowMax = 0.0;
+ BuildupTime = 0.0;
It = 0.0;
+ ThrustVariation = 0.0;
+ TotalIspVariation = 0.0;
// Defaults
MinThrottle = 0.0;
if (el->FindElement("isp"))
Isp = el->FindElementValueAsNumber("isp");
+ if (el->FindElement("builduptime"))
+ BuildupTime = el->FindElementValueAsNumber("builduptime");
if (el->FindElement("maxthrottle"))
MaxThrottle = el->FindElementValueAsNumber("maxthrottle");
if (el->FindElement("minthrottle"))
if (el->FindElement("sloxiflowmax"))
SLOxiFlowMax = el->FindElementValueAsNumberConvertTo("sloxiflowmax", "LBS/SEC");
+ // If there is a thrust table element, this is a solid propellant engine.
thrust_table_element = el->FindElement("thrust_table");
if (thrust_table_element) {
ThrustTable = new FGTable(PropertyManager, thrust_table_element);
+ Element* variation_element = el->FindElement("variation");
+ if (variation_element) {
+ if (variation_element->FindElement("thrust")) {
+ ThrustVariation = variation_element->FindElementValueAsNumber("thrust");
+ }
+ if (variation_element->FindElement("total_isp")) {
+ TotalIspVariation = variation_element->FindElementValueAsNumber("total_isp");
+ }
+ }
}
bindmodel();
if (ThrustTable != 0L) { // Thrust table given -> Solid fuel used
if ((Throttle == 1 || BurnTime > 0.0 ) && !Starved) {
- BurnTime += State->Getdt();
double TotalEngineFuelBurned=0.0;
for (int i=0; i<(int)SourceTanks.size(); i++) {
FGTank* tank = Propulsion->GetTank(i);
}
}
- VacThrust = ThrustTable->GetValue(TotalEngineFuelBurned);
+ VacThrust = ThrustTable->GetValue(TotalEngineFuelBurned)
+ * (ThrustVariation + 1)
+ * (TotalIspVariation + 1);
+ if (BurnTime <= BuildupTime && BuildupTime > 0.0) {
+ VacThrust *= sin((BurnTime/BuildupTime)*M_PI/2.0);
+ // VacThrust *= (1-cos((BurnTime/BuildupTime)*M_PI))/2.0; // 1 - cos approach
+ }
+ BurnTime += State->Getdt(); // Increment burn time
} else {
VacThrust = 0.0;
}
} else { // Calculate thrust
- PctPower = Throttle / MaxThrottle; // Min and MaxThrottle range from 0.0 to 1.0, normally.
+ // This is nonsensical. Max throttle should be assumed to be 1.0. One might
+ // conceivably have a throttle setting > 1.0 for some rocket engines. But, 1.0
+ // should always be the default.
+ // PctPower = Throttle / MaxThrottle; // Min and MaxThrottle range from 0.0 to 1.0, normally.
+
+ PctPower = Throttle;
Flameout = false;
VacThrust = Isp * PropellantFlowRate;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+//
+// The FuelFlowRate can be affected by the TotalIspVariation value (settable
+// in a config file or via properties). The TotalIspVariation parameter affects
+// thrust, but the thrust determines fuel flow rate, so it must be adjusted
+// for Total Isp Variation.
double FGRocket::CalcFuelNeed(void)
{
if (ThrustTable != 0L) { // Thrust table given - infers solid fuel
FuelFlowRate = VacThrust/Isp; // This calculates wdot (weight flow rate in lbs/sec)
+ FuelFlowRate /= (1 + TotalIspVariation);
} else {
FuelFlowRate = SLFuelFlowMax*PctPower;
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-// This funciton should tie properties to rocket engine specific properties
+// This function should tie properties to rocket engine specific properties
// that are not bound in the base class (FGEngine) code.
//
void FGRocket::bindmodel()
property_name = base_property_name + "/total-impulse";
PropertyManager->Tie( property_name.c_str(), this, &FGRocket::GetTotalImpulse);
- property_name = base_property_name + "/oxi-flow-rate-pps";
- PropertyManager->Tie( property_name.c_str(), this, &FGRocket::GetOxiFlowRate);
property_name = base_property_name + "/vacuum-thrust_lbs";
PropertyManager->Tie( property_name.c_str(), this, &FGRocket::GetVacThrust);
+
+ if (ThrustTable) { // Solid rocket motor
+ property_name = base_property_name + "/thrust-variation_pct";
+ PropertyManager->Tie( property_name.c_str(), this, &FGRocket::GetThrustVariation,
+ &FGRocket::SetThrustVariation);
+ property_name = base_property_name + "/total-isp-variation_pct";
+ PropertyManager->Tie( property_name.c_str(), this, &FGRocket::GetTotalIspVariation,
+ &FGRocket::SetTotalIspVariation);
+ } else { // Liquid rocket motor
+ property_name = base_property_name + "/oxi-flow-rate-pps";
+ PropertyManager->Tie( property_name.c_str(), this, &FGRocket::GetOxiFlowRate);
+ }
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%