@@ -331,7 +331,7 @@ public class MSTSSteamLocomotive : MSTSLocomotive
331
331
float[,] TractiveForceAverageN = new float[5, 37];
332
332
float AverageTractiveForceN;
333
333
334
- public Orts.Simulation.Simulation.RollingStocks.SubSystems.PowerSupplies. SteamEngines SteamEngines;
334
+ public SteamEngines SteamEngines;
335
335
336
336
// steam performance reporting
337
337
public float SteamPerformanceTimeS = 0.0f; // Records the time since starting movement
@@ -664,7 +664,6 @@ public float TenderFuelMassKG // Decreased by firing and increased
664
664
float MaxIndicatedHorsePowerHP; // IHP @ max performance for the locomotive
665
665
float DisplayMaxIndicatedHorsePowerHP; // Display value for HUD of IHP @ max performance for the geared locomotive
666
666
float RetainedGearedMaxMaxIndicatedHorsePowerHP; // Retrains maximum IHP value for steam locomotives.
667
- float absSpeedMpS;
668
667
float CombFrictionN; // Temporary parameter to store combined friction values of locomotive and tender
669
668
float CombGravityN; // Temporary parameter to store combined Gravity values of locomotive and tender
670
669
float CombTunnelN; // Temporary parameter to store combined Tunnel values of locomotive and tender
@@ -2601,9 +2600,11 @@ public override void Update(float elapsedClockSeconds)
2601
2600
{
2602
2601
var enginethrottle = 0.0f;
2603
2602
2603
+ float absSpeedRefMpS = Simulator.UseAdvancedAdhesion ? Math.Abs((float)SteamEngines[i].AttachedAxle.AxleSpeedMpS) : AbsTractionSpeedMpS;
2604
+
2604
2605
if (SteamEngines[i].AuxiliarySteamEngineType != SteamEngine.AuxiliarySteamEngineTypes.Booster)
2605
2606
{
2606
- UpdateCylinders(elapsedClockSeconds, throttle, cutoff, Math.Abs((float)SteamEngines[i].AttachedAxle.AxleSpeedMpS) , i);
2607
+ UpdateCylinders(elapsedClockSeconds, throttle, cutoff, absSpeedRefMpS , i);
2607
2608
}
2608
2609
else if (SteamEngines[i].AuxiliarySteamEngineType == SteamEngine.AuxiliarySteamEngineTypes.Booster) // Booster Engine
2609
2610
{
@@ -2725,7 +2726,7 @@ public override void Update(float elapsedClockSeconds)
2725
2726
BoosterEngineSpeedRpM = 0.0f;
2726
2727
}
2727
2728
2728
- UpdateCylinders(elapsedClockSeconds, enginethrottle, BoosterCylinderExhaustOpenFactor, Math.Abs((float)SteamEngines[i].AttachedAxle.AxleSpeedMpS) , i);
2729
+ UpdateCylinders(elapsedClockSeconds, enginethrottle, BoosterCylinderExhaustOpenFactor, absSpeedRefMpS , i);
2729
2730
2730
2731
// Update Booster steam consumption
2731
2732
if (SteamBoosterIdleMode)
@@ -2885,6 +2886,8 @@ private void UpdateFX(float elapsedClockSeconds)
2885
2886
{
2886
2887
var TotalNumberCyindersEng1 = 0;
2887
2888
2889
+ float absSpeedRefMpS = Simulator.UseAdvancedAdhesion ? Math.Abs((float)SteamEngines[0].AttachedAxle.AxleSpeedMpS) : AbsTractionSpeedMpS;
2890
+
2888
2891
if (SteamEngineType == SteamEngineTypes.Compound)
2889
2892
{
2890
2893
TotalNumberCyindersEng1 = SteamEngines[0].NumberCylinders + SteamEngines[0].LPNumberCylinders;
@@ -2931,8 +2934,8 @@ private void UpdateFX(float elapsedClockSeconds)
2931
2934
ExhaustnormalisedCrankAngleRad[i] = normalisedCrankAngleRad;
2932
2935
ExhaustexhaustCrankAngleRad[i] = exhaustCrankAngleRadFor;
2933
2936
2934
-
2935
- if (AbsTractionSpeedMpS > 0.001)
2937
+
2938
+ if (absSpeedRefMpS > 0.001)
2936
2939
{
2937
2940
if (i == 0 && ((normalisedCrankAngleRad >= exhaustCrankAngleRadFor && normalisedCrankAngleRad <= MathHelper.Pi) || (normalisedCrankAngleRad >= exhaustCrankAngleRadRev && normalisedCrankAngleRad < 2 * MathHelper.Pi )))
2938
2941
{
@@ -3131,6 +3134,7 @@ private void UpdateFX(float elapsedClockSeconds)
3131
3134
{
3132
3135
var TotalNumberCyindersEng2 = SteamEngines[1].NumberCylinders; // currently assume 2nd engine is non-compound
3133
3136
3137
+ absSpeedRefMpS = Simulator.UseAdvancedAdhesion ? Math.Abs((float)SteamEngines[1].AttachedAxle.AxleSpeedMpS) : AbsTractionSpeedMpS;
3134
3138
// Engine #2
3135
3139
for (int i = 0; i < TotalNumberCyindersEng2; i++)
3136
3140
{
@@ -3162,7 +3166,7 @@ private void UpdateFX(float elapsedClockSeconds)
3162
3166
exhaustCrankAngleRadRev -= 2 * (float)Math.PI;
3163
3167
}
3164
3168
3165
- if (AbsTractionSpeedMpS > 0.001)
3169
+ if (absSpeedRefMpS > 0.001)
3166
3170
{
3167
3171
if (i == 0 && ((normalisedCrankAngleRad >= exhaustCrankAngleRadFor && normalisedCrankAngleRad <= MathHelper.Pi) || (normalisedCrankAngleRad >= exhaustCrankAngleRadRev && normalisedCrankAngleRad < 2 * MathHelper.Pi)))
3168
3172
{
@@ -3464,29 +3468,29 @@ private void UpdateFX(float elapsedClockSeconds)
3464
3468
GeneratorSteamVelocityMpS = 50.0f;
3465
3469
GeneratorSteamVolumeM3pS = 4.0f * SteamEffectsFactor;
3466
3470
GeneratorParticleDurationS = 1.0f;
3467
- GeneratorParticleDurationS = MathHelper.Clamp(GeneratorParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 1.0f);
3471
+ GeneratorParticleDurationS = MathHelper.Clamp(GeneratorParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 1.0f);
3468
3472
3469
3473
// Injector Steam Effects
3470
3474
Injector1SteamVolumeM3pS = (Injector1IsOn ? (5.0f * SteamEffectsFactor) : 0);
3471
3475
Injector1SteamVelocityMpS = 10.0f;
3472
3476
Injector1ParticleDurationS = 1.0f;
3473
- Injector1ParticleDurationS = MathHelper.Clamp(Injector1ParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 1.0f);
3477
+ Injector1ParticleDurationS = MathHelper.Clamp(Injector1ParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 1.0f);
3474
3478
3475
3479
Injector2SteamVolumeM3pS = (Injector2IsOn ? (5.0f * SteamEffectsFactor) : 0);
3476
3480
Injector2SteamVelocityMpS = 10.0f;
3477
3481
Injector2ParticleDurationS = 1.0f;
3478
- Injector2ParticleDurationS = MathHelper.Clamp(Injector2ParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 1.0f);
3482
+ Injector2ParticleDurationS = MathHelper.Clamp(Injector2ParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 1.0f);
3479
3483
3480
3484
// Ejector Steam Effects
3481
3485
SmallEjectorSteamVolumeM3pS = (SmallSteamEjectorIsOn ? (1.5f * SteamEffectsFactor) : 0);
3482
3486
SmallEjectorSteamVelocityMpS = 10.0f;
3483
3487
SmallEjectorParticleDurationS = 1.0f;
3484
- SmallEjectorParticleDurationS = MathHelper.Clamp(SmallEjectorParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 1.0f);
3488
+ SmallEjectorParticleDurationS = MathHelper.Clamp(SmallEjectorParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 1.0f);
3485
3489
3486
3490
LargeEjectorSteamVolumeM3pS = (LargeSteamEjectorIsOn ? (1.5f * SteamEffectsFactor) : 0);
3487
3491
LargeEjectorSteamVelocityMpS = 10.0f;
3488
3492
LargeEjectorParticleDurationS = 1.0f;
3489
- LargeEjectorParticleDurationS = MathHelper.Clamp(LargeEjectorParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 1.0f);
3493
+ LargeEjectorParticleDurationS = MathHelper.Clamp(LargeEjectorParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 1.0f);
3490
3494
3491
3495
// Compressor Steam Effects
3492
3496
// Only show compressor steam effects if it is not a vacuum controlled steam engine
@@ -3495,22 +3499,22 @@ private void UpdateFX(float elapsedClockSeconds)
3495
3499
CompressorSteamVelocityMpS = 10.0f;
3496
3500
CompressorSteamVolumeM3pS = (CompressorIsOn ? (1.5f * SteamEffectsFactor) : 0);
3497
3501
CompressorParticleDurationS = 1.0f;
3498
- CompressorParticleDurationS = MathHelper.Clamp(CompressorParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 1.0f);
3502
+ CompressorParticleDurationS = MathHelper.Clamp(CompressorParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 1.0f);
3499
3503
}
3500
3504
3501
3505
// Whistle Steam Effects
3502
3506
WhistleSteamVelocityMpS = 10.0f;
3503
3507
WhistleSteamVolumeM3pS = (Horn ? (5.0f * SteamEffectsFactor) : 0);
3504
3508
WhistleParticleDurationS = 3.0f;
3505
- WhistleParticleDurationS = MathHelper.Clamp(WhistleParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 3.0f);
3509
+ WhistleParticleDurationS = MathHelper.Clamp(WhistleParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 3.0f);
3506
3510
3507
3511
// Safety Valves Steam Effects
3508
3512
3509
3513
SafetyValvesSteamVelocityMpS = (float)Math.Sqrt(KPa.FromPSI(MaxBoilerPressurePSI) * 1000 * 2 / WaterDensityAt100DegC1BarKGpM3);
3510
3514
//SafetyValvesSteamVolumeM3pS = SafetyIsOn ? Kg.FromLb(SafetyValveUsageLBpS) * SteamVaporSpecVolumeAt100DegC1BarM3pKG : 0;
3511
3515
SafetyValvesSteamVolumeM3pS = SafetyIsOn ? 5.0f : 0;
3512
3516
SafetyValvesParticleDurationS = 3.0f;
3513
- SafetyValvesParticleDurationS = MathHelper.Clamp(SafetyValvesParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 3.0f);
3517
+ SafetyValvesParticleDurationS = MathHelper.Clamp(SafetyValvesParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 3.0f);
3514
3518
3515
3519
// Smoke Stack Smoke Effects
3516
3520
// Colur for smoke is determined by the amount of air flowing through the fire (ie damper ).
@@ -3523,7 +3527,7 @@ private void UpdateFX(float elapsedClockSeconds)
3523
3527
}
3524
3528
else
3525
3529
{
3526
- SmokeColorDamper = absSpeedMpS * DamperFactorManual; // Damper value for manual firing - related to increased speed, and airflow through fire
3530
+ SmokeColorDamper = AbsSpeedMpS * DamperFactorManual; // Damper value for manual firing - related to increased speed, and airflow through fire
3527
3531
}
3528
3532
3529
3533
SmokeColorDamper = MathHelper.Clamp(SmokeColorDamper, 0.0f, TheoreticalMaxSteamOutputLBpS); // set damper maximum to the max generation rate
@@ -3550,12 +3554,12 @@ private void UpdateFX(float elapsedClockSeconds)
3550
3554
}
3551
3555
else // when not exhausting
3552
3556
{
3553
- if (absSpeedMpS < 10)
3557
+ if (AbsSpeedMpS < 10)
3554
3558
{
3555
3559
float smokeRestVelocityVariationFactor = 2 * cutoff; // adjust smoke velocity based upon throttle and cutoff settings
3556
3560
float smokeRestVolumeVariationFactor = 1 * cutoff; // adjust smoke volume based upon throttle and cutoff settings
3557
3561
3558
- float velocityRate = (absSpeedMpS < 1 ? 1 .0f : 1.0f / AbsSpeedMpS);
3562
+ float velocityRate = Math.Min(1 .0f, 1.0f / AbsSpeedMpS);
3559
3563
StackSteamVelocityMpS.Update(elapsedClockSeconds, velocityRate);
3560
3564
StackSteamVolumeM3pS = Kg.FromLb(BlowerSteamUsageLBpS + RadiationSteamLossLBpS + CompSteamUsageLBpS + GeneratorSteamUsageLBpS) * smokeRestVolumeVariationFactor * SteamVaporSpecVolumeAt100DegC1BarM3pKG;
3561
3565
StackSteamVolumeM3pS = StackSteamVolumeM3pS / StackCount + FireRatio;
@@ -3824,7 +3828,7 @@ private void UpdateTender(float elapsedClockSeconds)
3824
3828
float HeatLossNoWindBTUph = (1- AreaExposedtoWindMovementFraction) * HeatTransferCoefficientBtuphft2F * AssumedSurfaceAreaFt2 * HeatDiff;
3825
3829
3826
3830
// To compensate for the train movement we need to add a wind factor
3827
- float WindCoeff = -0.0074f * absSpeedMpS * absSpeedMpS + 0.3817f * absSpeedMpS + 1f;
3831
+ float WindCoeff = -0.0074f * AbsSpeedMpS * AbsSpeedMpS + 0.3817f * AbsSpeedMpS + 1f;
3828
3832
WindCoeff = MathHelper.Clamp(WindCoeff, 1.0f, 5.78f); // Wind speed effect will not cause any more impact once over about 25 m/s
3829
3833
3830
3834
float HeatLossWindBTUph = (1 - AreaExposedtoWindMovementFraction) * HeatTransferCoefficientBtuphft2F * AssumedSurfaceAreaFt2 * HeatDiff * WindCoeff;
@@ -3957,7 +3961,7 @@ private void UpdateTender(float elapsedClockSeconds)
3957
3961
Trace.TraceInformation(" Water Percent {0} AuxTenderCoupled {1} SteamAuxTenderCoupled {2}", TenderWaterPercent, Train.IsAuxTenderCoupled, SteamIsAuxTenderCoupled);
3958
3962
Trace.TraceInformation("Water Controller Current Value {0} Previous Value {1}", WaterController.CurrentValue, PreviousTenderWaterVolumeUKG);
3959
3963
#endif
3960
- if (absSpeedMpS > 0.5) // Indicates train has moved, and therefore game started
3964
+ if (AbsSpeedMpS > 0.5) // Indicates train has moved, and therefore game started
3961
3965
{
3962
3966
AuxTenderMoveFlag = true;
3963
3967
}
@@ -4291,8 +4295,6 @@ private void UpdateFirebox(float elapsedClockSeconds, float absSpeedMpS)
4291
4295
4292
4296
private void UpdateBoiler(float elapsedClockSeconds)
4293
4297
{
4294
- absSpeedMpS = Math.Abs(Train.SpeedMpS);
4295
-
4296
4298
#region Safety valves - determine number and size
4297
4299
4298
4300
// Determine number and size of safety valves
@@ -4762,14 +4764,14 @@ private void UpdateBoiler(float elapsedClockSeconds)
4762
4764
float HighSpeedMpS = 20.0f;
4763
4765
float KcMinSpeed = 10.45f - LowSpeedMpS + (10.0f * (float)Math.Pow(LowSpeedMpS, 0.5)); // Minimum speed of 2m/s
4764
4766
float KcMaxSpeed = 10.45f - HighSpeedMpS + (10.0f * (float)Math.Pow(HighSpeedMpS, 0.5)); // Maximum speed of 20m/s
4765
- float KcActualSpeed = 10.45f - absSpeedMpS + (10.0f * (float)Math.Pow(absSpeedMpS , 0.5));
4767
+ float KcActualSpeed = 10.45f - AbsSpeedMpS + (10.0f * (float)Math.Pow(AbsSpeedMpS , 0.5));
4766
4768
float KcMovementFraction = 0;
4767
4769
4768
- if (absSpeedMpS > 2 && absSpeedMpS < 20.0f)
4770
+ if (AbsSpeedMpS > 2 && AbsSpeedMpS < 20.0f)
4769
4771
{
4770
4772
KcMovementFraction = KcActualSpeed / KcMinSpeed; // Calculate fraction only between 2 and 20
4771
4773
}
4772
- else if (absSpeedMpS < 2)
4774
+ else if (AbsSpeedMpS < 2)
4773
4775
{
4774
4776
KcMovementFraction = 1.0f; // If speed less then 2m/s then set fracftion to give stationary Kc value
4775
4777
}
@@ -6688,7 +6690,7 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds)
6688
6690
DrawBarPullLbsF = N.ToLbf(Math.Abs(DisplayTractiveForceN) - LocoTenderFrictionForceN); // Locomotive drawbar pull is equal to motive force of locomotive (+ tender) - friction forces of locomotive (+ tender)
6689
6691
DrawBarPullLbsF = MathHelper.Clamp(DrawBarPullLbsF, 0, DrawBarPullLbsF); // clamp value so it doesn't go negative
6690
6692
6691
- DrawbarHorsePowerHP = (DrawBarPullLbsF * MpS.ToMpH(absSpeedMpS )) / 375.0f; // TE in this instance is a maximum, and not at the wheel???
6693
+ DrawbarHorsePowerHP = (DrawBarPullLbsF * MpS.ToMpH(AbsSpeedMpS )) / 375.0f; // TE in this instance is a maximum, and not at the wheel???
6692
6694
DrawbarHorsePowerHP = MathHelper.Clamp(DrawbarHorsePowerHP, 0, DrawbarHorsePowerHP); // clamp value so it doesn't go negative
6693
6695
6694
6696
// Set Max Velocity of locomotive
@@ -7216,18 +7218,18 @@ private void UpdateWaterInjection(float elapsedClockSeconds)
7216
7218
{
7217
7219
MaximumWaterMotionPumpFlowRateLBpS = (1.2f * EvaporationLBpS) / 2.0f; // Assume two pumps and that they can pump a fraction more water the the maximum steam production
7218
7220
7219
- if (WaterMotionPump1IsOn && absSpeedMpS > 0)
7221
+ if (WaterMotionPump1IsOn && AbsTractionSpeedMpS > 0)
7220
7222
{
7221
- WaterMotionPump1FlowRateLBpS = MaximumWaterMotionPumpFlowRateLBpS * absSpeedMpS / MpS.FromMpH(MaxLocoSpeedMpH);
7223
+ WaterMotionPump1FlowRateLBpS = MaximumWaterMotionPumpFlowRateLBpS * AbsTractionSpeedMpS / MpS.FromMpH(MaxLocoSpeedMpH);
7222
7224
}
7223
7225
else
7224
7226
{
7225
7227
WaterMotionPump1FlowRateLBpS = 0;
7226
7228
}
7227
7229
7228
- if (WaterMotionPump2IsOn && absSpeedMpS > 0)
7230
+ if (WaterMotionPump2IsOn && AbsTractionSpeedMpS > 0)
7229
7231
{
7230
- WaterMotionPump2FlowRateLBpS = MaximumWaterMotionPumpFlowRateLBpS * absSpeedMpS / MpS.FromMpH(MaxLocoSpeedMpH);
7232
+ WaterMotionPump2FlowRateLBpS = MaximumWaterMotionPumpFlowRateLBpS * AbsTractionSpeedMpS / MpS.FromMpH(MaxLocoSpeedMpH);
7231
7233
}
7232
7234
else
7233
7235
{
0 commit comments