Skip to content

Commit 6dd0947

Browse files
authored
Merge pull request #1141 from openrails/release/1.6
Merge pull request #1132 from SteelFill/correct_questionable_leaks
2 parents 63aebcd + e6e9aa3 commit 6dd0947

File tree

6 files changed

+38
-43
lines changed

6 files changed

+38
-43
lines changed

Source/Documentation/Manual/options.rst

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -863,21 +863,23 @@ are a problem for OR, which has a more sophisticated braking model. The
863863
problem usually is that the train brakes require a long time to release,
864864
and in some times do not release at all.
865865

866-
.. index::
867-
single: AirBrakesAirCompressorPowerRating
868-
869866
The following checks and corrections are performed if the option is
870-
checked (only for single-pipe brake system):
867+
checked:
871868

872869
- if the compressor restart pressure is smaller or very near to the max
873870
system pressure, the compressor restart pressure and if necessary the max
874-
main reservoir pressure are increased;
871+
main reservoir pressure are increased (single pipe air brakes only)
875872
- if the main reservoir volume is smaller than 0.3 m\ :sup:`3` and the
876873
engine mass is higher than 20 tons, the reservoir volume is raised to 0.78
877-
m\ :sup:`3`;
878-
- the charging rate of the reservoir is derived from the .eng parameter
879-
``AirBrakesAirCompressorPowerRating`` (if this generates a value greater
880-
than 0.5 psi/s) instead of using a default value.
874+
m\ :sup:`3`
875+
- the maximum brake cylinder pressure will be reduced to the maximum pressure
876+
possible from a full service train brake application if it was set above this
877+
amount
878+
- any brake pipe leakage specified by ``TrainPipeLeakRate`` is limited to 2.5 psi/minute
879+
- the dynamic brake delay on electric locomotives is reduced to 2 seconds
880+
if it was defined to be above 4 seconds
881+
- dynamic brake force left at the default value of 20kN will be increased to
882+
half the locomotive's continuous force, or 150kN, whichever is lower
881883

882884
For a full list of parameters, see :ref:`Developing ORTS Content - Parameters and Tokens<parameters_and_tokens>`
883885

Source/Orts.Formats.Msts/CabViewFile.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,9 +1150,10 @@ public CVCDiscrete(STFReader stf, string basepath, DiscreteStates discreteState)
11501150
if (Positions.Count > 0 && Positions[0] > Positions[Positions.Count - 1])
11511151
{
11521152
Reversed ^= true;
1153+
int maxPos = Positions.Max();
11531154
// Recalculate positions in reverse
11541155
for (int i = 0; i < Positions.Count; i++)
1155-
Positions[i] = (FramesCount - 1) - Positions[i];
1156+
Positions[i] = maxPos - Positions[i];
11561157
}
11571158

11581159
// Check if eligible for filling

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ public float OdometerM
389389
public float CompressorRestartPressurePSI = 110;
390390
public float CompressorChargingRateM3pS = 0.075f;
391391
public bool CompressorIsMUControlled = false;
392-
public float MainResChargingRatePSIpS = 0.4f;
392+
public float MainResChargingRatePSIpS = -1.0f;
393393
public float EngineBrakeReleaseRatePSIpS = 12.5f;
394394
public float EngineBrakeApplyRatePSIpS = 12.5f;
395395
public float BrakePipeTimeFactorS = 0.0015f;
@@ -1875,21 +1875,6 @@ public override void Initialize()
18751875
}
18761876
}
18771877

