1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 Purpose: Encapsulates the rotor object
8 ------------- Copyright (C) 2000 Jon S. Berndt (jon@jsbsim.org) -------------
10 This program is free software; you can redistribute it and/or modify it under
11 the terms of the GNU Lesser General Public License as published by the Free Software
12 Foundation; either version 2 of the License, or (at your option) any later
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
20 You should have received a copy of the GNU Lesser General Public License along with
21 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22 Place - Suite 330, Boston, MA 02111-1307, USA.
24 Further information about the GNU Lesser General Public License can also be found on
25 the world wide web at http://www.gnu.org.
27 FUNCTIONAL DESCRIPTION
28 --------------------------------------------------------------------------------
31 --------------------------------------------------------------------------------
33 01/01/10 T.Kreitler test implementation
34 11/15/10 T.Kreitler treated flow solver bug, flow and torque calculations
35 simplified, tiploss influence removed from flapping angles
36 01/10/11 T.Kreitler changed to single rotor model
37 03/06/11 T.Kreitler added brake, clutch, and experimental free-wheeling-unit,
38 reasonable estimate for inflowlag
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
48 #include "input_output/FGXMLElement.h"
49 #include "models/FGMassBalance.h"
50 #include "models/FGPropulsion.h" // to get the GearRatio from a linked rotor
54 using std::ostringstream;
59 static const char *IdSrc = "$Id: FGRotor.cpp,v 1.18 2011/10/15 21:30:28 jentron Exp $";
60 static const char *IdHdr = ID_ROTOR;
62 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
66 static inline double sqr(double x) { return x*x; }
68 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
73 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 // Note: The FGTransmission class is currently carried 'pick-a-pack' by
78 FGTransmission::FGTransmission(FGFDMExec *exec, int num) :
79 FreeWheelTransmission(1.0),
80 ThrusterMoment(1.0), EngineMoment(1.0), EngineFriction(0.0),
81 ClutchCtrlNorm(1.0), BrakeCtrlNorm(0.0), MaxBrakePower(0.0),
82 EngineRPM(0.0), ThrusterRPM(0.0)
85 PropertyManager = exec->GetPropertyManager();
86 dt = exec->GetDeltaT();
88 // avoid too abrupt changes in transmission
89 FreeWheelLag = Filter(200.0,dt);
93 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 FGTransmission::~FGTransmission(){
98 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
100 // basically P = Q*w and Q_Engine + (-Q_Rotor) = J * dw/dt, J = Moment
102 void FGTransmission::Calculate(double EnginePower, double ThrusterTorque, double dt) {
104 double coupling = 1.0, coupling_sq = 1.0;
105 double fw_mult = 1.0;
107 double d_omega = 0.0, engine_d_omega = 0.0, thruster_d_omega = 0.0; // relative changes
109 double engine_omega = rpm_to_omega(EngineRPM);
110 double safe_engine_omega = engine_omega < 1e-1 ? 1e-1 : engine_omega;
111 double engine_torque = EnginePower / safe_engine_omega;
113 double thruster_omega = rpm_to_omega(ThrusterRPM);
114 double safe_thruster_omega = thruster_omega < 1e-1 ? 1e-1 : thruster_omega;
116 engine_torque -= EngineFriction / safe_engine_omega;
117 ThrusterTorque += Constrain(0.0, BrakeCtrlNorm, 1.0) * MaxBrakePower / safe_thruster_omega;
119 // would the FWU release ?
120 engine_d_omega = engine_torque/EngineMoment * dt;
121 thruster_d_omega = - ThrusterTorque/ThrusterMoment * dt;
123 if ( thruster_omega+thruster_d_omega > engine_omega+engine_d_omega ) {
124 // don't drive the engine
125 FreeWheelTransmission = 0.0;
127 FreeWheelTransmission = 1.0;
130 fw_mult = FreeWheelLag.execute(FreeWheelTransmission);
131 coupling = fw_mult * Constrain(0.0, ClutchCtrlNorm, 1.0);
133 if (coupling < 0.999999) { // are the separate calculations needed ?
134 // assume linear transfer
136 (engine_torque - ThrusterTorque*coupling)/(ThrusterMoment*coupling + EngineMoment) * dt;
138 (engine_torque*coupling - ThrusterTorque)/(ThrusterMoment + EngineMoment*coupling) * dt;
140 EngineRPM += omega_to_rpm(engine_d_omega);
141 ThrusterRPM += omega_to_rpm(thruster_d_omega);
143 // simulate friction in clutch
144 coupling_sq = coupling*coupling;
145 EngineRPM = (1.0-coupling_sq) * EngineRPM + coupling_sq * 0.02 * (49.0*EngineRPM + ThrusterRPM);
146 ThrusterRPM = (1.0-coupling_sq) * ThrusterRPM + coupling_sq * 0.02 * (EngineRPM + 49.0*ThrusterRPM);
149 if ( fabs(EngineRPM-ThrusterRPM) < 1e-3 ) {
150 EngineRPM = ThrusterRPM = 0.5 * (EngineRPM+ThrusterRPM);
153 d_omega = (engine_torque - ThrusterTorque)/(ThrusterMoment + EngineMoment) * dt;
154 EngineRPM = ThrusterRPM += omega_to_rpm(d_omega);
157 // nothing will turn backward
158 if (EngineRPM < 0.0 ) EngineRPM = 0.0;
159 if (ThrusterRPM < 0.0 ) ThrusterRPM = 0.0;
163 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
165 bool FGTransmission::BindModel(int num)
167 string property_name, base_property_name;
168 base_property_name = CreateIndexedPropertyName("propulsion/engine", num);
170 property_name = base_property_name + "/brake-ctrl-norm";
171 PropertyManager->Tie( property_name.c_str(), this, &FGTransmission::GetBrakeCtrl, &FGTransmission::SetBrakeCtrl);
172 property_name = base_property_name + "/free-wheel-transmission";
173 PropertyManager->Tie( property_name.c_str(), this, &FGTransmission::GetFreeWheelTransmission);
180 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
184 FGRotor::FGRotor(FGFDMExec *exec, Element* rotor_element, int num)
185 : FGThruster(exec, rotor_element, num),
186 rho(0.002356), // environment
187 Radius(0.0), BladeNum(0), // configuration parameters
188 Sense(1.0), NominalRPM(0.0), MinimalRPM(0.0), MaximalRPM(0.0),
189 ExternalRPM(0), RPMdefinition(0), ExtRPMsource(NULL), SourceGearRatio(1.0),
190 BladeChord(0.0), LiftCurveSlope(0.0), BladeTwist(0.0), HingeOffset(0.0),
191 BladeFlappingMoment(0.0), BladeMassMoment(0.0), PolarMoment(0.0),
192 InflowLag(0.0), TipLossB(0.0),
193 GroundEffectExp(0.0), GroundEffectShift(0.0),
194 LockNumberByRho(0.0), Solidity(0.0), // derived parameters
195 RPM(0.0), Omega(0.0), // dynamic values
197 a0(0.0), a_1(0.0), b_1(0.0), a_dw(0.0),
199 H_drag(0.0), J_side(0.0), Torque(0.0), C_T(0.0),
200 lambda(-0.001), mu(0.0), nu(0.001), v_induced(0.0),
201 theta_downwash(0.0), phi_downwash(0.0),
202 ControlMap(eMainCtrl), // control
203 CollectiveCtrl(0.0), LateralCtrl(0.0), LongitudinalCtrl(0.0),
204 Transmission(NULL), // interaction with engine
205 EngineRPM(0.0), MaxBrakePower(0.0), GearLoss(0.0), GearMoment(0.0)
207 FGColumnVector3 location(0.0, 0.0, 0.0), orientation(0.0, 0.0, 0.0);
208 Element *thruster_element;
210 // initialise/set remaining variables
211 SetTransformType(FGForce::tCustom);
212 PropertyManager = exec->GetPropertyManager();
216 dt = exec->GetDeltaT();
217 for (int i=0; i<5; i++) R[i] = 0.0;
218 for (int i=0; i<5; i++) B[i] = 0.0;
221 thruster_element = rotor_element->GetParent()->FindElement("sense");
222 if (thruster_element) {
223 double s = thruster_element->GetDataAsNumber();
225 Sense = -1.0; // 'CW' as seen from above
226 } else if (s < 0.1) {
227 Sense = 0.0; // 'coaxial'
229 Sense = 1.0; // 'CCW' as seen from above
233 thruster_element = rotor_element->GetParent()->FindElement("location");
234 if (thruster_element) {
235 location = thruster_element->FindElementTripletConvertTo("IN");
237 cerr << "No thruster location found." << endl;
240 thruster_element = rotor_element->GetParent()->FindElement("orient");
241 if (thruster_element) {
242 orientation = thruster_element->FindElementTripletConvertTo("RAD");
244 cerr << "No thruster orientation found." << endl;
247 SetLocation(location);
248 SetAnglesToBody(orientation);
249 InvTransform = Transform().Transposed();
252 ControlMap = eMainCtrl;
253 if (rotor_element->FindElement("controlmap")) {
254 string cm = rotor_element->FindElementValue("controlmap");
257 ControlMap = eTailCtrl;
258 } else if (cm == "TANDEM") {
259 ControlMap = eTandemCtrl;
261 cerr << "# found unknown controlmap: '" << cm << "' using main rotor config." << endl;
265 // ExternalRPM -- is the RPM dictated ?
266 if (rotor_element->FindElement("ExternalRPM")) {
268 SourceGearRatio = 1.0;
269 RPMdefinition = (int) rotor_element->FindElementValueAsNumber("ExternalRPM");
270 int rdef = RPMdefinition;
271 if (RPMdefinition>=0) {
272 // avoid ourself and (still) unknown engines.
273 if (!exec->GetPropulsion()->GetEngine(RPMdefinition) || RPMdefinition==num) {
276 FGThruster *tr = exec->GetPropulsion()->GetEngine(RPMdefinition)->GetThruster();
277 SourceGearRatio = tr->GetGearRatio();
278 // cout << "# got sources' GearRatio: " << SourceGearRatio << endl;
281 if (RPMdefinition != rdef) {
282 cerr << "# discarded given RPM source (" << rdef << ") and switched to external control (-1)." << endl;
286 // configure the rotor parameters
287 Configure(rotor_element);
289 // configure the transmission parameters
291 Transmission = new FGTransmission(exec, num);
293 Transmission->SetMaxBrakePower(MaxBrakePower);
295 if (rotor_element->FindElement("gearloss")) {
296 GearLoss = rotor_element->FindElementValueAsNumberConvertTo("gearloss","HP");
297 GearLoss *= hptoftlbssec;
300 if (GearLoss<1e-6) { // TODO, allow 0 ?
301 double ehp = 0.5 * BladeNum*BladeChord*Radius*Radius; // guess engine power
302 //cout << "# guessed engine power: " << ehp << endl;
303 GearLoss = 0.0025 * ehp * hptoftlbssec;
305 Transmission->SetEngineFriction(GearLoss);
307 // The MOI sensed behind the gear ( MOI_engine*sqr(GearRatio) ).
308 if (rotor_element->FindElement("gearmoment")) {
309 GearMoment = rotor_element->FindElementValueAsNumberConvertTo("gearmoment","SLUG*FT2");
312 if (GearMoment<1e-2) { // TODO, need better check for lower limit
313 GearMoment = 0.1*PolarMoment;
315 Transmission->SetEngineMoment(GearMoment);
317 Transmission->SetThrusterMoment(PolarMoment);
320 // shaft representation - a rather simple transform,
321 // but using a matrix is safer.
322 TboToHsr.InitMatrix( 0.0, 0.0, 1.0,
325 HsrToTbo = TboToHsr.Transposed();
327 // smooth out jumps in hagl reported, otherwise the ground effect
328 // calculation would cause jumps too. 1Hz seems sufficient.
329 damp_hagl = Filter(1.0, dt);
331 // enable import-export
338 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
341 if (Transmission) delete Transmission;
346 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
348 // 5in1: value-fetch-convert-default-return function
350 double FGRotor::ConfigValueConv( Element* el, const string& ename, double default_val,
351 const string& unit, bool tell)
355 double val = default_val;
357 string pname = "*No parent element*";
360 e = el->FindElement(ename);
361 pname = el->GetName();
366 val = e->GetDataAsNumber();
368 val = el->FindElementValueAsNumberConvertTo(ename,unit);
372 cerr << pname << ": missing element '" << ename <<
373 "' using estimated value: " << default_val << endl;
380 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
382 double FGRotor::ConfigValue(Element* el, const string& ename, double default_val, bool tell)
384 return ConfigValueConv(el, ename, default_val, "", tell);
387 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
389 // 1. read configuration and try to fill holes, ymmv
390 // 2. calculate derived parameters
391 void FGRotor::Configure(Element* rotor_element)
395 const bool yell = true;
396 const bool silent = false;
399 Radius = 0.5 * ConfigValueConv(rotor_element, "diameter", 42.0, "FT", yell);
400 Radius = Constrain(1e-3, Radius, 1e9);
402 BladeNum = (int) ConfigValue(rotor_element, "numblades", 3 , yell);
404 GearRatio = ConfigValue(rotor_element, "gearratio", 1.0, yell);
406 // make sure that v_tip (omega*r) is below 0.7mach ~ 750ft/s
407 estimate = (750.0/Radius)/(2.0*M_PI) * 60.0; // 7160/Radius
408 NominalRPM = ConfigValue(rotor_element, "nominalrpm", estimate, yell);
409 NominalRPM = Constrain(2.0, NominalRPM, 1e9);
411 MinimalRPM = ConfigValue(rotor_element, "minrpm", 1.0);
412 MinimalRPM = Constrain(1.0, MinimalRPM, NominalRPM - 1.0);
414 MaximalRPM = ConfigValue(rotor_element, "maxrpm", 2.0*NominalRPM);
415 MaximalRPM = Constrain(NominalRPM, MaximalRPM, 1e9);
417 estimate = Constrain(0.07, 2.0/Radius , 0.14); // guess solidity
418 estimate = estimate * M_PI*Radius/BladeNum;
419 BladeChord = ConfigValueConv(rotor_element, "chord", estimate, "FT", yell);
421 LiftCurveSlope = ConfigValue(rotor_element, "liftcurveslope", 6.0); // "1/RAD"
422 BladeTwist = ConfigValueConv(rotor_element, "twist", -0.17, "RAD");
424 HingeOffset = ConfigValueConv(rotor_element, "hingeoffset", 0.05 * Radius, "FT" );
426 estimate = sqr(BladeChord) * sqr(Radius - HingeOffset) * 0.57;
427 BladeFlappingMoment = ConfigValueConv(rotor_element, "flappingmoment", estimate, "SLUG*FT2");
428 BladeFlappingMoment = Constrain(1.0e-6, BladeFlappingMoment, 1e9);
430 // guess mass from moment of a thin stick, and multiply by the blades cg distance
431 estimate = ( 3.0 * BladeFlappingMoment / sqr(Radius) ) * (0.45 * Radius) ;
432 BladeMassMoment = ConfigValue(rotor_element, "massmoment", estimate); // unit is slug-ft
433 BladeMassMoment = Constrain(0.001, BladeMassMoment, 1e9);
435 estimate = 1.1 * BladeFlappingMoment * BladeNum;
436 PolarMoment = ConfigValueConv(rotor_element, "polarmoment", estimate, "SLUG*FT2");
437 PolarMoment = Constrain(1e-6, PolarMoment, 1e9);
439 // "inflowlag" is treated further down.
441 TipLossB = ConfigValue(rotor_element, "tiplossfactor", 1.0, silent);
443 estimate = 0.01 * PolarMoment ; // guesses for huey, bo105 20-30hp
444 MaxBrakePower = ConfigValueConv(rotor_element, "maxbrakepower", estimate, "HP");
445 MaxBrakePower *= hptoftlbssec;
448 if (rotor_element->FindElement("cgroundeffect")) {
450 cge = rotor_element->FindElementValueAsNumber("cgroundeffect");
451 cge = Constrain(1e-9, cge, 1.0);
452 gee = 1.0 / ( 2.0*Radius * cge );
453 cerr << "# *** 'cgroundeffect' is defunct." << endl;
454 cerr << "# *** use 'groundeffectexp' with: " << gee << endl;
457 GroundEffectExp = ConfigValue(rotor_element, "groundeffectexp", 0.0);
458 GroundEffectShift = ConfigValueConv(rotor_element, "groundeffectshift", 0.0, "FT");
460 // precalc often used powers
461 R[0]=1.0; R[1]=Radius; R[2]=R[1]*R[1]; R[3]=R[2]*R[1]; R[4]=R[3]*R[1];
462 B[0]=1.0; B[1]=TipLossB; B[2]=B[1]*B[1]; B[3]=B[2]*B[1]; B[4]=B[3]*B[1];
464 // derived parameters
465 LockNumberByRho = LiftCurveSlope * BladeChord * R[4] / BladeFlappingMoment;
466 Solidity = BladeNum * BladeChord / (M_PI * Radius);
468 // estimate inflow lag, see /GE49/ eqn(1)
469 double omega_tmp = (NominalRPM/60.0)*2.0*M_PI;
470 estimate = 16.0/(LockNumberByRho*rho * omega_tmp ); // 16/(gamma*Omega)
471 // printf("# Est. InflowLag: %f\n", estimate);
472 InflowLag = ConfigValue(rotor_element, "inflowlag", estimate, yell);
473 InflowLag = Constrain(1.0e-6, InflowLag, 2.0);
478 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
480 // calculate control-axes components of total airspeed at the hub.
481 // sets rotor orientation angle (beta) as side effect. /SH79/ eqn(19-22)
483 FGColumnVector3 FGRotor::hub_vel_body2ca( const FGColumnVector3 &uvw,
484 const FGColumnVector3 &pqr,
485 double a_ic, double b_ic)
487 FGColumnVector3 v_r, v_shaft, v_w;
490 pos = fdmex->GetMassBalance()->StructuralToBody(GetActingLocation());
493 v_shaft = TboToHsr * InvTransform * v_r;
495 beta_orient = atan2(v_shaft(eV),v_shaft(eU));
497 v_w(eU) = v_shaft(eU)*cos(beta_orient) + v_shaft(eV)*sin(beta_orient);
499 v_w(eW) = v_shaft(eW) - b_ic*v_shaft(eU) - a_ic*v_shaft(eV);
504 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
506 // express fuselage angular velocity in control axes /SH79/ eqn(30,31)
508 FGColumnVector3 FGRotor::fus_angvel_body2ca( const FGColumnVector3 &pqr)
510 FGColumnVector3 av_s_fus, av_w_fus;
513 // av_s_fus = BodyToShaft * pqr; /SH79/
514 // BodyToShaft = TboToHsr * InvTransform
515 av_s_fus = TboToHsr * InvTransform * pqr;
517 av_w_fus(eP)= av_s_fus(eP)*cos(beta_orient) + av_s_fus(eQ)*sin(beta_orient);
518 av_w_fus(eQ)= - av_s_fus(eP)*sin(beta_orient) + av_s_fus(eQ)*cos(beta_orient);
519 av_w_fus(eR)= av_s_fus(eR);
525 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
527 // The calculation is a bit tricky because thrust depends on induced velocity,
530 // The flow_scale parameter (ranging from 0.5-1.0) is used to approximate a
531 // reduction of inflow if the helicopter is close to the ground, yielding to
532 // higher thrust, see /TA77/ eqn(10a).
534 void FGRotor::calc_flow_and_thrust( double theta_0, double Uw, double Ww,
538 double ct_over_sigma = 0.0;
539 double c0, ct_l, ct_t0, ct_t1;
542 mu = Uw/(Omega*Radius); // /SH79/ eqn(24)
543 if (mu > 0.7) mu = 0.7;
546 ct_t0 = (1.0/3.0*B[3] + 1.0/2.0 * TipLossB*mu2 - 4.0/(9.0*M_PI) * mu*mu2 ) * theta_0;
547 ct_t1 = (1.0/4.0*B[4] + 1.0/4.0 * B[2]*mu2) * BladeTwist;
549 ct_l = (1.0/2.0*B[2] + 1.0/4.0 * mu2) * lambda; // first time
551 c0 = (LiftCurveSlope/2.0)*(ct_l + ct_t0 + ct_t1) * Solidity;
552 c0 = c0 / ( 2.0 * sqrt( sqr(mu) + sqr(lambda) ) + 1e-15);
554 // replacement for /SH79/ eqn(26).
555 // ref: dnu/dt = 1/tau ( Ct / (2*sqrt(mu^2+lambda^2)) - nu )
556 // taking mu and lambda constant, this integrates to
558 nu = flow_scale * ((nu - c0) * exp(-dt/InflowLag) + c0);
560 // now from nu to lambda, C_T, and Thrust
562 lambda = Ww/(Omega*Radius) - nu; // /SH79/ eqn(25)
564 ct_l = (1.0/2.0*B[2] + 1.0/4.0 * mu2) * lambda;
566 ct_over_sigma = (LiftCurveSlope/2.0)*(ct_l + ct_t0 + ct_t1); // /SH79/ eqn(27)
568 Thrust = BladeNum*BladeChord*Radius*rho*sqr(Omega*Radius) * ct_over_sigma;
570 C_T = ct_over_sigma * Solidity;
571 v_induced = nu * (Omega*Radius);
576 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
578 // The coning angle doesn't apply for teetering rotors, but calculating
579 // doesn't hurt. /SH79/ eqn(29)
581 void FGRotor::calc_coning_angle(double theta_0)
583 double lock_gamma = LockNumberByRho * rho;
585 double a0_l = (1.0/6.0 + 0.04 * mu*mu*mu) * lambda;
586 double a0_t0 = (1.0/8.0 + 1.0/8.0 * mu*mu) * theta_0;
587 double a0_t1 = (1.0/10.0 + 1.0/12.0 * mu*mu) * BladeTwist;
588 a0 = lock_gamma * ( a0_l + a0_t0 + a0_t1);
592 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
594 // Flapping angles relative to control axes /SH79/ eqn(32)
596 void FGRotor::calc_flapping_angles(double theta_0, const FGColumnVector3 &pqr_fus_w)
598 double lock_gamma = LockNumberByRho * rho;
601 double mu2_2 = sqr(mu)/2.0;
602 double t075 = theta_0 + 0.75 * BladeTwist; // common approximation for rectangular blades
604 a_1 = 1.0/(1.0 - mu2_2) * (
605 (2.0*lambda + (8.0/3.0)*t075)*mu
606 + pqr_fus_w(eP)/Omega
607 - 16.0 * pqr_fus_w(eQ)/(lock_gamma*Omega)
610 b_1 = 1.0/(1.0 + mu2_2) * (
612 - pqr_fus_w(eQ)/Omega
613 - 16.0 * pqr_fus_w(eP)/(lock_gamma*Omega)
616 // used in force calc
617 a_dw = 1.0/(1.0 - mu2_2) * (
618 (2.0*lambda + (8.0/3.0)*t075)*mu
619 - 24.0 * pqr_fus_w(eQ)/(lock_gamma*Omega)
620 * ( 1.0 - ( 0.29 * t075 / (C_T/Solidity) ) )
626 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
630 void FGRotor::calc_drag_and_side_forces(double theta_0)
632 double cy_over_sigma;
633 double t075 = theta_0 + 0.75 * BladeTwist;
635 H_drag = Thrust * a_dw;
638 0.75*b_1*lambda - 1.5*a0*mu*lambda + 0.25*a_1*b_1*mu
639 - a0*a_1*sqr(mu) + (1.0/6.0)*a0*a_1
640 - (0.75*mu*a0 - (1.0/3.0)*b_1 - 0.5*sqr(mu)*b_1)*t075
642 cy_over_sigma *= LiftCurveSlope/2.0;
644 J_side = BladeNum * BladeChord * Radius * rho * sqr(Omega*Radius) * cy_over_sigma;
649 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
651 // Simplified version of /SH79/ eqn(36). Uses an estimate for blade drag
652 // (a new config parameter to come...).
653 // From "Bramwell's Helicopter Dynamics", second edition, eqn(3.43) and (3.44)
655 void FGRotor::calc_torque(double theta_0)
657 // estimate blade drag
658 double delta_dr = 0.009 + 0.3*sqr(6.0*C_T/(LiftCurveSlope*Solidity));
660 Torque = rho * BladeNum * BladeChord * delta_dr * sqr(Omega*Radius) * R[2] *
661 (1.0+4.5*sqr(mu))/8.0
662 - (Thrust*lambda + H_drag*mu)*Radius;
667 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
669 // transform rotor forces from control axes to shaft axes, and express
670 // in body axes /SH79/ eqn(40,41)
672 FGColumnVector3 FGRotor::body_forces(double a_ic, double b_ic)
675 - H_drag*cos(beta_orient) - J_side*sin(beta_orient) + Thrust*b_ic,
676 - H_drag*sin(beta_orient) + J_side*cos(beta_orient) + Thrust*a_ic,
679 return HsrToTbo * F_s;
682 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
684 // calculates the additional moments due to hinge offset and handles
687 FGColumnVector3 FGRotor::body_moments(double a_ic, double b_ic)
689 FGColumnVector3 M_s, M_hub, M_h;
692 // cyclic flapping relative to shaft axes /SH79/ eqn(43)
693 a1s = a_1*cos(beta_orient) + b_1*sin(beta_orient) - b_ic;
694 b1s = b_1*cos(beta_orient) - a_1*sin(beta_orient) + a_ic;
696 mf = 0.5 * HingeOffset * BladeNum * Omega*Omega * BladeMassMoment;
700 M_s(eN) = Torque * Sense ;
702 return HsrToTbo * M_s;
705 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
707 void FGRotor::CalcRotorState(void)
709 double A_IC; // lateral (roll) control in radians
710 double B_IC; // longitudinal (pitch) control in radians
711 double theta_col; // rotor collective pitch in radians
713 FGColumnVector3 vHub_ca, avFus_ca;
715 double filtered_hagl = 0.0;
716 double ge_factor = 1.0;
718 // fetch needed values from environment
719 rho = in.Density; // slugs/ft^3.
720 double h_agl_ft = in.H_agl;
721 // update InvTransform, the rotor orientation could have been altered
722 InvTransform = Transform().Transposed();
724 // handle RPM requirements, calc omega.
725 if (ExternalRPM && ExtRPMsource) {
726 RPM = ExtRPMsource->getDoubleValue() * ( SourceGearRatio / GearRatio );
729 // MinimalRPM is always >= 1. MaximalRPM is always >= NominalRPM
730 RPM = Constrain(MinimalRPM, RPM, MaximalRPM);
732 Omega = (RPM/60.0)*2.0*M_PI;
734 // set control inputs
736 B_IC = LongitudinalCtrl;
737 theta_col = CollectiveCtrl;
740 if (GroundEffectExp > 1e-5) {
741 if (h_agl_ft<0.0) h_agl_ft = 0.0; // clamp
742 filtered_hagl = damp_hagl.execute(h_agl_ft) + GroundEffectShift;
743 // actual/nominal factor avoids absurd scales at startup
744 ge_factor -= exp(-filtered_hagl*GroundEffectExp) * (RPM / NominalRPM);
745 if (ge_factor<0.5) ge_factor=0.5; // clamp
748 // all set, start calculations
750 vHub_ca = hub_vel_body2ca(in.AeroUVW, in.AeroPQR, A_IC, B_IC);
752 avFus_ca = fus_angvel_body2ca(in.AeroPQR);
754 calc_flow_and_thrust(theta_col, vHub_ca(eU), vHub_ca(eW), ge_factor);
756 calc_coning_angle(theta_col);
758 calc_flapping_angles(theta_col, avFus_ca);
760 calc_drag_and_side_forces(theta_col);
762 calc_torque(theta_col);
764 // Fixme: only valid for a 'decent' rotor
765 theta_downwash = atan2( -in.AeroUVW(eU), v_induced - in.AeroUVW(eW));
766 phi_downwash = atan2( in.AeroUVW(eV), v_induced - in.AeroUVW(eW));
768 vFn = body_forces(A_IC, B_IC);
769 vMn = Transform() * body_moments(A_IC, B_IC);
773 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
775 double FGRotor::Calculate(double EnginePower)
781 Transmission->SetClutchCtrlNorm(ClutchCtrlNorm);
783 // the RPM values are handled inside Transmission
784 Transmission->Calculate(EnginePower, Torque, in.TotalDeltaT);
786 EngineRPM = Transmission->GetEngineRPM() * GearRatio;
787 RPM = Transmission->GetThrusterRPM();
789 EngineRPM = RPM * GearRatio;
792 RPM = Constrain(MinimalRPM, RPM, MaximalRPM); // trim again
798 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
801 bool FGRotor::BindModel(void)
803 string property_name, base_property_name;
804 base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNum);
806 property_name = base_property_name + "/rotor-rpm";
807 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetRPM );
809 property_name = base_property_name + "/engine-rpm";
810 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetEngineRPM );
812 property_name = base_property_name + "/rotor-thrust-lbs"; // might be redundant - check!
813 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetThrust );
815 property_name = base_property_name + "/a0-rad";
816 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetA0 );
818 property_name = base_property_name + "/a1-rad";
819 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetA1 );
821 property_name = base_property_name + "/b1-rad";
822 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetB1 );
824 property_name = base_property_name + "/inflow-ratio";
825 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetLambda );
827 property_name = base_property_name + "/advance-ratio";
828 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetMu );
830 property_name = base_property_name + "/induced-inflow-ratio";
831 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetNu );
833 property_name = base_property_name + "/vi-fps";
834 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetVi );
836 property_name = base_property_name + "/thrust-coefficient";
837 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetCT );
839 property_name = base_property_name + "/torque-lbsft";
840 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetTorque );
842 property_name = base_property_name + "/theta-downwash-rad";
843 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetThetaDW );
845 property_name = base_property_name + "/phi-downwash-rad";
846 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetPhiDW );
848 switch (ControlMap) {
850 property_name = base_property_name + "/antitorque-ctrl-rad";
851 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetCollectiveCtrl, &FGRotor::SetCollectiveCtrl);
854 property_name = base_property_name + "/tail-collective-ctrl-rad";
855 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetCollectiveCtrl, &FGRotor::SetCollectiveCtrl);
856 property_name = base_property_name + "/lateral-ctrl-rad";
857 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetLateralCtrl, &FGRotor::SetLateralCtrl);
858 property_name = base_property_name + "/longitudinal-ctrl-rad";
859 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetLongitudinalCtrl, &FGRotor::SetLongitudinalCtrl);
861 default: // eMainCtrl
862 property_name = base_property_name + "/collective-ctrl-rad";
863 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetCollectiveCtrl, &FGRotor::SetCollectiveCtrl);
864 property_name = base_property_name + "/lateral-ctrl-rad";
865 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetLateralCtrl, &FGRotor::SetLateralCtrl);
866 property_name = base_property_name + "/longitudinal-ctrl-rad";
867 PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetLongitudinalCtrl, &FGRotor::SetLongitudinalCtrl);
871 if (RPMdefinition == -1) {
872 property_name = base_property_name + "/x-rpm-dict";
873 ExtRPMsource = PropertyManager->GetNode(property_name, true);
874 } else if (RPMdefinition >= 0 && RPMdefinition != EngineNum) {
875 string ipn = CreateIndexedPropertyName("propulsion/engine", RPMdefinition);
876 property_name = ipn + "/rotor-rpm";
877 ExtRPMsource = PropertyManager->GetNode(property_name, false);
878 if (! ExtRPMsource) {
879 cerr << "# Warning: Engine number " << EngineNum << "." << endl;
880 cerr << "# No 'rotor-rpm' property found for engine " << RPMdefinition << "." << endl;
881 cerr << "# Please check order of engine definitons." << endl;
884 cerr << "# Engine number " << EngineNum;
885 cerr << ", given ExternalRPM value '" << RPMdefinition << "' unhandled." << endl;
892 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
894 string FGRotor::GetThrusterLabels(int id, string delimeter)
899 buf << Name << " RPM (engine " << id << ")";
905 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
907 string FGRotor::GetThrusterValues(int id, string delimeter)
918 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
919 // The bitmasked value choices are as follows:
920 // unset: In this case (the default) JSBSim would only print
921 // out the normally expected messages, essentially echoing
922 // the config files as they are read. If the environment
923 // variable is not set, debug_lvl is set to 1 internally
924 // 0: This requests JSBSim not to output any messages
926 // 1: This value explicity requests the normal JSBSim
928 // 2: This value asks for a message to be printed out when
929 // a class is instantiated
930 // 4: When this value is set, a message is displayed when a
931 // FGModel object executes its Run() method
932 // 8: When this value is set, various runtime state variables
933 // are printed out periodically
934 // 16: When set various parameters are sanity checked and
935 // a message is printed out when they go out of bounds
937 void FGRotor::Debug(int from)
939 string ControlMapName;
941 if (debug_lvl <= 0) return;
943 if (debug_lvl & 1) { // Standard console startup message output
944 if (from == 0) { // Constructor
945 cout << "\n Rotor Name: " << Name << endl;
946 cout << " Diameter = " << 2.0 * Radius << " ft." << endl;
947 cout << " Number of Blades = " << BladeNum << endl;
948 cout << " Gear Ratio = " << GearRatio << endl;
949 cout << " Sense = " << Sense << endl;
950 cout << " Nominal RPM = " << NominalRPM << endl;
951 cout << " Minimal RPM = " << MinimalRPM << endl;
952 cout << " Maximal RPM = " << MaximalRPM << endl;
955 if (RPMdefinition == -1) {
956 cout << " RPM is controlled externally" << endl;
958 cout << " RPM source set to thruster " << RPMdefinition << endl;
962 cout << " Blade Chord = " << BladeChord << endl;
963 cout << " Lift Curve Slope = " << LiftCurveSlope << endl;
964 cout << " Blade Twist = " << BladeTwist << endl;
965 cout << " Hinge Offset = " << HingeOffset << endl;
966 cout << " Blade Flapping Moment = " << BladeFlappingMoment << endl;
967 cout << " Blade Mass Moment = " << BladeMassMoment << endl;
968 cout << " Polar Moment = " << PolarMoment << endl;
969 cout << " Inflow Lag = " << InflowLag << endl;
970 cout << " Tip Loss = " << TipLossB << endl;
971 cout << " Lock Number = " << LockNumberByRho * 0.002356 << " (SL)" << endl;
972 cout << " Solidity = " << Solidity << endl;
973 cout << " Max Brake Power = " << MaxBrakePower/hptoftlbssec << " HP" << endl;
974 cout << " Gear Loss = " << GearLoss/hptoftlbssec << " HP" << endl;
975 cout << " Gear Moment = " << GearMoment << endl;
977 switch (ControlMap) {
978 case eTailCtrl: ControlMapName = "Tail Rotor"; break;
979 case eTandemCtrl: ControlMapName = "Tandem Rotor"; break;
980 default: ControlMapName = "Main Rotor";
982 cout << " Control Mapping = " << ControlMapName << endl;
986 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
987 if (from == 0) cout << "Instantiated: FGRotor" << endl;
988 if (from == 1) cout << "Destroyed: FGRotor" << endl;
990 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
992 if (debug_lvl & 8 ) { // Runtime state variables
994 if (debug_lvl & 16) { // Sanity checking
996 if (debug_lvl & 64) {
997 if (from == 0) { // Constructor
998 cout << IdSrc << endl;
999 cout << IdHdr << endl;
1006 } // namespace JSBSim