X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FYASim%2FJet.cpp;h=afbb669cde95956af65c2865aa9757791abaad16;hb=c62048d5e26a2931f2a0f5fa7e94b3f7203e4762;hp=82d1172a57add29bf666653f4c0d5f38ec27e923;hpb=f0e6716953604730579a5e45f785fd063737dce4;p=flightgear.git diff --git a/src/FDM/YASim/Jet.cpp b/src/FDM/YASim/Jet.cpp index 82d1172a5..afbb669cd 100644 --- a/src/FDM/YASim/Jet.cpp +++ b/src/FDM/YASim/Jet.cpp @@ -10,13 +10,14 @@ Jet::Jet() _reheat = 0; _rotControl = 0; _maxRot = 0; + _reverseThrust = false; // Initialize parameters for an early-ish subsonic turbojet. More // recent turbofans will typically have a lower vMax, epr0, and // tsfc. _vMax = 800; _epr0 = 3.0; - _tsfc = 0.8; + _tsfc = 0.8f; _egt0 = 1050; _n1Min = 55; _n1Max = 102; @@ -29,6 +30,9 @@ Jet::Jet() _n2 = _n2Min; // And sanify the remaining junk, just in case. + _running = true; + _cranking = false; + _fuel = true; _epr = 1; _fuelFlow = 0; _egt = 273; @@ -83,7 +87,7 @@ void Jet::setSpooling(float time) // 2.3 = -ln(0.1), i.e. x=2.3 is the 90% point we're defining // The extra fudge factor is there because the N1 speed (which // determines thrust) lags the N2 speed. - _decay = 1.5 * 2.3 / time; + _decay = 1.5f * 2.3f / time; } void Jet::setVectorAngle(float angle) @@ -103,7 +107,6 @@ void Jet::setRotation(float rot) _rotControl = rot; } - float Jet::getN1() { return _n1 * _tempCorrect; @@ -147,16 +150,22 @@ void Jet::integrate(float dt) _pressureCorrect = statP/P0; _tempCorrect = Math::sqrt(statT/T0); + // Handle running out of fuel. This is a hack. What should + // really happen is a simulation of ram air torque on the + // turbine. This just forces the engine into ground idle. + if(_fuel == false) + _throttle = 0; + // Linearly taper maxThrust to zero at vMax float vCorr = 1 - (speed/_vMax); float maxThrust = _maxThrust * vCorr * (statD/D0); - _thrust = maxThrust * _throttle; + float setThrust = maxThrust * _throttle; // Now get a "beta" (i.e. EPR - 1) value. The output values are // expressed as functions of beta. float ibeta0 = 1/(_epr0 - 1); - float betaTarget = (_epr0 - 1) * (_thrust/_maxThrust) * (P0/_pressure) + float betaTarget = (_epr0 - 1) * (setThrust/_maxThrust) * (P0/_pressure) * (_temp/statT); float n2Target = _n2Min + (betaTarget*ibeta0) * (_n2Max - _n2Min); @@ -172,19 +181,32 @@ void Jet::integrate(float dt) // The actual thrust produced is keyed to the N1 speed. Add the // afterburners in at the end. float betaN1 = (_epr0-1) * (_n1 - _n1Min) / (_n1Max - _n1Min); - _thrust *= betaN1/(betaTarget+.00001); // blowup protection + _thrust = _maxThrust * betaN1/((_epr0-1)*(P0/_pressure)*(_temp/statT)); _thrust *= 1 + _reheat*(_abFactor-1); // Finally, calculate the output variables. Use a 80/20 mix of // the N2/N1 speeds as the key. - float beta = 0.8*betaN2 + 0.2*betaN1; + float beta = 0.8f*betaN2 + 0.2f*betaN1; _epr = beta + 1; - float ff0 = _maxThrust*_tsfc*(1/(3600*9.8)); // takeoff fuel flow, kg/s + float ff0 = _maxThrust*_tsfc*(1/(3600.0f*9.8f)); // takeoff fuel flow, kg/s _fuelFlow = ff0 * beta*ibeta0; - _fuelFlow *= 1 + (3.5 * _reheat * _abFactor); // Afterburners take + _fuelFlow *= 1 + (3.5f * _reheat * _abFactor); // Afterburners take // 3.5 times as much // fuel per thrust unit _egt = T0 + beta*ibeta0 * (_egt0 - T0); + + // Thrust reverse handling: + if(_reverseThrust) _thrust *= -_reverseEff; +} + +bool Jet::isRunning() +{ + return _running; +} + +bool Jet::isCranking() +{ + return _cranking; } void Jet::getThrust(float* out)