@@ -615,8 +615,6 @@ public Direction Direction
615615 public float CurrentElevationPercent ;
616616
617617 public bool CurveSpeedDependent ;
618- public bool TunnelResistanceDependent ;
619-
620618
621619 protected float MaxDurableSafeCurveSpeedMpS ;
622620
@@ -728,11 +726,10 @@ public struct CarTunnelInfoData
728726 public virtual void Initialize ( )
729727 {
730728 CurveSpeedDependent = Simulator . Settings . CurveSpeedDependent ;
731- TunnelResistanceDependent = Simulator . Settings . TunnelResistanceDependent ;
732729
733730 //CurveForceFilter.Initialize();
734- // Initialize tunnel resistance values
735731
732+ // Initialize tunnel resistance values
736733 DoubleTunnelCrossSectAreaM2 = ( float ) Simulator . TRK . Tr_RouteFile . DoubleTunnelAreaM2 ;
737734 SingleTunnelCrossSectAreaM2 = ( float ) Simulator . TRK . Tr_RouteFile . SingleTunnelAreaM2 ;
738735 DoubleTunnelPerimeterM = ( float ) Simulator . TRK . Tr_RouteFile . DoubleTunnelPerimeterM ;
@@ -1116,62 +1113,51 @@ public virtual void UpdateTunnelForce()
11161113 {
11171114 if ( Train . IsPlayerDriven ) // Only calculate tunnel resistance when it is the player train.
11181115 {
1119- if ( TunnelResistanceDependent )
1116+ if ( CarTunnelData . FrontPositionBeyondStartOfTunnel . HasValue )
11201117 {
1121- if ( CarTunnelData . FrontPositionBeyondStartOfTunnel . HasValue )
1122- {
1118+ float ? TunnelStart ;
1119+ float ? TunnelAhead ;
1120+ float ? TunnelBehind ;
11231121
1124- float ? TunnelStart ;
1125- float ? TunnelAhead ;
1126- float ? TunnelBehind ;
1127-
1128- TunnelStart = CarTunnelData . FrontPositionBeyondStartOfTunnel ; // position of front of wagon wrt start of tunnel
1129- TunnelAhead = CarTunnelData . LengthMOfTunnelAheadFront ; // Length of tunnel remaining ahead of front of wagon (negative if front of wagon out of tunnel)
1130- TunnelBehind = CarTunnelData . LengthMOfTunnelBehindRear ; // Length of tunnel behind rear of wagon (negative if rear of wagon has not yet entered tunnel)
1131-
1132- // Calculate tunnel default effective cross-section area, and tunnel perimeter - based upon the designed speed limit of the railway (TRK File)
1133-
1134- float TunnelLengthM = CarTunnelData . LengthMOfTunnelAheadFront . Value + CarTunnelData . LengthMOfTunnelBehindRear . Value ;
1135- float TrainLengthTunnelM = Train . Length ;
1136- float TrainMassTunnelKg = Train . MassKg ;
1137- float PrevTrainCrossSectionAreaM2 = TrainCrossSectionAreaM2 ;
1138- TrainCrossSectionAreaM2 = CarWidthM * CarHeightM ;
1139- if ( TrainCrossSectionAreaM2 < PrevTrainCrossSectionAreaM2 )
1140- {
1141- TrainCrossSectionAreaM2 = PrevTrainCrossSectionAreaM2 ; // Assume locomotive cross-sectional area is the largest, if not use new one.
1142- }
1143- const float DensityAirKgpM3 = 1.2f ;
1144-
1145- // Determine tunnel X-sect area and perimeter based upon number of tracks
1146- if ( CarTunnelData . numTunnelPaths >= 2 )
1147- {
1148- TunnelCrossSectionAreaM2 = DoubleTunnelCrossSectAreaM2 ; // Set values for double track tunnels and above
1149- TunnelPerimeterM = DoubleTunnelPerimeterM ;
1150- }
1151- else
1152- {
1153- TunnelCrossSectionAreaM2 = SingleTunnelCrossSectAreaM2 ; // Set values for single track tunnels
1154- TunnelPerimeterM = SingleTunnelPerimeterAreaM ;
1155- }
1156-
1157- //
1158- // Calculate first tunnel factor
1159-
1160- float TunnelAComponent = ( 0.00003318f * DensityAirKgpM3 * TunnelCrossSectionAreaM2 ) / ( ( 1 - ( TrainCrossSectionAreaM2 / TunnelCrossSectionAreaM2 ) ) * ( 1 - ( TrainCrossSectionAreaM2 / TunnelCrossSectionAreaM2 ) ) ) ;
1161- float TunnelBComponent = 174.419f * ( 1 - ( TrainCrossSectionAreaM2 / TunnelCrossSectionAreaM2 ) ) * ( 1 - ( TrainCrossSectionAreaM2 / TunnelCrossSectionAreaM2 ) ) ;
1162- float TunnelCComponent = ( 2.907f * ( 1 - ( TrainCrossSectionAreaM2 / TunnelCrossSectionAreaM2 ) ) * ( 1 - ( TrainCrossSectionAreaM2 / TunnelCrossSectionAreaM2 ) ) ) / ( 4.0f * ( TunnelCrossSectionAreaM2 / TunnelPerimeterM ) ) ;
1163-
1164- float TempTunnel1 = ( float ) Math . Sqrt ( TunnelBComponent + ( TunnelCComponent * ( TunnelLengthM - TrainLengthTunnelM ) / TrainLengthTunnelM ) ) ;
1165- float TempTunnel2 = ( 1.0f - ( 1.0f / ( 1.0f + TempTunnel1 ) ) ) * ( 1.0f - ( 1.0f / ( 1.0f + TempTunnel1 ) ) ) ;
1166-
1167- float UnitAerodynamicDrag = ( ( TunnelAComponent * TrainLengthTunnelM ) / Kg . ToTonne ( TrainMassTunnelKg ) ) * TempTunnel2 ;
1122+ // Calculate tunnel default effective cross-section area, and tunnel perimeter - based upon the designed speed limit of the railway (TRK File)
1123+ float TunnelLengthM = CarTunnelData . LengthMOfTunnelAheadFront . Value + CarTunnelData . LengthMOfTunnelBehindRear . Value ;
1124+ float TrainLengthTunnelM = Train . Length ;
1125+ float TrainMassTunnelKg = Train . MassKg ;
1126+ float PrevTrainCrossSectionAreaM2 = TrainCrossSectionAreaM2 ;
1127+ TrainCrossSectionAreaM2 = CarWidthM * CarHeightM ;
1128+ if ( TrainCrossSectionAreaM2 < PrevTrainCrossSectionAreaM2 )
1129+ {
1130+ TrainCrossSectionAreaM2 = PrevTrainCrossSectionAreaM2 ; // Assume locomotive cross-sectional area is the largest, if not use new one.
1131+ }
1132+ const float DensityAirKgpM3 = 1.2f ;
11681133
1169- TunnelForceN = UnitAerodynamicDrag * Kg . ToTonne ( MassKG ) * AbsSpeedMpS * AbsSpeedMpS ;
1134+ // Determine tunnel X-sect area and perimeter based upon number of tracks
1135+ if ( CarTunnelData . numTunnelPaths >= 2 )
1136+ {
1137+ TunnelCrossSectionAreaM2 = DoubleTunnelCrossSectAreaM2 ; // Set values for double track tunnels and above
1138+ TunnelPerimeterM = DoubleTunnelPerimeterM ;
11701139 }
11711140 else
11721141 {
1173- TunnelForceN = 0.0f ; // Reset tunnel force to zero when train is no longer in the tunnel
1142+ TunnelCrossSectionAreaM2 = SingleTunnelCrossSectAreaM2 ; // Set values for single track tunnels
1143+ TunnelPerimeterM = SingleTunnelPerimeterAreaM ;
11741144 }
1145+
1146+ // Calculate first tunnel factor
1147+ float TunnelAComponent = ( 0.00003318f * DensityAirKgpM3 * TunnelCrossSectionAreaM2 ) / ( ( 1 - ( TrainCrossSectionAreaM2 / TunnelCrossSectionAreaM2 ) ) * ( 1 - ( TrainCrossSectionAreaM2 / TunnelCrossSectionAreaM2 ) ) ) ;
1148+ float TunnelBComponent = 174.419f * ( 1 - ( TrainCrossSectionAreaM2 / TunnelCrossSectionAreaM2 ) ) * ( 1 - ( TrainCrossSectionAreaM2 / TunnelCrossSectionAreaM2 ) ) ;
1149+ float TunnelCComponent = ( 2.907f * ( 1 - ( TrainCrossSectionAreaM2 / TunnelCrossSectionAreaM2 ) ) * ( 1 - ( TrainCrossSectionAreaM2 / TunnelCrossSectionAreaM2 ) ) ) / ( 4.0f * ( TunnelCrossSectionAreaM2 / TunnelPerimeterM ) ) ;
1150+
1151+ float TempTunnel1 = ( float ) Math . Sqrt ( TunnelBComponent + ( TunnelCComponent * ( TunnelLengthM - TrainLengthTunnelM ) / TrainLengthTunnelM ) ) ;
1152+ float TempTunnel2 = ( 1.0f - ( 1.0f / ( 1.0f + TempTunnel1 ) ) ) * ( 1.0f - ( 1.0f / ( 1.0f + TempTunnel1 ) ) ) ;
1153+
1154+ float UnitAerodynamicDrag = ( ( TunnelAComponent * TrainLengthTunnelM ) / Kg . ToTonne ( TrainMassTunnelKg ) ) * TempTunnel2 ;
1155+
1156+ TunnelForceN = UnitAerodynamicDrag * Kg . ToTonne ( MassKG ) * AbsSpeedMpS * AbsSpeedMpS ;
1157+ }
1158+ else
1159+ {
1160+ TunnelForceN = 0.0f ; // Reset tunnel force to zero when train is no longer in the tunnel
11751161 }
11761162 }
11771163 }
0 commit comments