Skip to content

Commit 1985cbe

Browse files
committed
Adjust combustion times
1 parent 956a8ec commit 1985cbe

File tree

1 file changed

+76
-67
lines changed

1 file changed

+76
-67
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/MSTSSteamLocomotive.cs

Lines changed: 76 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,9 @@ public class MSTSSteamLocomotive : MSTSLocomotive
294294
SmoothedData FuelRateStoker = new SmoothedData(15); // Stoker is more responsive and only takes x seconds to fully react to changing needs.
295295
SmoothedData FuelRateCoal = new SmoothedData(45); // Automatic fireman takes x seconds to fully react to changing needs for coal firing.
296296
SmoothedData CoalBurnRateSmoothKGpS = new SmoothedData(150); // Changes in BurnRate take x seconds to fully react to changing needs - models increase and decrease in heat.
297-
SmoothedData OilBurnRateSmoothKGpS = new SmoothedData(3); // Changes in Oil BurnRate take x seconds to fully react to changing needs - models increase and decrease in heat. Oil faster then steam
297+
SmoothedData OilBurnRateSmoothKGpS = new SmoothedData(6); // Changes in Oil BurnRate take x seconds to fully react to changing needs - models increase and decrease in heat. Oil faster then steam
298+
SmoothedData OilBurnRateReductionSmoothKGpS = new SmoothedData(0.25f); // When in reduction we would expect the heat to drop off rapidly for an oil fire
299+
298300
float FuelFeedRateSmoothedKGpS = 0.0f; // Smoothed Fuel feedd Rate
299301
public float FuelBurnRateSmoothedKGpS; // Smoothed fuel burning rate
300302
float OilSpecificGravity = 0.9659f; // Assume a mid range of API for this value, say API = 15 @ 20 Cdeg.
@@ -488,6 +490,7 @@ public float TenderCoalMassKG // Decreased by firing and increased
488490
float TimeFuelBoostOnS = 300.0f; // Time to allow fuel boosting to go on for
489491
float TimeFuelBoostResetS = 1200.0f;// Time to wait before next fuel boost
490492
float throttle;
493+
float previousThrottle;
491494
float SpeedEquivMpS = 27.0f; // Equvalent speed of 60mph in mps (27m/s) - used for damper control
492495

