Skip to content

Commit 922abd7

Browse files
committed
Correct an issue with Compensated Force causing locomotive to speed up in a slip.
1 parent 6c47e01 commit 922abd7

File tree

1 file changed

+18
-6
lines changed
  • Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerTransmissions

1 file changed

+18
-6
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerTransmissions/Axle.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public class Axles : ISubSystem<Axles>
7171
protected readonly TrainCar Car;
7272

7373
/// <summary>
74-
/// Get total axle out force with brake force substracted
74+
/// Get total axle out force with brake and friction force substracted
7575
/// </summary>
7676
public float CompensatedForceN
7777
{
@@ -317,7 +317,7 @@ public class Axle : ISubSystem<Axle>
317317
public int NumOfSubstepsPS { get; set; }
318318

319319
/// <summary>
320-
/// Positive only brake force to the axle, in Newtons
320+
/// Positive only brake force to the individual axle, in Newtons
321321
/// </summary>
322322
public float BrakeRetardForceN;
323323

@@ -334,6 +334,9 @@ public class Axle : ISubSystem<Axle>
334334

335335
protected float frictionN;
336336

337+
/// <summary>
338+
/// Positive only friction force to the axle, in Newtons
339+
/// </summary>
337340
public float FrictionN { set { frictionN = Math.Abs(value); } get { return frictionN; } }
338341

339342
/// <summary>
@@ -568,7 +571,7 @@ public float TransmissionEfficiency
568571
public float AxleForceN { get; private set; }
569572

570573
/// <summary>
571-
/// Compensated Axle force value, this provided the motive force equivalent excluding brake force, in Newtons
574+
/// Compensated Axle force value, this provided the motive force equivalent excluding brake and friction force, in Newtons
572575
/// </summary>
573576
public float CompensatedAxleForceN { get; protected set; }
574577

@@ -1091,9 +1094,18 @@ public virtual void Update(float timeSpan)
10911094
// And thus there is a duplication of the braking effect in OR. To compensate for this, after the slip characteristics have been calculated, the output of the axle
10921095
// module has the brake force "added" back in to give the appropriate motive force output for the locomotive. Braking force is handled separately.
10931096
// Hence CompensatedAxleForce is the actual output force on the axle. Similarly friction is also handled separately so it is also discounted from the CompensatedForce.
1094-
if (Math.Abs(TrainSpeedMpS) < 0.001f && AxleForceN == 0) CompensatedAxleForceN = DriveForceN;
1095-
else if (TrainSpeedMpS < 0) CompensatedAxleForceN = AxleForceN - BrakeRetardForceN - FrictionN;
1096-
else CompensatedAxleForceN = AxleForceN + BrakeRetardForceN + FrictionN;
1097+
1098+
// Make sure that compensated value never exceeds the "output" force, otherwise resulting value will be overcompensated
1099+
var CompensationVariation = BrakeRetardForceN + FrictionN;
1100+
1101+
if (CompensationVariation > Math.Abs(AxleForceN))
1102+
{
1103+
CompensationVariation = Math.Abs(AxleForceN); ;
1104+
}
1105+
1106+
if (Math.Abs(TrainSpeedMpS) < 0.001f && AxleForceN == 0) CompensatedAxleForceN = 0;
1107+
else if (TrainSpeedMpS < 0) CompensatedAxleForceN = AxleForceN - CompensationVariation;
1108+
else CompensatedAxleForceN = AxleForceN + CompensationVariation;
10971109

10981110
if (Math.Abs(SlipSpeedMpS) > WheelSlipThresholdMpS)
10991111
{

0 commit comments

Comments
 (0)