Skip to content

Commit 04bd431

Browse files
committed
Further corrections
1 parent 89d8d80 commit 04bd431

File tree

1 file changed

+45
-44
lines changed

1 file changed

+45
-44
lines changed

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

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,6 @@ public float TenderCoalMassKG // Decreased by firing and increased
625625

626626
// Rotative Force and adhesion
627627

628-
float CalculatedFactorofAdhesion; // Calculated factor of adhesion
629-
630628
float ReciprocatingWeightLb = 580.0f; // Weight of reciprocating parts of the rod driving gears
631629
float ConnectingRodWeightLb = 600.0f; // Weignt of connecting rod
632630
float ConnectingRodBalanceWeightLb = 300.0f; // Balance weight for connecting rods
@@ -1471,7 +1469,7 @@ public override void Initialize()
14711469
// Adjust resistance for neutral gearing
14721470
GearedRetainedDavisAN = DavisAN; // remember davis a value for later
14731471
NeutralGearedDavisAN = DavisAN; // Initialise neutral gear value
1474-
float TempDavisAAmount = N.FromLbf((DavisMechanicalResistanceFactor * Kg.ToTUS(DrvWheelWeightKg))); // Based upon the Davis formula for steam locomotive resistance
1472+
float TempDavisAAmount = N.FromLbf((DavisMechanicalResistanceFactor * Kg.ToTUS(SteamEngines[0].AttachedAxle.WheelWeightKg))); // Based upon the Davis formula for steam locomotive resistance
14751473
if (TempDavisAAmount > 0.5 * DavisAN)
14761474
{
14771475
TempDavisAAmount = DavisAN * 0.5f; // If calculated mechanical resistance is greater then then 50% of the DavisA amount then set to an arbitary value of 50%.
@@ -1716,10 +1714,10 @@ public override void Initialize()
17161714
DisplaySpeedFactor = MaxSpeedFactor;
17171715
}
17181716

1719-
// Calculate max velocity of the locomotive based upon above piston speed
1717+
// Calculate max velocity of the locomotive based upon above piston speed (use first steam engine as the reference)
17201718
if (SteamEngineType != SteamEngineTypes.Geared)
17211719
{
1722-
MaxLocoSpeedMpH = MpS.ToMpH(Me.FromFt(pS.FrompM(MaxPistonSpeedFtpM / SteamGearRatio))) * 2.0f * MathHelper.Pi * DriverWheelRadiusM / (2.0f * MSTSCylinderStrokeM);
1720+
MaxLocoSpeedMpH = MpS.ToMpH(Me.FromFt(pS.FrompM(MaxPistonSpeedFtpM / SteamGearRatio))) * 2.0f * MathHelper.Pi * DriverWheelRadiusM / (2.0f * SteamEngines[0].CylindersStrokeM);
17231721
DisplayMaxLocoSpeedMpH = MaxLocoSpeedMpH;
17241722
}
17251723

@@ -1931,17 +1929,18 @@ public override void Initialize()
19311929

19321930
for (int i = 0; i < SteamEngines.Count; i++)
19331931
{
1934-
if (SteamEngines[i].MaxIndicatedHorsePowerHP == 0 && SteamEngines.Count == 0 && MaxIndicatedHorsePowerHP != 0) // if MaxIHP is not set in ENG file, then set a default
1932+
if (SteamEngines[i].MaxIndicatedHorsePowerHP == 0 && SteamEngines.Count == 0 && MaxIndicatedHorsePowerHP != 0)
1933+
// if MaxIHP is not set in ENG file, then set a default
19351934
{
19361935
SteamEngines[i].MaxIndicatedHorsePowerHP = MaxIndicatedHorsePowerHP;
19371936
}
1938-
else
1937+
else if (SteamEngines[i].MaxIndicatedHorsePowerHP == 0)
19391938
{
19401939
// Max IHP = (Max TE x Speed) / 375.0, use a factor of 0.85 to calculate max TE
19411940
SteamEngines[i].MaxIndicatedHorsePowerHP = MaxSpeedFactor * (SteamEngines[i].MaxTractiveEffortLbf * MaxLocoSpeedMpH) / 375.0f; // To be checked what MaxTractive Effort is for the purposes of this formula.
1942-
1943-
MaxIndicatedHorsePowerHP += SteamEngines[i].MaxIndicatedHorsePowerHP;
19441941
}
1942+
1943+
MaxIndicatedHorsePowerHP += SteamEngines[i].MaxIndicatedHorsePowerHP;
19451944
}
19461945