493496
// Cylinder related parameters
@@ -3742,84 +3745,77 @@ private void UpdateFirebox(float elapsedClockSeconds, float absSpeedMpS)
37423745
else // *********** AI Fireman *****************
37433746
{
37443747

3745-
// if (SteamLocomotiveFuelType == SteamLocomotiveFuelTypes.Oil)
3746-
// {
3747-
// BurnRateRawKGpS = (W.ToKW(W.FromBTUpS(PreviousBoilerHeatOutBTUpS - BoilerHeatExceptionsBtupS)) / FuelCalorificKJpKG);
3748-
// }
3749-
// else
3748+
if (PreviousTotalSteamUsageLBpS > TheoreticalMaxSteamOutputLBpS)
37503749
{
3751-
if (PreviousTotalSteamUsageLBpS > TheoreticalMaxSteamOutputLBpS)
3752-
{
3753-
FiringSteamUsageRateLBpS = TheoreticalMaxSteamOutputLBpS; // hold usage rate if steam usage rate exceeds boiler max output
3754-
}
3755-
else
3756-
{
3757-
FiringSteamUsageRateLBpS = PreviousTotalSteamUsageLBpS; // Current steam usage rate
3758-
}
3750+
FiringSteamUsageRateLBpS = TheoreticalMaxSteamOutputLBpS; // hold usage rate if steam usage rate exceeds boiler max output
3751+
}
3752+
else
3753+
{
3754+
FiringSteamUsageRateLBpS = PreviousTotalSteamUsageLBpS; // Current steam usage rate
3755+
}
37593756

3760-
AIFiremanBurnFactorExceed = HeatRatio * PressureRatio; // Firing rate for AI fireman if firemass drops, and fireman needs to exceed normal capacity
3761-
AIFiremanBurnFactor = HeatRatio * PressureRatio * FullBoilerHeatRatio * MaxBoilerHeatRatio; // Firing rate factor under normal conditions
3762-
float AIFiremanStartingBurnFactor = 4.0f;
3757+
AIFiremanBurnFactorExceed = HeatRatio * PressureRatio; // Firing rate for AI fireman if firemass drops, and fireman needs to exceed normal capacity
3758+
AIFiremanBurnFactor = HeatRatio * PressureRatio * FullBoilerHeatRatio * MaxBoilerHeatRatio; // Firing rate factor under normal conditions
3759+
float AIFiremanStartingBurnFactor = 4.0f;
37633760

3764-
if (ShovelAnyway && BoilerHeatBTU < MaxBoilerHeatBTU) // will force fire burn rate to increase even though boiler heat seems excessive
3761+
if (ShovelAnyway && BoilerHeatBTU < MaxBoilerHeatBTU) // will force fire burn rate to increase even though boiler heat seems excessive
3762+
{
3763+
// burnrate will be the radiation loss @ rest & then related to heat usage as a factor of the maximum boiler output
3764+
// ignores total bolier heat to allow burn rate to increase if boiler heat usage is exceeding input
3765+
BurnRateRawKGpS = (W.ToKW(W.FromBTUpS(PreviousBoilerHeatOutBTUpS - BoilerHeatExceptionsBtupS)) / FuelCalorificKJpKG) * AIFiremanBurnFactorExceed;
3766+
}
3767+
else
3768+
{
3769+
3770+
if (BoilerHeatBTU > MaxBoilerHeatBTU && BoilerHeatBTU <= MaxBoilerSafetyPressHeatBTU && throttle > 0.1 && cutoff > 0.1 && BoilerHeatInBTUpS < PreviousBoilerHeatOutBTUpS && FullMaxPressBoilerHeat)
3771+
// This allows for situation where boiler heat has gone beyond safety valve heat, and is reducing, but steam will be required shortly so don't allow fire to go too low
37653772
{
3766-
// burnrate will be the radiation loss @ rest & then related to heat usage as a factor of the maximum boiler output
3767-
// ignores total bolier heat to allow burn rate to increase if boiler heat usage is exceeding input
3768-
BurnRateRawKGpS = (W.ToKW(W.FromBTUpS(PreviousBoilerHeatOutBTUpS - BoilerHeatExceptionsBtupS)) / FuelCalorificKJpKG) * AIFiremanBurnFactorExceed;
3773+
// Burn Rate rate if Boiler Heat is too high
3774+
BurnRateRawKGpS = (W.ToKW(W.FromBTUpS(PreviousBoilerHeatOutBTUpS - BoilerHeatExceptionsBtupS)) / FuelCalorificKJpKG) * AIFiremanStartingBurnFactor; // Calculate the amount of coal that should be burnt based upon heat used by boiler
37693775
}
37703776
else
37713777
{
3772-
3773-
if (BoilerHeatBTU > MaxBoilerHeatBTU && BoilerHeatBTU <= MaxBoilerSafetyPressHeatBTU && throttle > 0.1 && cutoff > 0.1 && BoilerHeatInBTUpS < PreviousBoilerHeatOutBTUpS && FullMaxPressBoilerHeat)
3774-
// This allows for situation where boiler heat has gone beyond safety valve heat, and is reducing, but steam will be required shortly so don't allow fire to go too low
3775-
{
3776-
// Burn Rate rate if Boiler Heat is too high
3777-
BurnRateRawKGpS = (W.ToKW(W.FromBTUpS(PreviousBoilerHeatOutBTUpS - BoilerHeatExceptionsBtupS)) / FuelCalorificKJpKG) * AIFiremanStartingBurnFactor; // Calculate the amount of coal that should be burnt based upon heat used by boiler
3778-
}
3779-
else
3780-
{
3781-
// Burn Rate rate if Boiler Heat is "normal"
3782-
BurnRateRawKGpS = (W.ToKW(W.FromBTUpS(PreviousBoilerHeatOutBTUpS - BoilerHeatExceptionsBtupS)) / FuelCalorificKJpKG) * AIFiremanBurnFactor;
3783-
}
3778+
// Burn Rate rate if Boiler Heat is "normal"
3779+
BurnRateRawKGpS = (W.ToKW(W.FromBTUpS(PreviousBoilerHeatOutBTUpS - BoilerHeatExceptionsBtupS)) / FuelCalorificKJpKG) * AIFiremanBurnFactor;
37843780
}
3781+
}
37853782

3786-
// AIFireOverride flag set to challenge driver if boiler AI fireman is overriden - ie steam safety valves will be set and blow if pressure is excessive
3787-
if (SetFireOn || SetFireOff) // indicate that AI fireman override is in use
3788-
{
3789-
AIFireOverride = true; // Set whenever SetFireOn or SetFireOff are selected
3790-
}
3791-
else if (BoilerPressurePSI < MaxBoilerPressurePSI && BoilerHeatSmoothedBTU < MaxBoilerHeatBTU && BoilerHeatBTU < MaxBoilerSafetyPressHeatBTU)
3792-
{
3793-
AIFireOverride = false; // Reset if pressure and heat back to "normal"
3794-
}
3783+
// AIFireOverride flag set to challenge driver if boiler AI fireman is overriden - ie steam safety valves will be set and blow if pressure is excessive
3784+
if (SetFireOn || SetFireOff) // indicate that AI fireman override is in use
3785+
{
3786+
AIFireOverride = true; // Set whenever SetFireOn or SetFireOff are selected
3787+
}
3788+
else if (BoilerPressurePSI < MaxBoilerPressurePSI && BoilerHeatSmoothedBTU < MaxBoilerHeatBTU && BoilerHeatBTU < MaxBoilerSafetyPressHeatBTU)
3789+
{
3790+
AIFireOverride = false; // Reset if pressure and heat back to "normal"
3791+
}
37953792

3796-
if (SetFireReset) // Check FireReset Override command - resets fireoff and fireon override
3797-
{
3798-
SetFireOff = false;
3799-
SetFireOn = false;
3800-
SetFireReset = false;
3801-
}
3793+
if (SetFireReset) // Check FireReset Override command - resets fireoff and fireon override
3794+
{
3795+
SetFireOff = false;
3796+
SetFireOn = false;
3797+
SetFireReset = false;
3798+
}
38023799

3803-
// Check FireOff Override command - allows player to force fire low in preparation for a station stop
3804-
if (SetFireOff)
3800+
// Check FireOff Override command - allows player to force fire low in preparation for a station stop
3801+
if (SetFireOff)
3802+
{
3803+
if (BoilerPressurePSI < MaxBoilerPressurePSI - 20.0f || BoilerHeatSmoothedBTU < 0.90f || (absSpeedMpS < 0.01f && throttle < 0.01f))
38053804
{
3806-
if (BoilerPressurePSI < MaxBoilerPressurePSI - 20.0f || BoilerHeatSmoothedBTU < 0.90f || (absSpeedMpS < 0.01f && throttle < 0.01f))
3807-
{
3808-
SetFireOff = false; // Disable FireOff if bolierpressure too low
3809-
}
3810-
3811-
BurnRateRawKGpS = 0.0035f;
3805+
SetFireOff = false; // Disable FireOff if bolierpressure too low
38123806
}
38133807

3814-
// Check FireOn Override command - allows player to force the fire up in preparation for a station departure
3815-
if (SetFireOn)
3808+
BurnRateRawKGpS = 0.0035f;
3809+
}
3810+
3811+
// Check FireOn Override command - allows player to force the fire up in preparation for a station departure
3812+
if (SetFireOn)
3813+
{
3814+
if ((BoilerHeatSmoothedBTU > 0.995f * MaxBoilerHeatBTU && absSpeedMpS > 10.0f) || BoilerPressurePSI > MaxBoilerPressurePSI || absSpeedMpS <= 10.0f && (BoilerHeatSmoothedBTU > MaxBoilerHeatBTU || BoilerHeatBTU > 1.1f * MaxBoilerSafetyPressHeatBTU))
38163815
{
3817-
if ((BoilerHeatSmoothedBTU > 0.995f * MaxBoilerHeatBTU && absSpeedMpS > 10.0f) || BoilerPressurePSI > MaxBoilerPressurePSI || absSpeedMpS <= 10.0f && (BoilerHeatSmoothedBTU > MaxBoilerHeatBTU || BoilerHeatBTU > 1.1f * MaxBoilerSafetyPressHeatBTU))
3818-
{
3819-
SetFireOn = false; // Disable FireOn if bolierpressure and boilerheat back to "normal"
3820-
}
3821-
BurnRateRawKGpS = 0.9f * pS.FrompH(Kg.FromLb(NewBurnRateSteamToCoalLbspH[pS.TopH(TheoreticalMaxSteamOutputLBpS)])); // AI fire on goes to approx 100% of fire needed to maintain full boiler steam generation
3816+
SetFireOn = false; // Disable FireOn if bolierpressure and boilerheat back to "normal"
38223817
}
3818+
BurnRateRawKGpS = 0.9f * pS.FrompH(Kg.FromLb(NewBurnRateSteamToCoalLbspH[pS.TopH(TheoreticalMaxSteamOutputLBpS)])); // AI fire on goes to approx 100% of fire needed to maintain full boiler steam generation
38233819
}
38243820
}
38253821

@@ -3877,7 +3873,7 @@ private void UpdateFirebox(float elapsedClockSeconds, float absSpeedMpS)
38773873
{
38783874
BurnRateRawKGpS = 0.0f; // Drop fire due to melting of fusible plug and steam quenching fire, change later to allow graduate ramp down.
38793875
}
3880-
3876+
38813877
if (SteamLocomotiveFuelType == SteamLocomotiveFuelTypes.Oil)
38823878
{
38833879
var oilburnrate = BurnRateRawKGpS;
@@ -3887,10 +3883,23 @@ private void UpdateFirebox(float elapsedClockSeconds, float absSpeedMpS)
38873883
oilburnrate = MaxFiringRateKGpS; // burning rate can never be more then the max firing rate
38883884
}
38893885

3890-
// OilBurnRateSmoothKGpS.ForceSmoothValue(oilburnrate);
3891-
3886+
OilBurnRateReductionSmoothKGpS.Update(elapsedClockSeconds, oilburnrate);
38923887
OilBurnRateSmoothKGpS.Update(elapsedClockSeconds, oilburnrate);
3893-
FuelBurnRateSmoothedKGpS = OilBurnRateSmoothKGpS.SmoothedValue;
3888+
3889+
if (previousThrottle < throttle)
3890+
{
3891+
// Fire combustion drops rapidly if throttle closed (assume fuel feed is reduced rapidly)
3892+
FuelBurnRateSmoothedKGpS = OilBurnRateReductionSmoothKGpS.SmoothedValue;
3893+
OilBurnRateSmoothKGpS.ForceSmoothValue(oilburnrate);
3894+
}
3895+
else
3896+
{
3897+
// Fire combustion is normal
3898+
FuelBurnRateSmoothedKGpS = OilBurnRateSmoothKGpS.SmoothedValue;
3899+
}
3900+
3901+
previousThrottle = throttle;
3902+
38943903
}
38953904
else
38963905
{

0 commit comments

Comments
 (0)