From 26c6f3f407a94e5faf414479e2f742a27e756ce5 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 14 Dec 2001 23:57:05 +0000 Subject: [PATCH] Latest JSBSim changes. --- src/FDM/JSBSim/FGPiston.cpp | 28 +++++++++++++++++++++------- src/FDM/JSBSim/FGPropeller.cpp | 8 ++++---- src/FDM/JSBSim/FGPropulsion.cpp | 2 +- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/FDM/JSBSim/FGPiston.cpp b/src/FDM/JSBSim/FGPiston.cpp index 725499f1a..0065ff9d9 100644 --- a/src/FDM/JSBSim/FGPiston.cpp +++ b/src/FDM/JSBSim/FGPiston.cpp @@ -1,7 +1,8 @@ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Module: FGPiston.cpp - Author: Jon S. Berndt + Author: Jon S. Berndt, JSBSim framework + Dave Luff, Piston engine model Date started: 09/12/2000 Purpose: This module models a Piston engine @@ -85,6 +86,7 @@ FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg) : FGEngine(exec), crank_counter = 0; EngineNumber = 0; OilTemp_degK = 298; + ManifoldPressure_inHg = Atmosphere->GetPressure() * 0.014138; // psf to in Hg dt = State->Getdt(); @@ -285,8 +287,12 @@ void FGPiston::doEngineStartup(void) void FGPiston::doManifoldPressure(void) { - ManifoldPressure_inHg = MinManifoldPressure_inHg + - (Throttle * (MaxManifoldPressure_inHg - MinManifoldPressure_inHg)); + if (Running || Cranking) { + ManifoldPressure_inHg = MinManifoldPressure_inHg + + (Throttle * (MaxManifoldPressure_inHg - MinManifoldPressure_inHg)); + } else { + ManifoldPressure_inHg = Atmosphere->GetPressure() * 0.014138; // psf to in Hg + } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -390,11 +396,19 @@ void FGPiston::doEnginePower(void) void FGPiston::doEGT(void) { + double delta_T_exhaust = 0.0; + double heat_capacity_exhaust; + double enthalpy_exhaust; + combustion_efficiency = Lookup_Combustion_Efficiency->GetValue(equivalence_ratio); - double enthalpy_exhaust = m_dot_fuel * calorific_value_fuel * - combustion_efficiency * 0.33; - double heat_capacity_exhaust = (Cp_air * m_dot_air) + (Cp_fuel * m_dot_fuel); - double delta_T_exhaust = enthalpy_exhaust / heat_capacity_exhaust; + enthalpy_exhaust = m_dot_fuel * calorific_value_fuel * combustion_efficiency * 0.33; + heat_capacity_exhaust = (Cp_air * m_dot_air) + (Cp_fuel * m_dot_fuel); + + if (heat_capacity_exhaust >= 0.0000001) + delta_T_exhaust = enthalpy_exhaust / heat_capacity_exhaust; + else + delta_T_exhaust = 0.0; + ExhaustGasTemp_degK = T_amb + delta_T_exhaust; ExhaustGasTemp_degK *= 0.444 + ((0.544 - 0.444) * Percentage_Power / 100.0); } diff --git a/src/FDM/JSBSim/FGPropeller.cpp b/src/FDM/JSBSim/FGPropeller.cpp index 92e4c5340..b47ba0c7f 100644 --- a/src/FDM/JSBSim/FGPropeller.cpp +++ b/src/FDM/JSBSim/FGPropeller.cpp @@ -147,8 +147,8 @@ double FGPropeller::Calculate(double PowerAvailable) if (P_Factor > 0.0001) { alpha = fdmex->GetTranslation()->Getalpha(); beta = fdmex->GetTranslation()->Getbeta(); - SetActingLocationY( GetLocationY() + P_Factor*alpha*fabs(Sense)/Sense); - SetActingLocationZ( GetLocationZ() + P_Factor*beta*fabs(Sense)/Sense); + SetActingLocationY( GetLocationY() + P_Factor*alpha*Sense); + SetActingLocationZ( GetLocationZ() + P_Factor*beta*Sense); } else if (P_Factor < 0.000) { cerr << "P-Factor value in config file must be greater than zero" << endl; } @@ -161,7 +161,7 @@ double FGPropeller::Calculate(double PowerAvailable) // natural axis of the engine. The transform takes place in the base class // FGForce::GetBodyForces() function. - vH(eX) = Ixx*omega*fabs(Sense)/Sense; + vH(eX) = Ixx*omega*Sense; vH(eY) = 0.0; vH(eZ) = 0.0; @@ -208,7 +208,7 @@ double FGPropeller::GetPowerRequired(void) PowerRequired = cPReq*RPS*RPS*RPS*Diameter*Diameter*Diameter*Diameter *Diameter*rho; - vTorque(eX) = PowerRequired / ((RPM/60)*2.0*M_PI); + vTorque(eX) = -Sense*PowerRequired / (RPS*2.0*M_PI); return PowerRequired; } diff --git a/src/FDM/JSBSim/FGPropulsion.cpp b/src/FDM/JSBSim/FGPropulsion.cpp index 177e954fe..2b8767dd0 100644 --- a/src/FDM/JSBSim/FGPropulsion.cpp +++ b/src/FDM/JSBSim/FGPropulsion.cpp @@ -317,7 +317,7 @@ bool FGPropulsion::Load(FGConfigFile* AC_cfg) if (thrType == "FG_PROPELLER" && P_Factor > 0.001) { ((FGPropeller*)Thrusters[numThrusters])->SetPFactor(P_Factor); if (debug_lvl > 0) cout << " P-Factor: " << P_Factor << endl; - ((FGPropeller*)Thrusters[numThrusters])->SetSense(Sense); + ((FGPropeller*)Thrusters[numThrusters])->SetSense(fabs(Sense)/Sense); if (debug_lvl > 0) cout << " Sense: " << Sense << endl; } Thrusters[numThrusters]->SetdeltaT(dt*rate);