Skip to content

Commit

Permalink
Let RF use stock's useThrottleIspCurve @Capkirk123
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanKell authored Apr 29, 2024
1 parent 8d07edd commit 0dab7c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Source/Engines/ModuleEnginesRF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 10 additions & 2 deletions Source/Engines/SolverRF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -61,6 +61,8 @@ public void InitializeOverallEngineData(
FloatCurve nVelCurve,
FloatCurve nAtmCurveIsp,
FloatCurve nVelCurveIsp,
FloatCurve nthrottleIspCurve,
FloatCurve nthrottleIspCurveAtmStrength,
bool nDisableUnderwater,
double nThrottleResponseRate,
double nChamberNominalTemp,
Expand All @@ -83,6 +85,8 @@ public void InitializeOverallEngineData(
velCurve = nVelCurve;
atmCurveIsp = nAtmCurveIsp;
velCurveIsp = nVelCurveIsp;
throttleIspCurve = nthrottleIspCurve;
throttleIspCurveAtmStrength = nthrottleIspCurveAtmStrength;
disableUnderwater = nDisableUnderwater;
throttleResponseRate = nThrottleResponseRate;
chamberTemp = 288d;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 0dab7c4

Please sign in to comment.