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