@@ -173,6 +173,7 @@ public class MSTSSteamLocomotive : MSTSLocomotive
173173 int BoosterEngineNumber;
174174
175175 bool CounterPressureBrakingFitted = false;
176+ float CounterPressureMEP;
176177
177178 /// <summary>
178179 /// Grate limit of locomotive exceedeed?
@@ -1480,7 +1481,6 @@ public override void Initialize()
14801481 Trace.TraceWarning("Boiler Volume not found in ENG file, or doesn't appear to be a valid figure, and has been set to {0} Ft^3", BoilerVolumeFT3);
14811482 }
14821483
1483-
14841484 // Assign default steam table values if table not in ENG file
14851485 if (BoilerEfficiencyGrateAreaLBpFT2toX == null)
14861486 {
@@ -1678,6 +1678,13 @@ public override void Initialize()
16781678
16791679 for (int i = 0; i < SteamEngines.Count; i++)
16801680 {
1681+
1682+ // Check that this is across all steam engines
1683+ if (LocomotiveRailDriveType == LocomotiveRailDriveTypes.Rack && SteamEngines[i].AttachedAxle.CogWheelRadiusM == 0)
1684+ {
1685+ SteamEngines[i].AttachedAxle.CogWheelRadiusM = CogWheelRadiusM;
1686+ }
1687+
16811688 if (SteamEngines[i].AuxiliarySteamEngineType != SteamEngine.AuxiliarySteamEngineTypes.Booster)
16821689 {
16831690 if (SteamEngineType == SteamEngineTypes.Compound)
@@ -6018,8 +6025,9 @@ private void UpdateCylinders(float elapsedClockSeconds, float throttle, float cu
60186025 float CylinderRatio_compression = CylinderVolumePoint_compression / CylinderClearancePC;
60196026 float CylinderRatio_release = CylinderVolumePoint_compression / (Me.ToIn(SteamEngines[numberofengine].CylindersStrokeM) + 2 * CylinderClearancePC);
60206027
6021- float CompMeanPressure_compressionAtmPSI = OneAtmospherePSI * CylinderRatio_compression * ((float)Math.Log(CylinderRatio_compression, 10) / (CylinderRatio_compression - 1.0f));
6022- float CompMeanPressure_releaseAtmPSI = CompMeanPressure_compressionAtmPSI * CylinderRatio_release * ((float)Math.Log(CylinderRatio_release) / (CylinderRatio_release - 1.0f));
6028+ // Note to convert to hyperbolic log, value needs to be multiplied by 2
6029+ float CompMeanPressure_compressionAtmPSI = OneAtmospherePSI * CylinderRatio_compression * (2.0f * (float)Math.Log(CylinderRatio_compression, 10) / (CylinderRatio_compression - 1.0f));
6030+ float CompMeanPressure_releaseAtmPSI = CompMeanPressure_compressionAtmPSI * CylinderRatio_release * (2.0f * (float)Math.Log(CylinderRatio_release) / (CylinderRatio_release - 1.0f));
60236031
60246032 // Trace.TraceInformation("MEPcomp {0} Log {1} CompRatio {2}", CompMeanPressure_compressionAtmPSI, (float)Math.Log(CylinderRatio_compression), CylinderRatio_compression);
60256033
@@ -6030,18 +6038,21 @@ private void UpdateCylinders(float elapsedClockSeconds, float throttle, float cu
60306038
60316039 float TotalWorkCounterPressure = CylinderWork_compression_InLbs + CylinderWork_release_InLbs;
60326040
6033- float CounterPressureMEP = TotalWorkCounterPressure / Me.ToIn(SteamEngines[numberofengine].CylindersStrokeM);
6041+ CounterPressureMEP = TotalWorkCounterPressure / Me.ToIn(SteamEngines[numberofengine].CylindersStrokeM);
60346042
60356043 // Assume no impact of "return" stroke as air is being drawn into cylinder
60366044
6045+ float CounterBalanceWheelDiamM = 2 * SteamEngines[numberofengine].AttachedAxle.CogWheelRadiusM;
6046+
60376047 // Calculate tractive retarding force
6038- SteamEngines[numberofengine].CylinderCounterPressureBrakeForceN = N.FromLbf(CounterPressureMEP * Me.ToIn(SteamEngines[numberofengine].CylindersDiameterM) * Me.ToIn(SteamEngines[numberofengine].CylindersDiameterM) * Me.ToIn(SteamEngines[numberofengine].CylindersStrokeM) / Me.ToIn(SteamEngines[numberofengine].AttachedAxle.CogWheelRadiusM ));
6048+ SteamEngines[numberofengine].CylinderCounterPressureBrakeForceN = N.FromLbf(CounterPressureMEP * Me.ToIn(SteamEngines[numberofengine].CylindersDiameterM) * Me.ToIn(SteamEngines[numberofengine].CylindersDiameterM) * Me.ToIn(SteamEngines[numberofengine].CylindersStrokeM) / Me.ToIn(CounterBalanceWheelDiamM ));
60396049
6040- // Trace.TraceInformation("CogRetardForce {0} throttle {1} MEP {2} Ratio-Comp {3} Ratio-Rel {4}", N.ToLbf(SteamLocomotiveRetardingDynamicBrakeForceN ), throttle, CounterPressureMEP, CylinderRatio_compression, CylinderRatio_release);
6041- }
6042- else
6050+ // Trace.TraceInformation("CogRetardForce {0} throttle {1} MEP {2} Ratio-Comp {3} Ratio-Rel {4} Pc {5} Pr {6} ", N.ToLbf(SteamEngines[numberofengine].CylinderCounterPressureBrakeForceN ), throttle, CounterPressureMEP, CylinderRatio_compression, CylinderRatio_release, CompMeanPressure_compressionAtmPSI, CompMeanPressure_releaseAtmPSI );
6051+ }
6052+ else
60436053 {
60446054 SteamEngines[numberofengine].CylinderCounterPressureBrakeForceN = 0;
6055+ CounterPressureMEP = 0;
60456056 }
60466057 }
60476058
@@ -6573,6 +6584,7 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float loc
65736584 MaxPowerW = 0;
65746585 MaxForceN = 0;
65756586 DisplayTractiveForceN = 0;
6587+ float CounterPressureRetardingForceN = 0;
65766588
65776589 if (WheelSlip && AdvancedAdhesionModel)
65786590 {
@@ -6588,30 +6600,44 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float loc
65886600 {
65896601 ApplyDirectionToTractiveForce(ref SteamEngines[i].RealTractiveForceN, i);
65906602
6591- TractiveForceN += SteamEngines[i].RealTractiveForceN + DynamicBrakeForceN;
6592-
65936603 if (Simulator.UseAdvancedAdhesion && !Simulator.Settings.SimpleControlPhysics)
65946604 {
6595- SteamEngines[i].AttachedAxle.DriveForceN = SteamEngines[i].RealTractiveForceN;
6596-
6597- // Counter Pressure braking system
6598-
6605+ // Riggenbach Counter Pressure braking system
6606+ // Note valve motion needs to be reversed, ie if travelling forward reverser needs to be set in reverse, similarly if travelling in reverse,
6607+ // needs to be set in forward.
65996608 if (DynamicBrakePercent > 0 && CounterPressureBrakingFitted && absSpeedMpS > 0.1)
6600- {
6601- DynamicBrakeForceN += SteamEngines[i].CylinderCounterPressureBrakeForceN;
6602- TractiveForceN -= (SpeedMpS > 0 ? 1 : SpeedMpS < 0 ? -1 : Direction == Direction.Reverse ? -1 : 1) * DynamicBrakeForceN;
6603- SteamEngines[i].AttachedAxle.DriveForceN = SteamEngines[i].RealTractiveForceN;
6604- }
6605- else
6606- {
6607- DynamicBrakeForceN = 0;
6609+ {
6610+ if (SpeedMpS > 0)
6611+ {
6612+ if (Direction == Direction.Reverse)
6613+ {
6614+ CounterPressureRetardingForceN = -1 * SteamEngines[i].CylinderCounterPressureBrakeForceN;
6615+ }
6616+ else
6617+ {
6618+ CounterPressureRetardingForceN = 0;
6619+ }
6620+ }
6621+ else if (SpeedMpS < 0)
6622+ {
6623+ if (Direction == Direction.Forward)
6624+ {
6625+ CounterPressureRetardingForceN = SteamEngines[i].CylinderCounterPressureBrakeForceN;
6626+ }
6627+ else
6628+ {
6629+ CounterPressureRetardingForceN = 0;
6630+ }
6631+ }
6632+ else
6633+ {
6634+ CounterPressureRetardingForceN = 0;
6635+ }
66086636 }
66096637
6610- if (DynamicBrakeForceN > 0)
6611- {
6612-
6613- SteamEngines[i].AttachedAxle.DriveForceN = DynamicBrakeForceN;
6614- }
6638+ SteamEngines[i].AttachedAxle.DriveForceN = SteamEngines[i].RealTractiveForceN + CounterPressureRetardingForceN;
6639+ TractiveForceN += SteamEngines[i].RealTractiveForceN + CounterPressureRetardingForceN;
6640+ DynamicBrakeForceN += SteamEngines[i].CylinderCounterPressureBrakeForceN;
66156641
66166642 UpdateAxleDriveForce();
66176643
@@ -6624,7 +6650,6 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float loc
66246650 SteamEngines[i].DisplayTractiveForceN = SteamEngines[i].RealTractiveForceN;
66256651 MotiveForceN += SteamEngines[i].RealTractiveForceN;
66266652 DisplayTractiveForceN += SteamEngines[i].RealTractiveForceN;
6627-
66286653 }
66296654
66306655 // Set Max Power equal to max IHP
@@ -8699,6 +8724,36 @@ public override string GetDebugStatus()
86998724 }
87008725 }
87018726
8727+ if (CounterPressureBrakingFitted)
8728+ {
8729+ status.AppendFormat("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\t{13}\t{14:N0}{15}\t{16}\t{17}\t{18}\t{19}\t{20}\t{21}\n",
8730+ Simulator.Catalog.GetString("ForceTot:"),
8731+ Simulator.Catalog.GetString("TheorTE"),
8732+ FormatStrings.FormatForce(N.FromLbf(MaxTractiveEffortLbf), IsMetric),
8733+ Simulator.Catalog.GetString("StartTE"),
8734+ FormatStrings.FormatForce(absStartTractiveEffortN, IsMetric),
8735+ Simulator.Catalog.GetString("AvTE"),
8736+ FormatStrings.FormatForce(DisplayTractiveForceN, IsMetric),
8737+ Simulator.Catalog.GetString("Draw"),
8738+ FormatStrings.FormatForce(N.FromLbf(DrawBarPullLbsF), IsMetric),
8739+ Simulator.Catalog.GetString("CritSpeed"),
8740+ FormatStrings.FormatSpeedDisplay(MpS.FromMpH(MaxLocoSpeedMpH), IsMetric),
8741+ Simulator.Catalog.GetString("SpdLmt"),
8742+ IsCritTELimit ? Simulator.Catalog.GetString("Yes") : Simulator.Catalog.GetString("No"),
8743+ Simulator.Catalog.GetString("Hammer"),
8744+ FormatStrings.FormatForce(N.FromLbf(SteamEngines[0].HammerForceLbs), IsMetric),
8745+ SteamEngines[0].IsWheelHammerForce ? "!!!" : SteamEngines[0].IsWheelHammerForceWarning ? "???" : "",
8746+ Simulator.Catalog.GetString("CtPress"),
8747+ FormatStrings.FormatPressure(CounterPressureMEP, PressureUnit.PSI, MainPressureUnit, true),
8748+ Simulator.Catalog.GetString("CtForce"),
8749+ FormatStrings.FormatForce(SteamEngines[0].CylinderCounterPressureBrakeForceN, IsMetric),
8750+ Simulator.Catalog.GetString("DyForce"),
8751+ FormatStrings.FormatForce(DynamicBrakeForceN, IsMetric)
8752+
8753+ );
8754+ }
8755+ else
8756+ {
87028757 status.AppendFormat("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\t{13} \t{14:N0}{15}\n",
87038758 Simulator.Catalog.GetString("ForceTot:"),
87048759 Simulator.Catalog.GetString("TheorTE"),
@@ -8719,6 +8774,10 @@ public override string GetDebugStatus()
87198774
87208775 );
87218776
8777+
8778+
8779+ }
8780+
87228781 status.AppendFormat("{0}\t{1}\t{2:N0} {5}/{6}\t\t{3}\t{4:N0} \t{7} {8:N2}\n",
87238782 Simulator.Catalog.GetString("Move:"),
87248783 Simulator.Catalog.GetString("Piston"),
@@ -8729,7 +8788,6 @@ public override string GetDebugStatus()
87298788 FormatStrings.min,
87308789 Simulator.Catalog.GetString("Max-SpdF"),
87318790 DisplaySpeedFactor
8732-
87338791 );
87348792 }
87358793
0 commit comments