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