3 #include "Atmosphere.hpp"
5 #include "Propeller.hpp"
8 Propeller::Propeller(float radius, float v, float omega,
9 float rho, float power)
11 // Initialize numeric constants:
12 _lambdaPeak = Math::pow(5.0, -1.0/4.0);
13 _beta = 1.0f/(Math::pow(5.0f, -1.0f/4.0f) - Math::pow(5.0f, -5.0f/4.0f));
16 _etaC = 0.85f; // make this settable?
18 _j0 = v/(omega*_lambdaPeak);
21 float V2 = v*v + (_r*omega)*(_r*omega);
22 _f0 = 2*_etaC*power/(rho*v*V2);
24 _matchTakeoff = false;
29 void Propeller::setTakeoff(float omega0, float power0)
31 // Takeoff thrust coefficient at lambda==0
33 float V2 = _r*omega0 * _r*omega0;
34 float gamma = _etaC * _beta / _j0;
35 float torque = power0 / omega0;
36 float density = Atmosphere::getStdDensity(0);
37 _tc0 = (torque * gamma) / (0.5f * density * V2 * _f0);
40 void Propeller::modPitch(float mod)
43 if(_j0 < 0.25f*_baseJ0) _j0 = 0.25f*_baseJ0;
44 if(_j0 > 4*_baseJ0) _j0 = 4*_baseJ0;
47 void Propeller::setManualPitch()
52 void Propeller::setPropPitch(float proppitch)
54 // makes only positive range of axis effective.
55 _proppitch = Math::clamp(proppitch, 0, 1);
58 void Propeller::calc(float density, float v, float omega,
59 float* thrustOut, float* torqueOut)
62 float pps = _proppitch * 0.9999f; // avoid singularity
63 pps = 1 + ( Math::pow(pps,-1/(pps-1)) - Math::pow(pps,-pps/(pps-1)) );
64 _j0 = (4*_baseJ0) - ( ((4*_baseJ0) - (0.26f*_baseJ0)) * pps );
67 float tipspd = _r*omega;
68 float V2 = v*v + tipspd*tipspd;
70 // Clamp v (forward velocity) to zero, now that we've used it to
71 // calculate V (propeller "speed")
74 // The model doesn't work for propellers turning backwards.
75 if(omega < 0.001) omega = 0.001;
83 torque = (density*V2*_f0*_j0)/(4*_etaC*_beta*(1-_lambdaPeak));
86 // There's an undefined point at 1. Just offset by a tiny bit to
87 // fix (note: the discontinuity is at EXACTLY one, this is about
88 // the only time in history you'll see me use == on a floating
90 if(lambda == 1.0) lambda = 0.9999f;
93 float l4 = lambda*lambda; l4 = l4*l4;
95 // thrust/torque ratio
96 float gamma = (_etaC*_beta/_j0)*(1-l4);
98 // Compute a thrust, clamp to takeoff thrust to prevend huge
99 // numbers at slow speeds.
100 float tc = (1 - lambda) / (1 - _lambdaPeak);
101 if(_matchTakeoff && tc > _tc0) tc = _tc0;
103 float thrust = 0.5f * density * V2 * _f0 * tc;
106 torque -= thrust/gamma;
109 torque = thrust/gamma;
116 }; // namespace yasim