@@ -324,7 +324,7 @@ public class MSTSSteamLocomotive : MSTSLocomotive
324324 float[,] TractiveForceAverageN = new float[5, 37];
325325 float AverageTractiveForceN;
326326
327- public Orts.Simulation.Simulation.RollingStocks.SubSystems.PowerSupplies. SteamEngines SteamEngines;
327+ public SteamEngines SteamEngines;
328328
329329 // steam performance reporting
330330 public float SteamPerformanceTimeS = 0.0f; // Records the time since starting movement
@@ -653,7 +653,6 @@ public float TenderFuelMassKG // Decreased by firing and increased
653653 float MaxIndicatedHorsePowerHP; // IHP @ max performance for the locomotive
654654 float DisplayMaxIndicatedHorsePowerHP; // Display value for HUD of IHP @ max performance for the geared locomotive
655655 float RetainedGearedMaxMaxIndicatedHorsePowerHP; // Retrains maximum IHP value for steam locomotives.
656- float absSpeedMpS;
657656 float CombFrictionN; // Temporary parameter to store combined friction values of locomotive and tender
658657 float CombGravityN; // Temporary parameter to store combined Gravity values of locomotive and tender
659658 float CombTunnelN; // Temporary parameter to store combined Tunnel values of locomotive and tender
@@ -2515,9 +2514,11 @@ public override void Update(float elapsedClockSeconds)
25152514 {
25162515 var enginethrottle = 0.0f;
25172516
2517+ float absSpeedRefMpS = Simulator.UseAdvancedAdhesion ? Math.Abs((float)SteamEngines[i].AttachedAxle.AxleSpeedMpS) : AbsTractionSpeedMpS;
2518+
25182519 if (SteamEngines[i].AuxiliarySteamEngineType != SteamEngine.AuxiliarySteamEngineTypes.Booster)
25192520 {
2520- UpdateCylinders(elapsedClockSeconds, throttle, cutoff, Math.Abs((float)SteamEngines[i].AttachedAxle.AxleSpeedMpS) , i);
2521+ UpdateCylinders(elapsedClockSeconds, throttle, cutoff, absSpeedRefMpS , i);
25212522 }
25222523 else if (SteamEngines[i].AuxiliarySteamEngineType == SteamEngine.AuxiliarySteamEngineTypes.Booster) // Booster Engine
25232524 {
@@ -2639,7 +2640,7 @@ public override void Update(float elapsedClockSeconds)
26392640 BoosterEngineSpeedRpM = 0.0f;
26402641 }
26412642
2642- UpdateCylinders(elapsedClockSeconds, enginethrottle, BoosterCylinderExhaustOpenFactor, Math.Abs((float)SteamEngines[i].AttachedAxle.AxleSpeedMpS) , i);
2643+ UpdateCylinders(elapsedClockSeconds, enginethrottle, BoosterCylinderExhaustOpenFactor, absSpeedRefMpS , i);
26432644
26442645 // Update Booster steam consumption
26452646 if (SteamBoosterIdleMode)
@@ -2799,6 +2800,8 @@ private void UpdateFX(float elapsedClockSeconds)
27992800 {
28002801 var TotalNumberCyindersEng1 = 0;
28012802
2803+ float absSpeedRefMpS = Simulator.UseAdvancedAdhesion ? Math.Abs((float)SteamEngines[0].AttachedAxle.AxleSpeedMpS) : AbsTractionSpeedMpS;
2804+
28022805 if (SteamEngineType == SteamEngineTypes.Compound)
28032806 {
28042807 TotalNumberCyindersEng1 = SteamEngines[0].NumberCylinders + SteamEngines[0].LPNumberCylinders;
@@ -2845,8 +2848,8 @@ private void UpdateFX(float elapsedClockSeconds)
28452848 ExhaustnormalisedCrankAngleRad[i] = normalisedCrankAngleRad;
28462849 ExhaustexhaustCrankAngleRad[i] = exhaustCrankAngleRadFor;
28472850
2848-
2849- if (AbsTractionSpeedMpS > 0.001)
2851+
2852+ if (absSpeedRefMpS > 0.001)
28502853 {
28512854 if (i == 0 && ((normalisedCrankAngleRad >= exhaustCrankAngleRadFor && normalisedCrankAngleRad <= MathHelper.Pi) || (normalisedCrankAngleRad >= exhaustCrankAngleRadRev && normalisedCrankAngleRad < 2 * MathHelper.Pi )))
28522855 {
@@ -3045,6 +3048,7 @@ private void UpdateFX(float elapsedClockSeconds)
30453048 {
30463049 var TotalNumberCyindersEng2 = SteamEngines[1].NumberCylinders; // currently assume 2nd engine is non-compound
30473050
3051+ absSpeedRefMpS = Simulator.UseAdvancedAdhesion ? Math.Abs((float)SteamEngines[1].AttachedAxle.AxleSpeedMpS) : AbsTractionSpeedMpS;
30483052 // Engine #2
30493053 for (int i = 0; i < TotalNumberCyindersEng2; i++)
30503054 {
@@ -3076,7 +3080,7 @@ private void UpdateFX(float elapsedClockSeconds)
30763080 exhaustCrankAngleRadRev -= 2 * (float)Math.PI;
30773081 }
30783082
3079- if (AbsTractionSpeedMpS > 0.001)
3083+ if (absSpeedRefMpS > 0.001)
30803084 {
30813085 if (i == 0 && ((normalisedCrankAngleRad >= exhaustCrankAngleRadFor && normalisedCrankAngleRad <= MathHelper.Pi) || (normalisedCrankAngleRad >= exhaustCrankAngleRadRev && normalisedCrankAngleRad < 2 * MathHelper.Pi)))
30823086 {
@@ -3378,29 +3382,29 @@ private void UpdateFX(float elapsedClockSeconds)
33783382 GeneratorSteamVelocityMpS = 50.0f;
33793383 GeneratorSteamVolumeM3pS = 4.0f * SteamEffectsFactor;
33803384 GeneratorParticleDurationS = 1.0f;
3381- GeneratorParticleDurationS = MathHelper.Clamp(GeneratorParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 1.0f);
3385+ GeneratorParticleDurationS = MathHelper.Clamp(GeneratorParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 1.0f);
33823386
33833387 // Injector Steam Effects
33843388 Injector1SteamVolumeM3pS = (Injector1IsOn ? (5.0f * SteamEffectsFactor) : 0);
33853389 Injector1SteamVelocityMpS = 10.0f;
33863390 Injector1ParticleDurationS = 1.0f;
3387- Injector1ParticleDurationS = MathHelper.Clamp(Injector1ParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 1.0f);
3391+ Injector1ParticleDurationS = MathHelper.Clamp(Injector1ParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 1.0f);
33883392
33893393 Injector2SteamVolumeM3pS = (Injector2IsOn ? (5.0f * SteamEffectsFactor) : 0);
33903394 Injector2SteamVelocityMpS = 10.0f;
33913395 Injector2ParticleDurationS = 1.0f;
3392- Injector2ParticleDurationS = MathHelper.Clamp(Injector2ParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 1.0f);
3396+ Injector2ParticleDurationS = MathHelper.Clamp(Injector2ParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 1.0f);
33933397
33943398 // Ejector Steam Effects
33953399 SmallEjectorSteamVolumeM3pS = (SmallSteamEjectorIsOn ? (1.5f * SteamEffectsFactor) : 0);
33963400 SmallEjectorSteamVelocityMpS = 10.0f;
33973401 SmallEjectorParticleDurationS = 1.0f;
3398- SmallEjectorParticleDurationS = MathHelper.Clamp(SmallEjectorParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 1.0f);
3402+ SmallEjectorParticleDurationS = MathHelper.Clamp(SmallEjectorParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 1.0f);
33993403
34003404 LargeEjectorSteamVolumeM3pS = (LargeSteamEjectorIsOn ? (1.5f * SteamEffectsFactor) : 0);
34013405 LargeEjectorSteamVelocityMpS = 10.0f;
34023406 LargeEjectorParticleDurationS = 1.0f;
3403- LargeEjectorParticleDurationS = MathHelper.Clamp(LargeEjectorParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 1.0f);
3407+ LargeEjectorParticleDurationS = MathHelper.Clamp(LargeEjectorParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 1.0f);
34043408
34053409 // Compressor Steam Effects
34063410 // Only show compressor steam effects if it is not a vacuum controlled steam engine
@@ -3409,22 +3413,22 @@ private void UpdateFX(float elapsedClockSeconds)
34093413 CompressorSteamVelocityMpS = 10.0f;
34103414 CompressorSteamVolumeM3pS = (CompressorIsOn ? (1.5f * SteamEffectsFactor) : 0);
34113415 CompressorParticleDurationS = 1.0f;
3412- CompressorParticleDurationS = MathHelper.Clamp(CompressorParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 1.0f);
3416+ CompressorParticleDurationS = MathHelper.Clamp(CompressorParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 1.0f);
34133417 }
34143418
34153419 // Whistle Steam Effects
34163420 WhistleSteamVelocityMpS = 10.0f;
34173421 WhistleSteamVolumeM3pS = (Horn ? (5.0f * SteamEffectsFactor) : 0);
34183422 WhistleParticleDurationS = 3.0f;
3419- WhistleParticleDurationS = MathHelper.Clamp(WhistleParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 3.0f);
3423+ WhistleParticleDurationS = MathHelper.Clamp(WhistleParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 3.0f);
34203424
34213425 // Safety Valves Steam Effects
34223426
34233427 SafetyValvesSteamVelocityMpS = (float)Math.Sqrt(KPa.FromPSI(MaxBoilerPressurePSI) * 1000 * 2 / WaterDensityAt100DegC1BarKGpM3);
34243428 //SafetyValvesSteamVolumeM3pS = SafetyIsOn ? Kg.FromLb(SafetyValveUsageLBpS) * SteamVaporSpecVolumeAt100DegC1BarM3pKG : 0;
34253429 SafetyValvesSteamVolumeM3pS = SafetyIsOn ? 5.0f : 0;
34263430 SafetyValvesParticleDurationS = 3.0f;
3427- SafetyValvesParticleDurationS = MathHelper.Clamp(SafetyValvesParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 3.0f);
3431+ SafetyValvesParticleDurationS = MathHelper.Clamp(SafetyValvesParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 3.0f);
34283432
34293433 // Smoke Stack Smoke Effects
34303434 // Colur for smoke is determined by the amount of air flowing through the fire (ie damper ).
@@ -3437,7 +3441,7 @@ private void UpdateFX(float elapsedClockSeconds)
34373441 }
34383442 else
34393443 {
3440- SmokeColorDamper = absSpeedMpS * DamperFactorManual; // Damper value for manual firing - related to increased speed, and airflow through fire
3444+ SmokeColorDamper = AbsSpeedMpS * DamperFactorManual; // Damper value for manual firing - related to increased speed, and airflow through fire
34413445 }
34423446
34433447 SmokeColorDamper = MathHelper.Clamp(SmokeColorDamper, 0.0f, TheoreticalMaxSteamOutputLBpS); // set damper maximum to the max generation rate
@@ -3464,12 +3468,12 @@ private void UpdateFX(float elapsedClockSeconds)
34643468 }
34653469 else // when not exhausting
34663470 {
3467- if (absSpeedMpS < 10)
3471+ if (AbsSpeedMpS < 10)
34683472 {
34693473 float smokeRestVelocityVariationFactor = 2 * cutoff; // adjust smoke velocity based upon throttle and cutoff settings
34703474 float smokeRestVolumeVariationFactor = 1 * cutoff; // adjust smoke volume based upon throttle and cutoff settings
34713475
3472- float velocityRate = (absSpeedMpS < 1 ? 1 .0f : 1.0f / AbsSpeedMpS);
3476+ float velocityRate = Math.Min(1 .0f, 1.0f / AbsSpeedMpS);
34733477 StackSteamVelocityMpS.Update(elapsedClockSeconds, velocityRate);
34743478 StackSteamVolumeM3pS = Kg.FromLb(BlowerSteamUsageLBpS + RadiationSteamLossLBpS + CompSteamUsageLBpS + GeneratorSteamUsageLBpS) * smokeRestVolumeVariationFactor * SteamVaporSpecVolumeAt100DegC1BarM3pKG;
34753479 StackSteamVolumeM3pS = StackSteamVolumeM3pS / StackCount + FireRatio;
@@ -3738,7 +3742,7 @@ private void UpdateTender(float elapsedClockSeconds)
37383742 float HeatLossNoWindBTUph = (1- AreaExposedtoWindMovementFraction) * HeatTransferCoefficientBtuphft2F * AssumedSurfaceAreaFt2 * HeatDiff;
37393743
37403744 // To compensate for the train movement we need to add a wind factor
3741- float WindCoeff = -0.0074f * absSpeedMpS * absSpeedMpS + 0.3817f * absSpeedMpS + 1f;
3745+ float WindCoeff = -0.0074f * AbsSpeedMpS * AbsSpeedMpS + 0.3817f * AbsSpeedMpS + 1f;
37423746 WindCoeff = MathHelper.Clamp(WindCoeff, 1.0f, 5.78f); // Wind speed effect will not cause any more impact once over about 25 m/s
37433747
37443748 float HeatLossWindBTUph = (1 - AreaExposedtoWindMovementFraction) * HeatTransferCoefficientBtuphft2F * AssumedSurfaceAreaFt2 * HeatDiff * WindCoeff;
@@ -3871,7 +3875,7 @@ private void UpdateTender(float elapsedClockSeconds)
38713875 Trace.TraceInformation(" Water Percent {0} AuxTenderCoupled {1} SteamAuxTenderCoupled {2}", TenderWaterPercent, Train.IsAuxTenderCoupled, SteamIsAuxTenderCoupled);
38723876 Trace.TraceInformation("Water Controller Current Value {0} Previous Value {1}", WaterController.CurrentValue, PreviousTenderWaterVolumeUKG);
38733877#endif
3874- if (absSpeedMpS > 0.5) // Indicates train has moved, and therefore game started
3878+ if (AbsSpeedMpS > 0.5) // Indicates train has moved, and therefore game started
38753879 {
38763880 AuxTenderMoveFlag = true;
38773881 }
@@ -4205,8 +4209,6 @@ private void UpdateFirebox(float elapsedClockSeconds, float absSpeedMpS)
42054209
42064210 private void UpdateBoiler(float elapsedClockSeconds)
42074211 {
4208- absSpeedMpS = Math.Abs(Train.SpeedMpS);
4209-
42104212 #region Safety valves - determine number and size
42114213
42124214 // Determine number and size of safety valves
@@ -4676,14 +4678,14 @@ private void UpdateBoiler(float elapsedClockSeconds)
46764678 float HighSpeedMpS = 20.0f;
46774679 float KcMinSpeed = 10.45f - LowSpeedMpS + (10.0f * (float)Math.Pow(LowSpeedMpS, 0.5)); // Minimum speed of 2m/s
46784680 float KcMaxSpeed = 10.45f - HighSpeedMpS + (10.0f * (float)Math.Pow(HighSpeedMpS, 0.5)); // Maximum speed of 20m/s
4679- float KcActualSpeed = 10.45f - absSpeedMpS + (10.0f * (float)Math.Pow(absSpeedMpS , 0.5));
4681+ float KcActualSpeed = 10.45f - AbsSpeedMpS + (10.0f * (float)Math.Pow(AbsSpeedMpS , 0.5));
46804682 float KcMovementFraction = 0;
46814683
4682- if (absSpeedMpS > 2 && absSpeedMpS < 20.0f)
4684+ if (AbsSpeedMpS > 2 && AbsSpeedMpS < 20.0f)
46834685 {
46844686 KcMovementFraction = KcActualSpeed / KcMinSpeed; // Calculate fraction only between 2 and 20
46854687 }
4686- else if (absSpeedMpS < 2)
4688+ else if (AbsSpeedMpS < 2)
46874689 {
46884690 KcMovementFraction = 1.0f; // If speed less then 2m/s then set fracftion to give stationary Kc value
46894691 }
@@ -6602,7 +6604,7 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds)
66026604 DrawBarPullLbsF = N.ToLbf(Math.Abs(DisplayTractiveForceN) - LocoTenderFrictionForceN); // Locomotive drawbar pull is equal to motive force of locomotive (+ tender) - friction forces of locomotive (+ tender)
66036605 DrawBarPullLbsF = MathHelper.Clamp(DrawBarPullLbsF, 0, DrawBarPullLbsF); // clamp value so it doesn't go negative
66046606
6605- DrawbarHorsePowerHP = (DrawBarPullLbsF * MpS.ToMpH(absSpeedMpS )) / 375.0f; // TE in this instance is a maximum, and not at the wheel???
6607+ DrawbarHorsePowerHP = (DrawBarPullLbsF * MpS.ToMpH(AbsSpeedMpS )) / 375.0f; // TE in this instance is a maximum, and not at the wheel???
66066608 DrawbarHorsePowerHP = MathHelper.Clamp(DrawbarHorsePowerHP, 0, DrawbarHorsePowerHP); // clamp value so it doesn't go negative
66076609
66086610 // Set Max Velocity of locomotive
@@ -7078,18 +7080,18 @@ private void UpdateWaterInjection(float elapsedClockSeconds)
70787080 {
70797081 MaximumWaterMotionPumpFlowRateLBpS = (1.2f * EvaporationLBpS) / 2.0f; // Assume two pumps and that they can pump a fraction more water the the maximum steam production
70807082
7081- if (WaterMotionPump1IsOn && absSpeedMpS > 0)
7083+ if (WaterMotionPump1IsOn && AbsTractionSpeedMpS > 0)
70827084 {
7083- WaterMotionPump1FlowRateLBpS = MaximumWaterMotionPumpFlowRateLBpS * absSpeedMpS / MpS.FromMpH(MaxLocoSpeedMpH);
7085+ WaterMotionPump1FlowRateLBpS = MaximumWaterMotionPumpFlowRateLBpS * AbsTractionSpeedMpS / MpS.FromMpH(MaxLocoSpeedMpH);
70847086 }
70857087 else
70867088 {
70877089 WaterMotionPump1FlowRateLBpS = 0;
70887090 }
70897091
7090- if (WaterMotionPump2IsOn && absSpeedMpS > 0)
7092+ if (WaterMotionPump2IsOn && AbsTractionSpeedMpS > 0)
70917093 {
7092- WaterMotionPump2FlowRateLBpS = MaximumWaterMotionPumpFlowRateLBpS * absSpeedMpS / MpS.FromMpH(MaxLocoSpeedMpH);
7094+ WaterMotionPump2FlowRateLBpS = MaximumWaterMotionPumpFlowRateLBpS * AbsTractionSpeedMpS / MpS.FromMpH(MaxLocoSpeedMpH);
70937095 }
70947096 else
70957097 {
0 commit comments