Skip to content

Commit 0914a53

Browse files
authored
Merge pull request #803 from peternewell/steam_slip#3
Various adjustments to steam adhesion
2 parents 40a311d + 7157e08 commit 0914a53

File tree

1 file changed

+43
-27
lines changed

1 file changed

+43
-27
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/MSTSSteamLocomotive.cs

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,6 @@ public float TenderCoalMassKG // Decreased by firing and increased
584584
public float MaxTractiveEffortLbf; // Maximum theoritical tractive effort for locomotive
585585
public float DisplayMaxTractiveEffortLbf; // HuD display value of maximum theoritical tractive effort for locomotive
586586

587-
float DisplayTractiveEffortLbsF; // Value of Tractive effort to display in HUD
588587
float MaxCriticalSpeedTractiveEffortLbf; // Maximum power value @ critical speed of piston
589588
float DisplayCriticalSpeedTractiveEffortLbf; // Display power value @ speed of piston
590589
float absStartTractiveEffortN = 0.0f; // Record starting tractive effort
@@ -790,7 +789,6 @@ public override void Parse(string lowercasetoken, STFReader stf)
790789
Cylinder2CrankAngleRad = stf.ReadFloat(STFReader.UNITS.Angle, 0.0f);
791790
Cylinder3CrankAngleRad = stf.ReadFloat(STFReader.UNITS.Angle, 0.0f);
792791
Cylinder4CrankAngleRad = stf.ReadFloat(STFReader.UNITS.Angle, 0.0f);
793-
Trace.TraceInformation("Input - CrankAngle {0} {1} {2} {3}", Cylinder1CrankAngleRad, Cylinder2CrankAngleRad, Cylinder3CrankAngleRad, Cylinder4CrankAngleRad);
794792
stf.SkipRestOfBlock();
795793
break;
796794
case "engine(cylinderstroke": CylinderStrokeM = stf.ReadFloatBlock(STFReader.UNITS.Distance, null); break;
@@ -1290,13 +1288,20 @@ public override void Initialize()
12901288
WheelCrankAngleDiffRad[0] = MathHelper.ToRadians(0.0f);
12911289
WheelCrankAngleDiffRad[1] = MathHelper.ToRadians(90.0f);
12921290
}
1291+
1292+
if (Simulator.Settings.VerboseConfigurationMessages)
1293+
Trace.TraceInformation("CrankAngle set to default values {0} rad {1} rad {2} rad {3} rad", WheelCrankAngleDiffRad[0], WheelCrankAngleDiffRad[1], WheelCrankAngleDiffRad[2], WheelCrankAngleDiffRad[3]);
12931294
}
12941295
else // set values set by user
12951296
{
12961297
WheelCrankAngleDiffRad[0] = Cylinder1CrankAngleRad;
12971298
WheelCrankAngleDiffRad[1] = Cylinder2CrankAngleRad;
12981299
WheelCrankAngleDiffRad[2] = Cylinder3CrankAngleRad;
12991300
WheelCrankAngleDiffRad[3] = Cylinder4CrankAngleRad;
1301+
1302+
if (Simulator.Settings.VerboseConfigurationMessages)
1303+
Trace.TraceInformation("CrankAngle set to user values {0} rad {1} rad {2} rad {3} rad", WheelCrankAngleDiffRad[0], WheelCrankAngleDiffRad[1], WheelCrankAngleDiffRad[2], WheelCrankAngleDiffRad[3]);
1304+
13001305
}
13011306

13021307
// ****************** Test Locomotive and Gearing type ***********************
@@ -2533,7 +2538,16 @@ private void UpdateFX(float elapsedClockSeconds)
25332538
SmokeColor.Update(elapsedClockSeconds, MathHelper.Clamp(SmokeColorUnits, 0.25f, 1));
25342539

25352540
// Variable1 is proportional to angular speed, value of 10 means 1 rotation/second.
2536-
var variable1 = Math.Abs(WheelSpeedSlipMpS / DriverWheelRadiusM / MathHelper.Pi * 5);
2541+
// If wheel is not slipping then use normal wheel speed, this reduces oscillations in variable1 which causes issues with sounds.
2542+
var variable1 = 0.0f;
2543+
if (WheelSlip)
2544+
{
2545+
variable1 = Math.Abs(WheelSpeedSlipMpS / DriverWheelRadiusM / MathHelper.Pi * 5);
2546+
}
2547+
else
2548+
{
2549+
variable1 = Math.Abs(WheelSpeedMpS / DriverWheelRadiusM / MathHelper.Pi * 5);
2550+
}
25372551
Variable1 = ThrottlePercent == 0 ? 0 : variable1;
25382552
Variable2 = MathHelper.Clamp((CylinderCocksPressureAtmPSI - OneAtmospherePSI) / BoilerPressurePSI * 100f, 0, 100);
25392553
Variable3 = FuelRateSmoothed * 100;
@@ -4869,8 +4883,7 @@ private void UpdateMotion(float elapsedClockSeconds, float cutoff, float absSpee
48694883
TractiveEffortLbsF = 0.0f;
48704884
}
48714885
TractiveEffortLbsF = MathHelper.Clamp(TractiveEffortLbsF, 0, TractiveEffortLbsF);
4872-
DisplayTractiveEffortLbsF = TractiveEffortLbsF;
4873-
4886+
48744887
// Calculate IHP
48754888
// IHP = (MEP x CylStroke(ft) x cylArea(sq in) x No Strokes (/min)) / 33000) - this is per cylinder
48764889

