]> git.mxchange.org Git - flightgear.git/commitdiff
Sync JSBSim again
authorErik Hofman <erik@ehofman.com>
Mon, 7 Dec 2015 10:10:03 +0000 (11:10 +0100)
committerErik Hofman <erik@ehofman.com>
Mon, 7 Dec 2015 10:10:03 +0000 (11:10 +0100)
src/FDM/JSBSim/FGFDMExec.cpp
src/FDM/JSBSim/models/propulsion/FGTank.cpp
src/FDM/JSBSim/models/propulsion/FGTurbine.cpp
src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp
src/FDM/JSBSim/models/propulsion/FGTurboProp.h

index 0c73e8caeed864401ee43aedf1c70c74141bd894..f0226850b62c8266d6bdd6ad80ce273c37cfccc3 100644 (file)
@@ -73,7 +73,7 @@ using namespace std;
 
 namespace JSBSim {
 
-IDENT(IdSrc,"$Id: FGFDMExec.cpp,v 1.181 2015/10/25 21:18:29 dpculp Exp $");
+IDENT(IdSrc,"$Id: FGFDMExec.cpp,v 1.182 2015/11/24 13:06:24 ehofman Exp $");
 IDENT(IdHdr,ID_FDMEXEC);
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1176,13 +1176,16 @@ void FGFDMExec::DoTrim(int mode)
   if (Constructing) return;
 
   if (mode < 0 || mode > JSBSim::tNone) {
-    cerr << endl << "Illegal trimming mode!" << endl << endl;
+    throw("Illegal trimming mode!");
     return;
   }
  
 
   FGTrim trim(this, (JSBSim::TrimMode)mode);
-  if ( !trim.DoTrim() ) cerr << endl << "Trim Failed" << endl << endl;
+  if ( !trim.DoTrim() ) {
+    throw("Trim Failed");
+    return;
+  }
   trim.Report();
   trim_completed = 1;
 }
