LCOV - code coverage report
Current view: top level - models/propulsion - FGTurbine.cpp (source / functions) Hit Total Coverage
Test: JSBSim-Coverage-Statistics Lines: 1 343 0.3 %
Date: 2010-08-24 Functions: 3 26 11.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 434 0.7 %

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

Generated by: LCOV version 1.9