Skip to content

Commit

Permalink
Automatic merge of T1.5.1-757-gef6c1a8c8 and 17 pull requests
Browse files Browse the repository at this point in the history
- Pull request #570 at 3539862: Experimental glTF 2.0 support with PBR lighting
- Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters
- Pull request #874 at f8dbeab: Dynamic brake controller refactoring
- Pull request #875 at 43bf33e: Bug fix for https://bugs.launchpad.net/or/+bug/2036346 Player train switching doesn't work with 3D cabs
- Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder
- Pull request #882 at a055bca: Blueprint/train car operations UI window
- Pull request #885 at c81447b: feat: Add notifications to Menu
- Pull request #886 at 1b88d7a: Scene viewer extension to TrackViewer
- Pull request #888 at b20b888: docs: Document player application model
- Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH
- Pull request #893 at bf8876b: Signal errors
- Pull request #894 at 5ff1e73: Correct Decrease Colour
- Pull request #896 at 5866028: First implementation of https://blueprints.launchpad.net/or/+spec/specific-sounds-for-ai-trains
- Pull request #897 at 0a9d939: feat: Improved system information collection
- Pull request #898 at e271395: Extra line with all the arguments for debugging purposes in logfile
- Pull request #899 at 28638b2: Duplex steam engines - Booster Engine addition
- Pull request #900 at 42ea7ad: DMI updates
  • Loading branch information
