3#include "Atmosphere.hpp"
5#include "Propeller.hpp"
8Propeller::Propeller(
float radius,
float v,
float omega,
9 float rho,
float power)
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));
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;
30void Propeller::setTakeoff(
float omega0,
float power0)
34 float V2 = _r*omega0 * _r*omega0;
35 float gamma = _etaC * _beta / _j0;
36 float torque = power0 / omega0;
37 float density = Atmosphere::getStdDensity(0);
38 _tc0 = (torque * gamma) / (0.5f * density * V2 * _f0);
41void Propeller::setStops(
float fine_stop,
float coarse_stop)
43 _fine_stop = fine_stop;
44 _coarse_stop = coarse_stop;
47void Propeller::modPitch(
float mod)
50 if(_j0 < _fine_stop*_baseJ0) _j0 = _fine_stop*_baseJ0;
51 if(_j0 > _coarse_stop*_baseJ0) _j0 = _coarse_stop*_baseJ0;
54void Propeller::setManualPitch()
59void Propeller::setPropPitch(
float proppitch)
62 _proppitch = Math::clamp(proppitch, 0, 1);
65void Propeller::setPropFeather(
int state)
68 _propfeather = (state != 0);
71void Propeller::calc(
float density,
float v,
float omega,
72 float* thrustOut,
float* torqueOut)
79 _j0 = _baseJ0 * Math::pow(2, 2 - 4*_proppitch);
81 float tipspd = _r*omega;
82 float V2 = v*v + tipspd*tipspd;
86 if(omega < 0.001) omega = 0.001;
92 if(lambda == 1.0f) lambda = 0.9999f;
94 float l4 = lambda*lambda; l4 = l4*l4;
95 float gamma = (_etaC*_beta/_j0)*(1-l4);
99 float tc = (1 - lambda) / (1 - _lambdaPeak);
100 if(_matchTakeoff && tc > _tc0) tc = _tc0;
102 float thrust = 0.5f * density * V2 * _f0 * tc;
103 float torque = thrust/gamma;
112 float tau0 = (0.25f * _j0) / (_etaC * _beta * (1 - _lambdaPeak));
113 float lambdaWM = 1.2f;
114 torque = tau0 - tau0 * (lambda - 1) / (lambdaWM - 1);
115 torque *= 0.5f * density * V2 * _f0;