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