]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp
Merge branch 'next' of git@gitorious.org:fg/flightgear into next
[flightgear.git] / src / FDM / JSBSim / models / propulsion / FGTurboProp.cpp
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Module:       FGTurboProp.cpp
4  Author:       Jiri "Javky" Javurek
5                based on SimTurbine and Turbine engine from David Culp
6  Date started: 05/14/2004
7  Purpose:      This module models a turbo propeller engine.
8
9  ------------- Copyright (C) 2004  (javky@email.cz) ---------
10
11  This program is free software; you can redistribute it and/or modify it under
12  the terms of the GNU Lesser General Public License as published by the Free Software
13  Foundation; either version 2 of the License, or (at your option) any later
14  version.
15
16  This program is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
19  details.
20
21  You should have received a copy of the GNU Lesser General Public License along with
22  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23  Place - Suite 330, Boston, MA  02111-1307, USA.
24
25  Further information about the GNU Lesser General Public License can also be found on
26  the world wide web at http://www.gnu.org.
27
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30
31 This class descends from the FGEngine class and models a Turbo propeller engine
32 based on parameters given in the engine config file for this class
33
34 HISTORY
35 --------------------------------------------------------------------------------
36 05/14/2004  Created
37
38 //JVK (mark)
39
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41 INCLUDES
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
43
44 #include <iostream>
45 #include <sstream>
46 #include "FGTurboProp.h"
47 #include "FGPropeller.h"
48 #include "models/FGPropulsion.h"
49 #include "models/FGAuxiliary.h"
50
51 using namespace std;
52
53 namespace JSBSim {
54
55 static const char *IdSrc = "$Id: FGTurboProp.cpp,v 1.16 2010/02/25 05:21:36 jberndt Exp $";
56 static const char *IdHdr = ID_TURBOPROP;
57
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 CLASS IMPLEMENTATION
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61
62 FGTurboProp::FGTurboProp(FGFDMExec* exec, Element *el, int engine_number)
63   : FGEngine(exec, el, engine_number),
64     ITT_N1(NULL), EnginePowerRPM_N1(NULL), EnginePowerVC(NULL)
65 {
66   SetDefaults();
67
68   Load(exec, el);
69   Debug(0);
70 }
71
72 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73
74 FGTurboProp::~FGTurboProp()
75 {
76   delete ITT_N1;
77   delete EnginePowerRPM_N1;
78   delete EnginePowerVC;
79   Debug(1);
80 }
81
82 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83
84 bool FGTurboProp::Load(FGFDMExec* exec, Element *el)
85 {
86   IdleFF=-1;
87   MaxStartingTime = 999999; //very big timeout -> infinite
88   Ielu_max_torque=-1;
89
90 // ToDo: Need to make sure units are properly accounted for below.
91
92   if (el->FindElement("milthrust"))
93     MilThrust = el->FindElementValueAsNumberConvertTo("milthrust","LBS");
94   if (el->FindElement("idlen1"))
95     IdleN1 = el->FindElementValueAsNumber("idlen1");
96   if (el->FindElement("idlen2"))
97     IdleN2 = el->FindElementValueAsNumber("idlen2");
98   if (el->FindElement("maxn1"))
99     MaxN1 = el->FindElementValueAsNumber("maxn1");
100   if (el->FindElement("maxn2"))
101     MaxN2 = el->FindElementValueAsNumber("maxn2");
102   if (el->FindElement("betarangeend"))
103     BetaRangeThrottleEnd = el->FindElementValueAsNumber("betarangeend")/100.0;
104   if (el->FindElement("reversemaxpower"))
105     ReverseMaxPower = el->FindElementValueAsNumber("reversemaxpower")/100.0;
106
107   if (el->FindElement("maxpower"))
108     MaxPower = el->FindElementValueAsNumber("maxpower");
109   if (el->FindElement("idlefuelflow"))
110     IdleFF = el->FindElementValueAsNumber("idlefuelflow");
111   if (el->FindElement("psfc"))
112     PSFC = el->FindElementValueAsNumber("psfc");
113   if (el->FindElement("n1idle_max_delay"))
114     Idle_Max_Delay = el->FindElementValueAsNumber("n1idle_max_delay");
115   if (el->FindElement("maxstartingtime"))
116     MaxStartingTime = el->FindElementValueAsNumber("maxstartingtime");
117   if (el->FindElement("startern1"))
118     StarterN1 = el->FindElementValueAsNumber("startern1");
119   if (el->FindElement("ielumaxtorque"))
120     Ielu_max_torque = el->FindElementValueAsNumber("ielumaxtorque");
121   if (el->FindElement("itt_delay"))
122     ITT_Delay = el->FindElementValueAsNumber("itt_delay");
123
124   Element *table_element;
125   string name;
126   FGPropertyManager* PropertyManager = exec->GetPropertyManager();
127
128   while (true) {
129     table_element = el->FindNextElement("table");
130     if (!table_element) break;
131     name = table_element->GetAttributeValue("name");
132     if (name == "EnginePowerVC") {
133       EnginePowerVC = new FGTable(PropertyManager, table_element);
134     } else if (name == "EnginePowerRPM_N1") {
135       EnginePowerRPM_N1 = new FGTable(PropertyManager, table_element);
136     } else if (name == "ITT_N1") {
137       ITT_N1 = new FGTable(PropertyManager, table_element);
138     } else {
139       cerr << "Unknown table type: " << name << " in turbine definition." <<
140       endl;
141     }
142   }
143
144   // Pre-calculations and initializations
145
146   delay=1;
147   N1_factor = MaxN1 - IdleN1;
148   N2_factor = MaxN2 - IdleN2;
149   OilTemp_degK = (Auxiliary->GetTotalTemperature() - 491.69) * 0.5555556 + 273.0;
150   if (IdleFF==-1) IdleFF = pow(MilThrust, 0.2) * 107.0;  // just an estimate
151
152   cout << "ENG POWER:" << EnginePowerRPM_N1->GetValue(1200,90) << "\n";
153
154   return true;
155 }
156
157 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
158 // The main purpose of Calculate() is to determine what phase the engine should
159 // be in, then call the corresponding function.
160
161 double FGTurboProp::Calculate(void)
162 {
163   TAT = (Auxiliary->GetTotalTemperature() - 491.69) * 0.5555556;
164   dt = FDMExec->GetDeltaT() * Propulsion->GetRate();
165
166   ThrottleCmd = FCS->GetThrottleCmd(EngineNumber);
167
168   Prop_RPM = Thruster->GetRPM() * Thruster->GetGearRatio();
169   if (Thruster->GetType() == FGThruster::ttPropeller) {
170     ((FGPropeller*)Thruster)->SetAdvance(FCS->GetPropAdvance(EngineNumber));
171     ((FGPropeller*)Thruster)->SetFeather(FCS->GetPropFeather(EngineNumber));
172     ((FGPropeller*)Thruster)->SetReverse(Reversed);
173     if (Reversed) {
174       ((FGPropeller*)Thruster)->SetReverseCoef(ThrottleCmd);
175     } else {
176       ((FGPropeller*)Thruster)->SetReverseCoef(0.0);
177     }
178   }
179
180   if (Reversed) {
181     if (ThrottleCmd < BetaRangeThrottleEnd) {
182         ThrottleCmd = 0.0;  // idle when in Beta-range
183     } else {
184       // when reversed:
185       ThrottleCmd = (ThrottleCmd-BetaRangeThrottleEnd)/(1-BetaRangeThrottleEnd) * ReverseMaxPower;
186     }
187   }
188
189   // When trimming is finished check if user wants engine OFF or RUNNING
190   if ((phase == tpTrim) && (dt > 0)) {
191     if (Running && !Starved) {
192       phase = tpRun;
193       N2 = IdleN2;
194       N1 = IdleN1;
195       OilTemp_degK = 366.0;
196       Cutoff = false;
197     } else {
198       phase = tpOff;
199       Cutoff = true;
200       Eng_ITT_degC = TAT;
201       Eng_Temperature = TAT;
202       OilTemp_degK = TAT+273.15;
203     }
204   }
205
206   if (!Running && Starter) {
207     if (phase == tpOff) {
208       phase = tpSpinUp;
209       if (StartTime < 0) StartTime=0;
210     }
211   }
212   if (!Running && !Cutoff && (N1 > 15.0)) {
213     phase = tpStart;
214     StartTime = -1;
215   }
216   if (Cutoff && (phase != tpSpinUp)) phase = tpOff;
217   if (dt == 0) phase = tpTrim;
218   if (Starved) phase = tpOff;
219   if (Condition >= 10) {
220     phase = tpOff;
221     StartTime=-1;
222   }
223
224   if (Condition < 1) {
225     if (Ielu_max_torque > 0
226       && -Ielu_max_torque > ((FGPropeller*)(Thruster))->GetTorque()
227       && ThrottleCmd >= OldThrottle ) {
228       ThrottleCmd = OldThrottle - 0.1 * dt; //IELU down
229       Ielu_intervent = true;
230     } else if (Ielu_max_torque > 0 && Ielu_intervent && ThrottleCmd >= OldThrottle) {
231       ThrottleCmd = OldThrottle;
232       ThrottleCmd = OldThrottle + 0.05 * dt; //IELU up
233       Ielu_intervent = true;
234     } else {
235       Ielu_intervent = false;
236     }
237   } else {
238     Ielu_intervent = false;
239   }
240   OldThrottle = ThrottleCmd;
241
242   switch (phase) {
243     case tpOff:    Eng_HP = Off(); break;
244     case tpRun:    Eng_HP = Run(); break;
245     case tpSpinUp: Eng_HP = SpinUp(); break;
246     case tpStart:  Eng_HP = Start(); break;
247     default: Eng_HP = 0;
248   }
249
250   //printf ("EngHP: %lf / Requi: %lf\n",Eng_HP,Prop_Required_Power);
251   PowerAvailable = (Eng_HP * hptoftlbssec) - Thruster->GetPowerRequired();
252
253   return Thruster->Calculate(PowerAvailable);
254
255 }
256
257 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
258
259 double FGTurboProp::Off(void)
260 {
261   double qbar = Auxiliary->Getqbar();
262   Running = false; EngStarting = false;
263
264   FuelFlow_pph = Seek(&FuelFlow_pph, 0, 800.0, 800.0);
265
266   //allow the air turn with generator
267   N1 = ExpSeek(&N1, qbar/15.0, Idle_Max_Delay*2.5, Idle_Max_Delay * 5);
268
269   OilTemp_degK = ExpSeek(&OilTemp_degK,273.15 + TAT, 400 , 400);
270
271   Eng_Temperature = ExpSeek(&Eng_Temperature,TAT,300,400);
272   double ITT_goal = ITT_N1->GetValue(N1,0.1) + ((N1>20) ? 0.0 : (20-N1)/20.0 * Eng_Temperature);
273   Eng_ITT_degC  = ExpSeek(&Eng_ITT_degC,ITT_goal,ITT_Delay,ITT_Delay*1.2);
274
275   OilPressure_psi = (N1/100.0*0.25+(0.1-(OilTemp_degK-273.15)*0.1/80.0)*N1/100.0) / 7692.0e-6; //from MPa to psi
276
277   ConsumeFuel(); // for possible setting Starved = false when fuel tank
278                  // is refilled (fuel crossfeed etc.)
279
280   if (Prop_RPM>5) return -0.012; // friction in engine when propeller spining (estimate)
281   return 0.0;
282 }
283
284 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
285
286 double FGTurboProp::Run(void)
287 {
288   double thrust = 0.0, EngPower_HP, eff_coef;
289   Running = true; Starter = false; EngStarting = false;
290
291 //---
292   double old_N1 = N1;
293   N1 = ExpSeek(&N1, IdleN1 + ThrottleCmd * N1_factor, Idle_Max_Delay, Idle_Max_Delay * 2.4);
294
295   EngPower_HP = EnginePowerRPM_N1->GetValue(Prop_RPM,N1);
296   EngPower_HP *= EnginePowerVC->GetValue();
297   if (EngPower_HP > MaxPower) EngPower_HP = MaxPower;
298
299   eff_coef = 9.333 - (N1)/12; // 430%Fuel at 60%N1
300   FuelFlow_pph = PSFC * EngPower_HP * eff_coef;
301
302   Eng_Temperature = ExpSeek(&Eng_Temperature,Eng_ITT_degC,300,400);
303   double ITT_goal = ITT_N1->GetValue((N1-old_N1)*300+N1,1);
304   Eng_ITT_degC  = ExpSeek(&Eng_ITT_degC,ITT_goal,ITT_Delay,ITT_Delay*1.2);
305
306   OilPressure_psi = (N1/100.0*0.25+(0.1-(OilTemp_degK-273.15)*0.1/80.0)*N1/100.0) / 7692.0e-6; //from MPa to psi
307 //---
308   EPR = 1.0 + thrust/MilThrust;
309
310   OilTemp_degK = Seek(&OilTemp_degK, 353.15, 0.4-N1*0.001, 0.04);
311
312   ConsumeFuel();
313
314   if (Cutoff) phase = tpOff;
315   if (Starved) phase = tpOff;
316
317   return EngPower_HP;
318 }
319
320 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
321
322 double FGTurboProp::SpinUp(void)
323 {
324   double EngPower_HP;
325   Running = false; EngStarting = true;
326   FuelFlow_pph = 0.0;
327
328   if (!GeneratorPower) {
329     EngStarting=false;
330     phase=tpOff;
331     StartTime = -1;
332     return 0.0;
333   }
334
335   N1 = ExpSeek(&N1, StarterN1, Idle_Max_Delay * 6, Idle_Max_Delay * 2.4);
336
337   Eng_Temperature = ExpSeek(&Eng_Temperature,TAT,300,400);
338   double ITT_goal = ITT_N1->GetValue(N1,0.1) + ((N1>20) ? 0.0 : (20-N1)/20.0 * Eng_Temperature);
339   Eng_ITT_degC  = ExpSeek(&Eng_ITT_degC,ITT_goal,ITT_Delay,ITT_Delay*1.2);
340
341   OilTemp_degK = ExpSeek(&OilTemp_degK,273.15 + TAT, 400 , 400);
342
343   OilPressure_psi = (N1/100.0*0.25+(0.1-(OilTemp_degK-273.15)*0.1/80.0)*N1/100.0) / 7692.0e-6; //from MPa to psi
344   NozzlePosition = 1.0;
345
346   EngPower_HP = EnginePowerRPM_N1->GetValue(Prop_RPM,N1);
347   EngPower_HP *= EnginePowerVC->GetValue();
348   if (EngPower_HP > MaxPower) EngPower_HP = MaxPower;
349
350   if (StartTime>=0) StartTime+=dt;
351   if (StartTime > MaxStartingTime && MaxStartingTime > 0) { //start failed due timeout
352     phase = tpOff;
353     StartTime = -1;
354   }
355
356   ConsumeFuel(); // for possible setting Starved = false when fuel tank
357                  // is refilled (fuel crossfeed etc.)
358
359   return EngPower_HP;
360 }
361
362 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
363
364 double FGTurboProp::Start(void)
365 {
366   double EngPower_HP,eff_coef;
367   EngStarting = false;
368   if ((N1 > 15.0) && !Starved) {       // minimum 15% N2 needed for start
369     double old_N1 = N1;
370     Cranking = true;                   // provided for sound effects signal
371     if (N1 < IdleN1) {
372       EngPower_HP = EnginePowerRPM_N1->GetValue(Prop_RPM,N1);
373       EngPower_HP *= EnginePowerVC->GetValue();
374       if (EngPower_HP > MaxPower) EngPower_HP = MaxPower;
375       N1 = ExpSeek(&N1, IdleN1*1.1, Idle_Max_Delay*4, Idle_Max_Delay * 2.4);
376       eff_coef = 9.333 - (N1)/12; // 430%Fuel at 60%N1
377       FuelFlow_pph = PSFC * EngPower_HP * eff_coef;
378       Eng_Temperature = ExpSeek(&Eng_Temperature,Eng_ITT_degC,300,400);
379       double ITT_goal = ITT_N1->GetValue((N1-old_N1)*300+N1,1);
380       Eng_ITT_degC  = ExpSeek(&Eng_ITT_degC,ITT_goal,ITT_Delay,ITT_Delay*1.2);
381
382       OilPressure_psi = (N1/100.0*0.25+(0.1-(OilTemp_degK-273.15)*0.1/80.0)*N1/100.0) / 7692.0e-6; //from MPa to psi
383       OilTemp_degK = Seek(&OilTemp_degK, 353.15, 0.4-N1*0.001, 0.04);
384
385     } else {
386       phase = tpRun;
387       Running = true;
388       Starter = false;
389       Cranking = false;
390       FuelFlow_pph = 0;
391       EngPower_HP=0.0;
392     }
393   } else {                 // no start if N2 < 15% or Starved
394     phase = tpOff;
395     Starter = false;
396   }
397
398   ConsumeFuel();
399
400   return EngPower_HP;
401 }
402
403
404 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
405
406 double FGTurboProp::CalcFuelNeed(void)
407 {
408   double dT = FDMExec->GetDeltaT() * Propulsion->GetRate();
409   FuelFlowRate = FuelFlow_pph / 3600.0;
410   FuelExpended = FuelFlowRate * dT;
411   return FuelExpended;
412 }
413
414 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
415
416 double FGTurboProp::Seek(double *var, double target, double accel, double decel)
417 {
418   double v = *var;
419   if (v > target) {
420     v -= dt * decel;
421     if (v < target) v = target;
422   } else if (v < target) {
423     v += dt * accel;
424     if (v > target) v = target;
425   }
426   return v;
427 }
428
429 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
430
431 double FGTurboProp::ExpSeek(double *var, double target, double accel_tau, double decel_tau)
432 {
433 // exponential delay instead of the linear delay used in Seek
434   double v = *var;
435   if (v > target) {
436     v = (v - target) * exp ( -dt / decel_tau) + target;
437   } else if (v < target) {
438     v = (target - v) * (1 - exp ( -dt / accel_tau)) + v;
439   }
440   return v;
441 }
442
443 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
444
445 void FGTurboProp::SetDefaults(void)
446 {
447 //  Name = "Not defined";
448   N1 = N2 = 0.0;
449   Type = etTurboprop;
450   MilThrust = 10000.0;
451   IdleN1 = 30.0;
452   IdleN2 = 60.0;
453   MaxN1 = 100.0;
454   MaxN2 = 100.0;
455   ThrottleCmd = 0.0;
456   InletPosition = 1.0;
457   NozzlePosition = 1.0;
458   Reversed = false;
459   Cutoff = true;
460   phase = tpOff;
461   Stalled = false;
462   Seized = false;
463   Overtemp = false;
464   Fire = false;
465   Eng_ITT_degC = 0.0;
466
467   GeneratorPower=true;
468   Condition = 0;
469   Ielu_intervent=false;
470
471   Idle_Max_Delay = 1.0;
472 }
473
474 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
475
476
477 string FGTurboProp::GetEngineLabels(const string& delimiter)
478 {
479   std::ostringstream buf;
480
481   buf << Name << "_N1[" << EngineNumber << "]" << delimiter
482       << Name << "_N2[" << EngineNumber << "]" << delimiter
483       << Name << "_PwrAvail[" << EngineNumber << "]" << delimiter
484       << Thruster->GetThrusterLabels(EngineNumber, delimiter);
485
486   return buf.str();
487 }
488
489 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
490
491 string FGTurboProp::GetEngineValues(const string& delimiter)
492 {
493   std::ostringstream buf;
494
495   buf << PowerAvailable << delimiter
496       << N1 << delimiter
497       << N2 << delimiter
498       << Thruster->GetThrusterValues(EngineNumber,delimiter);
499
500   return buf.str();
501 }
502
503 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
504
505 int FGTurboProp::InitRunning(void)
506 {
507   FDMExec->SuspendIntegration();
508   Cutoff=false;
509   Running=true;  
510   N2=16.0;
511   Calculate();
512   FDMExec->ResumeIntegration();
513   return phase==tpRun;
514 }
515
516 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
517
518 void FGTurboProp::bindmodel()
519 {
520   string property_name, base_property_name;
521   base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
522   property_name = base_property_name + "/n1";
523   PropertyManager->Tie( property_name.c_str(), &N1);
524   property_name = base_property_name + "/n2";
525   PropertyManager->Tie( property_name.c_str(), &N2);
526   property_name = base_property_name + "/reverser";
527   PropertyManager->Tie( property_name.c_str(), &Reversed);
528 }
529
530 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
531 //    The bitmasked value choices are as follows:
532 //    unset: In this case (the default) JSBSim would only print
533 //       out the normally expected messages, essentially echoing
534 //       the config files as they are read. If the environment
535 //       variable is not set, debug_lvl is set to 1 internally
536 //    0: This requests JSBSim not to output any messages
537 //       whatsoever.
538 //    1: This value explicity requests the normal JSBSim
539 //       startup messages
540 //    2: This value asks for a message to be printed out when
541 //       a class is instantiated
542 //    4: When this value is set, a message is displayed when a
543 //       FGModel object executes its Run() method
544 //    8: When this value is set, various runtime state variables
545 //       are printed out periodically
546 //    16: When set various parameters are sanity checked and
547 //       a message is printed out when they go out of bounds
548
549 void FGTurboProp::Debug(int from)
550 {
551   if (debug_lvl <= 0) return;
552
553   if (debug_lvl & 1) { // Standard console startup message output
554     if (from == 0) { // Constructor
555
556     }
557     if (from == 2) { // called from Load()
558       cout << "\n ****MUJ MOTOR TURBOPROP****\n";
559       cout << "\n    Engine Name: "         << Name << endl;
560       cout << "      MilThrust:   "         << MilThrust << endl;
561       cout << "      IdleN1:      "         << IdleN1 << endl;
562       cout << "      MaxN1:       "         << MaxN1 << endl;
563
564       cout << endl;
565     }
566   }
567   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
568     if (from == 0) cout << "Instantiated: FGTurboProp" << endl;
569     if (from == 1) cout << "Destroyed:    FGTurboProp" << endl;
570   }
571   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
572   }
573   if (debug_lvl & 8 ) { // Runtime state variables
574   }
575   if (debug_lvl & 16) { // Sanity checking
576   }
577   if (debug_lvl & 64) {
578     if (from == 0) { // Constructor
579       cout << IdSrc << endl;
580       cout << IdHdr << endl;
581     }
582   }
583 }
584 }