index b5786a0cb225975a15e132eb3c98543429fc84b4..d2c73f3a53171a827c314298b27e36af8b2394ad 100644 (file)
@@ -48,7 +48,7 @@ using namespace std;
 
 namespace JSBSim {
 
-IDENT(IdSrc,"$Id: FGTank.cpp,v 1.43 2015/02/02 20:49:11 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGTank.cpp,v 1.44 2015/12/02 04:23:26 dpculp Exp $");
 IDENT(IdHdr,ID_TANK);
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -323,7 +323,7 @@ double FGTank::Calculate(double dt, double TAT_C)
   double TempFlowFactor = 1.115;      // Watts/sqft/C
   double Tdiff = TAT_C - Temperature;
   double dTemp = 0.0;                 // Temp change due to one surface
-  if (fabs(Tdiff) > 0.1) {
+  if (fabs(Tdiff) > 0.1 && Contents > 0.01) {
     dTemp = (TempFlowFactor * Area * Tdiff * dt) / (Contents * HeatCapacity);
   }
 
index 0b3171b07a9fa0cf75eb1b19df8162ed0dd7b272..8b4eeac3e2771e27727714022f570f3ac015cfb8 100644 (file)
@@ -51,7 +51,7 @@ using namespace std;
 
 namespace JSBSim {
 
-IDENT(IdSrc,"$Id: FGTurbine.cpp,v 1.47 2015/09/27 10:07:53 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGTurbine.cpp,v 1.48 2015/12/02 04:25:23 dpculp Exp $");
 IDENT(IdHdr,ID_TURBINE);
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -569,7 +569,7 @@ int FGTurbine::InitRunning(void)
   N1 = IdleN1 + ThrottlePos * N1_factor;
   Calculate();
   FDMExec->ResumeIntegration();
-  return phase==tpRun;
+  return phase=tpRun;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index 10e0a9475f2ce7ba9f96a0e0d501a37177d8a45d..e3533049c9ba024f704752745e8925741b06210a 100644 (file)
@@ -48,6 +48,7 @@ INCLUDES
 #include "FGTurboProp.h"
 #include "FGPropeller.h"
 #include "FGRotor.h"
+#include "math/FGFunction.h"
 #include "input_output/FGXMLElement.h"
 
 using namespace std;
@@ -63,15 +64,12 @@ CLASS IMPLEMENTATION
 
 FGTurboProp::FGTurboProp(FGFDMExec* exec, Element *el, int engine_number, struct Inputs& input)
   : FGEngine(engine_number, input),
-    ITT_N1(NULL), EnginePowerRPM_N1(NULL), EnginePowerVC(NULL), CombustionEfficiency_N1(NULL),
+    ITT_N1(NULL), EnginePowerRPM_N1(NULL), EnginePowerVC(NULL), EnginePowerVCFN(NULL), CombustionEfficiency_N1(NULL),
     FDMExec(exec)
 {
-  FGEngine::Load(exec, el);
   SetDefaults();
-  thrusterType = Thruster->GetType();
 
   Load(exec, el);
-  bindmodel(exec->GetPropertyManager());
   Debug(0);
 }
 
@@ -93,6 +91,24 @@ bool FGTurboProp::Load(FGFDMExec* exec, Element *el)
   MaxStartingTime = 999999; //very big timeout -> infinite
   Ielu_max_torque=-1;
 
+  Element* function_element = el->FindElement("function");
+
+  while(function_element) {
+    string name = function_element->GetAttributeValue("name");
+    if (name == "EnginePowerVC")
+      function_element->SetAttributeValue("name", string("propulsion/engine[#]/") + name);
+
+    function_element = el->FindNextElement("function");
+  }
+
+  FGEngine::Load(exec, el);
+  thrusterType = Thruster->GetType();
+
+  string property_prefix = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
+
+  EnginePowerVCFN = GetPreFunction(property_prefix+"/EnginePowerVC");
+
+
 // ToDo: Need to make sure units are properly accounted for below.
 
   if (el->FindElement("milthrust"))
@@ -138,8 +154,9 @@ bool FGTurboProp::Load(FGFDMExec* exec, Element *el)
     table_element = el->FindNextElement("table");
     if (!table_element) break;
     name = table_element->GetAttributeValue("name");
-    if (name == "EnginePowerVC") {
+    if (!EnginePowerVCFN && name == "EnginePowerVC") {
       EnginePowerVC = new FGTable(PropertyManager, table_element);
+      std::cerr << "Note: Using the EnginePowerVC without enclosed <function> tag is deprecated" << std::endl;
     } else if (name == "EnginePowerRPM_N1") {
       EnginePowerRPM_N1 = new FGTable(PropertyManager, table_element);
     } else if (name == "ITT_N1") {
@@ -171,7 +188,7 @@ bool FGTurboProp::Load(FGFDMExec* exec, Element *el)
     *CombustionEfficiency_N1 << 110.0 << 6.0;
   }
   
-
+  bindmodel(exec->GetPropertyManager());
   return true;
 }
 
@@ -321,7 +338,7 @@ double FGTurboProp::Run(void)
   N1 = ExpSeek(&N1, IdleN1 + ThrottlePos * N1_factor, Idle_Max_Delay, Idle_Max_Delay * 2.4);
 
   EngPower_HP = EnginePowerRPM_N1->GetValue(RPM,N1);
-  EngPower_HP *= EnginePowerVC->GetValue();
+  EngPower_HP *= EnginePowerVCFN ? EnginePowerVCFN->GetValue() : EnginePowerVC->GetValue();
   if (EngPower_HP > MaxPower) EngPower_HP = MaxPower;
 
   CombustionEfficiency = CombustionEfficiency_N1->GetValue(N1);
@@ -370,7 +387,7 @@ double FGTurboProp::SpinUp(void)
   NozzlePosition = 1.0;
 
   EngPower_HP = EnginePowerRPM_N1->GetValue(RPM,N1);
-  EngPower_HP *= EnginePowerVC->GetValue();
+  EngPower_HP *= EnginePowerVCFN ? EnginePowerVCFN->GetValue() : EnginePowerVC->GetValue();
   if (EngPower_HP > MaxPower) EngPower_HP = MaxPower;
 
   if (StartTime>=0) StartTime+=in.TotalDeltaT;
@@ -394,7 +411,7 @@ double FGTurboProp::Start(void)
     Cranking = true;                   // provided for sound effects signal
     if (N1 < IdleN1) {
       EngPower_HP = EnginePowerRPM_N1->GetValue(RPM,N1);
-      EngPower_HP *= EnginePowerVC->GetValue();
+      EngPower_HP *= EnginePowerVCFN ? EnginePowerVCFN->GetValue() : EnginePowerVC->GetValue();
       if (EngPower_HP > MaxPower) EngPower_HP = MaxPower;
       N1 = ExpSeek(&N1, IdleN1*1.1, Idle_Max_Delay*4, Idle_Max_Delay * 2.4);
       CombustionEfficiency = CombustionEfficiency_N1->GetValue(N1);
index 97b69c1a580e059e94c616a7fcc642a58c44910a..74df2d92261dc4487c01a41dde4c5b0f4baa6bab 100644 (file)
@@ -221,6 +221,7 @@ private:
   FGTable* ITT_N1;             // ITT temperature depending on throttle command
   FGTable* EnginePowerRPM_N1;
   FGTable* EnginePowerVC;
+  FGFunction* EnginePowerVCFN;
   FGTable* CombustionEfficiency_N1;
   FGFDMExec* FDMExec;
 };