55 :
FGEngine(engine_number, input), isp_function(nullptr), FDMExec(exec)
60 Element* thrust_table_element =
nullptr;
61 ThrustTable =
nullptr;
63 previousFuelNeedPerTank = 0.0;
64 previousOxiNeedPerTank = 0.0;
65 PropellantFlowRate = 0.0;
66 TotalPropellantExpended = 0.0;
68 OxidizerFlowRate = OxidizerExpended = 0.0;
73 ThrustVariation = 0.0;
74 TotalIspVariation = 0.0;
82 std::stringstream strEngineNumber;
86 bindmodel(PropertyManager);
95 isp_function =
new FGFunction(exec, isp_func_el, strEngineNumber.str());
100 throw(
"Specific Impulse <isp> must be specified for a rocket engine");
126 if (isp_function) Isp = isp_function->GetValue();
128 thrust_table_element = el->
FindElement(
"thrust_table");
129 if (thrust_table_element) {
130 ThrustTable =
new FGTable(PropertyManager, thrust_table_element);
132 if (variation_element) {
158 if (FDMExec->IntegrationSuspended())
return;
162 PropellantFlowRate = (
FuelExpended + OxidizerExpended)/
in.TotalDeltaT;
163 TotalPropellantExpended +=
FuelExpended + OxidizerExpended;
166 if (isp_function) Isp = isp_function->GetValue();
172 if (ThrustTable != 0L) {
176 VacThrust = ThrustTable->GetValue(TotalPropellantExpended)
177 * (ThrustVariation + 1)
178 * (TotalIspVariation + 1);
179 if (BurnTime <= BuildupTime && BuildupTime > 0.0) {
180 VacThrust *= sin((BurnTime/BuildupTime)*
M_PI/2.0);
183 BurnTime +=
in.TotalDeltaT;
202 VacThrust = Isp * PropellantFlowRate;
209 It +=
Thruster->Calculate(VacThrust) *
in.TotalDeltaT;
210 ItVac += VacThrust *
in.TotalDeltaT;
224 if (ThrustTable != 0L) {
240 SLOxiFlowMax = PropFlowMax * MxR / (1 + MxR);
241 OxidizerFlowRate = SLOxiFlowMax *
PctPower;
242 OxidizerExpended = OxidizerFlowRate *
in.TotalDeltaT;
243 return OxidizerExpended;
250 std::ostringstream buf;
252 buf <<
Name <<
" Total Impulse (engine " <<
EngineNumber <<
" in lbf)" << delimiter
253 <<
Name <<
" Total Vacuum Impulse (engine " <<
EngineNumber <<
" in lbf)" << delimiter
254 <<
Name <<
" Roll Moment (engine " <<
EngineNumber <<
" in ft-lbf)" << delimiter
255 <<
Name <<
" Pitch Moment (engine " <<
EngineNumber <<
" in ft-lbf)" << delimiter
256 <<
Name <<
" Yaw Moment (engine " <<
EngineNumber <<
" in ft-lbf)" << delimiter
269 std::ostringstream buf;
271 buf << It << delimiter
272 << ItVac << delimiter
274 <<
Thruster->GetBodyForces().Dump(delimiter) << delimiter
286 string property_name, base_property_name;
289 property_name = base_property_name +
"/total-impulse";
291 property_name = base_property_name +
"/total-vac-impulse";
293 property_name = base_property_name +
"/vacuum-thrust_lbs";
294 PropertyManager->
Tie( property_name.c_str(),
this, &FGRocket::GetVacThrust);
297 property_name = base_property_name +
"/thrust-variation_pct";
300 property_name = base_property_name +
"/total-isp-variation_pct";
304 property_name = base_property_name +
"/oxi-flow-rate-pps";
306 property_name = base_property_name +
"/mixture-ratio";
309 property_name = base_property_name +
"/isp";
334void FGRocket::Debug(
int from)
340 cout <<
" Engine Name: " <<
Name << endl;
341 cout <<
" Vacuum Isp = " << Isp << endl;
342 cout <<
" Maximum Throttle = " <<
MaxThrottle << endl;
343 cout <<
" Minimum Throttle = " <<
MinThrottle << endl;
345 cout <<
" Oxidizer Flow (max) = " << SLOxiFlowMax << endl;
347 cout <<
" Mixture ratio = " << SLOxiFlowMax/
SLFuelFlowMax << endl;
351 if (from == 0) cout <<
"Instantiated: FGRocket" << endl;
352 if (from == 1) cout <<
"Destroyed: FGRocket" << endl;
double FindElementValueAsNumberConvertTo(const std::string &el, const std::string &target_units)
Searches for the named element and converts and returns the data belonging to it.
double FindElementValueAsNumber(const std::string &el="")
Searches for the named element and returns the data belonging to it as a number.
Element * FindElement(const std::string &el="")
Searches for a specified element.
std::string Dump(const std::string &delimeter) const
Prints the contents of the vector.
virtual const FGColumnVector3 & GetMoments(void)
bool Load(FGFDMExec *exec, Element *el)
void LoadThrusterInputs()
FGEngine(int engine_number, struct Inputs &input)
FGPropertyManager * GetPropertyManager(void)
Returns a pointer to the property manager object.
Represents a mathematical function.
static std::string CreateIndexedPropertyName(const std::string &Property, int index)
void RunPostFunctions(void)
void RunPreFunctions(void)
void Tie(const std::string &name, T *pointer)
Tie a property to an external variable.
void SetMixtureRatio(double mix)
double GetVacTotalImpulse(void) const
Gets the total impulse of the rocket.
double GetOxiFlowRate(void) const
void SetTotalIspVariation(double var)
Sets the variation in total motor energy.
double CalcOxidizerNeed(void)
The oxidizer need is calculated based on power levels and flow rate for that power level.
void SetThrustVariation(double var)
Sets the thrust variation for a solid rocket engine.
std::string GetEngineValues(const std::string &delimiter)
double GetTotalImpulse(void) const
Gets the total impulse of the rocket.
double GetThrustVariation(void) const
Returns the thrust variation, if any.
void Calculate(void)
Determines the thrust.
~FGRocket(void)
Destructor.
double GetIsp(void) const
double GetTotalIspVariation(void) const
Returns the Total Isp variation, if any.
std::string GetEngineLabels(const std::string &delimiter)
double CalcFuelNeed(void)
The fuel need is calculated based on power levels and flow rate for that power level.
FGRocket(FGFDMExec *exec, Element *el, int engine_number, struct FGEngine::Inputs &input)
Constructor.
double GetMixtureRatio(void) const