Skip to content

Commit 51067c3

Browse files
committed
Streamline code
1 parent a5df286 commit 51067c3

File tree

3 files changed

+24
-78
lines changed

3 files changed

+24
-78
lines changed

Source/Documentation/Manual/physics.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2753,7 +2753,7 @@ Brake Shoe Force - This is the current change being implemented. The following c
27532753

27542754
``ORTSBrakeShoeType`` - this defines a number of different brake shoe types and curves. To provide a more realistic representation of the braking force the default CoF curves are 2D, ie
27552755
they are impacted by both the speed and Brake Shoe Force. Typically ``ORTSBrakeShoeType`` will have one of the following keywords included -
2756-
``Cast_Iron`` - older cast iron brake shoes, 2D as above, ``Cast_Iron_P10`` - newer cast iron brake shoes with increased phosphorous, 2D as above, ``Hi_Friction_Composite``
2756+
``Cast_Iron_P6`` - older cast iron brake shoes, 2D as above, ``Cast_Iron_P10`` - newer cast iron brake shoes with increased phosphorous, 2D as above, ``Hi_Friction_Composite``
27572757
- high friction composite shoe, 2D as above, ``Disc_Pads`` - brakes with disc pads, 2D as above, ``User_Defined`` - is a user defined curve
27582758
using the ORTSBrakeShoeFriction parameter, 1D (ie, speed only, see above section for the parameter format).
27592759

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ public virtual void LoadFromWagFile(string wagFilePath)
632632
NumberCarBrakeShoes = (LocoNumDrvAxles * 4) + (WagonNumAxles * 4); // Assume 4 brake shoes per axle on all wheels
633633
}
634634

