Skip to content

Commit 34a1786

Browse files
committed
Calculate average Tractive force
1 parent b5bd060 commit 34a1786

File tree

2 files changed

+30
-28
lines changed

2 files changed

+30
-28
lines changed

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

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,9 @@ public class MSTSSteamLocomotive : MSTSLocomotive
291291
SmoothedData BurnRateSmoothKGpS = new SmoothedData(150); // Changes in BurnRate take x seconds to fully react to changing needs - models increase and decrease in heat.
292292
float FuelRateSmoothed = 0.0f; // Smoothed Fuel Rate
293293

294-
int NumberofMotiveForceValues = 36;
295-
float[] MotiveForceAverageN = new float[36];
296-
float DisplayAverageMotiveForceN;
294+
int NumberofTractiveForceValues = 36;
295+
float[,] TractiveForceAverageN = new float[5, 37];
296+
float AverageTractiveForceN;
297297

298298
public Orts.Simulation.Simulation.RollingStocks.SubSystems.PowerSupplies.SteamEngines SteamEngines;
299299

@@ -3069,7 +3069,7 @@ private void UpdateFX(float elapsedClockSeconds)
30693069
BoosterCylinderSteamExhaust02SteamVolumeM3pS = BoosterCylinderSteamExhaustOn && BoosterCylinderSteamExhaust02On ? (10.0f * BoosterSteamFraction) : 0.0f;
30703070
BoosterCylinderSteamExhaust02SteamVelocityMpS = 100.0f;
30713071

3072-
Trace.TraceInformation("Booster Exhaust - ExhaustOn {0} Exhaust01On {1} Exhaust02On {2} ExhaustVolume01 {3} ExhaustVolume02 {4} SteamFraction {5} Speed {6}", BoosterCylinderSteamExhaustOn, BoosterCylinderSteamExhaust01On, BoosterCylinderSteamExhaust02On, BoosterCylinderSteamExhaust01SteamVolumeM3pS, BoosterCylinderSteamExhaust02SteamVolumeM3pS, BoosterSteamFraction, BoosterEngineSpeedRpM);
3072+
// Trace.TraceInformation("Booster Exhaust - ExhaustOn {0} Exhaust01On {1} Exhaust02On {2} ExhaustVolume01 {3} ExhaustVolume02 {4} SteamFraction {5} Speed {6}", BoosterCylinderSteamExhaustOn, BoosterCylinderSteamExhaust01On, BoosterCylinderSteamExhaust02On, BoosterCylinderSteamExhaust01SteamVolumeM3pS, BoosterCylinderSteamExhaust02SteamVolumeM3pS, BoosterSteamFraction, BoosterEngineSpeedRpM);
30733073

30743074
// Booster Cylinder Steam Cylinder Cocks (automatic)
30753075
BoosterCylinderCockSteam11VolumeMpS = BoosterCylinderCocksOn && BoosterCylinderCock11On ? (10.0f * BoosterSteamFraction) : 0.0f;
@@ -3235,9 +3235,8 @@ private void UpdateFX(float elapsedClockSeconds)
32353235
// overwrite Booster variable if in Idle or Run mode - gears not engaged
32363236
if (SteamEngines[i].AuxiliarySteamEngineType != SteamEngine.AuxiliarySteamEngineTypes.Booster && (SteamBoosterRunMode && !BoosterGearsEngaged) || SteamBoosterIdleMode)
32373237
{
3238-
variable[i] = BoosterEngineSpeedRpM;
3238+
variable[i] = BoosterEngineSpeedRpM / MathHelper.Pi * 5;
32393239
}
3240-
32413240
}
32423241

32433242
// Set variables for each engine
@@ -5880,7 +5879,7 @@ private void UpdateSteamTractiveForce(float elapsedClockSeconds, float locomotiv
58805879
excessBalanceForcelbf *= -1;
58815880
}
58825881

5883-
// For more then two cylinder eingines inertia is not required as it only applies to the geraing on each side and not the number of cylinders
5882+
// For more then two cylinder eingines inertia is not required as it only applies to the gearing on each side and not the number of cylinders
58845883
if ((SteamEngines[numberofengine].NumberCylinders == 3 && i > 1) || (SteamEngines[numberofengine].NumberCylinders == 4 && (i == 1 || i == 3)))
58855884
{
58865885
excessBalanceForcelbf = 0;
@@ -5898,14 +5897,15 @@ private void UpdateSteamTractiveForce(float elapsedClockSeconds, float locomotiv
58985897
{
58995898
totalDrvWeightN += N.FromLbf(excessBalanceForcelbf - verticalThrustForcelbf);
59005899
}
5901-
5902-
// Trace.TraceInformation("Excess {0} Vertical {1}", excessBalanceForcelbf, verticalThrustForcelbf);
59035900
}
59045901

59055902
SteamEngines[numberofengine].AttachedAxle.AxleWeightN = totalDrvWeightN + 9.81f * SteamEngines[numberofengine].AttachedAxle.WheelWeightKg;
59065903
SteamEngines[numberofengine].SteamStaticWheelForce = N.ToLbf(9.81f * SteamEngines[numberofengine].AttachedAxle.WheelWeightKg) * LocomotiveCoefficientFrictionHUD;
59075904

5908-
SteamEngines[numberofengine].IndicatedHorsePowerHP = (N.ToLbf(SteamEngines[numberofengine].TractiveForceN) * pS.TopH(Me.ToMi(absSpeedMpS))) / 375.0f;
5905+
// Average tarctive force is calculated for display purposes as tractive force varies dramatically as the wheel rotates, and this is difficult to follow on HuD
5906+
SteamEngines[numberofengine].AverageTractiveForceN = AverageTractiveForce(elapsedClockSeconds, numberofengine, NumberofTractiveForceValues);
5907+
5908+
SteamEngines[numberofengine].IndicatedHorsePowerHP = (N.ToLbf(SteamEngines[numberofengine].AverageTractiveForceN) * pS.TopH(Me.ToMi(absSpeedMpS))) / 375.0f;
59095909

59105910
}
59115911
else // typically this will be a booster or geared engine
@@ -6056,7 +6056,7 @@ private void UpdateSteamTractiveForce(float elapsedClockSeconds, float locomotiv
60566056
}
60576057

