1
1
package fr .sncf .osrd .envelope_sim ;
2
2
3
- import com .google .common .collect .RangeMap ;
4
- import fr .sncf .osrd .envelope_sim .etcs .BrakingType ;
5
-
6
3
import static fr .sncf .osrd .envelope_sim .PhysicsRollingStock .getGradientAcceleration ;
7
4
import static fr .sncf .osrd .envelope_sim .PhysicsRollingStock .getMaxEffort ;
8
5
import static fr .sncf .osrd .envelope_sim .etcs .ConstantsKt .mRotatingMax ;
9
6
import static fr .sncf .osrd .envelope_sim .etcs .ConstantsKt .mRotatingMin ;
10
7
8
+ import com .google .common .collect .RangeMap ;
9
+ import fr .sncf .osrd .envelope_sim .etcs .BrakingType ;
10
+
11
11
/**
12
12
* A utility class to help simulate the train, using numerical integration. It's used when
13
13
* simulating the train, and it is passed to speed controllers so they can take decisions about what
@@ -39,8 +39,7 @@ private TrainPhysicsIntegrator(
39
39
Action action ,
40
40
double directionSign ,
41
41
RangeMap <Double , PhysicsRollingStock .TractiveEffortPoint []> tractiveEffortCurveMap ,
42
- BrakingType brakingType
43
- ) {
42
+ BrakingType brakingType ) {
44
43
this .rollingStock = rollingStock ;
45
44
this .path = path ;
46
45
this .action = action ;
@@ -86,8 +85,7 @@ private IntegrationStep step(double timeStep, double initialLocation, double ini
86
85
}
87
86
88
87
private IntegrationStep step (double timeStep , double position , double speed ) {
89
- if (action == Action .BRAKE )
90
- return newtonStep (timeStep , speed , getDeceleration (speed , position ), directionSign );
88
+ if (action == Action .BRAKE ) return newtonStep (timeStep , speed , getDeceleration (speed , position ), directionSign );
91
89
92
90
double tractionForce = 0 ;
93
91
var tractiveEffortCurve = tractiveEffortCurveMap .get (Math .min (Math .max (0 , position ), path .getLength ()));
@@ -104,24 +102,24 @@ private IntegrationStep step(double timeStep, double position, double speed) {
104
102
}
105
103
106
104
if (action == Action .ACCELERATE ) tractionForce = maxTractionForce ;
107
- double acceleration = computeAcceleration (
108
- rollingStock , rollingResistance , weightForce , speed , tractionForce , directionSign );
105
+ double acceleration =
106
+ computeAcceleration ( rollingStock , rollingResistance , weightForce , speed , tractionForce , directionSign );
109
107
return newtonStep (timeStep , speed , acceleration , directionSign );
110
108
}
111
109
112
110
private double getDeceleration (double speed , double position ) {
113
- assert (action == Action .BRAKE );
114
- if (brakingType == BrakingType .CONSTANT )
115
- return rollingStock .getDeceleration ();
116
- //TODO: check if we want min or max grade
111
+ assert (action == Action .BRAKE );
112
+ if (brakingType == BrakingType .CONSTANT ) return rollingStock .getDeceleration ();
113
+ // TODO: check if we want min or max grade
117
114
var grade = getMinGrade (rollingStock , path , position );
118
115
var mRotating = grade >= 0 ? mRotatingMax : mRotatingMin ;
119
116
var gradientAcceleration = getGradientAcceleration (grade , mRotating );
120
117
return switch (brakingType ) {
121
118
case ETCS_EBD -> -rollingStock .getSafeBrakingAcceleration (speed ) + gradientAcceleration ;
122
119
case ETCS_SBD -> -rollingStock .getServiceBrakingAcceleration (speed ) + gradientAcceleration ;
123
- case ETCS_GUI -> -rollingStock .getNormalServiceBrakingAcceleration (speed ) + gradientAcceleration
124
- + rollingStock .getGradientAccelerationCorrection (gradientAcceleration , speed );
120
+ case ETCS_GUI -> -rollingStock .getNormalServiceBrakingAcceleration (speed )
121
+ + gradientAcceleration
122
+ + rollingStock .getGradientAccelerationCorrection (gradientAcceleration , speed );
125
123
default -> throw new UnsupportedOperationException ("Braking type not supported: " + brakingType );
126
124
};
127
125
}
0 commit comments