From: Erik Hofman Date: Mon, 7 Dec 2015 10:10:03 +0000 (+0100) Subject: Sync JSBSim again X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5c7d261df53e8a30cc382985794afae37e2ca34d;p=flightgear.git Sync JSBSim again --- diff --git a/src/FDM/JSBSim/FGFDMExec.cpp b/src/FDM/JSBSim/FGFDMExec.cpp index 0c73e8cae..f0226850b 100644 --- a/src/FDM/JSBSim/FGFDMExec.cpp +++ b/src/FDM/JSBSim/FGFDMExec.cpp @@ -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; } diff --git a/src/FDM/JSBSim/models/propulsion/FGTank.cpp b/src/FDM/JSBSim/models/propulsion/FGTank.cpp index b5786a0cb..d2c73f3a5 100644 --- a/src/FDM/JSBSim/models/propulsion/FGTank.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGTank.cpp @@ -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); } diff --git a/src/FDM/JSBSim/models/propulsion/FGTurbine.cpp b/src/FDM/JSBSim/models/propulsion/FGTurbine.cpp index 0b3171b07..8b4eeac3e 100644 --- a/src/FDM/JSBSim/models/propulsion/FGTurbine.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGTurbine.cpp @@ -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; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp b/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp index 10e0a9475..e3533049c 100644 --- a/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp @@ -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 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); diff --git a/src/FDM/JSBSim/models/propulsion/FGTurboProp.h b/src/FDM/JSBSim/models/propulsion/FGTurboProp.h index 97b69c1a5..74df2d922 100644 --- a/src/FDM/JSBSim/models/propulsion/FGTurboProp.h +++ b/src/FDM/JSBSim/models/propulsion/FGTurboProp.h @@ -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; };