]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGRocket.cpp
Make yasim accept the launchbar and hook properties. They are not tied to anything...
[flightgear.git] / src / FDM / JSBSim / FGRocket.cpp
index f2c7fb3775ee8b5d0567870fe48725c68a40a48d..c7131f341071861055b51f89ee1623524523e9dc 100644 (file)
@@ -38,6 +38,8 @@ HISTORY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
+#include <sstream>
+
 #include "FGRocket.h"
 
 namespace JSBSim {
@@ -49,7 +51,8 @@ static const char *IdHdr = ID_ROCKET;
 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;
 
@@ -71,7 +74,6 @@ FGRocket::FGRocket(FGFDMExec* exec, FGConfigFile* Eng_cfg) : FGEngine(exec)
 
   Debug(0);
 
-  EngineNumber = 0;
   Type = etRocket;
   Flameout = false;
 
@@ -88,7 +90,7 @@ FGRocket::~FGRocket(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-double FGRocket::Calculate(double pe)
+double FGRocket::Calculate(void)
 {
   double Cf=0;
 
@@ -103,11 +105,38 @@ double FGRocket::Calculate(double pe)
   } 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 Thrust = Thruster->Calculate(Cf*maxPC*PctPower*propEff);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGRocket::GetEngineLabels(string delimeter)
+{
+  std::ostringstream buf;
+
+  buf << Name << "_ChamberPress[" << EngineNumber << "]" << delimeter
+      << Thruster->GetThrusterLabels(EngineNumber, delimeter);
+
+  return buf.str();
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGRocket::GetEngineValues(string delimeter)
+{
+  std::ostringstream buf;
+
+  buf << PC << delimeter << Thruster->GetThrusterValues(EngineNumber, delimeter);
+
+  return buf.str();
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%