@@ -4979,25 +4992,6 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
49794992
if (absSpeedMpS == 0 && cutoff < 0.05f) // If the reverser is set too low then not sufficient steam is admitted to the steam cylinders, and hence insufficient Motive Force will produced to move the train.
49804993
TractiveForceN = 0;
49814994

4982-
// Based upon max IHP, limit motive force.
4983-
4984-
if (IndicatedHorsePowerHP >= MaxIndicatedHorsePowerHP)
4985-
{
4986-
TractiveForceN = N.FromLbf((MaxIndicatedHorsePowerHP * 375.0f) / pS.TopH(Me.ToMi(SpeedMpS)));
4987-
IndicatedHorsePowerHP = MaxIndicatedHorsePowerHP; // Set IHP to maximum value
4988-
IsCritTELimit = true; // Flag if limiting TE
4989-
}
4990-
else
4991-
{
4992-
IsCritTELimit = false; // Reset flag if limiting TE
4993-
}
4994-
4995-
DrawBarPullLbsF = N.ToLbf(Math.Abs(TractiveForceN) - LocoTenderFrictionForceN); // Locomotive drawbar pull is equal to motive force of locomotive (+ tender) - friction forces of locomotive (+ tender)
4996-
DrawBarPullLbsF = MathHelper.Clamp(DrawBarPullLbsF, 0, DrawBarPullLbsF); // clamp value so it doesn't go negative
4997-
4998-
DrawbarHorsePowerHP = (DrawBarPullLbsF * MpS.ToMpH(absSpeedMpS)) / 375.0f; // TE in this instance is a maximum, and not at the wheel???
4999-
DrawbarHorsePowerHP = MathHelper.Clamp(DrawbarHorsePowerHP, 0, DrawbarHorsePowerHP); // clamp value so it doesn't go negative
5000-
50014995
#region - Steam Adhesion Model Input for Steam Locomotives
50024996

50034997
// Based upon information presented on pg 276 of "Locomotive Operation - A Technical and Practical Analysis" by G. R. Henderson -
@@ -5377,7 +5371,21 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
53775371
TractiveForceN = 0.5f;
53785372
}
53795373

5380-
#endregion
5374+
#endregion
5375+
5376+
5377+
// Based upon max IHP, limit motive force.
5378+
5379+
if (IndicatedHorsePowerHP >= MaxIndicatedHorsePowerHP)
5380+
{
5381+
TractiveForceN = N.FromLbf((MaxIndicatedHorsePowerHP * 375.0f) / pS.TopH(Me.ToMi(SpeedMpS)));
5382+
IndicatedHorsePowerHP = MaxIndicatedHorsePowerHP; // Set IHP to maximum value
5383+
IsCritTELimit = true; // Flag if limiting TE
5384+
}
5385+
else
5386+
{
5387+
IsCritTELimit = false; // Reset flag if limiting TE
5388+
}
53815389

53825390
// Find the maximum TE for debug i.e. @ start and full throttle
53835391
if (absSpeedMpS < 1.0)
@@ -6310,6 +6318,14 @@ public override string GetStatus()
63106318

63116319
public override string GetDebugStatus()
63126320
{
6321+
6322+
6323+
DrawBarPullLbsF = N.ToLbf(Math.Abs(MotiveForceN) - LocoTenderFrictionForceN); // Locomotive drawbar pull is equal to motive force of locomotive (+ tender) - friction forces of locomotive (+ tender)
6324+
DrawBarPullLbsF = MathHelper.Clamp(DrawBarPullLbsF, 0, DrawBarPullLbsF); // clamp value so it doesn't go negative
6325+
6326+
DrawbarHorsePowerHP = (DrawBarPullLbsF * MpS.ToMpH(absSpeedMpS)) / 375.0f; // TE in this instance is a maximum, and not at the wheel???
6327+
DrawbarHorsePowerHP = MathHelper.Clamp(DrawbarHorsePowerHP, 0, DrawbarHorsePowerHP); // clamp value so it doesn't go negative
6328+
63136329
var status = new StringBuilder(base.GetDebugStatus());
63146330

63156331
status.AppendFormat("\n\n\t\t === {0} === \t\t\n", Simulator.Catalog.GetString("Key Inputs"));
@@ -6752,7 +6768,7 @@ public override string GetDebugStatus()
67526768
Simulator.Catalog.GetString("StartTE"),
67536769
FormatStrings.FormatForce(absStartTractiveEffortN, IsMetric),
67546770
Simulator.Catalog.GetString("TE"),
6755-
FormatStrings.FormatForce(N.FromLbf(DisplayTractiveEffortLbsF), IsMetric),
6771+
FormatStrings.FormatForce(MotiveForceN, IsMetric),
67566772
Simulator.Catalog.GetString("Draw"),
67576773
FormatStrings.FormatForce(N.FromLbf(DrawBarPullLbsF), IsMetric),
67586774
Simulator.Catalog.GetString("CritSpeed"),
@@ -6797,7 +6813,7 @@ public override string GetDebugStatus()
67976813
Simulator.Catalog.GetString("StartTE"),
67986814
FormatStrings.FormatForce(absStartTractiveEffortN, IsMetric),
67996815
Simulator.Catalog.GetString("TE"),
6800-
FormatStrings.FormatForce(N.FromLbf(DisplayTractiveEffortLbsF), IsMetric),
6816+
FormatStrings.FormatForce(MotiveForceN, IsMetric),
68016817
Simulator.Catalog.GetString("Draw"),
68026818
FormatStrings.FormatForce(N.FromLbf(DrawBarPullLbsF), IsMetric),
68036819
Simulator.Catalog.GetString("CritSpeed"),

0 commit comments

Comments
 (0)