openrails-bot committed Dec 10, 2023
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 64 deletions.
127 changes: 63 additions & 64 deletions Source/Orts.Simulation/Simulation/RollingStocks/MSTSSteamLocomotive.cs
Expand Up @@ -1319,12 +1319,6 @@ public override void Initialize()
{
if (SteamEngines[i].AuxiliarySteamEngineType != SteamEngine.AuxiliarySteamEngineTypes.Booster)
{






if (SteamEngineType == SteamEngineTypes.Compound)
{
// Initialise Compound locomotive
Expand Down Expand Up @@ -2171,10 +2165,11 @@ public override void Update(float elapsedClockSeconds)
UpdateFirebox(elapsedClockSeconds, absSpeedMpS);
UpdateBoiler(elapsedClockSeconds);
UpdateAuxiliaries(elapsedClockSeconds, absSpeedMpS);

UpdateSuperHeat();

TractiveForceN = 0; // reset tractiveforceN in preparation to calculating a new value
MotiveForceN = 0;
CylinderSteamUsageLBpS = 0;

for (int i = 0; i < SteamEngines.Count; i++)
{
Expand Down Expand Up @@ -2214,7 +2209,7 @@ public override void Update(float elapsedClockSeconds)
{
SteamBoosterIdleMode = false;
SteamBoosterRunMode = true;
enginethrottle = 1.0f;
enginethrottle = throttle;
}
else if (!SteamBoosterAirOpen || !SteamBoosterLatchedLocked)
{
Expand All @@ -2231,6 +2226,7 @@ public override void Update(float elapsedClockSeconds)
TotalSteamUsageLBpS += SteamEngines[i].CylinderSteamUsageLBpS;
BoilerHeatOutBTUpS += SteamEngines[i].CylinderSteamUsageLBpS * (BoilerSteamHeatBTUpLB - BoilerWaterHeatBTUpLB);
CumulativeCylinderSteamConsumptionLbs += SteamEngines[i].CylinderSteamUsageLBpS * elapsedClockSeconds;
CylinderSteamUsageLBpS += SteamEngines[i].CylinderSteamUsageLBpS;

SteamEngines[i].MeanEffectivePressurePSI = MeanEffectivePressurePSI;

Expand Down Expand Up @@ -3895,7 +3891,63 @@ private void ApplyBoilerPressure()
TotalSteamUsageLBpS = 0.0f;
}

private void UpdateCylinders(float elapsedClockSeconds, float throttle, float cutoff, float absSpeedMpS, int numberofengine)
private void UpdateSuperHeat()
{
// Determine if Superheater in use
if (HasSuperheater)
{
CurrentSuperheatTempF = SuperheatTempLbpHtoDegF[pS.TopH(CylinderSteamUsageLBpS)] * SuperheatTempRatio; // Calculate current superheat temp
CurrentSuperheatTempF = MathHelper.Clamp(CurrentSuperheatTempF, 0.0f, MaxSuperheatRefTempF); // make sure that superheat temp does not exceed max superheat temp or drop below zero
float CylinderCondensationSpeedFactor = 1.0f - 0.00214f * pS.TopM(DrvWheelRevRpS); // This provides a speed related factor which reduces the amount of superheating required to overcome
// initial condensation, ie allows for condensation reduction as more steam goes through the cylinder as speed increases and the cylinder gets hotter
CylinderCondensationSpeedFactor = MathHelper.Clamp(CylinderCondensationSpeedFactor, 0.25f, 1.0f); // make sure that speed factor does not go out of bounds
float DifferenceSuperheatTeampF = CurrentSuperheatTempF - (SuperheatTempLimitXtoDegF[cutoff] * CylinderCondensationSpeedFactor); // reduce superheat temp due to cylinder condensation
SuperheatVolumeRatio = 1.0f + (0.0015f * DifferenceSuperheatTeampF); // Based on formula Vsup = Vsat ( 1 + 0.0015 Tsup) - Tsup temperature at superheated level
// look ahead to see what impact superheat will have on cylinder usage
float FutureCylinderSteamUsageLBpS = CylinderSteamUsageLBpS * 1.0f / SuperheatVolumeRatio; // Calculate potential future new cylinder steam usage
float FutureSuperheatTempF = SuperheatTempLbpHtoDegF[pS.TopH(FutureCylinderSteamUsageLBpS)] * SuperheatTempRatio; // Calculate potential future new superheat temp

float SuperheatTempThresholdXtoDegF = SuperheatTempLimitXtoDegF[cutoff] - 25.0f; // 10 deg bandwith reduction to reset superheat flag

if (CurrentSuperheatTempF > SuperheatTempLimitXtoDegF[cutoff] * CylinderCondensationSpeedFactor)
{
IsSuperSet = true; // Set to use superheat factor if above superheat temp threshold
}
else if (FutureSuperheatTempF < SuperheatTempThresholdXtoDegF * CylinderCondensationSpeedFactor)
{
IsSuperSet = false; // Reset if superheat temp drops
}

if (IsSuperSet)
{
SuperheaterSteamUsageFactor = 1.0f / SuperheatVolumeRatio; // set steam usage based upon the volume of superheated steam
}
else // Superheated locomotive, but superheat temp limit has not been reached.
{
CylinderCondensationFactor = CylinderCondensationFractionX[cutoff];

float CondensationFactorTemp = 1.0f + (CylinderCondensationFactor); // Calculate correcting factor for steam use due to compensation
float TempCondensationFactor = CondensationFactorTemp - 1.0f;
float SuperHeatMultiplier = (1.0f - (CurrentSuperheatTempF / SuperheatTempLimitXtoDegF[cutoff])) * TempCondensationFactor;
SuperHeatMultiplier = MathHelper.Clamp(SuperHeatMultiplier, 0.0f, SuperHeatMultiplier);
float SuperHeatFactorFinal = 1.0f + SuperHeatMultiplier;
SuperheaterSteamUsageFactor = SuperHeatFactorFinal;
SuperheaterSteamUsageFactor = MathHelper.Clamp(SuperheaterSteamUsageFactor, 0.0f, 1.0f); // In saturated mode steam usage should not be reduced
}
}
else // Saturated steam locomotive
{
CylinderCondensationFactor = CylinderCondensationFractionX[cutoff];
float CondensationFactorTemp = 1.0f + (CylinderCondensationFactor); // Calculate correcting factor for steam use due to compensation
SuperheaterSteamUsageFactor = CondensationFactorTemp;
// SuperheaterSteamUsageFactor = 1.0f; // Steam input to cylinder, but loses effectiveness. In saturated mode steam usage should not be reduced
}

SuperheaterSteamUsageFactor = MathHelper.Clamp(SuperheaterSteamUsageFactor, 0.60f, SuperheaterSteamUsageFactor); // ensure factor does not go below 0.6, as this represents base steam consumption by the cylinders.

}

private void UpdateCylinders(float elapsedClockSeconds, float throttle, float cutoff, float absSpeedMpS, int numberofengine)
{
// Calculate speed of locomotive in wheel rpm - used to determine changes in performance based upon speed.
DrvWheelRevRpS = absSpeedMpS / (2.0f * MathHelper.Pi * SteamEngines[numberofengine].AttachedAxle.WheelRadiusM);
Expand Down Expand Up @@ -4678,7 +4730,6 @@ private void UpdateCylinders(float elapsedClockSeconds, float throttle, float cu
CutoffPressureDropRatio = (1.0f - ((1 / SuperheatCutoffPressureFactor) * (float)Math.Sqrt(pS.TopM(DrvWheelRevRpS * MotiveForceGearRatio))));
}


// (b) - Cutoff Pressure
SteamEngines[numberofengine].Pressure_b_AtmPSI = SteamEngines[numberofengine].Pressure_a_AtmPSI * CutoffPressureDropRatio;

Expand Down Expand Up @@ -4818,58 +4869,6 @@ private void UpdateCylinders(float elapsedClockSeconds, float throttle, float cu
}

#endregion
// Determine if Superheater in use
if (HasSuperheater)
{
CurrentSuperheatTempF = SuperheatTempLbpHtoDegF[pS.TopH(CylinderSteamUsageLBpS)] * SuperheatTempRatio; // Calculate current superheat temp
CurrentSuperheatTempF = MathHelper.Clamp(CurrentSuperheatTempF, 0.0f, MaxSuperheatRefTempF); // make sure that superheat temp does not exceed max superheat temp or drop below zero
float CylinderCondensationSpeedFactor = 1.0f - 0.00214f * pS.TopM(DrvWheelRevRpS); // This provides a speed related factor which reduces the amount of superheating required to overcome
// initial condensation, ie allows for condensation reduction as more steam goes through the cylinder as speed increases and the cylinder gets hotter
CylinderCondensationSpeedFactor = MathHelper.Clamp(CylinderCondensationSpeedFactor, 0.25f, 1.0f); // make sure that speed factor does not go out of bounds
float DifferenceSuperheatTeampF = CurrentSuperheatTempF - (SuperheatTempLimitXtoDegF[cutoff] * CylinderCondensationSpeedFactor); // reduce superheat temp due to cylinder condensation
SuperheatVolumeRatio = 1.0f + (0.0015f * DifferenceSuperheatTeampF); // Based on formula Vsup = Vsat ( 1 + 0.0015 Tsup) - Tsup temperature at superheated level
// look ahead to see what impact superheat will have on cylinder usage
float FutureCylinderSteamUsageLBpS = CylinderSteamUsageLBpS * 1.0f / SuperheatVolumeRatio; // Calculate potential future new cylinder steam usage
float FutureSuperheatTempF = SuperheatTempLbpHtoDegF[pS.TopH(FutureCylinderSteamUsageLBpS)] * SuperheatTempRatio; // Calculate potential future new superheat temp

float SuperheatTempThresholdXtoDegF = SuperheatTempLimitXtoDegF[cutoff] - 25.0f; // 10 deg bandwith reduction to reset superheat flag

if (CurrentSuperheatTempF > SuperheatTempLimitXtoDegF[cutoff] * CylinderCondensationSpeedFactor)
{
IsSuperSet = true; // Set to use superheat factor if above superheat temp threshold
}
else if (FutureSuperheatTempF < SuperheatTempThresholdXtoDegF * CylinderCondensationSpeedFactor)
{
IsSuperSet = false; // Reset if superheat temp drops
}


if (IsSuperSet)
{
SuperheaterSteamUsageFactor = 1.0f / SuperheatVolumeRatio; // set steam usage based upon the volume of superheated steam
}
else // Superheated locomotive, but superheat temp limit has not been reached.
{
CylinderCondensationFactor = CylinderCondensationFractionX[cutoff];

float CondensationFactorTemp = 1.0f + (CylinderCondensationFactor); // Calculate correcting factor for steam use due to compensation
float TempCondensationFactor = CondensationFactorTemp - 1.0f;
float SuperHeatMultiplier = (1.0f - (CurrentSuperheatTempF / SuperheatTempLimitXtoDegF[cutoff])) * TempCondensationFactor;
SuperHeatMultiplier = MathHelper.Clamp(SuperHeatMultiplier, 0.0f, SuperHeatMultiplier);
float SuperHeatFactorFinal = 1.0f + SuperHeatMultiplier;
SuperheaterSteamUsageFactor = SuperHeatFactorFinal;
SuperheaterSteamUsageFactor = MathHelper.Clamp(SuperheaterSteamUsageFactor, 0.0f, 1.0f); // In saturated mode steam usage should not be reduced
}
}
else // Saturated steam locomotive
{
CylinderCondensationFactor = CylinderCondensationFractionX[cutoff];
float CondensationFactorTemp = 1.0f + (CylinderCondensationFactor); // Calculate correcting factor for steam use due to compensation
SuperheaterSteamUsageFactor = CondensationFactorTemp;
// SuperheaterSteamUsageFactor = 1.0f; // Steam input to cylinder, but loses effectiveness. In saturated mode steam usage should not be reduced
}

SuperheaterSteamUsageFactor = MathHelper.Clamp(SuperheaterSteamUsageFactor, 0.60f, SuperheaterSteamUsageFactor); // ensure factor does not go below 0.6, as this represents base steam consumption by the cylinders.

// mean pressure during stroke = ((absolute mean pressure + (clearance + cylstroke)) - (initial pressure + clearance)) / cylstroke
// Mean effective pressure = cylinderpressure - backpressure
Expand All @@ -4881,11 +4880,11 @@ private void UpdateCylinders(float elapsedClockSeconds, float throttle, float cu
{
if (HasSuperheater) // Superheated locomotive
{
CylCockPressReduceFactor = ((CylinderSteamUsageLBpS / SuperheaterSteamUsageFactor) / ((CylinderSteamUsageLBpS / SuperheaterSteamUsageFactor) + CylCockSteamUsageLBpS)); // For superheated locomotives temp convert back to a saturated comparison for calculation of steam cock reduction factor.
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.
}
else // Simple locomotive
{
CylCockPressReduceFactor = (CylinderSteamUsageLBpS / (CylinderSteamUsageLBpS + CylCockSteamUsageLBpS)); // Saturated steam locomotive
CylCockPressReduceFactor = (SteamEngines[numberofengine].CylinderSteamUsageLBpS / (SteamEngines[numberofengine].CylinderSteamUsageLBpS + SteamEngines[numberofengine].CylCockSteamUsageLBpS)); // Saturated steam locomotive
}

if (SteamEngineType == SteamEngineTypes.Compound)
Expand Down
Expand Up @@ -535,6 +535,11 @@ public enum AuxiliarySteamEngineTypes
/// </summary>
public float CylinderSteamUsageLBpS;

/// <summary>
/// Steam usage per steam engine steam cocks
/// </summary>
public float CylCockSteamUsageLBpS;

/// <summary>
/// Indicated Horse Power
/// </summary>
Expand Down

0 comments on commit cfc749d

Please sign in to comment.