From: Erik Hofman Date: Tue, 30 Nov 2010 12:44:10 +0000 (+0100) Subject: latest updates from JSBSim X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d66903e9ad63b91182ccc25d9bb82f18f8dd98b6;p=flightgear.git latest updates from JSBSim --- diff --git a/src/FDM/JSBSim/models/FGAircraft.cpp b/src/FDM/JSBSim/models/FGAircraft.cpp index 30649c6a4..e2adbe44c 100644 --- a/src/FDM/JSBSim/models/FGAircraft.cpp +++ b/src/FDM/JSBSim/models/FGAircraft.cpp @@ -67,7 +67,7 @@ DEFINITIONS GLOBAL DATA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -static const char *IdSrc = "$Id: FGAircraft.cpp,v 1.29 2010/11/18 12:38:06 jberndt Exp $"; +static const char *IdSrc = "$Id: FGAircraft.cpp,v 1.30 2010/11/29 12:33:57 jberndt Exp $"; static const char *IdHdr = ID_AIRCRAFT; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -153,7 +153,7 @@ bool FGAircraft::Run(void) double FGAircraft::GetNlf(void) const { if (FDMExec->GetMassBalance()->GetWeight() != 0) - return (-FDMExec->GetAerodynamics()->GetvFw(3))/FDMExec->GetMassBalance()->GetWeight(); + return (-FDMExec->GetAerodynamics()->GetvFw(3))/FDMExec->GetMassBalance()->GetWeight(); else return 0.; } diff --git a/src/FDM/JSBSim/models/FGAtmosphere.cpp b/src/FDM/JSBSim/models/FGAtmosphere.cpp index d2c6a3dac..f40fabcb5 100644 --- a/src/FDM/JSBSim/models/FGAtmosphere.cpp +++ b/src/FDM/JSBSim/models/FGAtmosphere.cpp @@ -61,7 +61,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGAtmosphere.cpp,v 1.40 2010/11/18 12:38:06 jberndt Exp $"; +static const char *IdSrc = "$Id: FGAtmosphere.cpp,v 1.41 2010/11/30 12:19:57 jberndt Exp $"; static const char *IdHdr = ID_ATMOSPHERE; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -572,8 +572,11 @@ void FGAtmosphere::Turbulence(void) } case ttMilspec: case ttTustin: { + double V = FDMExec->GetAuxiliary()->GetVt(); // true airspeed in ft/s + // an index of zero means turbulence is disabled - if (probability_of_exceedence_index == 0) { + // airspeed occurs as divisor in the code below + if (probability_of_exceedence_index == 0 || V == 0) { vTurbulenceNED(1) = vTurbulenceNED(2) = vTurbulenceNED(3) = 0.0; vTurbPQR(1) = vTurbPQR(2) = vTurbPQR(3) = 0.0; return; @@ -582,10 +585,11 @@ void FGAtmosphere::Turbulence(void) // Turbulence model according to MIL-F-8785C (Flying Qualities of Piloted Aircraft) double h = FDMExec->GetPropagate()->GetDistanceAGL(), - V = FDMExec->GetAuxiliary()->GetVt(), // true airspeed in ft/s b_w = wingspan, L_u, L_w, sig_u, sig_w; + if (b_w == 0.) b_w = 30.; + // clip height functions at 10 ft if (h <= 10.) h = 10; @@ -644,6 +648,10 @@ void FGAtmosphere::Turbulence(void) C_BLq = 1/tau_q/tan(T_V/2/tau_q), // eq. (24) C_BLr = 1/tau_r/tan(T_V/2/tau_r); // eq. (26) + // all values calculated so far are strictly positive, except for + // the random numbers nu_*. This means that in the code below, all + // divisors are strictly positive, too, and no floating point + // exception should occur. xi_u = -(1 - C_BL*tau_u)/(1 + C_BL*tau_u)*xi_u_km1 + sig_u*sqrt(2*tau_u/T_V)/(1 + C_BL*tau_u)*(nu_u + nu_u_km1); // eq. (18) xi_v = -2*(sqr(omega_v) - sqr(C_BL))/sqr(omega_v + C_BL)*xi_v_km1 diff --git a/src/FDM/JSBSim/models/propulsion/FGPiston.cpp b/src/FDM/JSBSim/models/propulsion/FGPiston.cpp index b225563c2..522a0b2fe 100644 --- a/src/FDM/JSBSim/models/propulsion/FGPiston.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGPiston.cpp @@ -53,7 +53,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGPiston.cpp,v 1.53 2010/08/21 17:13:48 jberndt Exp $"; +static const char *IdSrc = "$Id: FGPiston.cpp,v 1.54 2010/11/30 12:17:10 jberndt Exp $"; static const char *IdHdr = ID_PISTON; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -92,13 +92,14 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number) Bore = 5.125; Stroke = 4.375; Cylinders = 4; + CylinderHeadMass = 2; //kg CompressionRatio = 8.5; Z_airbox = -999; Ram_Air_Factor = 1; PeakMeanPistonSpeed_fps = 100; FMEPDynamic= 18400; FMEPStatic = 46500; - + Cooling_Factor = 0.5144444; // These are internal program variables @@ -200,10 +201,14 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number) Stroke = el->FindElementValueAsNumberConvertTo("stroke","IN"); if (el->FindElement("cylinders")) Cylinders = el->FindElementValueAsNumber("cylinders"); + if (el->FindElement("cylinder-head-mass")) + CylinderHeadMass = el->FindElementValueAsNumberConvertTo("cylinder-head-mass","KG"); if (el->FindElement("air-intake-impedance-factor")) Z_airbox = el->FindElementValueAsNumber("air-intake-impedance-factor"); if (el->FindElement("ram-air-factor")) Ram_Air_Factor = el->FindElementValueAsNumber("ram-air-factor"); + if (el->FindElement("cooling-factor")) + Cooling_Factor = el->FindElementValueAsNumber("cooling-factor"); if (el->FindElement("dynamic-fmep")) FMEPDynamic= el->FindElementValueAsNumberConvertTo("dynamic-fmep","PA"); if (el->FindElement("static-fmep")) @@ -303,8 +308,12 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number) PropertyManager->Tie(property_name, &Z_airbox); property_name = base_property_name + "/ram-air-factor"; PropertyManager->Tie(property_name, &Ram_Air_Factor); + property_name = base_property_name + "/cooling-factor"; + PropertyManager->Tie(property_name, &Cooling_Factor); property_name = base_property_name + "/boost-speed"; PropertyManager->Tie(property_name, &BoostSpeed); + property_name = base_property_name + "/cht-degF"; + PropertyManager->Tie(property_name, this, &FGPiston::getCylinderHeadTemp_degF); // Set up and sanity-check the turbo/supercharging configuration based on the input values. if (TakeoffBoost > RatedBoost[0]) bTakeoffBoost = true; @@ -642,7 +651,7 @@ void FGPiston::doAirFlow(void) // loss of volumentric efficiency due to difference between MAP and exhaust pressure // Eq 6-10 from The Internal Combustion Engine - Charles Taylor Vol 1 double ve =((gamma-1)/gamma) +( CompressionRatio -(p_amb/MAP))/(gamma*( CompressionRatio - 1)); - +// FGAtmosphere::GetDensity() * FGJSBBase::m3toft3 / FGJSBBase::kgtoslug; rho_air = p_amb / (R_air * T_amb); double swept_volume = (displacement_SI * (RPM/60)) / 2; double v_dot_air = swept_volume * volumetric_efficiency *ve; @@ -766,7 +775,7 @@ void FGPiston::doEGT(void) * Calculate the cylinder head temperature. * * Inputs: T_amb, IAS, rho_air, m_dot_fuel, calorific_value_fuel, - * combustion_efficiency, RPM, MaxRPM, Displacement + * combustion_efficiency, RPM, MaxRPM, Displacement, Cylinders * * Outputs: CylinderHeadTemp_degK */ @@ -779,17 +788,17 @@ void FGPiston::doCHT(void) double arbitary_area = Displacement/360.0; double CpCylinderHead = 800.0; - double MassCylinderHead = 8.0; + double MassCylinderHead = CylinderHeadMass * Cylinders; double temperature_difference = CylinderHeadTemp_degK - T_amb; - double v_apparent = IAS * 0.5144444; + double v_apparent = IAS * Cooling_Factor; double v_dot_cooling_air = arbitary_area * v_apparent; double m_dot_cooling_air = v_dot_cooling_air * rho_air; double dqdt_from_combustion = m_dot_fuel * calorific_value_fuel * combustion_efficiency * 0.33; double dqdt_forced = (h2 * m_dot_cooling_air * temperature_difference) + (h3 * RPM * temperature_difference / MaxRPM); - double dqdt_free = h1 * temperature_difference; + double dqdt_free = h1 * temperature_difference * arbitary_area; double dqdt_cylinder_head = dqdt_from_combustion + dqdt_forced + dqdt_free; double HeatCapacityCylinderHead = CpCylinderHead * MassCylinderHead; @@ -921,6 +930,7 @@ void FGPiston::Debug(int from) cout << " Bore: " << Bore << endl; cout << " Stroke: " << Stroke << endl; cout << " Cylinders: " << Cylinders << endl; + cout << " Cylinders Head Mass: " < {number} {number} {number} + {number} {number} {number} {number} @@ -101,6 +102,7 @@ CLASS DOCUMENTATION {number} {number} {number} + {number} @endcode @@ -160,8 +162,7 @@ CLASS DOCUMENTATION config file (and is above RATEDBOOST1), then the throttle position is interpreted as: - - 0 to 0.95 : idle manifold pressure to rated boost (where attainable) - - 0.96, 0.97, 0.98 : rated boost (where attainable). + - 0 to 0.98 : idle manifold pressure to rated boost (where attainable) - 0.99, 1.0 : takeoff boost (where attainable). A typical takeoff boost for an earlyish Merlin was about 12psi, compared @@ -181,7 +182,7 @@ CLASS DOCUMENTATION @author Dave Luff (engine operational code) @author David Megginson (initial porting and additional code) @author Ron Jensen (additional engine code) - @version $Id: FGPiston.h,v 1.24 2010/08/21 18:08:13 jberndt Exp $ + @version $Id: FGPiston.h,v 1.25 2010/11/30 12:17:10 jberndt Exp $ */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -200,21 +201,21 @@ public: std::string GetEngineValues(const std::string& delimiter); void Calculate(void); - double GetPowerAvailable(void) {return PowerAvailable;} + double GetPowerAvailable(void) const {return PowerAvailable;} double CalcFuelNeed(void); void ResetToIC(void); void SetMagnetos(int magnetos) {Magnetos = magnetos;} - double GetEGT(void) { return EGT_degC; } - int GetMagnetos(void) {return Magnetos;} + double GetEGT(void) const { return EGT_degC; } + int GetMagnetos(void) const {return Magnetos;} - double getExhaustGasTemp_degF(void) {return KelvinToFahrenheit(ExhaustGasTemp_degK);} + double getExhaustGasTemp_degF(void) const {return KelvinToFahrenheit(ExhaustGasTemp_degK);} double getManifoldPressure_inHg(void) const {return ManifoldPressure_inHg;} - double getCylinderHeadTemp_degF(void) {return KelvinToFahrenheit(CylinderHeadTemp_degK);} + double getCylinderHeadTemp_degF(void) const {return KelvinToFahrenheit(CylinderHeadTemp_degK);} double getOilPressure_psi(void) const {return OilPressure_psi;} - double getOilTemp_degF (void) {return KelvinToFahrenheit(OilTemp_degK);} - double getRPM(void) {return RPM;} + double getOilTemp_degF (void) const {return KelvinToFahrenheit(OilTemp_degK);} + double getRPM(void) const {return RPM;} protected: @@ -275,6 +276,7 @@ private: double Bore; // inches double Stroke; // inches double Cylinders; // number + double CylinderHeadMass; // kilograms double CompressionRatio; // number double Z_airbox; // number representing intake impediance before the throttle double Z_throttle; // number representing slope of throttle impediance @@ -321,6 +323,7 @@ private: double T_amb; // degrees Kelvin double RPM; // revolutions per minute double IAS; // knots + double Cooling_Factor; // normal bool Magneto_Left; bool Magneto_Right; int Magnetos;