1 #include "Atmosphere.hpp"
3 #include "TurbineEngine.hpp"
7 TurbineEngine::TurbineEngine(float power, float omega, float alt,
12 _rho0 = Atmosphere::getStdDensity(0);
13 _maxTorque = (power/omega) * _rho0 / Atmosphere::getStdDensity(alt);
14 _flatRating = flatRating;
15 _bsfc = 8.47e-08; // in kg/s per watt == 0.5 lb/hr per hp
22 _n2 = _n2Target = _n2Min = _n2LowIdle;
29 void TurbineEngine::setOutputFromN2()
31 float frac = (_n2 - _n2Min) / (_n2Max - _n2Min);
32 _torque = frac * _maxTorque * (_rho / _rho0);
33 _fuelFlow = _running ? _bsfc * _torque * _omega : 0;
36 void TurbineEngine::stabilize()
43 void TurbineEngine::integrate(float dt)
45 // Low-pass the N2 speed to give a realistic spooling time. See
46 // the notes in Jet::setSpooling() for details; this corresponds
47 // to a hard-coded spool time of 2 seconds.
48 const float DECAY = 1.15;
49 _n2 = (_n2 + dt * DECAY * _n2Target)/(1 + dt * DECAY);
53 void TurbineEngine::calc(float pressure, float temp, float omega)
55 _running = _fuel && _cond_lever > 0.001;
57 _n2Min = _n2LowIdle + (_n2HighIdle - _n2LowIdle) * _cond_lever;
59 _rho = Atmosphere::calcStdDensity(pressure, temp);
61 float torque = _throttle * _maxTorque * _rho / _rho0;
62 float power = torque * omega;
63 if(power > _flatRating)
64 torque = _flatRating / omega;
66 float frac = torque / (_maxTorque * (_rho / _rho0));
68 _n2Target = _running ? _n2Min + (_n2Max - _n2Min) * frac : 0;