From b1eebb21a672fa832c3d867932f7c4935c26760b Mon Sep 17 00:00:00 2001 From: ehofman Date: Mon, 2 Nov 2009 12:22:45 +0000 Subject: [PATCH] rocket engine and piston engine fixes --- src/FDM/JSBSim/models/propulsion/FGPiston.cpp | 41 ++++++++++++------- src/FDM/JSBSim/models/propulsion/FGRocket.cpp | 9 +++- src/FDM/JSBSim/models/propulsion/FGRocket.h | 1 + 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/FDM/JSBSim/models/propulsion/FGPiston.cpp b/src/FDM/JSBSim/models/propulsion/FGPiston.cpp index 116d20cc0..7f484e6b9 100644 --- a/src/FDM/JSBSim/models/propulsion/FGPiston.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGPiston.cpp @@ -88,7 +88,7 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number) MinManifoldPressure_inHg = 6.5; MaxManifoldPressure_inHg = 28.5; ISFC = -1; - volumetric_efficiency = -0.1; + volumetric_efficiency = 0.85; Bore = 5.125; Stroke = 4.375; Cylinders = 4; @@ -239,32 +239,41 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number) StarterHP = sqrt(MaxHP) * 0.4; displacement_SI = Displacement * in3tom3; + RatedMeanPistonSpeed_fps = ( MaxRPM * Stroke) / (360); // AKA 2 * (RPM/60) * ( Stroke / 12) or 2NS - // Create IFSC and VE to match the engine if not provided - int calculated_ve=0; - if (volumetric_efficiency < 0) { - volumetric_efficiency = MaxManifoldPressure_inHg / 29.92; - calculated_ve=1; - } + // Create IFSC to match the engine if not provided if (ISFC < 0) { - double pmep = MaxManifoldPressure_inHg > 29.92 ? 0 : 29.92 - MaxManifoldPressure_inHg; + double pmep = 29.92 - MaxManifoldPressure_inHg; pmep *= inhgtopa; - double fmep = (18400 * (2*(Stroke/12)*(MaxRPM/60)) * fttom + 46500)/2; + double fmep = (18400 * RatedMeanPistonSpeed_fps * fttom + 46500); double hp_loss = ((pmep + fmep) * displacement_SI * MaxRPM)/(Cycles*22371); - ISFC = ( Displacement * MaxRPM * volumetric_efficiency ) / (9411 * (MaxHP+hp_loss)); + ISFC = ( 1.1*Displacement * MaxRPM * volumetric_efficiency *(MaxManifoldPressure_inHg / 29.92) ) / (9411 * (MaxHP+hp_loss)); // cout <<"FMEP: "<< fmep <<" PMEP: "<< pmep << " hp_loss: " < 29.9 ) { // Don't allow boosting with a bogus number MaxManifoldPressure_inHg = 29.9; - if (calculated_ve) volumetric_efficiency = 1.0; } minMAP = MinManifoldPressure_inHg * inhgtopa; // inHg to Pa maxMAP = MaxManifoldPressure_inHg * inhgtopa; // For throttle - RatedMeanPistonSpeed_fps = ( MaxRPM * Stroke) / (360); // AKA 2 * (RPM/60) * ( Stroke / 12) or 2NS - if(Z_airbox < 998){ - double Ze=RatedMeanPistonSpeed_fps/PeakMeanPistonSpeed_fps; // engine impedence +/* + * Pm = ( Ze / ( Ze + Zi + Zt ) ) * Pa + * Where: + * Pm = Manifold Pressure + * Pa = Ambient Pressre + * Ze = engine impedance, Ze is effectively 1 / Mean Piston Speed + * Zi = airbox impedance + * Zt = throttle impedance + * + * For the calculation below throttle is fully open or Zt = 0 + * + * + * + */ + + if(Z_airbox < 0.0){ + double Ze=PeakMeanPistonSpeed_fps/RatedMeanPistonSpeed_fps; // engine impedence Z_airbox = (standard_pressure *Ze / maxMAP) - Ze; // impedence of airbox } Z_throttle=(((MaxRPM * Stroke) / 360)/((IdleRPM * Stroke) / 360))*(standard_pressure/minMAP - 1) - Z_airbox; // Constant for Throttle impedence @@ -913,7 +922,9 @@ void FGPiston::Debug(int from) cout << " MaxThrottle: " << MaxThrottle << endl; cout << " MinThrottle: " << MinThrottle << endl; cout << " ISFC: " << ISFC << endl; - cout << " Volumentric Efficiency: " << volumetric_efficiency << endl; + cout << " Volumetric Efficiency: " << volumetric_efficiency << endl; + cout << " PeakMeanPistonSpeed_fps: " << PeakMeanPistonSpeed_fps << endl; + cout << " Intake Impedance Factor: " << Z_airbox << endl; cout << endl; cout << " Combustion Efficiency table:" << endl; diff --git a/src/FDM/JSBSim/models/propulsion/FGRocket.cpp b/src/FDM/JSBSim/models/propulsion/FGRocket.cpp index 7a72c9fe9..eab01be15 100644 --- a/src/FDM/JSBSim/models/propulsion/FGRocket.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGRocket.cpp @@ -69,6 +69,7 @@ FGRocket::FGRocket(FGFDMExec* exec, Element *el, int engine_number) FuelFlowRate = 0.0; OxidizerFlowRate = 0.0; SLOxiFlowMax = 0.0; + BuildupTime = 0.0; It = 0.0; // Defaults @@ -77,6 +78,8 @@ FGRocket::FGRocket(FGFDMExec* exec, Element *el, int engine_number) if (el->FindElement("isp")) Isp = el->FindElementValueAsNumber("isp"); + if (el->FindElement("builduptime")) + BuildupTime = el->FindElementValueAsNumber("builduptime"); if (el->FindElement("maxthrottle")) MaxThrottle = el->FindElementValueAsNumber("maxthrottle"); if (el->FindElement("minthrottle")) @@ -127,7 +130,6 @@ double FGRocket::Calculate(void) if (ThrustTable != 0L) { // Thrust table given -> Solid fuel used if ((Throttle == 1 || BurnTime > 0.0 ) && !Starved) { - BurnTime += State->Getdt(); double TotalEngineFuelBurned=0.0; for (int i=0; i<(int)SourceTanks.size(); i++) { FGTank* tank = Propulsion->GetTank(i); @@ -137,6 +139,11 @@ double FGRocket::Calculate(void) } VacThrust = ThrustTable->GetValue(TotalEngineFuelBurned); + if (BurnTime <= BuildupTime && BuildupTime > 0.0) { + VacThrust *= sin((BurnTime/BuildupTime)*M_PI/2.0); + // VacThrust *= (1-cos((BurnTime/BuildupTime)*M_PI))/2.0; // 1 - cos approach + } + BurnTime += State->Getdt(); // Increment burn time } else { VacThrust = 0.0; } diff --git a/src/FDM/JSBSim/models/propulsion/FGRocket.h b/src/FDM/JSBSim/models/propulsion/FGRocket.h index 15235575b..b2cb76f4e 100644 --- a/src/FDM/JSBSim/models/propulsion/FGRocket.h +++ b/src/FDM/JSBSim/models/propulsion/FGRocket.h @@ -200,6 +200,7 @@ private: double OxidizerFlowRate; double PropellantFlowRate; bool Flameout; + double BuildupTime; FGTable* ThrustTable; void Debug(int from);