@@ -5023,7 +5023,6 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
5023
5023
LPslipBackPressureAtmPSI = LPCompPressure_m_AtmPSI ;
5024
5024
LPslipCompressionPressureAtmPSI = LPCompPressure_n_AtmPSI ;
5025
5025
LPslipAdmissionPressureAtmPSI = LPCompPressure_q_AtmPSI ;
5026
-
5027
5026
}
5028
5027
else // Simple mode
5029
5028
{
@@ -5042,7 +5041,6 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
5042
5041
LPslipBackPressureAtmPSI = LPPressure_d_AtmPSI ;
5043
5042
LPslipCompressionPressureAtmPSI = LPPressure_e_AtmPSI ;
5044
5043
LPslipAdmissionPressureAtmPSI = LPPressure_f_AtmPSI ;
5045
-
5046
5044
}
5047
5045
}
5048
5046
else // simple locomotive
@@ -5053,29 +5051,26 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
5053
5051
slipBackPressureAtmPSI = Pressure_d_AtmPSI ;
5054
5052
slipCompressionPressureAtmPSI = Pressure_e_AtmPSI ;
5055
5053
slipAdmissionPressureAtmPSI = Pressure_f_AtmPSI ;
5056
-
5057
- // Trace.TraceInformation("Initialise IntialPressure {0} Pressure A {1}", slipInitialPressureAtmPSI, Pressure_a_AtmPSI);
5058
-
5059
5054
}
5060
5055
5061
5056
TractiveForceN = 0 ;
5062
5057
float totalDrvWeightN = 0 ;
5063
5058
DisplayTangentialWheelTreadForceLbf = 0 ;
5064
- float testCrankAngle = 0 ;
5065
-
5059
+
5066
5060
for ( int i = 0 ; i < NumCylinders ; i ++ )
5067
5061
{
5068
- float crankAngleRad = ( float ) ( LocomotiveAxles [ 0 ] . AxlePositionRad + WheelCrankAngleDiffRad [ i ] ) ;
5069
-
5070
- testCrankAngle = crankAngleRad ;
5071
-
5072
- crankAngleRad = ( float ) ( MathHelper . WrapAngle ( crankAngleRad ) ) ;
5062
+ // This feature sues some different reference angles as follows:
5063
+ // AxlePositionRad - comes from the axle module and is -180 - 0 - 180
5064
+ // Crank Angle - converts the above range to 0 - 180 - 0 - this is the principle reference used so that it lines up with reference
5065
+ // tables used to buold this function
5066
+ // Normalised Crank Angle - converts the above to a 0 - 360 range, this is used for triggering special steam effects, etc.
5067
+ float axlePostionRad = LocomotiveAxles [ 0 ] . AxlePositionRad ;
5068
+ float crankAngleRad = ( float ) ( axlePostionRad + WheelCrankAngleDiffRad [ i ] ) ;
5073
5069
5074
- // Trace.TraceInformation("Cyl {0} crankAng {1} Position {2} Diff {3}", NumCylinders, MathHelper.ToDegrees(crankAngleRad), MathHelper.ToDegrees(LocomotiveAxle.AxlePositionRad), MathHelper.ToDegrees(WheelCrankAngleDiffRad));
5070
+ crankAngleRad = ( float ) ( MathHelper . WrapAngle ( crankAngleRad ) ) ; // Ensures that crank angle is in the range 0 - 180 - 0
5075
5071
5076
5072
float crankCylinderPressure = ( MeanEffectivePressurePSI * CylinderEfficiencyRate ) ; // fallback default value
5077
5073
5078
-
5079
5074
// Calculate cylinder position in relation to crank (and hence wheel) position.
5080
5075
// For each full wheel revolution, the cylinder will do two storkes (forward and backwards).
5081
5076
// Each stroke in turn will have a forward component with a corresponding pressure producing a "+ve" force and reverse component producing a "-ve" force.
@@ -5102,10 +5097,6 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
5102
5097
backwardCylinderPosition = crankCylinderPosition ;
5103
5098
}
5104
5099
5105
- /*
5106
- Trace.TraceInformation("Cyl {0} Position {1} testcrankAng {2} crankAngle {3} CrankPosition {4} forwardCrankPosition {5} backwardCrankPosition {6}", i+1, LocomotiveAxle.AxlePositionRad, MathHelper.ToDegrees(testCrankAngle), MathHelper.ToDegrees(crankAngleRad), crankCylinderPosition, forwardCylinderPosition, backwardCylinderPosition);
5107
- */
5108
-
5109
5100
float normalisedCrankAngleRad = NormalisedCrankAngle ( i ) ;
5110
5101
5111
5102
// Crank angles
@@ -5165,7 +5156,6 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
5165
5156
Trace . TraceInformation ( "Cylinder {0} CrankAngle {1} FwdCylPosition {2} FwdCylPressure {3} BwdCylPosition {4} BwdCylPressure {5} CrankPressure {6} ForwardStroke {7} Speed {8}" , i , MathHelper . ToDegrees ( crankAngleRad ) , forwardCylinderPosition , forwardCylinderPressure , backwardCylinderPosition , backwardCylinderPressure , crankCylinderPressure , forwardStroke , MpS . ToMpH ( absSpeedMpS ) ) ;
5166
5157
}
5167
5158
#endif
5168
-
5169
5159
// Calculate wheel tangential forces = Force applied to wheels
5170
5160
5171
5161
float pistonForceLbf = Me2 . ToIn2 ( Me2 . FromFt2 ( CylinderPistonAreaFt2 ) ) * crankCylinderPressure ;
@@ -5174,7 +5164,6 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
5174
5164
5175
5165
float tangentialForcelbf = tangentialCrankForceFactor * pistonForceLbf ;
5176
5166
5177
-
5178
5167
float reciprocatingInertiaAngleFactor = 0 ;
5179
5168
float connectRodInertiaAngleFactor = 0 ;
5180
5169
@@ -5194,7 +5183,7 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
5194
5183
float connectRodInertiaForcelbf = inertiaSpeedCorrectionFactor * connectRodInertiaAngleFactor * ConnectingRodWeightLb ;
5195
5184
5196
5185
// Account for the position of the crosshead position. In other words it depends upon whether the Rods and Reciporating gear is above or below the axle.
5197
- if ( crankAngleRad > 0 && crankAngleRad < Math . PI && normalisedCrankAngleRad < Math . PI )
5186
+ if ( axlePostionRad < 0 )
5198
5187
{
5199
5188
reciprocatingInertiaForcelbf *= - 1 ;
5200
5189
connectRodInertiaForcelbf *= - 1 ;
@@ -5219,18 +5208,6 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
5219
5208
// should be deducted from this as well.
5220
5209
float tangentialWheelTreadForceLbf = tangentialCrankWheelForceLbf * Me . ToIn ( CylinderStrokeM ) / Me . ToIn ( DrvWheelDiaM ) ;
5221
5210
5222
- // Debug Adhesion problem
5223
- /* if (SpeedMpS > 17.88 && SpeedMpS < 18.2 )
5224
- {
5225
- Trace.TraceInformation("Adhesion Debug - Cyl {0} Time {1} Speed {2} WheelRpM {3} CrankAngle {4} TotalTangForce {5} TangForce {6} TotalInertiaForce {7} TotalTangInertiaForce {8} RecipForce {9} RecipANgleFactor {10} RecipWeight {11} SpeedFactor {12} RodForce {13} RodAngleFactor {14} ForwardCyLPos {15} BackCylPos {16} CrankCylPos {17} NormCrankAngle {18}", i + 1, DebugTimerS, MpS.ToMpH(SpeedMpS), DrvWheelRevRpS * 60.0f, MathHelper.ToDegrees(crankAngleRad), tangentialWheelTreadForceLbf, tangentialForcelbf, totalInertiaForcelbf, totalTangentialInertiaForcelbf, reciprocatingInertiaForcelbf, reciprocatingInertiaAngleFactor, ReciprocatingWeightLb, inertiaSpeedCorrectionFactor, connectRodInertiaForcelbf, connectRodInertiaAngleFactor, forwardCylinderPosition, backwardCylinderPosition, crankCylinderPosition, normalisedCrankAngleRad);
5226
-
5227
- DebugTimerS += elapsedClockSeconds;
5228
-
5229
- }
5230
-
5231
- */
5232
-
5233
-
5234
5211
DisplayTangentialWheelTreadForceLbf += tangentialWheelTreadForceLbf ;
5235
5212
TractiveForceN += N . FromLbf ( tangentialWheelTreadForceLbf ) ;
5236
5213
@@ -5250,7 +5227,7 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
5250
5227
float excessBalanceForcelbf = inertiaSpeedCorrectionFactor * excessBalanceWeightLb * sin ;
5251
5228
5252
5229
// Account for the position of the crosshead position. In other words it depends upon whether the ExcessBalance is above or below the axle.
5253
- if ( crankAngleRad > 0 && crankAngleRad < Math . PI )
5230
+ if ( axlePostionRad < 0 )
5254
5231
{
5255
5232
excessBalanceForcelbf *= - 1 ;
5256
5233
}
@@ -5274,23 +5251,6 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
5274
5251
totalDrvWeightN += N . FromLbf ( excessBalanceForcelbf - verticalThrustForcelbf ) ;
5275
5252
}
5276
5253
5277
- /* if (DisplayTangentialWheelTreadForceLbf > SteamStaticWheelForce || WheelSlip)
5278
- {
5279
- // Trace.TraceInformation("MaxSpeed {0}", MaxLocoSpeedMpH);
5280
-
5281
- Trace.TraceInformation("Cylinder Pressures - Cylinder {0} CylinderPressure {1} forwardPressure {2} backwardPressure {3} InitialPressure {4} CutoffPressure {5} forwardPosition {6} backwardPosition {7}", i+1, crankCylinderPressure, forwardCylinderPressure, backwardCylinderPressure, slipInitialPressureAtmPSI, slipCutoffPressureAtmPSI, forwardCylinderPosition, backwardCylinderPosition);
5282
-
5283
- Trace.TraceInformation("Crank Angle {0} Cylinder Position {1} AxlePosition {2} Cylinder {3} CylArea {4} CylPress {5}", MathHelper.ToDegrees(crankAngleRad), crankCylinderPosition, MathHelper.ToDegrees(LocomotiveAxle.AxlePositionRad), i, Me2.ToIn2(Me2.FromFt2(CylinderPistonAreaFt2)), crankCylinderPressure);
5284
-
5285
- Trace.TraceInformation("Tang.CrankFactor {0} RecInertiaFactor {1}, ConInertiaFactor {2} VerticalForceFactor {3} InertiaSpeedFactor {4}", tangentialCrankForceFactor, reciprocatingInertiaAngleFactor, connectRodInertiaAngleFactor, verticalThrustFactor, inertiaSpeedCorrectionFactor);
5286
-
5287
- Trace.TraceInformation("PistonForce {0}lbf RodForce {1}lbf RecForce {2}lbf", pistonForceLbf, connectRodInertiaForcelbf, reciprocatingInertiaForcelbf);
5288
-
5289
- Trace.TraceInformation("VerticalThrustForce {0}lbf ExcessBalanceForce {1}lbf", verticalThrustForcelbf, excessBalanceForcelbf);
5290
-
5291
- }
5292
- */
5293
-
5294
5254
#if DEBUG_STEAM_SLIP
5295
5255
if ( throttle > 0.01 && ( absSpeedMpS < 0.2 || absSpeedMpS > 17.7 && absSpeedMpS < 18.2 ) )
5296
5256
{
@@ -5310,30 +5270,14 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
5310
5270
5311
5271
LocomotiveAxles [ 0 ] . AxleWeightN = totalDrvWeightN + 9.81f * DrvWheelWeightKg ;
5312
5272
SteamStaticWheelForce = N . ToLbf ( totalDrvWeightN + 9.81f * DrvWheelWeightKg ) * LocomotiveCoefficientFrictionHUD ;
5313
- /*
5314
- if (DisplayTangentialWheelTreadForceLbf > SteamStaticWheelForce)
5315
- {
5316
- Trace.TraceInformation("Static Wheel Slip (initiated by static comparison) - TangForce {0}lbf: AdhesiveForce {1}lbf: Speed {2}mph, WheelSpeed {3}mph, CrankAngle {4}deg, AdvSlip {5}, AdvSlipWarn {6}, AxleInput - DriveForceCorrect {7}lbf, TotalDriveW {8}lbf, AxleWeightForce {9}lbf, Friction {10}, throttle {11}, Reverser {12} SlipThresholdSpeed {13}mph, WheelSlipSpeed {14}mph, AxleDriveForce {15}lbf", DisplayTangentialWheelTreadForceLbf, SteamStaticWheelForce, MpS.ToMpH(absSpeedMpS), MpS.ToMpH(WheelSpeedMpS), MathHelper.ToDegrees(testCrankAngle), WheelSlip, WheelSlipWarning, N.ToLbf(totalDrvWeightN), N.ToLbf(9.81f * DrvWheelWeightKg), N.ToLbf(LocomotiveAxle.AxleWeightN), LocomotiveCoefficientFrictionHUD, throttle, cutoff, MpS.ToMpH(LocomotiveAxle.WheelSlipThresholdMpS), MpS.ToMpH(LocomotiveAxle.SlipSpeedMpS), N.ToLbf(LocomotiveAxle.DriveForceN));
5317
-
5318
- }
5319
-
5320
- if (WheelSlip && DisplayTangentialWheelTreadForceLbf < SteamStaticWheelForce)
5321
- {
5322
- Trace.TraceInformation("Static Wheel Slip (initiated by axle model) - TangForce {0}lbf: AdhesiveForce {1}lbf: Speed {2}mph, WheelSpeed {3}mph, CrankAngle {4}deg, AdvSlip {5}, AdvSlipWarn {6}, AxleInput - DriveForceCorrect {7}lbf, TotalDriveW {8}lbf, AxleWeightForce {9}lbf, Friction {10}, throttle {11}, Reverser {12} SlipThresholdSpeed {13}mph, WheelSlipSpeed {14}mph, AxleDriveForce {15}lbf", DisplayTangentialWheelTreadForceLbf, SteamStaticWheelForce, MpS.ToMpH(absSpeedMpS), MpS.ToMpH(WheelSpeedMpS), MathHelper.ToDegrees(testCrankAngle), WheelSlip, WheelSlipWarning, N.ToLbf(totalDrvWeightN), N.ToLbf(9.81f * DrvWheelWeightKg), N.ToLbf(LocomotiveAxle.AxleWeightN), LocomotiveCoefficientFrictionHUD, throttle, cutoff, MpS.ToMpH(LocomotiveAxle.WheelSlipThresholdMpS), MpS.ToMpH(LocomotiveAxle.SlipSpeedMpS), N.ToLbf(LocomotiveAxle.DriveForceN));
5323
-
5324
- }
5325
-
5326
- */
5327
5273
5328
5274
#if DEBUG_STEAM_SLIP
5329
-
5330
5275
if ( throttle > 0.01 && ( absSpeedMpS < 0.2 || absSpeedMpS > 17.7 && absSpeedMpS < 18.2 ) )
5331
5276
{
5332
5277
Trace . TraceInformation ( "RotationalForce {0} AdhesiveForce {1}" , N . ToLbf ( TractiveForceN ) , SteamStaticWheelForce ) ;
5333
5278
5334
5279
5335
5280
}
5336
-
5337
5281
#endif
5338
5282
5339
5283
@@ -5385,44 +5329,18 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
5385
5329
LocomotiveAxles [ 0 ] . DriveForceN = TractiveForceN ;
5386
5330
}
5387
5331
5388
-
5389
5332
/// <summary>
5390
5333
/// Normalise crank angle so that it is a value between 0 and 360 starting at the real crank angle difference
5391
5334
/// </summary>
5392
- private float NormalisedCrankAngle ( int cylinderNumber )
5335
+ private float NormalisedCrankAngle ( int cylinderNumber )
5393
5336
{
5394
- float realCrankAngleRad = ( float ) ( LocomotiveAxles [ 0 ] . AxlePositionRad ) ;
5395
- float normalisedCrankAngleRad = 0 ;
5396
-
5397
- realCrankAngleRad = ( float ) ( MathHelper . WrapAngle ( realCrankAngleRad ) ) ;
5398
-
5399
- if ( realCrankAngleRad < 0 )
5400
- {
5401
- realCrankAngleRad = ( float ) ( 2.0f * Math . PI + realCrankAngleRad ) ; // angle must be maintained in a +ve range, ie 0 - 360
5402
- }
5403
-
5337
+ float normalisedCrankAngleRad = ( float ) MathHelper . WrapAngle ( LocomotiveAxles [ 0 ] . AxlePositionRad + WheelCrankAngleDiffRad [ cylinderNumber ] ) ;
5404
5338
5405
- if ( cylinderNumber == 0 ) // initial cylinder
5406
- {
5407
- normalisedCrankAngleRad = realCrankAngleRad ;
5408
- }
5409
- else
5410
- {
5411
- normalisedCrankAngleRad = realCrankAngleRad + WheelCrankAngleDiffRad [ cylinderNumber ] ;
5412
- }
5413
-
5414
-
5415
- if ( normalisedCrankAngleRad > 2.0f * Math . PI )
5339
+ if ( normalisedCrankAngleRad < 0 )
5416
5340
{
5417
- normalisedCrankAngleRad -= ( float ) ( 2.0f * Math . PI ) ;
5418
-
5341
+ normalisedCrankAngleRad += ( float ) ( 2 * Math . PI ) ;
5419
5342
}
5420
5343
return normalisedCrankAngleRad ;
5421
-
5422
-
5423
- // if (SpeedMpS > 0)
5424
- // Trace.TraceInformation("Cylinder {0} CrankAngle {1} CrankDiff {2} RealCrank {3} NormalCrank {4}", i + 1, MathHelper.ToDegrees(crankAngleRad), MathHelper.ToDegrees(WheelCrankAngleDiffRad[i]), MathHelper.ToDegrees(realCrankAngleRad), MathHelper.ToDegrees(normalisedCrankAngleRad));
5425
-
5426
5344
}
5427
5345
5428
5346
0 commit comments