Skip to content

Commit bcb149e

Browse files
committed
Automatic merge of T1.5.1-687-gd279e384a and 10 pull requests
- Pull request #570 at c59c788: Experimental glTF 2.0 support with PBR lighting - Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters - Pull request #865 at 67014b7: Dispatcher window improvements - Pull request #874 at f8dbeab: Dynamic brake controller refactoring - Pull request #875 at 43bf33e: Bug fix for https://bugs.launchpad.net/or/+bug/2036346 Player train switching doesn't work with 3D cabs - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder - Pull request #878 at da8978d: Implement Polach Adhesion - Pull request #882 at e92ff49: Blueprint/train car operations UI window - Pull request #883 at edcc2dd: SwitchPanel disconnect/connect handling - Pull request #885 at c81447b: feat: Add notifications to Menu
12 parents 4d738d5 + d279e38 + c59c788 + d00beb9 + 67014b7 + f8dbeab + 43bf33e + f92de76 + da8978d + e92ff49 + edcc2dd + c81447b commit bcb149e

File tree

2 files changed

+28
-39
lines changed

2 files changed

+28
-39
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3181,7 +3181,6 @@ public virtual void UpdateFrictionCoefficient(float elapsedClockSeconds)
31813181

31823182
#endregion
31833183

3184-
31853184
public void UpdateTrackSander(float elapsedClockSeconds)
31863185
{
31873186
// updates track sander in terms of sand usage and impact on air compressor

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerTransmissions/Axle.cs

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ public float TransmissionEfficiency
582582
public float WheelSlipThresholdMpS;
583583
public void ComputeWheelSlipThresholdMpS()
584584
{
585-
// Bisection algorithm. We assume adhesion maximum is between 0 and 4 m/s
585+
// Bisection algorithm. We assume adhesion maximum is between 0 (0.005) and 4 m/s
586586
double a = 0.005f;
587587
double b = 4;
588588
// We have to find the zero of the derivative of adhesion curve
@@ -592,30 +592,7 @@ public void ComputeWheelSlipThresholdMpS()
592592
double fa = SlipCharacteristics(a + dx) - SlipCharacteristics(a);
593593
double fb = SlipCharacteristics(b + dx) - SlipCharacteristics(b);
594594

595-
double p = 0.025f;
596-
double s = 0.05f;
597-
double t = 0.1f;
598-
double q = 0.15f;
599-
double r = 0.2f;
600-
double u = 0.25f;
601-
double v = 0.5f;
602-
double x = 0.75f;
603-
double y = 1.0f;
604-
605-
double fa1 = SlipCharacteristics(a);
606-
double fb1 = SlipCharacteristics(b);
607-
608-
double fp = SlipCharacteristics(p);
609-
double fs = SlipCharacteristics(s);
610-
double ft = SlipCharacteristics(t);
611-
double fq = SlipCharacteristics(q);
612-
double fr = SlipCharacteristics(r);
613-
double fu = SlipCharacteristics(u);
614-
double fv = SlipCharacteristics(v);
615-
double fx = SlipCharacteristics(x);
616-
double fy = SlipCharacteristics(y);
617595
double SlipSpeedMpS = AxleSpeedMpS - TrainSpeedMpS;
618-
double fslip = SlipCharacteristics(SlipSpeedMpS);
619596

620597
MaximumPolachWheelAdhesion = (float)SlipCharacteristics(WheelSlipThresholdMpS);
621598

@@ -644,7 +621,6 @@ public void ComputeWheelSlipThresholdMpS()
644621
else
645622
{
646623
b = c;
647-
fb = fc;
648624
}
649625
}
650626
WheelSlipThresholdMpS = (float)Math.Max((a + b) / 2, MpS.FromKpH(0.1f));
@@ -724,7 +700,7 @@ public float SlipDerivationPercentpS
724700
}
725701

726702
double integratorError;
727-
int waitBeforeIntegreationRate;
703+
int waitBeforeChangingRate;
728704

