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