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