diff --git a/Source/Engines/ModuleEnginesRF.cs b/Source/Engines/ModuleEnginesRF.cs
index 3fb435d7..dec462bb 100644
--- a/Source/Engines/ModuleEnginesRF.cs
+++ b/Source/Engines/ModuleEnginesRF.cs
@@ -54,7 +54,7 @@ public class ModuleEnginesRF : ModuleEnginesSolver
protected Propellant curveProp;
- [KSPField(guiName = "#RF_EngineRF_IgnitedFor", guiUnits = "s", guiFormat = "F3", groupName = groupName)] // Ignited for
+ [KSPField(guiName = "#RF_EngineRF_IgnitedFor", guiUnits = "s", guiFormat = "F3", groupName = groupName)] // Ignited for
public float curveTime = 0f;
#endregion
@@ -496,9 +496,9 @@ private void SetFields()
tags += pressureFed ? ", " : string.Empty;
tags += $"{Localizer.GetStringByTag("#RF_EngineRF_Ullage")}"; // Ullage
}
- sISP = $"{atmosphereCurve.Evaluate(1):N0} (ASL) - {atmosphereCurve.Evaluate(0):N0} (Vac)"; //
+ sISP = $"{atmosphereCurve.Evaluate(1):N0} (ASL) - {atmosphereCurve.Evaluate(0):N0} (Vac)"; //
GetThrustData(out double thrustVac, out double thrustASL);
- sThrust = $"{Utilities.FormatThrust(thrustASL)} (ASL) - {Utilities.FormatThrust(thrustVac)} (Vac)"; //
+ sThrust = $"{Utilities.FormatThrust(thrustASL)} (ASL) - {Utilities.FormatThrust(thrustVac)} (Vac)"; //
if (ignitions > 0)
sIgnitions = $"{ignitions:N0}";
else if (ignitions == -1)
@@ -685,9 +685,8 @@ public override void UpdateSolver(EngineThermodynamics ambientTherm, double alti
{
if (EngineIgnited && ignited && throttledUp && rfSolver.GetRunning())
{
- double state = ullageSet.GetUllageStability();
- double testValue = Math.Pow(state, RFSettings.Instance.stabilityPower);
- if (staticRandom.NextDouble() > testValue)
+ double ullageProbability = ullageSet.GetUllageProbability();
+ if (staticRandom.NextDouble() > ullageProbability)
{
ScreenMessages.PostScreenMessage(ullageFail);
FlightLogger.fetch.LogEvent($"[{FormatTime(vessel.missionTime)}] {ullageFail.message}");
@@ -762,10 +761,10 @@ public void SetScale(double newScale)
#region Info
protected string ThrottleString()
{
- if (throttleLocked) { return ", throttle locked"; } //
- if (MinThrottle == 1f) { return ", unthrottleable"; } //
+ if (throttleLocked) { return ", throttle locked"; } //
+ if (MinThrottle == 1f) { return ", unthrottleable"; } //
if (MinThrottle < 0f || MinThrottle > 1f) { return string.Empty; }
- return $", {MinThrottle:P0} min throttle"; //
+ return $", {MinThrottle:P0} min throttle"; //
}
protected void GetThrustData(out double thrustVac, out double thrustASL)
@@ -850,8 +849,8 @@ protected string GetThrustInfo()
output += $"{MinThrottle:P0} {Localizer.GetStringByTag("#RF_EngineRF_MinThrottle")}\n"; // min throttle
if (thrustASL != thrustVac)
{
- output += $"{Localizer.GetStringByTag("#RF_EngineRF_MAXThrustInVac")}: {Utilities.FormatThrust(thrustVac)} (TWR {thrustVac / weight:0.0##})\n"; //Max. Thrust (Vac)
- output += $"{Localizer.GetStringByTag("#RF_EngineRF_MAXThrustInASL")}: {Utilities.FormatThrust(thrustASL)} (TWR {thrustASL / weight:0.0##})\n"; //Max. Thrust (ASL)
+ output += $"{Localizer.GetStringByTag("#RF_EngineRF_MAXThrustInVac")}: {Utilities.FormatThrust(thrustVac)} (TWR {thrustVac / weight:0.0##})\n"; //Max. Thrust (Vac)
+ output += $"{Localizer.GetStringByTag("#RF_EngineRF_MAXThrustInASL")}: {Utilities.FormatThrust(thrustASL)} (TWR {thrustASL / weight:0.0##})\n"; //Max. Thrust (ASL)
output += $"{Localizer.GetStringByTag("#RF_EngineRF_MINThrustInVac")}: {Utilities.FormatThrust(thrustVac * MinThrottle)} (TWR {thrustVac * MinThrottle / weight:0.0##})\n"; // Min. Thrust (Vac)
output += $"{Localizer.GetStringByTag("#RF_EngineRF_MINThrustInASL")}: {Utilities.FormatThrust(thrustASL * MinThrottle)} (TWR {thrustASL * MinThrottle / weight:0.0##})\n"; // Min. Thrust (ASL)
}
@@ -887,7 +886,7 @@ public string GetUllageIgnition()
return output;
}
-
+
public override string GetInfo()
{
string output = $"{GetThrustInfo()}" +
diff --git a/Source/Ullage/UllageSet.cs b/Source/Ullage/UllageSet.cs
index b07af9d6..aa490064 100644
--- a/Source/Ullage/UllageSet.cs
+++ b/Source/Ullage/UllageSet.cs
@@ -119,7 +119,7 @@ public void Update(Vector3 acc, Vector3 angVel, double timeDelta, double venting
angularVelocity = engine.transform.InverseTransformDirection(engine.part.rb.angularVelocity);
else
angularVelocity = engine.transform.InverseTransformDirection(angVel);
-
+
fuelRatio = 1d;
if(HighLogic.LoadedSceneIsFlight && engine.EngineIgnited)
{
@@ -139,6 +139,7 @@ public void Update(Vector3 acc, Vector3 angVel, double timeDelta, double venting
public void SetUllageStability(double newStability) => ullageSim.SetPropellantStability(newStability);
public string GetUllageState(out Color col) => ullageSim.GetPropellantStatus(out col);
public double GetUllageStability() => ullageSim.GetPropellantStability();
+ public double GetUllageProbability() => ullageSim.GetPropellantProbability();
public bool PressureOK() => !engine.pressureFed || tanksHighlyPressurized;
public bool EditorPressurized()
{
diff --git a/Source/Ullage/UllageSimulator.cs b/Source/Ullage/UllageSimulator.cs
index ce1ee860..86a6d270 100644
--- a/Source/Ullage/UllageSimulator.cs
+++ b/Source/Ullage/UllageSimulator.cs
@@ -105,7 +105,7 @@ public void Update(Vector3d localAcceleration, Vector3d rotation, double deltaTi
//if (ventingAcc != 0.0f) Debug.Log("BoilOffAcc: " + ventingAcc.ToString("F8"));
//else Debug.Log("BoilOffAcc: No boiloff.");
-
+
Vector3d localAccelerationAmount = localAcceleration * deltaTime;
Vector3d rotationAmount = rotation * deltaTime;
@@ -179,8 +179,6 @@ public void Update(Vector3d localAcceleration, Vector3d rotation, double deltaTi
//Debug.Log("Ullage: pHorizontal: " + pHorizontal.ToString("F3"));
propellantStability = Math.Max(0.0d, 1.0d - (pVertical * pHorizontal * (0.75d + Math.Sqrt(bLevel))));
- if (propellantStability >= veryStable)
- propellantStability = 1d;
//#if DEBUG
// if (propellantStability < 0.5d)
@@ -204,9 +202,15 @@ private void SetStateString()
propellantStatus = Localizer.GetStringByTag("#RF_UllageState_Unstable"); // "Unstable"
else
propellantStatus = Localizer.GetStringByTag("#RF_UllageState_VeryUnstable"); // "Very Unstable"
- propellantStatus += $" ({propellantStability:P2})";
+ propellantStatus += $" ({GetPropellantProbability():P2})";
}
public double GetPropellantStability() => propellantStability;
+ public double GetPropellantProbability()
+ {
+ // round up veryStable (>= 0.996) to 100% stable
+ double stability = propellantStability >= veryStable ? 1.0d : propellantStability;
+ return Math.Pow(stability, RFSettings.Instance.stabilityPower);
+ }
public void SetPropellantStability(double newStab) => propellantStability = newStab;
public string GetPropellantStatus(out Color col)
{