Skip to content

Commit e632edb

Browse files
committed
Fix bug introduced to dynamic brake blending
1 parent 4c9375e commit e632edb

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1834,7 +1834,7 @@ public void DynamicBrakeBlending(float elapsedClockSeconds)
18341834
{
18351835
if (DynamicBrakeBlendingForceMatch)
18361836
{
1837-
float diff = target * MaxBrakeForceN - DynamicBrakeForceN;
1837+
float diff = target * FrictionBrakeBlendingMaxForceN - DynamicBrakeForceN;
18381838
float threshold = 100;
18391839
if (diff > threshold && DynamicBrakeIntervention < 1)
18401840
DynamicBrakeIntervention = Math.Min(DynamicBrakeIntervention + elapsedClockSeconds, 1);

Source/Orts.Simulation/Simulation/RollingStocks/MSTSWagon.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,8 @@ public virtual void LoadFromWagFile(string wagFilePath)
598598

599599
MaxHandbrakeForceN = InitialMaxHandbrakeForceN;
600600

601+
FrictionBrakeBlendingMaxForceN = InitialMaxBrakeForceN; // set the value of braking when blended with dynamic brakes
602+
601603
if (MaxBrakeShoeForceN != 0 && BrakeShoeType != BrakeShoeTypes.Unknown)
602604
{
603605
MaxBrakeForceN = MaxBrakeShoeForceN;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -587,15 +587,15 @@ public override void Update(float elapsedClockSeconds)
587587
}
588588
}
589589
}
590-
if (loco.DynamicBrakePercent > 0 && Car.MaxBrakeForceN > 0)
590+
if (loco.DynamicBrakePercent > 0 && Car.FrictionBrakeBlendingMaxForceN > 0)
591591
{
592592
if (loco.DynamicBrakePartialBailOff)
593593
{
594-
var requiredBrakeForceN = Math.Min(AutoCylPressurePSI / MaxCylPressurePSI, 1) * Car.MaxBrakeForceN;
595-
var localBrakeForceN = loco.DynamicBrakeForceN + Math.Min(CylPressurePSI / MaxCylPressurePSI, 1) * Car.MaxBrakeForceN;
596-
if (localBrakeForceN > requiredBrakeForceN - 0.15f * Car.MaxBrakeForceN)
594+
var requiredBrakeForceN = Math.Min(AutoCylPressurePSI / MaxCylPressurePSI, 1) * Car.FrictionBrakeBlendingMaxForceN;
595+
var localBrakeForceN = loco.DynamicBrakeForceN + Math.Min(CylPressurePSI / MaxCylPressurePSI, 1) * Car.FrictionBrakeBlendingMaxForceN;
596+
if (localBrakeForceN > requiredBrakeForceN - 0.15f * Car.FrictionBrakeBlendingMaxForceN)
597597
{
598-
demandedPressurePSI = Math.Min(Math.Max((requiredBrakeForceN - loco.DynamicBrakeForceN)/Car.MaxBrakeForceN*MaxCylPressurePSI, 0), MaxCylPressurePSI);
598+
demandedPressurePSI = Math.Min(Math.Max((requiredBrakeForceN - loco.DynamicBrakeForceN)/Car.FrictionBrakeBlendingMaxForceN * MaxCylPressurePSI, 0), MaxCylPressurePSI);
599599
if (demandedPressurePSI > CylPressurePSI && demandedPressurePSI < CylPressurePSI + 4) // Allow some margin for unnecessary air brake application
600600
{
601601
demandedPressurePSI = CylPressurePSI;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,10 @@ public Direction Direction
578578

579579
public float TunnelForceN; // Resistive force due to tunnel, in Newtons
580580
public float FrictionForceN; // in Newtons ( kg.m/s^2 ) unsigned, includes effects of curvature
581-
public float BrakeForceN; // brake force applied to slow train (Newtons) - will be impacted by wheel/rail friction
581+
public float BrakeForceN; // current braking force applied to slow train (Newtons) - will be impacted by wheel/rail friction
582582
public float BrakeRetardForceN; // brake force applied to wheel by brakeshoe (Newtons) independent of friction wheel/rail friction
583583
public float BrakeShoeForceN;
584+
public float FrictionBrakeBlendingMaxForceN; // This is the maximum force for the friction barke when it is blended with the dynamic brake
584585

585586
// Sum of all the forces acting on a Traincar in the direction of driving.
586587
// MotiveForceN and GravityForceN act to accelerate the train. The others act to brake the train.

0 commit comments

Comments
 (0)