📄 fgturbine.cpp
字号:
return 0.0;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%double FGTurbine::Stall(void){ double qbar = Auxiliary->Getqbar(); EGT_degC = TAT + 903.14; FuelFlow_pph = IdleFF; N1 = Seek(&N1, qbar/10.0, 0, N1/10.0); N2 = Seek(&N2, qbar/15.0, 0, N2/10.0); ConsumeFuel(); if (ThrottlePos < 0.01) phase = tpRun; // clear the stall with throttle return 0.0;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%double FGTurbine::Seize(void){ double qbar = Auxiliary->Getqbar(); N2 = 0.0; N1 = Seek(&N1, qbar/20.0, 0, N1/15.0); FuelFlow_pph = IdleFF; ConsumeFuel(); OilPressure_psi = 0.0; OilTemp_degK = Seek(&OilTemp_degK, TAT + 273.0, 0, 0.2); Running = false; return 0.0;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%double FGTurbine::Trim(){ double idlethrust, milthrust, thrust, tdiff, N2norm; idlethrust = MilThrust * IdleThrustLookup->GetValue(); milthrust = (MilThrust - idlethrust) * MilThrustLookup->GetValue(); N2 = IdleN2 + ThrottlePos * N2_factor; N2norm = (N2 - IdleN2) / N2_factor; thrust = (idlethrust + (milthrust * N2norm * N2norm)) * (1.0 - BleedDemand); if (AugMethod == 1) { if ((ThrottlePos > 0.99) && (N2 > 97.0)) {Augmentation = true;} else {Augmentation = false;} } if ((Augmented == 1) && Augmentation && (AugMethod < 2)) { thrust = MaxThrust * MaxThrustLookup->GetValue(); } if (AugMethod == 2) { if (AugmentCmd > 0.0) { tdiff = (MaxThrust * MaxThrustLookup->GetValue()) - thrust; thrust += (tdiff * AugmentCmd); } } if ((Injected == 1) && Injection) { thrust = thrust * InjectionLookup->GetValue(); } return thrust;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%double FGTurbine::CalcFuelNeed(void){ double dT = State->Getdt() * Propulsion->GetRate(); FuelFlowRate = FuelFlow_pph / 3600.0; // Calculates flow in lbs/sec from lbs/hr FuelExpended = FuelFlowRate * dT; // Calculates fuel expended in this time step return FuelExpended;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%double FGTurbine::GetPowerAvailable(void) { if( ThrottlePos <= 0.77 ) return 64.94*ThrottlePos; else return 217.38*ThrottlePos - 117.38;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%double FGTurbine::Seek(double *var, double target, double accel, double decel) { double v = *var; if (v > target) { v -= dt * decel; if (v < target) v = target; } else if (v < target) { v += dt * accel; if (v > target) v = target; } return v;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%bool FGTurbine::Load(FGFDMExec* exec, Element *el){ char property_prefix[80]; snprintf(property_prefix, 80, "propulsion/engine[%u]/", EngineNumber); if (el->FindElement("milthrust")) MilThrust = el->FindElementValueAsNumberConvertTo("milthrust","LBS"); if (el->FindElement("maxthrust")) MaxThrust = el->FindElementValueAsNumberConvertTo("maxthrust","LBS"); if (el->FindElement("bypassratio")) BypassRatio = el->FindElementValueAsNumber("bypassratio"); if (el->FindElement("bleed")) BleedDemand = el->FindElementValueAsNumber("bleed"); if (el->FindElement("tsfc")) TSFC = el->FindElementValueAsNumber("tsfc"); if (el->FindElement("atsfc")) ATSFC = el->FindElementValueAsNumber("atsfc"); if (el->FindElement("idlen1")) IdleN1 = el->FindElementValueAsNumber("idlen1"); if (el->FindElement("idlen2")) IdleN2 = el->FindElementValueAsNumber("idlen2"); if (el->FindElement("maxn1")) MaxN1 = el->FindElementValueAsNumber("maxn1"); if (el->FindElement("maxn2")) MaxN2 = el->FindElementValueAsNumber("maxn2"); if (el->FindElement("augmented")) Augmented = (int)el->FindElementValueAsNumber("augmented"); if (el->FindElement("augmethod")) AugMethod = (int)el->FindElementValueAsNumber("augmethod"); if (el->FindElement("injected")) Injected = (int)el->FindElementValueAsNumber("injected"); if (el->FindElement("injection-time")) InjectionTime = el->FindElementValueAsNumber("injection-time"); Element *function_element; string name; FGPropertyManager* PropertyManager = exec->GetPropertyManager(); while (true) { function_element = el->FindNextElement("function"); if (!function_element) break; name = function_element->GetAttributeValue("name"); if (name == "IdleThrust") { IdleThrustLookup = new FGFunction(PropertyManager, function_element, property_prefix); } else if (name == "MilThrust") { MilThrustLookup = new FGFunction(PropertyManager, function_element, property_prefix); } else if (name == "AugThrust") { MaxThrustLookup = new FGFunction(PropertyManager, function_element, property_prefix); } else if (name == "Injection") { InjectionLookup = new FGFunction(PropertyManager, function_element, property_prefix); } else { cerr << "Unknown function type: " << name << " in turbine definition." << endl; } } // Pre-calculations and initializations delay = 60.0 / (BypassRatio + 3.0); N1_factor = MaxN1 - IdleN1; N2_factor = MaxN2 - IdleN2; OilTemp_degK = (Auxiliary->GetTotalTemperature() - 491.69) * 0.5555556 + 273.0; IdleFF = pow(MilThrust, 0.2) * 107.0; // just an estimate bindmodel(); return true;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%string FGTurbine::GetEngineLabels(string delimeter){ std::ostringstream buf; buf << Name << "_N1[" << EngineNumber << "]" << delimeter << Name << "_N2[" << EngineNumber << "]" << delimeter << Thruster->GetThrusterLabels(EngineNumber, delimeter); return buf.str();}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%string FGTurbine::GetEngineValues(string delimeter){ std::ostringstream buf; buf << N1 << delimeter << N2 << delimeter << Thruster->GetThrusterValues(EngineNumber, delimeter); return buf.str();}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%void FGTurbine::bindmodel(){ char property_name[80]; snprintf(property_name, 80, "propulsion/engine[%u]/n1", EngineNumber); PropertyManager->Tie( property_name, &N1); snprintf(property_name, 80, "propulsion/engine[%u]/n2", EngineNumber); PropertyManager->Tie( property_name, &N2); snprintf(property_name, 80, "propulsion/engine[%u]/injection_cmd", EngineNumber); PropertyManager->Tie( property_name, (FGTurbine*)this, &FGTurbine::GetInjection, &FGTurbine::SetInjection);}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%int FGTurbine::InitRunning(void) { State->SuspendIntegration(); Cutoff=false; Running=true; N2=16.0; Calculate(); State->ResumeIntegration(); return phase==tpRun;}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// The bitmasked value choices are as follows:// unset: In this case (the default) JSBSim would only print// out the normally expected messages, essentially echoing// the config files as they are read. If the environment// variable is not set, debug_lvl is set to 1 internally// 0: This requests JSBSim not to output any messages// whatsoever.// 1: This value explicity requests the normal JSBSim// startup messages// 2: This value asks for a message to be printed out when// a class is instantiated// 4: When this value is set, a message is displayed when a// FGModel object executes its Run() method// 8: When this value is set, various runtime state variables// are printed out periodically// 16: When set various parameters are sanity checked and// a message is printed out when they go out of boundsvoid FGTurbine::Debug(int from){ if (debug_lvl <= 0) return; if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor } if (from == 2) { // called from Load() cout << "\n Engine Name: " << Name << endl; cout << " MilThrust: " << MilThrust << endl; cout << " MaxThrust: " << MaxThrust << endl; cout << " BypassRatio: " << BypassRatio << endl; cout << " TSFC: " << TSFC << endl; cout << " ATSFC: " << ATSFC << endl; cout << " IdleN1: " << IdleN1 << endl; cout << " IdleN2: " << IdleN2 << endl; cout << " MaxN1: " << MaxN1 << endl; cout << " MaxN2: " << MaxN2 << endl; cout << " Augmented: " << Augmented << endl; cout << " AugMethod: " << AugMethod << endl; cout << " Injected: " << Injected << endl; cout << " MinThrottle: " << MinThrottle << endl; cout << endl; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification if (from == 0) cout << "Instantiated: FGTurbine" << endl; if (from == 1) cout << "Destroyed: FGTurbine" << endl; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } if (debug_lvl & 8 ) { // Runtime state variables } if (debug_lvl & 16) { // Sanity checking } if (debug_lvl & 64) { if (from == 0) { // Constructor cout << IdSrc << endl; cout << IdHdr << endl; } }}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -