Skip to content

Commit 2ae2e63

Browse files
committed
Correct operation of variable2
1 parent 04bd431 commit 2ae2e63

File tree

1 file changed

+51
-47
lines changed

1 file changed

+51
-47
lines changed

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

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5110,71 +5110,75 @@ private void UpdateCylinders(float elapsedClockSeconds, float throttle, float cu
51105110
// Cylinder pressure also reduced by steam vented through cylinder cocks.
51115111
CylCockPressReduceFactor = 1.0f;
51125112

5113-
if (CylinderCocksAreOpen && SteamEngines[numberofengine].AuxiliarySteamEngineType != SteamEngine.AuxiliarySteamEngineTypes.Booster)
5114-
// Don't apply steam cocks derate until Cylinder steam usage starts to work
5113+
if (SteamEngines[numberofengine].AuxiliarySteamEngineType != SteamEngine.AuxiliarySteamEngineTypes.Booster)
51155114
{
5116-
// The cock steam usage will be assumed equivalent to a steam orifice - it is initially updated ,and then recalculated again
5117-
// Steam Flow (lb/hr) = 24.24 x Press(Cylinder + Atmosphere(psi)) x CockDia^2 (in) - this needs to be multiplied by Num Cyls
51185115

5119-
if (throttle > 0.01 && absSpeedMpS > 0.1) // if regulator open & train moving
5120-
{
5121-
SteamEngines[numberofengine].CylCockSteamUsageLBpS = pS.FrompH(SteamEngines[numberofengine].NumberCylinders * (24.24f * (SteamEngines[numberofengine].CylinderCocksPressureAtmPSI) * CylCockDiaIN * CylCockDiaIN));
5122-
}
5123-
else if (throttle > 0.01 && absSpeedMpS <= 0.1) // if regulator open and train stationary
5124-
{
5125-
SteamEngines[numberofengine].CylCockSteamUsageLBpS = pS.FrompH(SteamEngines[numberofengine].NumberCylinders * (24.24f * (SteamEngines[numberofengine].Pressure_b_AtmPSI) * CylCockDiaIN * CylCockDiaIN));
5126-
}
5127-
else
5116+
if (CylinderCocksAreOpen)
5117+
// Don't apply steam cocks derate until Cylinder steam usage starts to work
51285118
{
5129-
SteamEngines[numberofengine].CylCockSteamUsageLBpS = 0;
5130-
}
5119+
// The cock steam usage will be assumed equivalent to a steam orifice - it is initially updated ,and then recalculated again
5120+
// Steam Flow (lb/hr) = 24.24 x Press(Cylinder + Atmosphere(psi)) x CockDia^2 (in) - this needs to be multiplied by Num Cyls
51315121

5132-
if (HasSuperheater) // Superheated locomotive
5133-
{
5134-
CylCockPressReduceFactor = ((SteamEngines[numberofengine].CylinderSteamUsageLBpS / SuperheaterSteamUsageFactor) / ((SteamEngines[numberofengine].CylinderSteamUsageLBpS / SuperheaterSteamUsageFactor) + SteamEngines[numberofengine].CylCockSteamUsageLBpS)); // For superheated locomotives temp convert back to a saturated comparison for calculation of steam cock reduction factor.
5135-
}
5136-
else // Simple locomotive
5137-
{
5138-
CylCockPressReduceFactor = (SteamEngines[numberofengine].CylinderSteamUsageLBpS / (SteamEngines[numberofengine].CylinderSteamUsageLBpS + SteamEngines[numberofengine].CylCockSteamUsageLBpS)); // Saturated steam locomotive
5139-
}
5122+
if (throttle > 0.01 && absSpeedMpS > 0.1) // if regulator open & train moving
5123+
{
5124+
SteamEngines[numberofengine].CylCockSteamUsageLBpS = pS.FrompH(SteamEngines[numberofengine].NumberCylinders * (24.24f * (SteamEngines[numberofengine].CylinderCocksPressureAtmPSI) * CylCockDiaIN * CylCockDiaIN));
5125+
}
5126+
else if (throttle > 0.01 && absSpeedMpS <= 0.1) // if regulator open and train stationary
5127+
{
5128+
SteamEngines[numberofengine].CylCockSteamUsageLBpS = pS.FrompH(SteamEngines[numberofengine].NumberCylinders * (24.24f * (SteamEngines[numberofengine].Pressure_b_AtmPSI) * CylCockDiaIN * CylCockDiaIN));
5129+
}
5130+
else
5131+
{
5132+
SteamEngines[numberofengine].CylCockSteamUsageLBpS = 0;
5133+
}
51405134

5141-
if (SteamEngineType == SteamEngineTypes.Compound)
5142-
{
5143-
if (CylinderCompoundOn) // Compound bypass valve open - simple mode for compound locomotive
5135+
if (HasSuperheater) // Superheated locomotive
51445136
{
5145-
SteamEngines[numberofengine].CylinderCocksPressureAtmPSI = SteamEngines[numberofengine].LPPressure_b_AtmPSI - (SteamEngines[numberofengine].LPPressure_b_AtmPSI * (1.0f - CylCockPressReduceFactor)); // Allow for pressure reduction due to Cylinder cocks being open.
5137+
CylCockPressReduceFactor = ((SteamEngines[numberofengine].CylinderSteamUsageLBpS / SuperheaterSteamUsageFactor) / ((SteamEngines[numberofengine].CylinderSteamUsageLBpS / SuperheaterSteamUsageFactor) + SteamEngines[numberofengine].CylCockSteamUsageLBpS)); // For superheated locomotives temp convert back to a saturated comparison for calculation of steam cock reduction factor.
51465138
}
5147-
else // Compound mode for compound locomotive
5139+
else // Simple locomotive
51485140
{
5149-
SteamEngines[numberofengine].CylinderCocksPressureAtmPSI = SteamEngines[numberofengine].HPCompPressure_b_AtmPSI - (SteamEngines[numberofengine].HPCompPressure_b_AtmPSI * (1.0f - CylCockPressReduceFactor)); // Allow for pressure reduction due to Cylinder cocks being open.
5141+
CylCockPressReduceFactor = (SteamEngines[numberofengine].CylinderSteamUsageLBpS / (SteamEngines[numberofengine].CylinderSteamUsageLBpS + SteamEngines[numberofengine].CylCockSteamUsageLBpS)); // Saturated steam locomotive
51505142
}
5151-
}
5152-
else // Simple locomotive
5153-
{
5154-
SteamEngines[numberofengine].CylinderCocksPressureAtmPSI = SteamEngines[numberofengine].Pressure_b_AtmPSI - (SteamEngines[numberofengine].Pressure_b_AtmPSI * (1.0f - CylCockPressReduceFactor)); // Allow for pressure reduction due to Cylinder cocks being open.
5155-
}
5156-
}
5157-
else if (SteamEngines[numberofengine].AuxiliarySteamEngineType != SteamEngine.AuxiliarySteamEngineTypes.Booster)
5158-
// Cylinder cocks closed, put back to normal
5159-
{
5160-
if (SteamEngineType == SteamEngineTypes.Compound)
5161-
{
5162-
if (CylinderCompoundOn) // simple mode for compound locomotive
5143+
5144+
if (SteamEngineType == SteamEngineTypes.Compound)
51635145
{
5164-
SteamEngines[numberofengine].CylinderCocksPressureAtmPSI = SteamEngines[numberofengine].LPPressure_b_AtmPSI;
5146+
if (CylinderCompoundOn) // Compound bypass valve open - simple mode for compound locomotive
5147+
{
5148+
SteamEngines[numberofengine].CylinderCocksPressureAtmPSI = SteamEngines[numberofengine].LPPressure_b_AtmPSI - (SteamEngines[numberofengine].LPPressure_b_AtmPSI * (1.0f - CylCockPressReduceFactor)); // Allow for pressure reduction due to Cylinder cocks being open.
5149+
}
5150+
else // Compound mode for compound locomotive
5151+
{
5152+
SteamEngines[numberofengine].CylinderCocksPressureAtmPSI = SteamEngines[numberofengine].HPCompPressure_b_AtmPSI - (SteamEngines[numberofengine].HPCompPressure_b_AtmPSI * (1.0f - CylCockPressReduceFactor)); // Allow for pressure reduction due to Cylinder cocks being open.
5153+
}
51655154
}
5166-
else // Compound mode for compound locomotive
5155+
else // Simple locomotive
51675156
{
5168-
SteamEngines[numberofengine].CylinderCocksPressureAtmPSI = SteamEngines[numberofengine].HPCompPressure_b_AtmPSI;
5157+
SteamEngines[numberofengine].CylinderCocksPressureAtmPSI = SteamEngines[numberofengine].Pressure_b_AtmPSI - (SteamEngines[numberofengine].Pressure_b_AtmPSI * (1.0f - CylCockPressReduceFactor)); // Allow for pressure reduction due to Cylinder cocks being open.
51695158
}
51705159
}
5171-
else // Simple locomotive
5160+
else
5161+
// Cylinder cocks closed, put back to normal
51725162
{
5173-
SteamEngines[numberofengine].CylinderCocksPressureAtmPSI = SteamEngines[numberofengine].Pressure_b_AtmPSI;
5163+
if (SteamEngineType == SteamEngineTypes.Compound)
5164+
{
5165+
if (CylinderCompoundOn) // simple mode for compound locomotive
5166+
{
5167+
SteamEngines[numberofengine].CylinderCocksPressureAtmPSI = SteamEngines[numberofengine].LPPressure_b_AtmPSI;
5168+
}
5169+
else // Compound mode for compound locomotive
5170+
{
5171+
SteamEngines[numberofengine].CylinderCocksPressureAtmPSI = SteamEngines[numberofengine].HPCompPressure_b_AtmPSI;
5172+
}
5173+
}
5174+
else // Simple locomotive
5175+
{
5176+
SteamEngines[numberofengine].CylinderCocksPressureAtmPSI = SteamEngines[numberofengine].Pressure_b_AtmPSI;
5177+
}
51745178
}
51755179
}
51765180

5177-
SteamEngines[numberofengine].CylinderCocksPressureAtmPSI = MathHelper.Clamp(CylinderCocksPressureAtmPSI, 0, MaxBoilerPressurePSI + OneAtmospherePSI); // Make sure that Cylinder pressure does not go negative
5181+
SteamEngines[numberofengine].CylinderCocksPressureAtmPSI = MathHelper.Clamp(SteamEngines[numberofengine].CylinderCocksPressureAtmPSI, 0, MaxBoilerPressurePSI + OneAtmospherePSI); // Make sure that Cylinder pressure does not go negative
51785182

51795183
CylinderCocksPressurePSI = SteamEngines[numberofengine].Pressure_b_AtmPSI - OneAtmospherePSI; // no longer used????
51805184

0 commit comments

Comments
 (0)