INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+#include <sstream>
+
#include "FGRocket.h"
namespace JSBSim {
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-FGRocket::FGRocket(FGFDMExec* exec, FGConfigFile* Eng_cfg) : FGEngine(exec)
+FGRocket::FGRocket(FGFDMExec* exec, FGConfigFile* Eng_cfg, int engine_number)
+ : FGEngine(exec, engine_number)
{
string token;
Debug(0);
- EngineNumber = 0;
Type = etRocket;
+ Flameout = false;
PC = 0.0;
kFactor = (2.0*SHR*SHR/(SHR-1.0))*pow(2.0/(SHR+1), (SHR+1)/(SHR-1));
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGRocket::~FGRocket()
+FGRocket::~FGRocket(void)
{
Debug(1);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-double FGRocket::Calculate(double pe)
+double FGRocket::Calculate(void)
{
double Cf=0;
- ConsumeFuel();
+ if (!Flameout && !Starved) ConsumeFuel();
Throttle = FCS->GetThrottlePos(EngineNumber);
} else {
PctPower = Throttle / MaxThrottle;
PC = maxPC*PctPower * (1.0 + Variance * ((double)rand()/(double)RAND_MAX - 0.5));
- Cf = sqrt(kFactor*(1 - pow(pe/(PC), (SHR-1)/SHR)));
+ // The Cf (below) is CF from Eqn. 3-30, "Rocket Propulsion Elements", Fifth Edition,
+ // George P. Sutton. Note that the thruster function GetPowerRequired() might
+ // be better called GetResistance() or something; this function returns the
+ // nozzle exit pressure.
+ Cf = sqrt(kFactor*(1 - pow(Thruster->GetPowerRequired()/(PC), (SHR-1)/SHR)));
Flameout = false;
}
- return Cf*maxPC*PctPower*propEff;
+ return Thruster->Calculate(Cf*maxPC*PctPower*propEff);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGRocket::GetEngineLabels(void)
+{
+ std::ostringstream buf;
+
+ buf << Name << "_ChamberPress[" << EngineNumber << "], "
+ << Thruster->GetThrusterLabels(EngineNumber);
+
+ return buf.str();
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGRocket::GetEngineValues(void)
+{
+ std::ostringstream buf;
+
+ buf << PC << ", " << Thruster->GetThrusterValues(EngineNumber);
+
+ return buf.str();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%