]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/propulsion/FGTurbine.cpp
d751654a03e7ba68a4f231e78bdc853321878456
[flightgear.git] / src / FDM / JSBSim / models / propulsion / FGTurbine.cpp
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Module:       FGTurbine.cpp
4  Author:       David Culp
5  Date started: 03/11/2003
6  Purpose:      This module models a turbine engine.
7
8  ------------- Copyright (C) 2003  David Culp (davidculp2@comcast.net) ---------
9
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
13  version.
14
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
18  details.
19
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.
23
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.
26
27 FUNCTIONAL DESCRIPTION
28 --------------------------------------------------------------------------------
29
30 This class descends from the FGEngine class and models a turbine engine based
31 on parameters given in the engine config file for this class
32
33 HISTORY
34 --------------------------------------------------------------------------------
35 03/11/2003  DPC  Created
36 09/08/2003  DPC  Changed Calculate() and added engine phases
37
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 INCLUDES
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
41
42 #include <vector>
43 #include <sstream>
44
45 #include "FGTurbine.h"
46
47 namespace JSBSim {
48
49 static const char *IdSrc = "$Id$";
50 static const char *IdHdr = ID_TURBINE;
51
52 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 CLASS IMPLEMENTATION
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55
56
57 FGTurbine::FGTurbine(FGFDMExec* exec, Element *el, int engine_number)
58   : FGEngine(exec, el, engine_number)
59 {
60   Type = etTurbine;
61
62   MilThrust = MaxThrust = 10000.0;
63   TSFC = 0.8;
64   ATSFC = 1.7;
65   IdleN1 = 30.0;
66   IdleN2 = 60.0;
67   MaxN1 = MaxN2 = 100.0;
68   Augmented = AugMethod = Injected = 0;
69   BypassRatio = BleedDemand = 0.0;
70   IdleThrustLookup = MilThrustLookup = MaxThrustLookup = InjectionLookup = 0;
71   N1_spinup = 1.0; N2_spinup = 3.0; 
72
73   ResetToIC();
74
75   Load(exec, el);
76   Debug(0);
77 }
78
79 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80
81 FGTurbine::~FGTurbine()
82 {
83   delete IdleThrustLookup;
84   delete MilThrustLookup;
85   delete MaxThrustLookup;
86   delete InjectionLookup;
87   Debug(1);
88 }
89
90 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91
92 void FGTurbine::ResetToIC(void)
93 {
94   N1 = N2 = 0.0;
95   correctedTSFC = TSFC;
96   ThrottlePos = AugmentCmd = 0.0;
97   InletPosition = NozzlePosition = 1.0;
98   Stalled = Seized = Overtemp = Fire = Augmentation = Injection = Reversed = false;
99   Cutoff = true;
100   phase = tpOff;
101   EGT_degC = 0.0;
102   OilTemp_degK = (Auxiliary->GetTotalTemperature() - 491.69) * 0.5555556 + 273.0;
103 }
104
105 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
106 // The main purpose of Calculate() is to determine what phase the engine should
107 // be in, then call the corresponding function.
108
109 double FGTurbine::Calculate(void)
110 {
111   double thrust;
112
113   TAT = (Auxiliary->GetTotalTemperature() - 491.69) * 0.5555556;
114   dt = State->Getdt() * Propulsion->GetRate();
115   ThrottlePos = FCS->GetThrottlePos(EngineNumber);
116   if (ThrottlePos > 1.0) {
117     AugmentCmd = ThrottlePos - 1.0;
118     ThrottlePos -= AugmentCmd;
119   } else {
120     AugmentCmd = 0.0;
121   }
122
123   // When trimming is finished check if user wants engine OFF or RUNNING
124   if ((phase == tpTrim) && (dt > 0)) {
125     if (Running && !Starved) {
126       phase = tpRun;
127       N2 = IdleN2 + ThrottlePos * N2_factor;
128       N1 = IdleN1 + ThrottlePos * N1_factor;
129       OilTemp_degK = 366.0;
130       Cutoff = false;
131       }
132     else {
133       phase = tpOff;
134       Cutoff = true;
135       EGT_degC = TAT;
136       }
137     }
138
139   if (!Running && Cutoff && Starter) {
140      if (phase == tpOff) phase = tpSpinUp;
141      }
142   if (!Running && !Cutoff && (N2 > 15.0)) phase = tpStart;
143   if (Cutoff && (phase != tpSpinUp)) phase = tpOff;
144   if (dt == 0) phase = tpTrim;
145   if (Starved) phase = tpOff;
146   if (Stalled) phase = tpStall;
147   if (Seized) phase = tpSeize;
148
149   switch (phase) {
150     case tpOff:    thrust = Off(); break;
151     case tpRun:    thrust = Run(); break;
152     case tpSpinUp: thrust = SpinUp(); break;
153     case tpStart:  thrust = Start(); break;
154     case tpStall:  thrust = Stall(); break;
155     case tpSeize:  thrust = Seize(); break;
156     case tpTrim:   thrust = Trim(); break;
157     default: thrust = Off();
158   }
159
160   thrust = Thruster->Calculate(thrust); // allow thruster to modify thrust (i.e. reversing)
161
162   return thrust;
163 }
164
165 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
166
167 double FGTurbine::Off(void)
168 {
169   double qbar = Auxiliary->Getqbar();
170   Running = false;
171   FuelFlow_pph = Seek(&FuelFlow_pph, 0, 1000.0, 10000.0);
172   N1 = Seek(&N1, qbar/10.0, N1/2.0, N1/2.0);
173   N2 = Seek(&N2, qbar/15.0, N2/2.0, N2/2.0);
174   EGT_degC = Seek(&EGT_degC, TAT, 11.7, 7.3);
175   OilTemp_degK = Seek(&OilTemp_degK, TAT + 273.0, 0.2, 0.2);
176   OilPressure_psi = N2 * 0.62;
177   NozzlePosition = Seek(&NozzlePosition, 1.0, 0.8, 0.8);
178   EPR = Seek(&EPR, 1.0, 0.2, 0.2);
179   Augmentation = false;
180   ConsumeFuel();  
181   return 0.0;
182 }
183
184 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
185
186 double FGTurbine::Run()
187 {
188   double idlethrust, milthrust, thrust;
189   double N2norm;   // 0.0 = idle N2, 1.0 = maximum N2
190
191   idlethrust = MilThrust * IdleThrustLookup->GetValue();
192   milthrust = (MilThrust - idlethrust) * MilThrustLookup->GetValue();
193
194   Running = true;
195   Starter = false;
196
197   N2 = Seek(&N2, IdleN2 + ThrottlePos * N2_factor, delay, delay * 3.0);
198   N1 = Seek(&N1, IdleN1 + ThrottlePos * N1_factor, delay, delay * 2.4);
199   N2norm = (N2 - IdleN2) / N2_factor;
200   thrust = idlethrust + (milthrust * N2norm * N2norm);
201   EGT_degC = TAT + 363.1 + ThrottlePos * 357.1;
202   OilPressure_psi = N2 * 0.62;
203   OilTemp_degK = Seek(&OilTemp_degK, 366.0, 1.2, 0.1);
204
205   if (!Augmentation) {
206     correctedTSFC = TSFC * (0.84 + (1-N2norm)*(1-N2norm));
207     FuelFlow_pph = Seek(&FuelFlow_pph, thrust * correctedTSFC, 1000.0, 100000);
208     if (FuelFlow_pph < IdleFF) FuelFlow_pph = IdleFF;
209     NozzlePosition = Seek(&NozzlePosition, 1.0 - N2norm, 0.8, 0.8);
210     thrust = thrust * (1.0 - BleedDemand);
211     EPR = 1.0 + thrust/MilThrust;
212   }
213
214   if (AugMethod == 1) {
215     if ((ThrottlePos > 0.99) && (N2 > 97.0)) {Augmentation = true;}
216     else {Augmentation = false;}
217   }
218
219   if ((Augmented == 1) && Augmentation && (AugMethod < 2)) {
220     thrust = MaxThrustLookup->GetValue() * MaxThrust;
221     FuelFlow_pph = Seek(&FuelFlow_pph, thrust * ATSFC, 5000.0, 10000.0);
222     NozzlePosition = Seek(&NozzlePosition, 1.0, 0.8, 0.8);
223   }
224
225   if (AugMethod == 2) {
226     if (AugmentCmd > 0.0) {
227       Augmentation = true;
228       double tdiff = (MaxThrust * MaxThrustLookup->GetValue()) - thrust;
229       thrust += (tdiff * AugmentCmd);
230       FuelFlow_pph = Seek(&FuelFlow_pph, thrust * ATSFC, 5000.0, 10000.0);
231       NozzlePosition = Seek(&NozzlePosition, 1.0, 0.8, 0.8);
232     } else {
233       Augmentation = false;
234     }
235   }
236
237   if ((Injected == 1) && Injection) {
238     InjectionTimer += dt;
239     if (InjectionTimer < InjectionTime) {
240        thrust = thrust * InjectionLookup->GetValue();
241     } else {
242        Injection = false;
243     }
244   }
245
246   ConsumeFuel();
247   if (Cutoff) phase = tpOff;
248   if (Starved) phase = tpOff;
249
250   return thrust;
251 }
252
253 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
254
255 double FGTurbine::SpinUp(void)
256 {
257   Running = false;
258   FuelFlow_pph = 0.0;
259   N2 = Seek(&N2, 25.18, N2_spinup, N2/2.0);
260   N1 = Seek(&N1, 5.21, N1_spinup, N1/2.0);
261   EGT_degC = Seek(&EGT_degC, TAT, 11.7, 7.3);
262   OilPressure_psi = N2 * 0.62;
263   OilTemp_degK = Seek(&OilTemp_degK, TAT + 273.0, 0.2, 0.2);
264   EPR = 1.0;
265   NozzlePosition = 1.0;
266   return 0.0;
267 }
268
269 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
270
271 double FGTurbine::Start(void)
272 {
273   if ((N2 > 15.0) && !Starved) {       // minimum 15% N2 needed for start
274     Cranking = true;                   // provided for sound effects signal
275     if (N2 < IdleN2) {
276       N2 = Seek(&N2, IdleN2, 2.0, N2/2.0);
277       N1 = Seek(&N1, IdleN1, 1.4, N1/2.0);
278       EGT_degC = Seek(&EGT_degC, TAT + 363.1, 21.3, 7.3);
279       FuelFlow_pph = Seek(&FuelFlow_pph, IdleFF, 103.7, 103.7);
280       OilPressure_psi = N2 * 0.62;
281       ConsumeFuel();
282       }
283     else {
284       phase = tpRun;
285       Running = true;
286       Starter = false;
287       Cranking = false;
288       }
289     }
290   else {                 // no start if N2 < 15%
291     phase = tpOff;
292     Starter = false;
293     }
294
295   return 0.0;
296 }
297
298 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
299
300 double FGTurbine::Stall(void)
301 {
302   double qbar = Auxiliary->Getqbar();
303   EGT_degC = TAT + 903.14;
304   FuelFlow_pph = IdleFF;
305   N1 = Seek(&N1, qbar/10.0, 0, N1/10.0);
306   N2 = Seek(&N2, qbar/15.0, 0, N2/10.0);
307   ConsumeFuel();
308   if (ThrottlePos < 0.01) phase = tpRun;        // clear the stall with throttle
309
310   return 0.0;
311 }
312
313 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
314
315 double FGTurbine::Seize(void)
316 {
317     double qbar = Auxiliary->Getqbar();
318     N2 = 0.0;
319     N1 = Seek(&N1, qbar/20.0, 0, N1/15.0);
320     FuelFlow_pph = IdleFF;
321     ConsumeFuel();
322     OilPressure_psi = 0.0;
323     OilTemp_degK = Seek(&OilTemp_degK, TAT + 273.0, 0, 0.2);
324     Running = false;
325     return 0.0;
326 }
327
328 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
329
330 double FGTurbine::Trim()
331 {
332     double idlethrust, milthrust, thrust, tdiff, N2norm;
333     idlethrust = MilThrust * IdleThrustLookup->GetValue();
334     milthrust = (MilThrust - idlethrust) * MilThrustLookup->GetValue();
335     N2 = IdleN2 + ThrottlePos * N2_factor;
336     N2norm = (N2 - IdleN2) / N2_factor;
337     thrust = (idlethrust + (milthrust * N2norm * N2norm))
338           * (1.0 - BleedDemand);
339
340     if (AugMethod == 1) {
341       if ((ThrottlePos > 0.99) && (N2 > 97.0)) {Augmentation = true;}
342       else {Augmentation = false;}
343     }
344
345     if ((Augmented == 1) && Augmentation && (AugMethod < 2)) {
346       thrust = MaxThrust * MaxThrustLookup->GetValue();
347     }
348
349     if (AugMethod == 2) {
350       if (AugmentCmd > 0.0) {
351         tdiff = (MaxThrust * MaxThrustLookup->GetValue()) - thrust;
352         thrust += (tdiff * AugmentCmd);
353       }
354     }
355
356     if ((Injected == 1) && Injection) {
357       thrust = thrust * InjectionLookup->GetValue();
358     }
359
360     return thrust;
361 }
362
363 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
364
365 double FGTurbine::CalcFuelNeed(void)
366 {
367   double dT = State->Getdt() * Propulsion->GetRate();
368   FuelFlowRate = FuelFlow_pph / 3600.0; // Calculates flow in lbs/sec from lbs/hr
369   FuelExpended = FuelFlowRate * dT;     // Calculates fuel expended in this time step
370   return FuelExpended;
371 }
372
373 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
374
375 double FGTurbine::GetPowerAvailable(void) {
376   if( ThrottlePos <= 0.77 )
377     return 64.94*ThrottlePos;
378   else
379     return 217.38*ThrottlePos - 117.38;
380 }
381
382 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
383
384 double FGTurbine::Seek(double *var, double target, double accel, double decel) {
385   double v = *var;
386   if (v > target) {
387     v -= dt * decel;
388     if (v < target) v = target;
389   } else if (v < target) {
390     v += dt * accel;
391     if (v > target) v = target;
392   }
393   return v;
394 }
395
396 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
397
398 bool FGTurbine::Load(FGFDMExec* exec, Element *el)
399 {
400   string property_name, property_prefix;
401   property_prefix = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
402
403   if (el->FindElement("milthrust"))
404     MilThrust = el->FindElementValueAsNumberConvertTo("milthrust","LBS");
405   if (el->FindElement("maxthrust"))
406     MaxThrust = el->FindElementValueAsNumberConvertTo("maxthrust","LBS");
407   if (el->FindElement("bypassratio"))
408     BypassRatio = el->FindElementValueAsNumber("bypassratio");
409   if (el->FindElement("bleed"))
410     BleedDemand = el->FindElementValueAsNumber("bleed");
411   if (el->FindElement("tsfc"))
412     TSFC = el->FindElementValueAsNumber("tsfc");
413   if (el->FindElement("atsfc"))
414     ATSFC = el->FindElementValueAsNumber("atsfc");
415   if (el->FindElement("idlen1"))
416     IdleN1 = el->FindElementValueAsNumber("idlen1");
417   if (el->FindElement("idlen2"))
418     IdleN2 = el->FindElementValueAsNumber("idlen2");
419   if (el->FindElement("maxn1"))
420     MaxN1 = el->FindElementValueAsNumber("maxn1");
421   if (el->FindElement("maxn2"))
422     MaxN2 = el->FindElementValueAsNumber("maxn2");
423   if (el->FindElement("n1spinup"))
424     N1_spinup = el->FindElementValueAsNumber("n1spinup");
425   if (el->FindElement("n2spinup"))
426     N2_spinup = el->FindElementValueAsNumber("n2spinup");
427   if (el->FindElement("augmented"))
428     Augmented = (int)el->FindElementValueAsNumber("augmented");
429   if (el->FindElement("augmethod"))
430     AugMethod = (int)el->FindElementValueAsNumber("augmethod");
431   if (el->FindElement("injected"))
432     Injected = (int)el->FindElementValueAsNumber("injected");
433   if (el->FindElement("injection-time"))
434     InjectionTime = el->FindElementValueAsNumber("injection-time");
435
436   Element *function_element;
437   string name;
438   FGPropertyManager* PropertyManager = exec->GetPropertyManager();
439
440   while (true) {
441     function_element = el->FindNextElement("function");
442     if (!function_element) break;
443     name = function_element->GetAttributeValue("name");
444     if (name == "IdleThrust") {
445       IdleThrustLookup = new FGFunction(PropertyManager, function_element, property_prefix);
446     } else if (name == "MilThrust") {
447       MilThrustLookup = new FGFunction(PropertyManager, function_element, property_prefix);
448     } else if (name == "AugThrust") {
449       MaxThrustLookup = new FGFunction(PropertyManager, function_element, property_prefix);
450     } else if (name == "Injection") {
451       InjectionLookup = new FGFunction(PropertyManager, function_element, property_prefix);
452     } else {
453       cerr << "Unknown function type: " << name << " in turbine definition." <<
454       endl;
455     }
456   }
457
458   // Pre-calculations and initializations
459
460   delay = 60.0 / (BypassRatio + 3.0);
461   N1_factor = MaxN1 - IdleN1;
462   N2_factor = MaxN2 - IdleN2;
463   OilTemp_degK = (Auxiliary->GetTotalTemperature() - 491.69) * 0.5555556 + 273.0;
464   IdleFF = pow(MilThrust, 0.2) * 107.0;  // just an estimate
465
466   bindmodel();
467   return true;
468 }
469
470 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
471
472 string FGTurbine::GetEngineLabels(string delimeter)
473 {
474   std::ostringstream buf;
475
476   buf << Name << "_N1[" << EngineNumber << "]" << delimeter
477       << Name << "_N2[" << EngineNumber << "]" << delimeter
478       << Thruster->GetThrusterLabels(EngineNumber, delimeter);
479
480   return buf.str();
481 }
482
483 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
484
485 string FGTurbine::GetEngineValues(string delimeter)
486 {
487   std::ostringstream buf;
488
489   buf << N1 << delimeter
490       << N2 << delimeter
491       << Thruster->GetThrusterValues(EngineNumber, delimeter);
492
493   return buf.str();
494 }
495
496 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
497
498 void FGTurbine::bindmodel()
499 {
500   string property_name, base_property_name;
501   base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
502   property_name = base_property_name + "/n1";
503   PropertyManager->Tie( property_name.c_str(), &N1);
504   property_name = base_property_name + "/n2";
505   PropertyManager->Tie( property_name.c_str(), &N2);
506   property_name = base_property_name + "/injection_cmd";
507   PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this, 
508                         &FGTurbine::GetInjection, &FGTurbine::SetInjection);
509 }
510
511 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
512
513 int FGTurbine::InitRunning(void) {
514   State->SuspendIntegration();
515   Cutoff=false;
516   Running=true;  
517   N2=16.0;
518   Calculate();
519   State->ResumeIntegration();
520   return phase==tpRun;
521 }
522
523 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
524 //    The bitmasked value choices are as follows:
525 //    unset: In this case (the default) JSBSim would only print
526 //       out the normally expected messages, essentially echoing
527 //       the config files as they are read. If the environment
528 //       variable is not set, debug_lvl is set to 1 internally
529 //    0: This requests JSBSim not to output any messages
530 //       whatsoever.
531 //    1: This value explicity requests the normal JSBSim
532 //       startup messages
533 //    2: This value asks for a message to be printed out when
534 //       a class is instantiated
535 //    4: When this value is set, a message is displayed when a
536 //       FGModel object executes its Run() method
537 //    8: When this value is set, various runtime state variables
538 //       are printed out periodically
539 //    16: When set various parameters are sanity checked and
540 //       a message is printed out when they go out of bounds
541
542 void FGTurbine::Debug(int from)
543 {
544   if (debug_lvl <= 0) return;
545
546   if (debug_lvl & 1) { // Standard console startup message output
547     if (from == 0) { // Constructor
548
549     }
550     if (from == 2) { // called from Load()
551       cout << "\n    Engine Name: "         << Name << endl;
552       cout << "      MilThrust:   "         << MilThrust << endl;
553       cout << "      MaxThrust:   "         << MaxThrust << endl;
554       cout << "      BypassRatio: "         << BypassRatio << endl;
555       cout << "      TSFC:        "         << TSFC << endl;
556       cout << "      ATSFC:       "         << ATSFC << endl;
557       cout << "      IdleN1:      "         << IdleN1 << endl;
558       cout << "      IdleN2:      "         << IdleN2 << endl;
559       cout << "      MaxN1:       "         << MaxN1 << endl;
560       cout << "      MaxN2:       "         << MaxN2 << endl;
561       cout << "      Augmented:   "         << Augmented << endl;
562       cout << "      AugMethod:   "         << AugMethod << endl;
563       cout << "      Injected:    "         << Injected << endl;
564       cout << "      MinThrottle: "         << MinThrottle << endl;
565
566       cout << endl;
567     }
568   }
569   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
570     if (from == 0) cout << "Instantiated: FGTurbine" << endl;
571     if (from == 1) cout << "Destroyed:    FGTurbine" << endl;
572   }
573   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
574   }
575   if (debug_lvl & 8 ) { // Runtime state variables
576   }
577   if (debug_lvl & 16) { // Sanity checking
578   }
579   if (debug_lvl & 64) {
580     if (from == 0) { // Constructor
581       cout << IdSrc << endl;
582       cout << IdHdr << endl;
583     }
584   }
585 }
586 }