729705
/// <summary>
730706
/// Read/Write relative slip speed warning threshold value, in percent of maximal effective slip
@@ -868,21 +844,23 @@ public void Save(BinaryWriter outf)
868844
/// <summary>
869845
/// Integrates the wheel rotation movement using a RK4 method,
870846
/// calculating the required number of substeps
847+
/// To maintain the accuracy of the integration method, the number of substeps needs to increase when slip speed approaches the slip threshold speed.
848+
/// The folloi=wing section attempts to calculate the optimal substep limit. This is a trade off between the accuracy of the slips calculations and the CPU load which impacts the screen FPS
871849
/// Outputs: wheel speed, wheel angular position and motive force
872850
/// </summary>
873851
void Integrate(float elapsedClockSeconds)
874852
{
875853
if (elapsedClockSeconds <= 0) return;
876854
double prevSpeedMpS = AxleSpeedMpS;
877855

878-
float upperSubStepStartingLimit = 120;
856+
float upperSubStepStartingLimit = 100;
879857
float tempupperSubStepLimit = upperSubStepStartingLimit;
880858
float lowerSubStepLimit = 1;
881859

882860
float screenFrameUpperLimit = 60;
883861
float screenFrameLowerLimit = 40;
884862

885-
// Reduces the number of substeps if screen FPS drops
863+
// Reduces the number of substeps if screen FPS drops below a nominal rate of 60 fps
886864
if ( (int)ScreenFrameRate >= screenFrameUpperLimit) // Screen FPS > 60, hold substeps @ maximum value
887865
{
888866
tempupperSubStepLimit = upperSubStepStartingLimit;
@@ -909,31 +887,44 @@ void Integrate(float elapsedClockSeconds)
909887
targetNumOfSubstepsPS = upperSubStepLimit;
910888
}
911889

912-
if (Math.Abs(integratorError) < 0.000277 && !IsWheelSlip && !IsWheelSlipWarning && SlipSpeedMpS < 0.4 * WheelSlipThresholdMpS)
890+
if (Math.Abs(integratorError) < 0.000277 && !IsWheelSlip && !IsWheelSlipWarning && SlipSpeedMpS < 0.25 * WheelSlipThresholdMpS && SlipSpeedMpS < previousSlipSpeedMpS)
913891
{
914-
if (--waitBeforeIntegreationRate <= 0) //wait for a while before changing the integration rate
892+
if (--waitBeforeChangingRate <= 0) //wait for a while before changing the integration rate
915893
{
916894
NumOfSubstepsPS -= 2; // decrease substeps when under low slip conditions
917-
waitBeforeIntegreationRate = 20;
895+
waitBeforeChangingRate = 30;
918896
}
919897
}
920898
else if (targetNumOfSubstepsPS > NumOfSubstepsPS) // increase substeps
921899
{
922-
if (--waitBeforeIntegreationRate <= 0 ) //wait for a while before changing the integration rate
900+
if (--waitBeforeChangingRate <= 0 ) //wait for a while before changing the integration rate
923901
{
924-
NumOfSubstepsPS += 5;
925-
waitBeforeIntegreationRate = 30; //not so fast ;)
902+
903+
if (IsWheelSlip || IsWheelSlipWarning || SlipSpeedMpS > previousSlipSpeedMpS)
904+
{
905+
// this speeds up the substep increase if the slip speed approaches the threshold or has exceeded it, ie "critical conditions".
906+
NumOfSubstepsPS += 10;
907+
waitBeforeChangingRate = 5;
908+
}
909+
else
910+
{
911+
// this speeds ups the substeps under "non critical" conditions
912+
NumOfSubstepsPS += 3;
913+
waitBeforeChangingRate = 30;
914+
}
915+
926916
}
927917
}
928918
else if (targetNumOfSubstepsPS < NumOfSubstepsPS) // decrease sub steps
929919
{
930-
if (--waitBeforeIntegreationRate <= 0) //wait for a while before changing the integration rate
920+
if (--waitBeforeChangingRate <= 0) //wait for a while before changing the integration rate
931921
{
932-
NumOfSubstepsPS -= 5;
933-
waitBeforeIntegreationRate = 20;
922+
NumOfSubstepsPS -= 3;
923+
waitBeforeChangingRate = 30;
934924
}
935925
}
936926

927+
// keeps the substeps to a relevant upper and lower limits
937928
if (NumOfSubstepsPS < lowerSubStepLimit)
938929
NumOfSubstepsPS = (int)lowerSubStepLimit;
939930

@@ -1178,7 +1169,6 @@ public double SlipCharacteristics(double slipSpeedMpS)
11781169
}
11791170
}
11801171

1181-
11821172
/// <summary>
11831173
/// Uses the Polach creep force curves calculation described in the following document
11841174
/// "Creep forces in simulations of traction vehicles running on adhesion limit" by O. Polach 2005 Wear - http://www.sze.hu/~szenasy/VILLVONT/polachslipvizsg.pdf

0 commit comments

Comments
 (0)