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