1878-
// Initialise Train Pipe Leak Rate
1879-
if (TrainBrakePipeLeakPSIorInHgpS == 0) // Check to see if TrainBrakePipeLeakPSIorInHgpS has been set in the ENG file.
1880-
{
1881-
// Set Default Train Brake Pipe Leak depending upon whether locomotive has Vacuum or air brakes - overwritten by ENG file setting.
1882-
// Default currently set to zero - means that by default function is off, and a value must be entered into the ENG file to get it to work
1883-
if ((BrakeSystem is VacuumSinglePipe))
1884-
{
1885-
TrainBrakePipeLeakPSIorInHgpS = 0.0f; // Vacuum brakes
1886-
}
1887-
else
1888-
{
1889-
TrainBrakePipeLeakPSIorInHgpS = 0.0f; // Air brakes
1890-
}
1891-
}
1892-
18931878
if (DynamicBrakeEngineBrakeReplacement && DynamicBrakeEngineBrakeReplacementSpeed == 0)
18941879
{
18951880
DynamicBrakeEngineBrakeReplacementSpeed = DynamicBrakeSpeed2MpS;
@@ -2011,16 +1996,18 @@ protected void CorrectBrakingParams()
20111996
// correct questionable MaxCylPressurePSI
20121997
BrakeSystem.CorrectMaxCylPressurePSI(this);
20131998
}
2014-
if (MainResChargingRatePSIpS <= 0)
2015-
{
2016-
MainResChargingRatePSIpS = Math.Max(0.5f, (CompressorChargingRateM3pS * Bar.ToPSI(1)) / MainResVolumeM3);
2017-
}
1999+
// Limit brake pipe leak to 2.5 psi/min (~ 1 bar every 6 minutes) to prevent stuck brakes
2000+
if (TrainBrakePipeLeakPSIorInHgpS > 2.5f / 60f)
2001+
TrainBrakePipeLeakPSIorInHgpS = 2.5f / 60f;
2002+
}
2003+
// No OR compressor speed defined, use MSTS compressor speed or 0.025 m^3/s (whichever is higher)
2004+
if (MainResChargingRatePSIpS < 0)
2005+
{
2006+
MainResChargingRatePSIpS = Math.Max(0.025f, CompressorChargingRateM3pS) * OneAtmospherePSI / MainResVolumeM3;
20182007
}
2019-
else if (MainResChargingRatePSIpS <= 0) MainResChargingRatePSIpS = 0.4f;
20202008

20212009
// Corrections for dynamic braking parameters
20222010

2023-
if (this is MSTSElectricLocomotive && DynamicBrakeDelayS > 4) DynamicBrakeDelayS = 2; // Electric locomotives have short engaging delays
20242011
if (DynamicBrakeSpeed2MpS > 0 && DynamicBrakeSpeed3MpS > 0 && DynamicBrakeSpeed2MpS > DynamicBrakeSpeed3MpS)
20252012
{
20262013
// also exchanging DynamicBrakesMaximumEffectiveSpeed with DynamicBrakesFadingSpeed is a frequent error that upsets operation of
@@ -2031,8 +2018,11 @@ protected void CorrectBrakingParams()
20312018
}
20322019
if (Simulator.Settings.CorrectQuestionableBrakingParams)
20332020
{
2021+
if (this is MSTSElectricLocomotive && DynamicBrakeDelayS > 4)
2022+
DynamicBrakeDelayS = 2; // Electric locomotives have short engaging delays
2023+
20342024
if (MaxDynamicBrakeForceN > 0 && MaxContinuousForceN > 0 &&
2035-
(MaxDynamicBrakeForceN / MaxContinuousForceN < 0.3f && MaxDynamicBrakeForceN == 20000))
2025+
(MaxDynamicBrakeForceN / MaxContinuousForceN < 0.3f && MaxDynamicBrakeForceN == 20000))
20362026
MaxDynamicBrakeForceN = Math.Min (MaxContinuousForceN * 0.5f, 150000); // 20000 is suggested as standard value in the MSTS documentation, but in general it is a too low value
20372027
}
20382028
}
@@ -4222,7 +4212,7 @@ public void StartThrottleToZero(float? target)
42224212
/// Returns the position of the throttle handle considering
42234213
/// whether it is used for cruise control or not
42244214
/// </summary>
4225-
/// <param name="intermediateValue">Whather asking for intermediate (for mouse operation) or notched (for displaying) value.</param>
4215+
/// <param name="intermediateValue">Whether asking for intermediate (for mouse operation) or notched (for displaying) value.</param>
42264216
/// <returns>Position into 0-1 range</returns>
42274217
public float GetThrottleHandleValue(bool intermediateValue)
42284218
{
@@ -4234,7 +4224,7 @@ public float GetThrottleHandleValue(bool intermediateValue)
42344224
if (CruiseControl?.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto && CruiseControl.UseThrottleAsSpeedSelector)
42354225
return CruiseControl.SelectedSpeedMpS / MaxSpeedMpS;
42364226

4237-
return intermediateValue ? ThrottleController.CurrentValue : ThrottleController.IntermediateValue;
4227+
return intermediateValue ? ThrottleController.IntermediateValue : ThrottleController.CurrentValue;
42384228
}
42394229

