JSBSim Flight Dynamics Model  1.0 (02 March 2017)
An Open Source Flight Dynamics and Control Software Library in C++
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 (daveculp@cox.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 "math/FGFunction.h"
46 #include "FGTurbine.h"
47 #include "FGThruster.h"
48 #include "input_output/FGXMLElement.h"
49 
50 using namespace std;
51 
52 namespace JSBSim {
53 
54 IDENT(IdSrc,"$Id: FGTurbine.cpp,v 1.48 2015/12/02 04:25:23 dpculp Exp $");
55 IDENT(IdHdr,ID_TURBINE);
56 
57 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 CLASS IMPLEMENTATION
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
60 
61 
62 FGTurbine::FGTurbine(FGFDMExec* exec, Element *el, int engine_number, struct Inputs& input)
63  : FGEngine(engine_number, input), FDMExec(exec)
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  InjectionTime = 30.0;
78  InjectionTimer = InjWaterNorm = 0.0;
79  EPR = 1.0;
80 
81  Load(exec, el);
82  Debug(0);
83 }
84 
85 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86 
88 {
89  Debug(1);
90 }
91 
92 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93 
95 {
96 
98 
99  N1 = N2 = InjN1increment = InjN2increment = 0.0;
100  N2norm = 0.0;
101  correctedTSFC = TSFC;
102  AugmentCmd = InjWaterNorm = 0.0;
103  InletPosition = NozzlePosition = 1.0;
104  Stalled = Seized = Overtemp = Fire = Augmentation = Injection = Reversed = false;
105  Cutoff = true;
106  phase = tpOff;
107  EGT_degC = in.TAT_c;
108  OilTemp_degK = in.TAT_c + 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 
116 {
117  double thrust;
118 
119  RunPreFunctions();
120 
121  ThrottlePos = in.ThrottlePos[EngineNumber];
122 
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) && (in.TotalDeltaT > 0)) {
132  if (Running && !Starved) {
133  phase = tpRun;
134  N1_factor = MaxN1 - IdleN1;
135  N2_factor = MaxN2 - IdleN2;
136  N2 = IdleN2 + ThrottlePos * N2_factor;
137  N1 = IdleN1 + ThrottlePos * N1_factor;
138  OilTemp_degK = 366.0;
139  Cutoff = false;
140  } else {
141  phase = tpOff;
142  Cutoff = true;
143  EGT_degC = in.TAT_c;
144  }
145  }
146 
147  if (!Running && Cutoff && Starter) {
148  if (phase == tpOff) phase = tpSpinUp;
149  }
150 
151  // start
152  if ((Starter == true) || (in.qbar > 30.0)) {
153  if (!Running && !Cutoff && (N2 > 15.0)) phase = tpStart;
154  }
155 
156  if (Cutoff && (phase != tpSpinUp)) phase = tpOff;
157  if (in.TotalDeltaT == 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  Thruster->Calculate(thrust); // allow thruster to modify thrust (i.e. reversing)
174 
175  RunPostFunctions();
176 }
177 
178 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179 
180 double FGTurbine::Off(void)
181 {
182  Running = false;
183  FuelFlow_pph = Seek(&FuelFlow_pph, 0, 1000.0, 10000.0);
184  N1 = Seek(&N1, in.qbar/10.0, N1/2.0, N1/2.0);
185  N2 = Seek(&N2, in.qbar/15.0, N2/2.0, N2/2.0);
186  EGT_degC = Seek(&EGT_degC, in.TAT_c, 11.7, 7.3);
187  OilTemp_degK = Seek(&OilTemp_degK, in.TAT_c + 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  return 0.0;
193 }
194 
195 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
196 
197 double FGTurbine::Run()
198 {
199  double idlethrust, milthrust, thrust;
200  double spoolup; // acceleration in pct/sec
201  double sigma = in.DensityRatio;
202  double T = in.Temperature;
203 
204  idlethrust = MilThrust * IdleThrustLookup->GetValue();
205  milthrust = (MilThrust - idlethrust) * MilThrustLookup->GetValue();
206 
207  Running = true;
208  Starter = false;
209 
210  // adjust acceleration for N2 and atmospheric density
211  double n = N2norm + 0.1;
212  if (n > 1) n = 1;
213  spoolup = delay / (1 + 3 * (1-n)*(1-n)*(1-n) + (1 - sigma));
214  N1_factor = MaxN1 - IdleN1;
215  N2_factor = MaxN2 - IdleN2;
216  if ((Injected == 1) && Injection && (InjWaterNorm > 0)) {
217  N1_factor += InjN1increment;
218  N2_factor += InjN2increment;
219  }
220  N2 = Seek(&N2, IdleN2 + ThrottlePos * N2_factor, spoolup, spoolup * 3.0);
221  N1 = Seek(&N1, IdleN1 + ThrottlePos * N1_factor, spoolup, spoolup * 2.4);
222  N2norm = (N2 - IdleN2) / N2_factor;
223  thrust = idlethrust + (milthrust * N2norm * N2norm);
224  EGT_degC = in.TAT_c + 363.1 + ThrottlePos * 357.1;
225  OilPressure_psi = N2 * 0.62;
226  OilTemp_degK = Seek(&OilTemp_degK, 366.0, 1.2, 0.1);
227 
228  if (!Augmentation) {
229  correctedTSFC = TSFC * sqrt(T/389.7) * (0.84 + (1-N2norm)*(1-N2norm));
230  FuelFlow_pph = Seek(&FuelFlow_pph, thrust * correctedTSFC, 1000.0, 10000.0);
231  if (FuelFlow_pph < IdleFF) FuelFlow_pph = IdleFF;
232  NozzlePosition = Seek(&NozzlePosition, 1.0 - N2norm, 0.8, 0.8);
233  thrust = thrust * (1.0 - BleedDemand);
234  EPR = 1.0 + thrust/MilThrust;
235  }
236 
237  if (AugMethod == 1) {
238  if ((ThrottlePos > 0.99) && (N2 > 97.0)) {Augmentation = true;}
239  else {Augmentation = false;}
240  }
241 
242  if ((Augmented == 1) && Augmentation && (AugMethod < 2)) {
243  thrust = MaxThrustLookup->GetValue() * MaxThrust;
244  FuelFlow_pph = Seek(&FuelFlow_pph, thrust * ATSFC, 5000.0, 10000.0);
245  NozzlePosition = Seek(&NozzlePosition, 1.0, 0.8, 0.8);
246  }
247 
248  if (AugMethod == 2) {
249  if (AugmentCmd > 0.0) {
250  Augmentation = true;
251  double tdiff = (MaxThrust * MaxThrustLookup->GetValue()) - thrust;
252  thrust += (tdiff * AugmentCmd);
253  FuelFlow_pph = Seek(&FuelFlow_pph, thrust * ATSFC, 5000.0, 10000.0);
254  NozzlePosition = Seek(&NozzlePosition, 1.0, 0.8, 0.8);
255  } else {
256  Augmentation = false;
257  }
258  }
259 
260  if ((Injected == 1) && Injection && (InjWaterNorm > 0.0)) {
261  InjectionTimer += in.TotalDeltaT;
262  if (InjectionTimer < InjectionTime) {
263  thrust = thrust * InjectionLookup->GetValue();
264  InjWaterNorm = 1.0 - (InjectionTimer/InjectionTime);
265  } else {
266  Injection = false;
267  InjWaterNorm = 0.0;
268  }
269  }
270 
271  if (Cutoff) phase = tpOff;
272  if (Starved) phase = tpOff;
273 
274  return thrust;
275 }
276 
277 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
278 
279 double FGTurbine::SpinUp(void)
280 {
281  Running = false;
282  FuelFlow_pph = 0.0;
283  N2 = Seek(&N2, 25.18, N2_spinup, N2/2.0);
284  N1 = Seek(&N1, 5.21, N1_spinup, N1/2.0);
285  EGT_degC = Seek(&EGT_degC, in.TAT_c, 11.7, 7.3);
286  OilPressure_psi = N2 * 0.62;
287  OilTemp_degK = Seek(&OilTemp_degK, in.TAT_c + 273.0, 0.2, 0.2);
288  EPR = 1.0;
289  NozzlePosition = 1.0;
290  if (Starter == false) phase = tpOff;
291  return 0.0;
292 }
293 
294 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
295 
296 double FGTurbine::Start(void)
297 {
298  if ((N2 > 15.0) && !Starved) { // minimum 15% N2 needed for start
299  Cranking = true; // provided for sound effects signal
300  if (N2 < IdleN2) {
301  N2 = Seek(&N2, IdleN2, 2.0, N2/2.0);
302  N1 = Seek(&N1, IdleN1, 1.4, N1/2.0);
303  EGT_degC = Seek(&EGT_degC, in.TAT_c + 363.1, 21.3, 7.3);
304  FuelFlow_pph = IdleFF * N2 / IdleN2;
305  OilPressure_psi = N2 * 0.62;
306  if ((Starter == false) && (in.qbar < 30.0)) phase = tpOff; // aborted start
307  }
308  else {
309  phase = tpRun;
310  Running = true;
311  Starter = false;
312  Cranking = false;
313  }
314  }
315  else { // no start if N2 < 15%
316  phase = tpOff;
317  Starter = false;
318  }
319 
320  return 0.0;
321 }
322 
323 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
324 
325 double FGTurbine::Stall(void)
326 {
327  EGT_degC = in.TAT_c + 903.14;
328  FuelFlow_pph = IdleFF;
329  N1 = Seek(&N1, in.qbar/10.0, 0, N1/10.0);
330  N2 = Seek(&N2, in.qbar/15.0, 0, N2/10.0);
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  N2 = 0.0;
343  N1 = Seek(&N1, in.qbar/20.0, 0, N1/15.0);
344  FuelFlow_pph = Cutoff ? 0.0 : IdleFF;
345  OilPressure_psi = 0.0;
346  OilTemp_degK = Seek(&OilTemp_degK, in.TAT_c + 273.0, 0, 0.2);
347  Running = false;
348  return 0.0;
349 }
350 
351 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
352 
353 double FGTurbine::Trim()
354 {
355  double idlethrust = MilThrust * IdleThrustLookup->GetValue();
356  double milthrust = (MilThrust - idlethrust) * MilThrustLookup->GetValue();
357  double N2 = IdleN2 + ThrottlePos * N2_factor;
358  double N2norm = (N2 - IdleN2) / N2_factor;
359  double thrust = (idlethrust + (milthrust * N2norm * N2norm))
360  * (1.0 - BleedDemand);
361 
362  if (AugMethod == 1) {
363  if ((ThrottlePos > 0.99) && (N2 > 97.0)) {Augmentation = true;}
364  else {Augmentation = false;}
365  }
366 
367  if ((Augmented == 1) && Augmentation && (AugMethod < 2)) {
368  thrust = MaxThrust * MaxThrustLookup->GetValue();
369  }
370 
371  if (AugMethod == 2) {
372  if (AugmentCmd > 0.0) {
373  double tdiff = (MaxThrust * MaxThrustLookup->GetValue()) - thrust;
374  thrust += (tdiff * AugmentCmd);
375  }
376  }
377 
378  if ((Injected == 1) && Injection) {
379  thrust = thrust * InjectionLookup->GetValue();
380  }
381 
382  return thrust;
383 }
384 
385 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
386 
388 {
389  FuelFlowRate = FuelFlow_pph / 3600.0; // Calculates flow in lbs/sec from lbs/hr
390  FuelExpended = FuelFlowRate * in.TotalDeltaT; // Calculates fuel expended in this time step
391  if (!Starved) FuelUsedLbs += FuelExpended;
392  return FuelExpended;
393 }
394 
395 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
396 
397 double FGTurbine::GetPowerAvailable(void) {
398  if( ThrottlePos <= 0.77 )
399  return 64.94*ThrottlePos;
400  else
401  return 217.38*ThrottlePos - 117.38;
402 }
403 
404 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
405 
406 double FGTurbine::Seek(double *var, double target, double accel, double decel) {
407  double v = *var;
408  if (v > target) {
409  v -= in.TotalDeltaT * decel;
410  if (v < target) v = target;
411  } else if (v < target) {
412  v += in.TotalDeltaT * accel;
413  if (v > target) v = target;
414  }
415  return v;
416 }
417 
418 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
419 
420 bool FGTurbine::Load(FGFDMExec* exec, Element *el)
421 {
422  Element* function_element = el->FindElement("function");
423 
424  while(function_element) {
425  string name = function_element->GetAttributeValue("name");
426  if (name == "IdleThrust" || name == "MilThrust" || name == "AugThrust" || name == "Injection")
427  function_element->SetAttributeValue("name", string("propulsion/engine[#]/") + name);
428 
429  function_element = el->FindNextElement("function");
430  }
431 
432  FGEngine::Load(exec, el);
433 
434  ResetToIC();
435 
436  if (el->FindElement("milthrust"))
437  MilThrust = el->FindElementValueAsNumberConvertTo("milthrust","LBS");
438  if (el->FindElement("maxthrust"))
439  MaxThrust = el->FindElementValueAsNumberConvertTo("maxthrust","LBS");
440  if (el->FindElement("bypassratio"))
441  BypassRatio = el->FindElementValueAsNumber("bypassratio");
442  if (el->FindElement("bleed"))
443  BleedDemand = el->FindElementValueAsNumber("bleed");
444  if (el->FindElement("tsfc"))
445  TSFC = el->FindElementValueAsNumber("tsfc");
446  if (el->FindElement("atsfc"))
447  ATSFC = el->FindElementValueAsNumber("atsfc");
448  if (el->FindElement("idlen1"))
449  IdleN1 = el->FindElementValueAsNumber("idlen1");
450  if (el->FindElement("idlen2"))
451  IdleN2 = el->FindElementValueAsNumber("idlen2");
452  if (el->FindElement("maxn1"))
453  MaxN1 = el->FindElementValueAsNumber("maxn1");
454  if (el->FindElement("maxn2"))
455  MaxN2 = el->FindElementValueAsNumber("maxn2");
456  if (el->FindElement("n1spinup"))
457  N1_spinup = el->FindElementValueAsNumber("n1spinup");
458  if (el->FindElement("n2spinup"))
459  N2_spinup = el->FindElementValueAsNumber("n2spinup");
460  if (el->FindElement("augmented"))
461  Augmented = (int)el->FindElementValueAsNumber("augmented");
462  if (el->FindElement("augmethod"))
463  AugMethod = (int)el->FindElementValueAsNumber("augmethod");
464  if (el->FindElement("injected"))
465  Injected = (int)el->FindElementValueAsNumber("injected");
466  if (el->FindElement("injection-time")){
467  InjectionTime = el->FindElementValueAsNumber("injection-time");
468  InjWaterNorm =1.0;
469  }
470  if (el->FindElement("injection-N1-inc"))
471  InjN1increment = el->FindElementValueAsNumber("injection-N1-inc");
472  if (el->FindElement("injection-N2-inc"))
473  InjN2increment = el->FindElementValueAsNumber("injection-N2-inc");
474 
475  string property_prefix = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
476 
477  IdleThrustLookup = GetPreFunction(property_prefix+"/IdleThrust");
478  MilThrustLookup = GetPreFunction(property_prefix+"/MilThrust");
479  MaxThrustLookup = GetPreFunction(property_prefix+"/AugThrust");
480  InjectionLookup = GetPreFunction(property_prefix+"/Injection");
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 = in.TAT_c + 273.0;
488  IdleFF = pow(MilThrust, 0.2) * 107.0; // just an estimate
489 
490  bindmodel(exec->GetPropertyManager());
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(FGPropertyManager* PropertyManager)
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  property_name = base_property_name + "/bleed-factor";
538  PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this, &FGTurbine::GetBleedDemand, &FGTurbine::SetBleedDemand);
539  property_name = base_property_name + "/MaxN1";
540  PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this,
541  &FGTurbine::GetMaxN1, &FGTurbine::SetMaxN1);
542  property_name = base_property_name + "/MaxN2";
543  PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this,
544  &FGTurbine::GetMaxN2, &FGTurbine::SetMaxN2);
545  property_name = base_property_name + "/InjectionTimer";
546  PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this,
547  &FGTurbine::GetInjectionTimer, &FGTurbine::SetInjectionTimer);
548  property_name = base_property_name + "/InjWaterNorm";
549  PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this,
550  &FGTurbine::GetInjWaterNorm, &FGTurbine::SetInjWaterNorm);
551  property_name = base_property_name + "/InjN1increment";
552  PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this,
553  &FGTurbine::GetInjN1increment, &FGTurbine::SetInjN1increment);
554  property_name = base_property_name + "/InjN2increment";
555  PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this,
556  &FGTurbine::GetInjN2increment, &FGTurbine::SetInjN2increment);
557 }
558 
559 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
560 
561 int FGTurbine::InitRunning(void)
562 {
563  FDMExec->SuspendIntegration();
564  Cutoff=false;
565  Running=true;
566  N1_factor = MaxN1 - IdleN1;
567  N2_factor = MaxN2 - IdleN2;
568  N2 = IdleN2 + ThrottlePos * N2_factor;
569  N1 = IdleN1 + ThrottlePos * N1_factor;
570  Calculate();
571  FDMExec->ResumeIntegration();
572  return phase=tpRun;
573 }
574 
575 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
576 // The bitmasked value choices are as follows:
577 // unset: In this case (the default) JSBSim would only print
578 // out the normally expected messages, essentially echoing
579 // the config files as they are read. If the environment
580 // variable is not set, debug_lvl is set to 1 internally
581 // 0: This requests JSBSim not to output any messages
582 // whatsoever.
583 // 1: This value explicity requests the normal JSBSim
584 // startup messages
585 // 2: This value asks for a message to be printed out when
586 // a class is instantiated
587 // 4: When this value is set, a message is displayed when a
588 // FGModel object executes its Run() method
589 // 8: When this value is set, various runtime state variables
590 // are printed out periodically
591 // 16: When set various parameters are sanity checked and
592 // a message is printed out when they go out of bounds
593 
594 void FGTurbine::Debug(int from)
595 {
596  if (debug_lvl <= 0) return;
597 
598  if (debug_lvl & 1) { // Standard console startup message output
599  if (from == 0) { // Constructor
600 
601  }
602  if (from == 2) { // called from Load()
603  cout << "\n Engine Name: " << Name << endl;
604  cout << " MilThrust: " << MilThrust << endl;
605  cout << " MaxThrust: " << MaxThrust << endl;
606  cout << " BypassRatio: " << BypassRatio << endl;
607  cout << " TSFC: " << TSFC << endl;
608  cout << " ATSFC: " << ATSFC << endl;
609  cout << " IdleN1: " << IdleN1 << endl;
610  cout << " IdleN2: " << IdleN2 << endl;
611  cout << " MaxN1: " << MaxN1 << endl;
612  cout << " MaxN2: " << MaxN2 << endl;
613  cout << " Augmented: " << Augmented << endl;
614  cout << " AugMethod: " << AugMethod << endl;
615  cout << " Injected: " << Injected << endl;
616  cout << " MinThrottle: " << MinThrottle << endl;
617 
618  cout << endl;
619  }
620  }
621  if (debug_lvl & 2 ) { // Instantiation/Destruction notification
622  if (from == 0) cout << "Instantiated: FGTurbine" << endl;
623  if (from == 1) cout << "Destroyed: FGTurbine" << endl;
624  }
625  if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
626  }
627  if (debug_lvl & 8 ) { // Runtime state variables
628  }
629  if (debug_lvl & 16) { // Sanity checking
630  }
631  if (debug_lvl & 64) {
632  if (from == 0) { // Constructor
633  cout << IdSrc << endl;
634  cout << IdHdr << endl;
635  }
636  }
637 }
638 }
~FGTurbine()
Destructor.
Definition: FGTurbine.cpp:87
std::string GetAttributeValue(const std::string &key)
Retrieves an attribute.
double Seek(double *var, double target, double accel, double decel)
A lag filter.
Definition: FGTurbine.cpp:406
void Calculate(void)
Calculates the thrust of the engine, and other engine functions.
Definition: FGTurbine.cpp:115
void SuspendIntegration(void)
Suspends the simulation and sets the delta T to zero.
Definition: FGFDMExec.h:539
double FindElementValueAsNumberConvertTo(const std::string &el, const std::string &target_units)
Searches for the named element and converts and returns the data belonging to it. ...
This class models a turbine engine.
Definition: FGTurbine.h:162
STL namespace.
Element * FindElement(const std::string &el="")
Searches for a specified element.
double FindElementValueAsNumber(const std::string &el="")
Searches for the named element and returns the data belonging to it as a number.
double GetValue(void) const
Retrieves the value of the function object.
Definition: FGFunction.cpp:364
FGPropertyManager * GetPropertyManager(void)
Returns a pointer to the property manager object.
Definition: FGFDMExec.cpp:1099
void ResetToIC(void)
Resets the Engine parameters to the initial conditions.
Definition: FGTurbine.cpp:94
FGFunction * GetPreFunction(const std::string &name)
Get one of the "pre" function.
void Tie(const std::string &name, bool *pointer, bool useDefault=true)
Tie a property to an external bool variable.
bool SetAttributeValue(const std::string &key, const std::string &value)
Modifies an attribute.
double CalcFuelNeed(void)
The fuel need is calculated based on power levels and flow rate for that power level.
Definition: FGTurbine.cpp:387
void ResumeIntegration(void)
Resumes the simulation by resetting delta T to the correct value.
Definition: FGFDMExec.h:542
Base class for all engines.
Definition: FGEngine.h:121
Element * FindNextElement(const std::string &el="")
Searches for the next element as specified.
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:189
virtual void ResetToIC(void)
Resets the Engine parameters to the initial conditions.
Definition: FGEngine.cpp:87