Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ETCS braking curves #1737

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions core/examples/rolling_stocks/fast_rolling_stock.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
"name": "fast_rolling_stock",
"mass": 900000,
"loading_gauge": "G1",
"gamma": {
"value": 0.5,
"type": "CONST"
},
"timetable_gamma": 0.5,
"max_braking_force": 0,
"effort_curve": {
"speeds": [
0.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
"name": "fast_rolling_stock_high_gamma",
"mass": 900000,
"loading_gauge": "G1",
"gamma": {
"value": 0.95,
"type": "CONST"
},
"timetable_gamma": 0.95,
"max_braking_force": 0,
"effort_curve": {
"speeds": [
0.0,
Expand Down
6 changes: 2 additions & 4 deletions core/examples/rolling_stocks/short_fast_rolling_stock.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
"name": "short_fast_rolling_stock",
"mass": 900000,
"loading_gauge": "G1",
"gamma": {
"value": 0.5,
"type": "CONST"
},
"timetable_gamma": 0.5,
"max_braking_force": 0,
"effort_curve": {
"speeds": [
0.0,
Expand Down
6 changes: 2 additions & 4 deletions core/examples/rolling_stocks/short_slow_rolling_stock.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
"name": "short_slow_rolling_stock",
"mass": 900000,
"loading_gauge": "G1",
"gamma": {
"value": 0.5,
"type": "CONST"
},
"timetable_gamma": 0.5,
"max_braking_force": 0,
"effort_curve": {
"speeds": [
0.0,
Expand Down
6 changes: 2 additions & 4 deletions core/examples/rolling_stocks/slow_rolling_stock.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
"name": "slow_rolling_stock",
"mass": 900000,
"loading_gauge": "G1",
"gamma": {
"value": 0.5,
"type": "CONST"
},
"timetable_gamma": 0.5,
"max_braking_force": 0,
"effort_curve": {
"speeds": [
0.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static fr.sncf.osrd.envelope.EnvelopePhysics.intersectStepWithSpeed;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import fr.sncf.osrd.envelope.EnvelopeAttr;
import fr.sncf.osrd.envelope.EnvelopePhysics;
import fr.sncf.osrd.envelope.SearchableEnvelope;
Expand Down Expand Up @@ -63,7 +62,6 @@ public final class EnvelopePart implements SearchableEnvelope {
// region CONSTRUCTORS

/** Creates an EnvelopePart */
@SuppressFBWarnings({"EI_EXPOSE_REP2"})
@ExcludeFromGeneratedCodeCoverage
public EnvelopePart(
Map<Class<? extends EnvelopeAttr>, EnvelopeAttr> attrs,
Expand All @@ -90,7 +88,6 @@ public EnvelopePart(
}

/** Creates an EnvelopePart */
@SuppressFBWarnings({"EI_EXPOSE_REP2"})
@ExcludeFromGeneratedCodeCoverage
public EnvelopePart(
Iterable<EnvelopeAttr> attrs,
Expand Down
30 changes: 29 additions & 1 deletion core/src/main/java/fr/sncf/osrd/envelope_sim/EnvelopePath.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class EnvelopePath implements PhysicsPath {
* Creates a new envelope path, which can be used to perform envelope simulations.
* @param length the length of the path
* @param gradePositions the points at which the grade (slope) changes
* @param gradeValues the values between consecutive pairs of grande positions
* @param gradeValues the values between consecutive pairs of grade positions
*/
@SuppressFBWarnings({"EI_EXPOSE_REP2"})
public EnvelopePath(double length, double[] gradePositions, double[] gradeValues) {
Expand Down Expand Up @@ -64,13 +64,41 @@ private double getCumGrade(double position) {
return gradeCumSum[gradeRangeIndex] + gradeValues[gradeRangeIndex] * (position - gradeRangeStart);
}


/** For a given position, return the index of the position just before in gradePositions */
public int getIndexBeforePos(double position) {
if (position <= gradePositions[0])
return 0;
if (position >= gradePositions[gradePositions.length - 1])
return gradePositions.length - 1;
for (int i = 0; i < gradePositions.length; i++) {
var pos = gradePositions[i];
if (pos > position)
return i - 1;
}
return gradePositions.length - 1;
}

@Override
public double getAverageGrade(double begin, double end) {
if (begin == end)
return getCumGrade(begin);
return (getCumGrade(end) - getCumGrade(begin)) / (end - begin);
}

@Override
public double getLowestGrade(double begin, double end) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method returns the "largest" negative grade, it seems to be the intended behavior but I'd prefer if we have a comment that explains it (both here and in the api file). I'd expect a function named getLowest to return something close to 0

int indexBegin = getIndexBeforePos(begin);
int indexEnd = getIndexBeforePos(end);
var lowestGradient = gradeValues[indexBegin];
for (int i = indexBegin; i < indexEnd; i++) {
var grad = gradeValues[i];
if (grad < lowestGradient)
lowestGradient = grad;
}
return lowestGradient;
}

@Override
@SuppressFBWarnings("FL_FLOATS_AS_LOOP_COUNTERS")
public double findHighGradePosition(double position, double endPos, double length, double gradeThreshold) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
package fr.sncf.osrd.envelope_sim;

public class EnvelopeSimContext {

public enum UseCase {
TIMETABLE,
RUNNING_TIME,
ETCS_EBD,
ETCS_SBD,
ETCS_GUI
}

public final PhysicsRollingStock rollingStock;
public final PhysicsPath path;
public final double timeStep;

public final UseCase useCase;

/** Creates a context suitable to run simulations on envelopes */
public EnvelopeSimContext(PhysicsRollingStock rollingStock, PhysicsPath path, double timeStep) {
this.rollingStock = rollingStock;
this.path = path;
this.timeStep = timeStep;
this.useCase = UseCase.TIMETABLE;
}

/** Creates a context suitable to run a specific ETCS braking curve envelopePart */
public EnvelopeSimContext(PhysicsRollingStock rollingStock, PhysicsPath path, double timeStep, UseCase useCase) {
this.rollingStock = rollingStock;
this.path = path;
this.timeStep = timeStep;
this.useCase = useCase;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public interface PhysicsPath {
/** The average slope on a given range, in meters per kilometers */
double getAverageGrade(double begin, double end);

/** The lowest slope on a given range, in meters per kilometers */
double getLowestGrade(double begin, double end);

/** Finds the next position for which getAverageGrade(position, position - length) is greater than gradeThreshold
* @param position the starting point of the search
* @param endPos the position where the search ends
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package fr.sncf.osrd.envelope_sim;

import fr.sncf.osrd.train.RollingStock;

public interface PhysicsRollingStock {
/** The mass of the train, in kilograms */
double getMass();
Expand All @@ -15,24 +13,30 @@ public interface PhysicsRollingStock {
/** The maximum speed the train can reach, in m/s */
double getMaxSpeed();

/** The type of gamma input of the train */
RollingStock.GammaType getGammaType();

/** The resistance to movement at a given speed, in newtons */
double getRollingResistance(double speed);

/** The first derivative of the resistance to movement at a given speed, in kg/s */
double getRollingResistanceDeriv(double speed);

/** The second derivative of the resistance to movement at a given speed, in kg/m */
double getRollingResistanceSecDeriv(double speed);

/** The maximum traction effort which can be deployed at a given speed, in newtons */
double getMaxEffort(double speed);

/** The maximum constant deceleration, in m/s^2 */
double getDeceleration();
/** The maximum constant deceleration used for timetable calculation, in m/s^2 */
double getTimetableDeceleration();

/** The maximum braking force which can be applied at a given speed, in newtons */
double getMaxBrakingForce(double speed);

/** The emergency braking force which can be applied at a given speed, in newtons */
double getSafeBrakingForce(double speed);

/** The service braking force which can be applied at a given speed, in newtons */
double getServiceBrakingForce(double speed);

/** The normal service braking force which can be applied at a given speed, in newtons */
double getNormalServiceBrakingForce(double speed);

/** The weight force correction applied for guidance computation in ETCS 2, in newtons */
double getGradientCorrection(double weightForce, double speed);
}
Loading