Date started: 09/12/2000
Purpose: This module models a rocket engine
- ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) --------------
+ ------------- Copyright (C) 2000 Jon S. Berndt (jon@jsbsim.org) --------------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+#include <iostream>
#include <sstream>
-
#include "FGRocket.h"
+#include "FGState.h"
+#include "models/FGPropulsion.h"
+#include "FGThruster.h"
+#include "FGTank.h"
+
+using namespace std;
namespace JSBSim {
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();
PropellantFlowRate = (FuelExpended + OxidizerExpended)/dT;
Throttle = FCS->GetThrottlePos(EngineNumber);
- // If there is a thrust table, it is a function of propellant remaining. The
+ // If there is a thrust table, it is a function of propellant burned. The
// engine is started when the throttle is advanced to 1.0. After that, it
- // burns without regard to throttle setting. The table returns a value between
- // zero and one, representing the percentage of maximum vacuum thrust being
- // applied.
+ // burns without regard to throttle setting.
if (ThrustTable != 0L) { // Thrust table given -> Solid fuel used
if ((Throttle == 1 || BurnTime > 0.0 ) && !Starved) {
- BurnTime += State->Getdt();
- double TotalEngineFuelAvailable=0.0;
- for (int i=0; i<(int)SourceTanks.size(); i++)
- TotalEngineFuelAvailable += Propulsion->GetTank(SourceTanks[i])->GetContents();
-
- VacThrust = ThrustTable->GetValue(TotalEngineFuelAvailable);
+ double TotalEngineFuelBurned=0.0;
+ for (int i=0; i<(int)SourceTanks.size(); i++) {
+ FGTank* tank = Propulsion->GetTank(i);
+ if (SourceTanks[i] == 1) {
+ TotalEngineFuelBurned += tank->GetCapacity() - tank->GetContents();
+ }
+ }
+
+ 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;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGRocket::GetEngineLabels(string delimeter)
+string FGRocket::GetEngineLabels(const string& delimiter)
{
std::ostringstream buf;
- buf << Name << " Total Impulse (engine " << EngineNumber << " in psf)" << delimeter
- << Thruster->GetThrusterLabels(EngineNumber, delimeter);
+ buf << Name << " Total Impulse (engine " << EngineNumber << " in psf)" << delimiter
+ << Thruster->GetThrusterLabels(EngineNumber, delimiter);
return buf.str();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGRocket::GetEngineValues(string delimeter)
+string FGRocket::GetEngineValues(const string& delimiter)
{
std::ostringstream buf;
- buf << It << delimeter << Thruster->GetThrusterValues(EngineNumber, delimeter);
+ buf << It << delimiter << Thruster->GetThrusterValues(EngineNumber, delimiter);
return buf.str();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-// 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);
+ }
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%