diff --git a/Source/Engines/ModuleEnginesRF.cs b/Source/Engines/ModuleEnginesRF.cs index 00d99396..f19b0d28 100644 --- a/Source/Engines/ModuleEnginesRF.cs +++ b/Source/Engines/ModuleEnginesRF.cs @@ -209,6 +209,8 @@ public override void CreateEngine() useVelCurve ? velCurve : null, useAtmCurveIsp ? atmCurveIsp : null, useVelCurveIsp ? velCurveIsp : null, + useThrottleIspCurve ? throttleIspCurve : null, + useThrottleIspCurve ? throttleIspCurveAtmStrength : null, disableUnderwater, throttleResponseRate, chamberNominalTemp, diff --git a/Source/Engines/SolverRF.cs b/Source/Engines/SolverRF.cs index 00a34d4b..dff50c81 100644 --- a/Source/Engines/SolverRF.cs +++ b/Source/Engines/SolverRF.cs @@ -16,7 +16,7 @@ public class SolverRF : EngineSolver double VarianceDuring = 0.2d; // engine params - private FloatCurve atmosphereCurve = null, atmCurve = null, velCurve = null, atmCurveIsp = null, velCurveIsp = null; + private FloatCurve atmosphereCurve = null, atmCurve = null, velCurve = null, atmCurveIsp = null, velCurveIsp = null, throttleIspCurve = null, throttleIspCurveAtmStrength = null; private double minFlow, maxFlow, maxFlowRecip, thrustRatio = 1d, throttleResponseRate, machLimit, machMult; private double flowMultMin, flowMultCap, flowMultCapSharpness; private bool combusting = true; @@ -61,6 +61,8 @@ public void InitializeOverallEngineData( FloatCurve nVelCurve, FloatCurve nAtmCurveIsp, FloatCurve nVelCurveIsp, + FloatCurve nthrottleIspCurve, + FloatCurve nthrottleIspCurveAtmStrength, bool nDisableUnderwater, double nThrottleResponseRate, double nChamberNominalTemp, @@ -83,6 +85,8 @@ public void InitializeOverallEngineData( velCurve = nVelCurve; atmCurveIsp = nAtmCurveIsp; velCurveIsp = nVelCurveIsp; + throttleIspCurve = nthrottleIspCurve; + throttleIspCurveAtmStrength = nthrottleIspCurveAtmStrength; disableUnderwater = nDisableUnderwater; throttleResponseRate = nThrottleResponseRate; chamberTemp = 288d; @@ -164,7 +168,8 @@ public override void CalculatePerformance(double airRatio, double commandedThrot M0 = mach; // Calculate Isp (before the shutdown check, so it displays even then) - Isp = atmosphereCurve.Evaluate((float)(p0 * 0.001d * PhysicsGlobals.KpaToAtmospheres)) * ispMult; + float pressureAtm = (float)(p0 * 0.001d * PhysicsGlobals.KpaToAtmospheres); + Isp = atmosphereCurve.Evaluate(pressureAtm) * ispMult; // if we're not combusting, don't combust and start cooling off combusting = running; @@ -263,6 +268,9 @@ public override void CalculatePerformance(double airRatio, double commandedThrot ispOtherMult *= atmCurveIsp.Evaluate((float)(rho * (1d / 1.225d))); if (velCurveIsp != null) ispOtherMult *= velCurveIsp.Evaluate((float)mach); + if (throttleIspCurve != null) + ispOtherMult *= Mathf.Lerp(1f, throttleIspCurve.Evaluate(commandedThrottle), + throttleIspCurveAtmStrength.Evaluate(pressureAtm)); if (HighLogic.LoadedSceneIsFlight && varyIsp > 0d && fuelFlow > 0d) {