42404230
#endregion

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/Brakes/MSTS/AirSinglePipe.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2171,7 +2171,7 @@ protected static void PropagateBrakeLinePressures(float elapsedClockSeconds, Tra
21712171
float supplyPressure = locoAirSystem.SupplyReservoirPresent ? locoAirSystem.SupplyResPressurePSI : loco.MainResPressurePSI; // Pressure of reservoir used for brake pipe charging
21722172

21732173
if (supplyPressure - locoAirSystem.BrakeLine1PressurePSI < 15.0f) // Reduce recharge rate if near MR pressure as per reality
2174-
PressureDiffEqualToPipePSI *= MathHelper.Lerp(0, 1.0f, (supplyPressure - train.EqualReservoirPressurePSIorInHg) / 15.0f);
2174+
PressureDiffEqualToPipePSI *= MathHelper.Lerp(0, 1.0f, (supplyPressure - locoAirSystem.BrakeLine1PressurePSI) / 15.0f);
21752175
if (train.EqualReservoirPressurePSIorInHg - locoAirSystem.BrakeLine1PressurePSI < chargeSlowdown) // Reduce recharge rate if near EQ to simulate feed valve behavior
21762176
PressureDiffEqualToPipePSI *= (float)Math.Pow((train.EqualReservoirPressurePSIorInHg - locoAirSystem.BrakeLine1PressurePSI) / chargeSlowdown,
21772177
1.0f/3.0f);

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/Controllers/MSTSBrakeController.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ public override void UpdatePressure(ref float pressureBar, float elapsedClockSec
105105
{
106106
PreviousNotchPosition = NotchController.GetCurrentNotch();
107107
BrakeControllerInitialised = true;
108+
if (PreviousNotchPosition != null)
109+
{
110+
var type = PreviousNotchPosition.Type;
111+
if (type == ControllerState.Lap || type == ControllerState.MinimalReduction) EnforceMinimalReduction = true;
112+
}
108113
}
109114
if (notch == null)
110115
{

Source/Orts.Simulation/Simulation/RollingStocks/TrainCar.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@
3737
using Orts.Common;
3838
using Orts.Formats.Msts;
3939
using Orts.Parsers.Msts;
40-
using Orts.Simulation.AIs;
4140
using Orts.Simulation.Physics;
4241
using Orts.Simulation.RollingStocks.Coupling;
4342
using Orts.Simulation.RollingStocks.SubSystems;
4443
using Orts.Simulation.RollingStocks.SubSystems.Brakes;
4544
using Orts.Simulation.RollingStocks.SubSystems.PowerSupplies;
4645
using Orts.Simulation.Signalling;
47-
using Orts.Simulation.Timetables;
4846
using ORTS.Common;
4947
using ORTS.Scripting.Api;
5048
using System;
@@ -2089,14 +2087,13 @@ public virtual void UpdateCurveForce(float elapsedClockSeconds)
20892087
// Base Curve Resistance (from refernce i)) = (Vehicle mass x Coeff Friction) * (Track Gauge + Vehicle Fixed Wheelbase) / (2 * curve radius)
20902088
// Vehicle Fixed Wheel base is the distance between the wheels, ie bogie or fixed wheels
20912089

2092-
var rBaseWagonN = 9.81f * MassKG * Train.WagonCoefficientFriction * (TrackGaugeM + RigidWheelBaseM) / (2.0f * CurrentCurveRadiusM);
2090+
float rBaseWagonN = GravitationalAccelerationMpS2 * MassKG * Train.WagonCoefficientFriction * (TrackGaugeM + RigidWheelBaseM) / (2.0f * CurrentCurveRadiusM);
20932091

20942092
// Speed Curve Resistance (from reference ii) - second term only) = ((Speed^2 / Curve Radius) - (Superelevation / Track Gauge) * Gravitational acceleration) * Constant
20952093

2096-
var speedConstant = 1.5f;
2097-
var MToMM = 1000;
2098-
var rspeedKgpTonne = speedConstant * Math.Abs((SpeedMpS * SpeedMpS / CurrentCurveRadiusM) - ((MToMM * SuperElevationM / MToMM * TrackGaugeM) * GravitationalAccelerationMpS2));
2099-
var rSpeedWagonN = GravitationalAccelerationMpS2 * (Kg.ToTonne(MassKG) * rspeedKgpTonne);
2094+
float speedConstant = 1.5f;
2095+
float rspeedKgpTonne = speedConstant * Math.Abs((SpeedMpS * SpeedMpS / CurrentCurveRadiusM) - (GravitationalAccelerationMpS2 * SuperElevationM / TrackGaugeM));
2096+
float rSpeedWagonN = GravitationalAccelerationMpS2 * (Kg.ToTonne(MassKG) * rspeedKgpTonne);
21002097

21012098
CurveForceN = rBaseWagonN + rSpeedWagonN;
21022099
}

0 commit comments

Comments
 (0)