19471946

@@ -1987,10 +1986,6 @@ public override void Initialize()
19871986
SteamEngines[i].CalculatedFactorOfAdhesion = Kg.ToLb(SteamEngines[i].AttachedAxle.WheelWeightKg) / SteamEngines[i].MaxTractiveEffortLbf;
19881987
}
19891988

1990-
// Total FoA
1991-
1992-
CalculatedFactorofAdhesion = Kg.ToLb(DrvWheelWeightKg) / MaxTractiveEffortLbf;
1993-
19941989
// Calculate "critical" power of locomotive to determine limit of max IHP
19951990
MaxCriticalSpeedTractiveEffortLbf = (MaxTractiveEffortLbf * CylinderEfficiencyRate) * MaxSpeedFactor;
19961991
DisplayCriticalSpeedTractiveEffortLbf = MaxCriticalSpeedTractiveEffortLbf;
@@ -5318,7 +5313,7 @@ private void UpdateSteamTractiveForce(float elapsedClockSeconds, float locomotiv
53185313
// only set advanced wheel slip when advanced adhesion, and simplecontrols/physics is not set and is in the the player train, AI locomotive will not work to this model.
53195314
// Don't use slip model when train is in auto pilot
53205315
{
5321-
if (SteamEngineType != SteamEngineTypes.Geared && SteamEngines[numberofengine].AuxiliarySteamEngineType != SteamEngine.AuxiliarySteamEngineTypes.Booster)
5316+
if (SteamEngineType != SteamEngineTypes.Geared || SteamEngines[numberofengine].AuxiliarySteamEngineType != SteamEngine.AuxiliarySteamEngineTypes.Booster)
53225317
{
53235318

53245319
float slipCutoffPressureAtmPSI;
@@ -5527,7 +5522,7 @@ private void UpdateSteamTractiveForce(float elapsedClockSeconds, float locomotiv
55275522

55285523
// For more then two cylinder eingines reciprocating inertia is not required as it only applies to the gearing on each side and not the number of cylinders.
55295524
// Hence "zero" it out, however reciprocating rods will still apply
5530-
if ((SteamEngines[numberofengine].NumberCylinders == 3 && i > 1) || (SteamEngines[numberofengine].NumberCylinders == 4 && (i == 1 || i == 3)))
5525+
if ((SteamEngines[numberofengine].NumberCylinders == 3 && i > 1) || (SteamEngines[numberofengine].NumberCylinders == 4 && (i == 1 || i == 3)) )
55315526
{
55325527
reciprocatingInertiaForcelbf = 0;
55335528
}
@@ -5652,7 +5647,7 @@ private void UpdateSteamTractiveForce(float elapsedClockSeconds, float locomotiv
56525647
SteamEngines[numberofengine].IndicatedHorsePowerHP = (N.ToLbf(SteamEngines[numberofengine].TractiveForceN) * pS.TopH(Me.ToMi(absSpeedMpS))) / 375.0f;
56535648
}
56545649
}
5655-
else // Adjust tractive force if "simple" friction is used, or is a geared steam locomotive
5650+
else // Adjust tractive force if "simple" friction is used
56565651
{
56575652
// This section updates the force calculations and maintains them at the current values.
56585653

@@ -5758,7 +5753,7 @@ private void UpdateSteamTractiveForce(float elapsedClockSeconds, float locomotiv
57585753
IsCritTELimit = false; // Reset flag if limiting TE
57595754
}
57605755

5761-
SteamEngines[numberofengine].AttachedAxle.DriveForceN = SteamEngines[numberofengine].TractiveForceN;
5756+
SteamEngines[numberofengine].AttachedAxle.DriveForceN = SteamEngines[numberofengine].TractiveForceN / SteamEngines[numberofengine].AttachedAxle.NumberWheelAxles;
57625757
}
57635758

57645759
/// <summary>
@@ -5778,6 +5773,11 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float loc
57785773
{
57795774
TractiveForceN += SteamEngines[i].TractiveForceN;
57805775

5776+
if (Simulator.UseAdvancedAdhesion && !Simulator.Settings.SimpleControlPhysics)
5777+
{
5778+
UpdateAxleDriveForce();
5779+
}
5780+
57815781
MotiveForceN += SteamEngines[i].AttachedAxle.CompensatedAxleForceN;
57825782

57835783
// Set Max Power equal to max IHP
@@ -5808,11 +5808,6 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float loc
58085808

58095809
DisplayTractiveForceN = TractiveForceN;
58105810

5811-
if (Simulator.UseAdvancedAdhesion && !Simulator.Settings.SimpleControlPhysics)
5812-
{
5813-
UpdateAxleDriveForce();
5814-
}
5815-
58165811
MotiveForceSmoothN.Update(elapsedClockSeconds, MotiveForceN);
58175812
MotiveForceSmoothedN = MotiveForceSmoothN.SmoothedValue;
58185813
if (float.IsNaN(MotiveForceN))
@@ -5850,8 +5845,15 @@ private float NormalisedCrankAngle(int cylinderNumber)
58505845
}
58515846

58525847

5848+
protected override void UpdateAxleDriveForce()
5849+
{
5850+
// No updates are done to Axle Drive Force in steam locomotives, unless a future slip control device is added.
5851+
}
5852+
5853+
58535854
public override void AdvancedAdhesion(float elapsedClockSeconds)
58545855
{
5856+
58555857
foreach (var axle in LocomotiveAxles)
58565858
{
58575859
SteamEngine linkedEngine = null;
@@ -5865,18 +5867,33 @@ public override void AdvancedAdhesion(float elapsedClockSeconds)
58655867
}
58665868
if (linkedEngine == null) continue;
58675869

5868-
if (SteamEngineType != SteamEngineTypes.Geared || linkedEngine.AuxiliarySteamEngineType != SteamEngine.AuxiliarySteamEngineTypes.Booster)
5870+
if (SteamEngineType == SteamEngineTypes.Geared || linkedEngine.AuxiliarySteamEngineType == SteamEngine.AuxiliarySteamEngineTypes.Booster)
5871+
// geared locomotive or booster locomotive
5872+
{
5873+
// Moment of Inertia (Wheel and axle) = (Mass x Radius^2) / 2.0
5874+
float AxleRadiusM = Me.FromIn(8.0f / 2.0f);
5875+
float WheelMomentInertia = (linkedEngine.AttachedAxle.WheelWeightKg * linkedEngine.AttachedAxle.WheelRadiusM * linkedEngine.AttachedAxle.WheelRadiusM) / 2.0f;
5876+
float AxleMomentInertia = (linkedEngine.AttachedAxle.WheelWeightKg * AxleRadiusM * AxleRadiusM) / 2.0f;
5877+
float TotalWheelMomentofInertia = WheelMomentInertia + AxleMomentInertia; // Total MoI for generic wheelset
5878+
float TotalMomentInertia = TotalWheelMomentofInertia;
5879+
axle.InertiaKgm2 = TotalMomentInertia;
5880+
axle.DampingNs = axle.AxleWeightN / 200;
5881+
// Calculate internal resistance - IR = 3.8 * diameter of cylinder^2 * stroke * dia of drivers (all in inches) - This should reduce wheel force
5882+
axle.FrictionN = N.FromLbf(3.8f * Me.ToIn(linkedEngine.CylindersDiameterM) * Me.ToIn(linkedEngine.CylindersDiameterM) * Me.ToIn(linkedEngine.CylindersStrokeM) / (Me.ToIn(axle.WheelRadiusM * 2.0f)));
5883+
}
5884+
5885+
else // normal locomotive
58695886
{
5887+
58705888
// This next section calculates wheel inertia, which is used in adhesion module
58715889
// A Generic wheel profile is used, so results may not be applicable to all locomotive, but should provide a "reasonable" guestimation
58725890
// Generic wheel assumptions are - 80 inch drive wheels ( 2.032 metre), a pair of drive wheels weighs approx 6,000lbs, axle weighs 1,000 lbs, and has a diameter of 8 inches.
58735891
// Moment of Inertia (Wheel and axle) = (Mass x Radius^2) / 2.0
5874-
float WheelRadiusAssumptM = Me.FromIn(80.0f / 2.0f);
5875-
float WheelWeightKG = Kg.FromLb(6000.0f);
5892+
58765893
float AxleWeighKG = Kg.FromLb(1000.0f);
58775894
float AxleRadiusM = Me.FromIn(8.0f / 2.0f);
5878-
float WheelMomentInertia = (WheelWeightKG * WheelRadiusAssumptM * WheelRadiusAssumptM) / 2.0f;
5879-
float AxleMomentInertia = (WheelWeightKG * AxleRadiusM * AxleRadiusM) / 2.0f;
5895+
float WheelMomentInertia = (linkedEngine.AttachedAxle.WheelWeightKg * linkedEngine.AttachedAxle.WheelRadiusM * linkedEngine.AttachedAxle.WheelRadiusM) / 2.0f;
5896+
float AxleMomentInertia = (linkedEngine.AttachedAxle.WheelWeightKg * AxleRadiusM * AxleRadiusM) / 2.0f;
58805897
float TotalWheelMomentofInertia = WheelMomentInertia + AxleMomentInertia; // Total MoI for generic wheelset
58815898

58825899
SteamDrvWheelWeightLbs = Kg.ToLb(DrvWheelWeightKg / axle.NumberWheelAxles); // Calculate the weight per axle (used in MSTSLocomotive for friction calculatons)
@@ -5892,33 +5909,17 @@ public override void AdvancedAdhesion(float elapsedClockSeconds)
58925909
float RodStrokeM = linkedEngine.CylindersStrokeM / 2.0f;
58935910
float RodMomentInertia = 0;
58945911

5895-
58965912
RodMomentInertia = RodWeightKG * RodStrokeM * RodStrokeM;
58975913

58985914
float TotalMomentInertia = TotalWheelMomentofInertia + RodMomentInertia;
58995915
axle.InertiaKgm2 = TotalMomentInertia;
59005916
axle.DampingNs = axle.AxleWeightN / 200;
59015917
// Calculate internal resistance - IR = 3.8 * diameter of cylinder^2 * stroke * dia of drivers (all in inches) - This should reduce wheel force
59025918
axle.FrictionN = N.FromLbf(3.8f * Me.ToIn(linkedEngine.CylindersDiameterM) * Me.ToIn(linkedEngine.CylindersDiameterM) * Me.ToIn(linkedEngine.CylindersStrokeM) / (Me.ToIn(axle.WheelRadiusM * 2.0f)));
5903-
}
5904-
5905-
else // geared locomotive or booster locomotive
5906-
{
5907-
// Moment of Inertia (Wheel and axle) = (Mass x Radius^2) / 2.0
5908-
float WheelRadiusAssumptM = Me.FromIn(80.0f / 2.0f);
5909-
float WheelWeightKG = Kg.FromLb(6000.0f);
5910-
float AxleRadiusM = Me.FromIn(8.0f / 2.0f);
5911-
float WheelMomentInertia = (WheelWeightKG * WheelRadiusAssumptM * WheelRadiusAssumptM) / 2.0f;
5912-
float AxleMomentInertia = (WheelWeightKG * AxleRadiusM * AxleRadiusM) / 2.0f;
5913-
float TotalWheelMomentofInertia = WheelMomentInertia + AxleMomentInertia; // Total MoI for generic wheelset
5914-
float TotalMomentInertia = TotalWheelMomentofInertia;
5915-
axle.InertiaKgm2 = TotalMomentInertia;
5916-
axle.DampingNs = axle.AxleWeightN / 200;
5917-
// Calculate internal resistance - IR = 3.8 * diameter of cylinder^2 * stroke * dia of drivers (all in inches) - This should reduce wheel force
5918-
axle.FrictionN = N.FromLbf(3.8f * Me.ToIn(linkedEngine.CylindersDiameterM) * Me.ToIn(linkedEngine.CylindersDiameterM) * Me.ToIn(linkedEngine.CylindersStrokeM) / (Me.ToIn(axle.WheelRadiusM * 2.0f)));
59195919

59205920
}
59215921
}
5922+
59225923
base.AdvancedAdhesion(elapsedClockSeconds);
59235924
}
59245925

0 commit comments

Comments
 (0)