635-
if (Simulator.Settings.VerboseConfigurationMessages && (BrakeShoeType == BrakeShoeTypes.Cast_Iron || BrakeShoeType == BrakeShoeTypes.High_Friction_Composite))
635+
if (Simulator.Settings.VerboseConfigurationMessages && (BrakeShoeType != BrakeShoeTypes.User_Defined || BrakeShoeType != BrakeShoeTypes.Unknown))
636636
{
637637
Trace.TraceInformation("Number of Locomotive Brakeshoes set to default value of {0}", NumberCarBrakeShoes);
638638
}
@@ -641,7 +641,7 @@ public virtual void LoadFromWagFile(string wagFilePath)
641641
{
642642
NumberCarBrakeShoes = WagonNumAxles * 4; // Assume 4 brake shoes per axle
643643

644-
if (Simulator.Settings.VerboseConfigurationMessages && (BrakeShoeType == BrakeShoeTypes.Cast_Iron || BrakeShoeType == BrakeShoeTypes.High_Friction_Composite))
644+
if (Simulator.Settings.VerboseConfigurationMessages && (BrakeShoeType != BrakeShoeTypes.User_Defined || BrakeShoeType != BrakeShoeTypes.Unknown))
645645
{
646646
Trace.TraceInformation("Number of Wagon Brakeshoes set to default value of {0}", NumberCarBrakeShoes);
647647
}

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

Lines changed: 21 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ public enum WagonSpecialTypes
684684
public enum BrakeShoeTypes
685685
{
686686
Unknown,
687-
Cast_Iron,
687+
Cast_Iron_P6,
688688
Cast_Iron_P10,
689689
Disc_Pads,
690690
High_Friction_Composite,
@@ -3243,53 +3243,21 @@ public virtual float GetBrakeShoeFrictionFactor()
32433243
// Karwatzki developed a formula for brakeshoe friction that used 5 constant values k1, ..... , k5.
32443244
// Wende present a number of different brake shoes k values, two sets of which line up with the UIC values above.
32453245

3246-
float NewtonsTokNewtons = 0.001f;
3247-
float brakeShoeForcekN = (NewtonsTokNewtons * BrakeShoeForceN) / NumberCarBrakeShoes;
3248-
float k1 = 0;
3249-
float k2 = 0;
3250-
float k3 = 0;
3251-
float k4 = 0;
3252-
float k5 = 0;
3253-
3254-
if (BrakeShoeType == BrakeShoeTypes.Cast_Iron)
3246+
if (BrakeShoeType == BrakeShoeTypes.Cast_Iron_P6)
32553247
{
3256-
k1 = 0.024f;
3257-
k2 = 62.5f;
3258-
k3 = 12.5f;
3259-
k4 = 100f;
3260-
k5 = 20f;
3261-
3262-
frictionfraction = k1 * ((brakeShoeForcekN + k2) / (brakeShoeForcekN + k3)) * ((MpS.ToKpH(AbsSpeedMpS) + k4) / (MpS.ToKpH(AbsSpeedMpS) + k5));
3248+
frictionfraction = KarwatzkiBrakeShoeFriction(0.024f, 62.5f, 12.5f, 100, 20);
32633249
}
32643250
else if (BrakeShoeType == BrakeShoeTypes.Cast_Iron_P10)
32653251
{
3266-
k1 = 0.05f;
3267-
k2 = 62.5f;
3268-
k3 = 31.25f;
3269-
k4 = 100f;
3270-
k5 = 20f;
3271-
3272-
frictionfraction = k1 * ((brakeShoeForcekN + k2) / (brakeShoeForcekN + k3)) * ((MpS.ToKpH(AbsSpeedMpS) + k4) / (MpS.ToKpH(AbsSpeedMpS) + k5));
3252+
frictionfraction = KarwatzkiBrakeShoeFriction(0.05f, 62.5f, 31.25f, 100, 20);
32733253
}
32743254
else if (BrakeShoeType == BrakeShoeTypes.High_Friction_Composite)
32753255
{
3276-
k1 = 0.055f;
3277-
k2 = 200f;
3278-
k3 = 50f;
3279-
k4 = 150f;
3280-
k5 = 75f;
3281-
3282-
frictionfraction = k1 * ((brakeShoeForcekN + k2) / (brakeShoeForcekN + k3)) * ((MpS.ToKpH(AbsSpeedMpS) + k4) / (MpS.ToKpH(AbsSpeedMpS) + k5));
3256+
frictionfraction = KarwatzkiBrakeShoeFriction(0.055f, 200, 50, 150, 75);
32833257
}
32843258
else if (BrakeShoeType == BrakeShoeTypes.Disc_Pads)
32853259
{
3286-
k1 = 0.385f;
3287-
k2 = -24.5f;
3288-
k3 = -27.2f;
3289-
k4 = 39.5f;
3290-
k5 = 33f;
3291-
3292-
frictionfraction = k1 * ((brakeShoeForcekN + k2) / (brakeShoeForcekN + k3)) * ((MpS.ToKpH(AbsSpeedMpS) + k4) / (MpS.ToKpH(AbsSpeedMpS) + k5));
3260+
frictionfraction = KarwatzkiBrakeShoeFriction(0.385f, -24.5f, -27.2f, 39.5f, 33);
32933261
}
32943262
else if (BrakeShoeType == BrakeShoeTypes.User_Defined)
32953263
{
@@ -3351,53 +3319,21 @@ public virtual float GetBrakeShoeFrictionCoefficientHuD()
33513319
// Karwatzki developed a formula for brakeshoe friction that used 5 constant values k1, ..... , k5.
33523320
// Wende present a number of different brake shoes k values, two sets of which line up with the UIC values above.
33533321

3354-
float NewtonsTokNewtons = 0.001f;
3355-
float brakeShoeForcekN = NewtonsTokNewtons * BrakeShoeForceN / NumberCarBrakeShoes;
3356-
float k1 = 0;
3357-
float k2 = 0;
3358-
float k3 = 0;
3359-
float k4 = 0;
3360-
float k5 = 0;
3361-
3362-
if (BrakeShoeType == BrakeShoeTypes.Cast_Iron)
3322+
if (BrakeShoeType == BrakeShoeTypes.Cast_Iron_P6)
33633323
{
3364-
k1 = 0.024f;
3365-
k2 = 62.5f;
3366-
k3 = 12.5f;
3367-
k4 = 100f;
3368-
k5 = 20f;
3369-
3370-
frictionfraction = k1 * ((brakeShoeForcekN + k2) / (brakeShoeForcekN + k3)) * ((MpS.ToKpH(AbsSpeedMpS) + k4) / (MpS.ToKpH(AbsSpeedMpS) + k5));
3324+
frictionfraction = KarwatzkiBrakeShoeFriction (0.024f, 62.5f, 12.5f, 100, 20);
33713325
}
33723326
else if (BrakeShoeType == BrakeShoeTypes.Cast_Iron_P10)
33733327
{
3374-
k1 = 0.05f;
3375-
k2 = 62.5f;
3376-
k3 = 31.25f;
3377-
k4 = 100f;
3378-
k5 = 20f;
3379-
3380-
frictionfraction = k1 * ((brakeShoeForcekN + k2) / (brakeShoeForcekN + k3)) * ((MpS.ToKpH(AbsSpeedMpS) + k4) / (MpS.ToKpH(AbsSpeedMpS) + k5));
3328+
frictionfraction = KarwatzkiBrakeShoeFriction(0.05f, 62.5f, 31.25f, 100, 20);
33813329
}
33823330
else if (BrakeShoeType == BrakeShoeTypes.High_Friction_Composite)
33833331
{
3384-
k1 = 0.055f;
3385-
k2 = 200f;
3386-
k3 = 50f;
3387-
k4 = 150f;
3388-
k5 = 75f;
3389-
3390-
frictionfraction = k1 * ((brakeShoeForcekN + k2) / (brakeShoeForcekN + k3)) * ((MpS.ToKpH(AbsSpeedMpS) + k4) / (MpS.ToKpH(AbsSpeedMpS) + k5));
3332+
frictionfraction = KarwatzkiBrakeShoeFriction(0.055f, 200, 50f, 150, 75);
33913333
}
33923334
else if (BrakeShoeType == BrakeShoeTypes.Disc_Pads)
33933335
{
3394-
k1 = 0.385f;
3395-
k2 = -24.5f;
3396-
k3 = -27.2f;
3397-
k4 = 39.5f;
3398-
k5 = 33f;
3399-
3400-
frictionfraction = k1 * ((brakeShoeForcekN + k2) / (brakeShoeForcekN + k3)) * ((MpS.ToKpH(AbsSpeedMpS) + k4) / (MpS.ToKpH(AbsSpeedMpS) + k5));
3336+
frictionfraction = KarwatzkiBrakeShoeFriction(0.385f, -24.5f, -27.2f, 39.5f, 33);
34013337
}
34023338
else if (BrakeShoeType == BrakeShoeTypes.User_Defined)
34033339
{
@@ -3424,6 +3360,16 @@ public virtual float GetBrakeShoeFrictionCoefficientHuD()
34243360
}
34253361
}
34263362

3363+
public float KarwatzkiBrakeShoeFriction ( float k1, float k2, float k3, float k4, float k5 )
3364+
{
3365+
var friction = 0.0f;
3366+
float NewtonsTokNewtons = 0.001f;
3367+
float brakeShoeForcekN = NewtonsTokNewtons * BrakeShoeForceN / NumberCarBrakeShoes;
3368+
friction = k1 * ((brakeShoeForcekN + k2) / (brakeShoeForcekN + k3)) * ((MpS.ToKpH(AbsSpeedMpS) + k4) / (MpS.ToKpH(AbsSpeedMpS) + k5));
3369+
3370+
return friction;
3371+
}
3372+
34273373
public virtual void InitializeCarHeatingVariables()
34283374
{
34293375
MSTSLocomotive mstsLocomotive = Train.LeadLocomotive as MSTSLocomotive;

0 commit comments

Comments
 (0)