60586058
/// <summary>
6059-
/// Update the tractive force for the complete steam locomotive
6059+
/// Averages the tractive force for the steam locomotive as tractive force varies throught the full wheel revolution
60606060
/// </summary>
60616061
protected override void UpdateTractiveForce(float elapsedClockSeconds, float locomotivethrottle, float AbsSpeedMpS, float AbsWheelSpeedMpS)
60626062
{
@@ -6123,9 +6123,6 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float loc
61236123

61246124
DisplayTractiveForceN = TractiveForceN;
61256125

6126-
DisplayAverageMotiveForceN = AverageMotiveForce(elapsedClockSeconds);
6127-
6128-
61296126
MotiveForceSmoothN.Update(elapsedClockSeconds, MotiveForceN);
61306127
MotiveForceSmoothedN = MotiveForceSmoothN.SmoothedValue;
61316128
if (float.IsNaN(MotiveForceN))
@@ -6191,24 +6188,24 @@ protected override void ApplyDirectionToTractiveForce(ref float tractiveForceN,
61916188
/// <summary>
61926189
/// Normalise booster engine crank angle so that it is a value between 0 and 360 starting at the real crank angle difference
61936190
/// </summary>
6194-
private float AverageMotiveForce(float elapsedClockSeconds)
6191+
private float AverageTractiveForce(float elapsedClockSeconds, int enginenumber, int tractiveforcevalues)
61956192
{
6196-
float AverageTotal = 0;
6197-
float AverageForceN = 0;
6193+
float AverageTractiveForceTotal = 0;
6194+
float AverageTractiveForceN = 0;
61986195

6199-
for (int i = 0; i < NumberofMotiveForceValues - 2; i++)
6196+
for (int i = 0; i < tractiveforcevalues - 1; i++)
62006197
{
62016198

6202-
MotiveForceAverageN[i] = MotiveForceAverageN[i + 1];
6203-
AverageTotal += MotiveForceAverageN[i+1];
6204-
6199+
TractiveForceAverageN[enginenumber, i] = TractiveForceAverageN[enginenumber, i + 1];
6200+
AverageTractiveForceTotal += TractiveForceAverageN[enginenumber, i+1];
62056201
}
6206-
MotiveForceAverageN[NumberofMotiveForceValues-1] = TractiveForceN;
6207-
AverageTotal += MotiveForceAverageN[NumberofMotiveForceValues-1];
6202+
TractiveForceAverageN[enginenumber, tractiveforcevalues - 1] = SteamEngines[enginenumber].TractiveForceN;
6203+
6204+
AverageTractiveForceTotal += TractiveForceAverageN[enginenumber, tractiveforcevalues - 1];
62086205

6209-
AverageForceN = AverageTotal / NumberofMotiveForceValues;
6206+
AverageTractiveForceN = AverageTractiveForceTotal / tractiveforcevalues;
62106207

6211-
return AverageForceN;
6208+
return AverageTractiveForceN;
62126209
}
62136210

62146211
/// <summary>
@@ -7845,7 +7842,7 @@ public override string GetDebugStatus()
78457842
Simulator.Catalog.GetString("AForceN"),
78467843
FormatStrings.FormatForce(SteamEngines[i].AttachedAxle.CompensatedAxleForceN, IsMetric),
78477844
Simulator.Catalog.GetString("Tang(t)"),
7848-
FormatStrings.FormatForce(SteamEngines[i].TractiveForceN, IsMetric),
7845+
FormatStrings.FormatForce(SteamEngines[i].AverageTractiveForceN, IsMetric),
78497846
Simulator.Catalog.GetString("Static"),
78507847
FormatStrings.FormatForce(N.FromLbf(SteamEngines[i].SteamStaticWheelForce), IsMetric),
78517848
Simulator.Catalog.GetString("Coeff"),
@@ -7877,8 +7874,8 @@ public override string GetDebugStatus()
78777874
CylinderSteamExhaust3On ? Simulator.Catalog.GetString("Yes") : Simulator.Catalog.GetString("No"),
78787875
Simulator.Catalog.GetString("#4"),
78797876
CylinderSteamExhaust4On ? Simulator.Catalog.GetString("Yes") : Simulator.Catalog.GetString("No"),
7880-
Simulator.Catalog.GetString("AvMF"),
7881-
FormatStrings.FormatForce(MotiveForceN, IsMetric)
7877+
Simulator.Catalog.GetString("AvTF"),
7878+
FormatStrings.FormatForce(AverageTractiveForceN, IsMetric)
78827879

78837880

78847881
);

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/SteamEngine.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,11 @@ public enum AuxiliarySteamEngineTypes
351351
/// </summary>
352352
public float TractiveForceN;
353353

354+
/// <summary>
355+
/// Steam Engine average tractive force
356+
/// </summary>
357+
public float AverageTractiveForceN;
358+
354359
/// <summary>
355360
/// Steam Engine maximum indicated horsepower
356361
/// </summary>

0 commit comments

Comments
 (0)