1#include "Atmosphere.hpp"
3#include "TurbineEngine.hpp"
7TurbineEngine::TurbineEngine(
float power,
float omega,
float alt,
12 _rho0 = Atmosphere::getStdDensity(0);
13 _maxTorque = (power/omega) * _rho0 / Atmosphere::getStdDensity(alt);
14 _flatRating = flatRating;
22 _n2 = _n2Target = _n2Min = _n2LowIdle;
29void TurbineEngine::setOutputFromN2()
31 float frac = (_n2 - _n2Min) / (_n2Max - _n2Min);
32 _torque = frac * _maxTorque * (_rho / _rho0);
33 _fuelFlow = _running ? _bsfc * _torque * _omega : 0;
36void TurbineEngine::stabilize()
43void TurbineEngine::integrate(
float dt)
48 const float DECAY = 1.15;
49 _n2 = (_n2 + dt * DECAY * _n2Target)/(1 + dt * DECAY);
53void 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;