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.0/(Math::pow(5.0, -1.0/4.0) - Math::pow(5.0, -5.0/4.0));
16 _etaC = 0.85; // 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;
27 void Propeller::setTakeoff(float omega0, float power0)
29 // Takeoff thrust coefficient at lambda==0
31 float V2 = _r*omega0 * _r*omega0;
32 float gamma = _etaC * _beta / _j0;
33 float torque = power0 / omega0;
34 float density = Atmosphere::getStdDensity(0);
35 _tc0 = (torque * gamma) / (0.5 * density * V2 * _f0);
38 void Propeller::modPitch(float mod)
41 if(_j0 < 0.25*_baseJ0) _j0 = 0.25*_baseJ0;
42 if(_j0 > 4*_baseJ0) _j0 = 4*_baseJ0;
46 void Propeller::calc(float density, float v, float omega,
47 float* thrustOut, float* torqueOut)
49 float tipspd = _r*omega;
50 float V2 = v*v + tipspd*tipspd;
52 // Clamp v (forward velocity) to zero, now that we've used it to
53 // calculate V (propeller "speed")
62 torque = (density*V2*_f0*_j0)/(4*_etaC*_beta*(1-_lambdaPeak));
65 // There's an undefined point at 1. Just offset by a tiny bit to
66 // fix (note: the discontinuity is at EXACTLY one, this is about
67 // the only time in history you'll see me use == on a floating
69 if(lambda == 1) lambda = 0.9999;
72 float l4 = lambda*lambda; l4 = l4*l4;
74 // thrust/torque ratio
75 float gamma = (_etaC*_beta/_j0)*(1-l4);
77 // Compute a thrust, clamp to takeoff thrust to prevend huge
78 // numbers at slow speeds.
79 float tc = (1 - lambda) / (1 - _lambdaPeak);
80 if(_matchTakeoff && tc > _tc0) tc = _tc0;
82 float thrust = 0.5 * density * V2 * _f0 * tc;
85 torque -= thrust/gamma;
88 torque = thrust/gamma;