📄 fgturbine.cpp
字号:
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Module: FGTurbine.cpp Author: David Culp Date started: 03/11/2003 Purpose: This module models a turbine engine. ------------- Copyright (C) 2003 David Culp (davidculp2@comcast.net) --------- This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Further information about the GNU Lesser General Public License can also be found on the world wide web at http://www.gnu.org.FUNCTIONAL DESCRIPTION--------------------------------------------------------------------------------This class descends from the FGEngine class and models a turbine engine basedon parameters given in the engine config file for this classHISTORY--------------------------------------------------------------------------------03/11/2003 DPC Created09/08/2003 DPC Changed Calculate() and added engine phases%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%INCLUDES%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/#include <vector>#include <sstream>#include "FGTurbine.h"namespace JSBSim {static const char *IdSrc = "$Id$";static const char *IdHdr = ID_TURBINE;/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%CLASS IMPLEMENTATION%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/FGTurbine::FGTurbine(FGFDMExec* exec, Element *el, int engine_number) : FGEngine(exec, el, engine_number){ Type = etTurbine; MilThrust = MaxThrust = 10000.0; TSFC = 0.8; ATSFC = 1.7; IdleN1 = 30.0; IdleN2 = 60.0; MaxN1 = MaxN2 = 100.0; Augmented = AugMethod = Injected = 0; BypassRatio = BleedDemand = 0.0; IdleThrustLookup = MilThrustLookup = MaxThrustLookup = InjectionLookup = 0; ResetToIC(); Load(exec, el); Debug(0);}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%FGTurbine::~FGTurbine(){ delete IdleThrustLookup; delete MilThrustLookup; delete MaxThrustLookup; delete InjectionLookup; Debug(1);}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%void FGTurbine::ResetToIC(void){ N1 = N2 = 0.0; correctedTSFC = TSFC; ThrottlePos = AugmentCmd = 0.0; InletPosition = NozzlePosition = 1.0; Stalled = Seized = Overtemp = Fire = Augmentation = Injection = Reversed = false; Cutoff = true; phase = tpOff; EGT_degC = 0.0; OilTemp_degK = (Auxiliary->GetTotalTemperature() - 491.69) * 0.5555556 + 273.0;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// The main purpose of Calculate() is to determine what phase the engine should// be in, then call the corresponding function.double FGTurbine::Calculate(void){ TAT = (Auxiliary->GetTotalTemperature() - 491.69) * 0.5555556; dt = State->Getdt() * Propulsion->GetRate(); ThrottlePos = FCS->GetThrottlePos(EngineNumber); if (ThrottlePos > 1.0) { AugmentCmd = ThrottlePos - 1.0; ThrottlePos -= AugmentCmd; } else { AugmentCmd = 0.0; } // When trimming is finished check if user wants engine OFF or RUNNING if ((phase == tpTrim) && (dt > 0)) { if (Running && !Starved) { phase = tpRun; N2 = IdleN2 + ThrottlePos * N2_factor; N1 = IdleN1 + ThrottlePos * N1_factor; OilTemp_degK = 366.0; Cutoff = false; } else { phase = tpOff; Cutoff = true; EGT_degC = TAT; } } if (!Running && Cutoff && Starter) { if (phase == tpOff) phase = tpSpinUp; } if (!Running && !Cutoff && (N2 > 15.0)) phase = tpStart; if (Cutoff && (phase != tpSpinUp)) phase = tpOff; if (dt == 0) phase = tpTrim; if (Starved) phase = tpOff; if (Stalled) phase = tpStall; if (Seized) phase = tpSeize; switch (phase) { case tpOff: Thrust = Off(); break; case tpRun: Thrust = Run(); break; case tpSpinUp: Thrust = SpinUp(); break; case tpStart: Thrust = Start(); break; case tpStall: Thrust = Stall(); break; case tpSeize: Thrust = Seize(); break; case tpTrim: Thrust = Trim(); break; default: Thrust = Off(); } Thrust = Thruster->Calculate(Thrust); // allow thruster to modify thrust (i.e. reversing) return Thrust;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%double FGTurbine::Off(void){ double qbar = Auxiliary->Getqbar(); Running = false; FuelFlow_pph = Seek(&FuelFlow_pph, 0, 1000.0, 10000.0); N1 = Seek(&N1, qbar/10.0, N1/2.0, N1/2.0); N2 = Seek(&N2, qbar/15.0, N2/2.0, N2/2.0); EGT_degC = Seek(&EGT_degC, TAT, 11.7, 7.3); OilTemp_degK = Seek(&OilTemp_degK, TAT + 273.0, 0.2, 0.2); OilPressure_psi = N2 * 0.62; NozzlePosition = Seek(&NozzlePosition, 1.0, 0.8, 0.8); EPR = Seek(&EPR, 1.0, 0.2, 0.2); Augmentation = false; ConsumeFuel(); return 0.0;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%double FGTurbine::Run(){ double idlethrust, milthrust, thrust; double N2norm; // 0.0 = idle N2, 1.0 = maximum N2 idlethrust = MilThrust * IdleThrustLookup->GetValue(); milthrust = (MilThrust - idlethrust) * MilThrustLookup->GetValue(); Running = true; Starter = false; N2 = Seek(&N2, IdleN2 + ThrottlePos * N2_factor, delay, delay * 3.0); N1 = Seek(&N1, IdleN1 + ThrottlePos * N1_factor, delay, delay * 2.4); N2norm = (N2 - IdleN2) / N2_factor; thrust = idlethrust + (milthrust * N2norm * N2norm); EGT_degC = TAT + 363.1 + ThrottlePos * 357.1; OilPressure_psi = N2 * 0.62; OilTemp_degK = Seek(&OilTemp_degK, 366.0, 1.2, 0.1); if (!Augmentation) { correctedTSFC = TSFC * (0.84 + (1-N2norm)*(1-N2norm)); FuelFlow_pph = Seek(&FuelFlow_pph, thrust * correctedTSFC, 1000.0, 100000); if (FuelFlow_pph < IdleFF) FuelFlow_pph = IdleFF; NozzlePosition = Seek(&NozzlePosition, 1.0 - N2norm, 0.8, 0.8); thrust = thrust * (1.0 - BleedDemand); EPR = 1.0 + thrust/MilThrust; } if (AugMethod == 1) { if ((ThrottlePos > 0.99) && (N2 > 97.0)) {Augmentation = true;} else {Augmentation = false;} } if ((Augmented == 1) && Augmentation && (AugMethod < 2)) { thrust = MaxThrustLookup->GetValue() * MaxThrust; FuelFlow_pph = Seek(&FuelFlow_pph, thrust * ATSFC, 5000.0, 10000.0); NozzlePosition = Seek(&NozzlePosition, 1.0, 0.8, 0.8); } if (AugMethod == 2) { if (AugmentCmd > 0.0) { Augmentation = true; double tdiff = (MaxThrust * MaxThrustLookup->GetValue()) - thrust; thrust += (tdiff * AugmentCmd); FuelFlow_pph = Seek(&FuelFlow_pph, thrust * ATSFC, 5000.0, 10000.0); NozzlePosition = Seek(&NozzlePosition, 1.0, 0.8, 0.8); } else { Augmentation = false; } } if ((Injected == 1) && Injection) { InjectionTimer += dt; if (InjectionTimer < InjectionTime) { thrust = thrust * InjectionLookup->GetValue(); } else { Injection = false; } } ConsumeFuel(); if (Cutoff) phase = tpOff; if (Starved) phase = tpOff; return thrust;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%double FGTurbine::SpinUp(void){ Running = false; FuelFlow_pph = 0.0; N2 = Seek(&N2, 25.18, 3.0, N2/2.0); N1 = Seek(&N1, 5.21, 1.0, N1/2.0); EGT_degC = Seek(&EGT_degC, TAT, 11.7, 7.3); OilPressure_psi = N2 * 0.62; OilTemp_degK = Seek(&OilTemp_degK, TAT + 273.0, 0.2, 0.2); EPR = 1.0; NozzlePosition = 1.0; return 0.0;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%double FGTurbine::Start(void){ if ((N2 > 15.0) && !Starved) { // minimum 15% N2 needed for start Cranking = true; // provided for sound effects signal if (N2 < IdleN2) { N2 = Seek(&N2, IdleN2, 2.0, N2/2.0); N1 = Seek(&N1, IdleN1, 1.4, N1/2.0); EGT_degC = Seek(&EGT_degC, TAT + 363.1, 21.3, 7.3); FuelFlow_pph = Seek(&FuelFlow_pph, IdleFF, 103.7, 103.7); OilPressure_psi = N2 * 0.62; ConsumeFuel(); } else { phase = tpRun; Running = true; Starter = false; Cranking = false; } } else { // no start if N2 < 15% phase = tpOff; Starter = false; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -