Skip to content

Commit d3722cd

Browse files
committed
Adjust injector operation
1 parent 5d1572f commit d3722cd

File tree

1 file changed

+77
-77
lines changed

1 file changed

+77
-77
lines changed

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

Lines changed: 77 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,34 @@ public override void Initialize()
14611461

14621462
CylinderSteamUsageLBpS = 1.0f; // Set to 1 to ensure that there are no divide by zero errors
14631463

1464+
if (BoilerEvapRateLbspFt2 == 0) // If boiler evaporation rate is not in ENG file then set a default value
1465+
{
1466+
if (SteamLocomotiveFuelType == SteamLocomotiveFuelTypes.Wood)
1467+
{
1468+
BoilerEvapRateLbspFt2 = 11.5f; // Default rate for evaporation rate. Assume a default rate of 12 lbs/sqft of evaporation area
1469+
}
1470+
else if (SteamLocomotiveFuelType == SteamLocomotiveFuelTypes.Oil)
1471+
{
1472+
BoilerEvapRateLbspFt2 = 18.0f; // Default rate for evaporation rate. Assume a default rate of 18 lbs/sqft of evaporation area
1473+
}
1474+
else
1475+
{
1476+
BoilerEvapRateLbspFt2 = 15.0f; // Default rate for evaporation rate. Assume a default rate of 15 lbs/sqft of evaporation area
1477+
}
1478+
}
1479+
BoilerEvapRateLbspFt2 = MathHelper.Clamp(BoilerEvapRateLbspFt2, 7.5f, 30.0f); // Clamp BoilerEvap Rate to between 7.5 & 30 - some modern locomotives can go as high as 30, but majority are around 15.
1480+
TheoreticalMaxSteamOutputLBpS = pS.FrompH(Me2.ToFt2(EvaporationAreaM2) * BoilerEvapRateLbspFt2); // set max boiler theoretical steam output
1481+
1482+
float BoilerVolumeCheck = Me2.ToFt2(EvaporationAreaM2) / BoilerVolumeFT3; //Calculate the Boiler Volume Check value.
1483+
if (BoilerVolumeCheck > 15) // If boiler volume is not in ENG file or less then a viable figure (ie high ratio figure), then set to a default value
1484+
{
1485+
BoilerVolumeFT3 = Me2.ToFt2(EvaporationAreaM2) / 8.3f; // Default rate for evaporation rate. Assume a default ratio of evaporation area * 1/8.3
1486+
// Advise player that Boiler Volume is missing from or incorrect in ENG file
1487+
if (Simulator.Settings.VerboseConfigurationMessages)
1488+
Trace.TraceWarning("Boiler Volume not found in ENG file, or doesn't appear to be a valid figure, and has been set to {0} Ft^3", BoilerVolumeFT3);
1489+
}
1490+
1491+
14641492
// Set up boiler water defaults
14651493

14661494
// Water Gauge Length - always use OR entered value as first preference
@@ -1469,11 +1497,46 @@ public override void Initialize()
14691497
// Boiler Length - always use OR entered value as first preference
14701498
BoilerLengthM = ORBoilerLengthM;
14711499

1500+
// If OR value hasn't been set, then use MSTS value if present
1501+
if (BoilerLengthM == 0 && MSTSBoilerLengthM > 0)
1502+
{
1503+
if (MSTSBoilerLengthM > 0.4f * CarLengthM && MSTSBoilerLengthM < CarLengthM) // Check validity of MSTS value
1504+
{
1505+
BoilerLengthM = MSTSBoilerLengthM;
1506+
}
1507+
else
1508+
{
1509+
BoilerLengthM = Me.FromFt(20.0f); // limit default boiler length to 20 ft
1510+
}
1511+
1512+
if (Simulator.Settings.VerboseConfigurationMessages)
1513+
{
1514+
Trace.TraceInformation("Boiler Length set as per MSTS default = {0}", FormatStrings.FormatDistance(BoilerLengthM, IsMetric));
1515+
}
1516+
}
1517+
else if (BoilerLengthM == 0 && MSTSBoilerLengthM == 0)
1518+
{
1519+
if (HasTenderCoupled)
1520+
{
1521+
BoilerLengthM = 0.48f * CarLengthM; // Set default boiler length for tank locomotives
1522+
}
1523+
else
1524+
{
1525+
BoilerLengthM = 0.6f * CarLengthM; // Set default boiler length for tender locomotives
1526+
}
1527+
1528+
if (Simulator.Settings.VerboseConfigurationMessages)
1529+
{
1530+
Trace.TraceInformation("Boiler Length set to default = {0}", FormatStrings.FormatDistance(BoilerLengthM, IsMetric));
1531+
}
1532+
}
1533+
14721534
if (BoilerDiameterM == 0)
14731535
{
1474-
BoilerDiameterM = Me.FromFt(6.0f); // Set default boiler diameter to 6 ft
1536+
BoilerDiameterM = 3.3f * (float)Math.Sqrt(Me3.FromFt3(BoilerVolumeFT3) / (float)(Math.PI * BoilerLengthM)); // Set default boiler diameter based upon boiler volume and length
1537+
14751538
if (Simulator.Settings.VerboseConfigurationMessages)
1476-
Trace.TraceWarning("Boiler Diameter not found in ENG file and has been set to {0}", FormatStrings.FormatDistance(BoilerDiameterM, IsMetric)); // Advise player that Boiler Diameter is missing from ENG file
1539+
Trace.TraceWarning("Boiler Diameter not found in ENG file and has been set to {0}", FormatStrings.FormatDistance(BoilerDiameterM, IsMetric));
14771540
}
14781541

14791542
// Water model - locomotive boilers require water level to be maintained above the firebox crown sheet
@@ -1492,37 +1555,10 @@ public override void Initialize()
14921555
{
14931556
BoilerCrownCoverageHeightM = Me.FromIn(3.0f); // Set default crown coverage height to 3"
14941557
if (Simulator.Settings.VerboseConfigurationMessages)
1495-
Trace.TraceWarning("Boiler Crown Coverage Height not found in ENG file and has been set to {0}", FormatStrings.FormatVeryShortDistanceDisplay(BoilerCrownCoverageHeightM, IsMetric)); // Advise player that Boiler Crown Coverage Height is missing from ENG file
1558+
Trace.TraceWarning("Boiler Crown Coverage Height not found in ENG file and has been set to {0}", FormatStrings.FormatVeryShortDistanceDisplay(BoilerCrownCoverageHeightM, IsMetric));
14961559
}
14971560

1498-
// Initialise Boiler parameters
1499-
1500-
// If OR value hasn't been set, then use MSTS value if present
1501-
if (BoilerLengthM == 0 && MSTSBoilerLengthM > 0)
1502-
{
1503-
if (MSTSBoilerLengthM > 0.4f * CarLengthM && MSTSBoilerLengthM < CarLengthM)
1504-
{
1505-
BoilerLengthM = MSTSBoilerLengthM;
1506-
}
1507-
else
1508-
{
1509-
BoilerLengthM = Me.FromFt(20.0f); // Set default boiler length to 20 ft
1510-
}
1511-
1512-
if (Simulator.Settings.VerboseConfigurationMessages)
1513-
{
1514-
Trace.TraceInformation("Boiler Length set as per MSTS default = {0}", FormatStrings.FormatDistance(BoilerLengthM, IsMetric));
1515-
}
1516-
}
1517-
else if (BoilerLengthM == 0 && MSTSBoilerLengthM == 0)
1518-
{
1519-
BoilerLengthM = Me.FromFt(20.0f); // Set default boiler length to 20 ft
1520-
1521-
if (Simulator.Settings.VerboseConfigurationMessages)
1522-
{
1523-
Trace.TraceInformation("Boiler Length set to default = {0}", FormatStrings.FormatDistance(BoilerLengthM, IsMetric));
1524-
}
1525-
}
1561+
// Initialise Boiler parameters, if not found in Eng file
15261562

15271563
// If OR value hasn't been set, then use MSTS value if present
15281564
if (WaterGlassLengthM == 0 && MSTSSteamGaugeGlassHeightM > 0 && MSTSSteamGaugeGlassHeightM < Me.FromIn(12))
@@ -1569,34 +1605,6 @@ public override void Initialize()
15691605

15701606
float MaxWaterFraction = BoilerWaterFractionAbs; // Initialise the max water fraction when the boiler starts
15711607

1572-
if (BoilerEvapRateLbspFt2 == 0) // If boiler evaporation rate is not in ENG file then set a default value
1573-
{
1574-
if (SteamLocomotiveFuelType == SteamLocomotiveFuelTypes.Wood)
1575-
{
1576-
BoilerEvapRateLbspFt2 = 11.5f; // Default rate for evaporation rate. Assume a default rate of 12 lbs/sqft of evaporation area
1577-
}
1578-
else if (SteamLocomotiveFuelType == SteamLocomotiveFuelTypes.Oil)
1579-
{
1580-
BoilerEvapRateLbspFt2 = 18.0f; // Default rate for evaporation rate. Assume a default rate of 18 lbs/sqft of evaporation area
1581-
}
1582-
else
1583-
{
1584-
BoilerEvapRateLbspFt2 = 15.0f; // Default rate for evaporation rate. Assume a default rate of 15 lbs/sqft of evaporation area
1585-
}
1586-
}
1587-
BoilerEvapRateLbspFt2 = MathHelper.Clamp(BoilerEvapRateLbspFt2, 7.5f, 30.0f); // Clamp BoilerEvap Rate to between 7.5 & 30 - some modern locomotives can go as high as 30, but majority are around 15.
1588-
TheoreticalMaxSteamOutputLBpS = pS.FrompH(Me2.ToFt2(EvaporationAreaM2) * BoilerEvapRateLbspFt2); // set max boiler theoretical steam output
1589-
1590-
float BoilerVolumeCheck = Me2.ToFt2(EvaporationAreaM2) / BoilerVolumeFT3; //Calculate the Boiler Volume Check value.
1591-
if (BoilerVolumeCheck > 15) // If boiler volume is not in ENG file or less then a viable figure (ie high ratio figure), then set to a default value
1592-
{
1593-
BoilerVolumeFT3 = Me2.ToFt2(EvaporationAreaM2) / 8.3f; // Default rate for evaporation rate. Assume a default ratio of evaporation area * 1/8.3
1594-
// Advise player that Boiler Volume is missing from or incorrect in ENG file
1595-
if (Simulator.Settings.VerboseConfigurationMessages)
1596-
Trace.TraceWarning("Boiler Volume not found in ENG file, or doesn't appear to be a valid figure, and has been set to {0} Ft^3", BoilerVolumeFT3);
1597-
}
1598-
1599-
16001608
// Assign default steam table values if table not in ENG file
16011609
if (BoilerEfficiencyGrateAreaLBpFT2toX == null)
16021610
{
@@ -7269,7 +7277,7 @@ private void UpdateWaterInjection(float elapsedClockSeconds)
72697277
BoilerHeatOutBTUpS += WaterMotionPumpHeatLossBTU; // Total loss of boiler heat due to water injection - inject steam and water Heat
72707278

72717279
// Update pump lockout timer
7272-
if (WaterMotionPump1IsOn || WaterMotionPump2IsOn)
7280+
if (WaterMotionPump1IsOn || WaterMotionPump2IsOn || WaterMotionPumpLockedOut)
72737281
{
72747282
if (WaterMotionPumpLockedOut)
72757283
{
@@ -7411,12 +7419,13 @@ private void UpdateWaterInjection(float elapsedClockSeconds)
74117419
}
74127420

74137421
// Update injector lockout timer
7414-
if (Injector1IsOn || Injector2IsOn)
7422+
if (Injector1IsOn || Injector2IsOn || InjectorLockedOut)
74157423
{
74167424
if (InjectorLockedOut)
74177425
{
74187426
InjectorLockOutTimeS += elapsedClockSeconds;
74197427
}
7428+
74207429
if (InjectorLockOutTimeS > InjectorLockOutResetTimeS)
74217430
{
74227431
InjectorLockedOut = false;
@@ -7520,7 +7529,7 @@ private void UpdateFiring(float absSpeedMpS)
75207529
StopInjector1Sound();
75217530
StopInjector2Sound();
75227531
}
7523-
else if (CurrentWaterGaugeFraction <= 0.55 && CurrentWaterGaugeFraction > 0.50 && !InjectorLockedOut) // turn injector 1 on 25% if water level in boiler drops between 0.5 and 0.55 water gauge
7532+
else if (CurrentWaterGaugeFraction <= 0.55 && CurrentWaterGaugeFraction > 0.525 && !InjectorLockedOut)
75247533
{
75257534
Injector1IsOn = true;
75267535
Injector1Fraction = 0.25f;
@@ -7529,7 +7538,7 @@ private void UpdateFiring(float absSpeedMpS)
75297538
InjectorLockedOut = true;
75307539
PlayInjector1SoundIfStarting();
75317540
}
7532-
else if (CurrentWaterGaugeFraction <= 0.50 && CurrentWaterGaugeFraction > 0.45 && !InjectorLockedOut) // turn injector 1 on 50% if water level in boiler drops between 0.5 and 0.45
7541+
else if (CurrentWaterGaugeFraction <= 0.525 && CurrentWaterGaugeFraction > 0.5 && !InjectorLockedOut)
75337542
{
75347543
Injector1IsOn = true;
75357544
Injector1Fraction = 0.5f;
@@ -7538,7 +7547,7 @@ private void UpdateFiring(float absSpeedMpS)
75387547
InjectorLockedOut = true;
75397548
PlayInjector1SoundIfStarting();
75407549
}
7541-
else if (CurrentWaterGaugeFraction <= 0.45 && CurrentWaterGaugeFraction > 0.40 && !InjectorLockedOut) // turn injector 1 on 100% if water level in boiler drops between 0.4 and 0.45
7550+
else if (CurrentWaterGaugeFraction <= 0.5 && CurrentWaterGaugeFraction > 0.475 && !InjectorLockedOut)
75427551
{
75437552
Injector1IsOn = true;
75447553
Injector1Fraction = 1.0f;
@@ -7549,7 +7558,7 @@ private void UpdateFiring(float absSpeedMpS)
75497558
}
75507559
else if (BoilerPressurePSI > (MaxBoilerPressurePSI - 100.0)) // If boiler pressure is not too low then turn on injector 2 as well
75517560
{
7552-
if (CurrentWaterGaugeFraction <= 0.40 && CurrentWaterGaugeFraction > 0.35 && !InjectorLockedOut)
7561+
if (CurrentWaterGaugeFraction <= 0.475 && CurrentWaterGaugeFraction > 0.45 && !InjectorLockedOut)
75537562
{
75547563

75557564
Injector1IsOn = true;
@@ -7559,7 +7568,7 @@ private void UpdateFiring(float absSpeedMpS)
75597568
InjectorLockedOut = true;
75607569
PlayInjector2SoundIfStarting();
75617570
}
7562-
else if (CurrentWaterGaugeFraction <= 0.35 && CurrentWaterGaugeFraction > 0.30 && !InjectorLockedOut)
7571+
else if (CurrentWaterGaugeFraction <= 0.45 && CurrentWaterGaugeFraction > 0.425 && !InjectorLockedOut)
75637572
{
75647573
Injector1IsOn = true;
75657574
Injector1Fraction = 1.0f;
@@ -7568,21 +7577,12 @@ private void UpdateFiring(float absSpeedMpS)
75687577
InjectorLockedOut = true;
75697578
PlayInjector2SoundIfStarting();
75707579
}
7571-
else if (CurrentWaterGaugeFraction <= 0.55 && CurrentWaterGaugeFraction > 0.5325 && !InjectorLockedOut)
7572-
{
7573-
Injector1IsOn = true;
7574-
Injector1Fraction = 1.0f;
7575-
Injector2IsOn = true;
7576-
Injector2Fraction = 0.3f;
7577-
InjectorLockedOut = true;
7578-
PlayInjector2SoundIfStarting();
7579-
}
7580-
else if (CurrentWaterGaugeFraction <= 0.5325 && CurrentWaterGaugeFraction > 0.525 && !InjectorLockedOut)
7580+
else if (CurrentWaterGaugeFraction <= 0.425 && !InjectorLockedOut)
75817581
{
75827582
Injector1IsOn = true;
75837583
Injector1Fraction = 1.0f;
75847584
Injector2IsOn = true;
7585-
Injector2Fraction = 0.4f;
7585+
Injector2Fraction = 1.0f;
75867586
InjectorLockedOut = true;
75877587
PlayInjector2SoundIfStarting();
75887588
}

0 commit comments

Comments
 (0)