Skip to content

Commit

Permalink
editoast, front, core: remove gamma type
Browse files Browse the repository at this point in the history
rename gamma to const_gamma to reflect its use: constant gamma braking
coefficient used when NOT circulating under ETCS/ERTMS signaling system in
m/s^2.

Signed-off-by: Pierre-Etienne Bougué <[email protected]>
  • Loading branch information
bougue-pe committed Nov 28, 2024
1 parent 9ad0c6b commit 1dbe992
Show file tree
Hide file tree
Showing 49 changed files with 151 additions and 301 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ public interface PhysicsRollingStock {
/** The maximum speed the train can reach, in m/s */
double getMaxSpeed();

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

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

Expand Down Expand Up @@ -61,9 +58,4 @@ static double getMaxEffort(double speed, TractiveEffortPoint[] tractiveEffortCur

/** The maximum acceleration, in m/s^2, which can be applied at a given speed, in m/s */
record TractiveEffortPoint(double speed, double maxEffort) {}

enum GammaType {
CONST,
MAX
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ public static double computeAcceleration(
assert brakingForce >= 0.;
assert tractionForce >= 0.;

if (brakingForce > 0 && rollingStock.getGammaType() == PhysicsRollingStock.GammaType.CONST)
if (brakingForce > 0) {
return rollingStock.getDeceleration();
}

// the sum of forces that always go the direction opposite to the train's movement
double oppositeForce = rollingResistance + brakingForce;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,8 @@ public class SimpleRollingStock implements PhysicsRollingStock {
public final double B; // in newtons / (m/s)
public final double C; // in newtons / (m/s^2)

/**
* the kind of deceleration input of the train. It can be: a constant value the maximum possible
* deceleration value
*/
public final GammaType gammaType;

/** the deceleration of the train, in m/s^2 */
public final double gamma;
public final double constGamma;

/** the length of the train, in meters. */
public final double length;
Expand Down Expand Up @@ -50,8 +44,7 @@ public SimpleRollingStock(
double b,
double c,
double maxSpeed,
double gamma,
GammaType gammaType) {
double constGamma) {
this.length = length;
this.mass = mass;
this.inertiaCoefficient = inertiaCoefficient;
Expand All @@ -60,8 +53,7 @@ public SimpleRollingStock(
this.B = b;
this.C = c;
this.maxSpeed = maxSpeed;
this.gamma = gamma;
this.gammaType = gammaType;
this.constGamma = constGamma;
}

@Override
Expand All @@ -84,11 +76,6 @@ public double getMaxSpeed() {
return maxSpeed;
}

@Override
public GammaType getGammaType() {
return gammaType;
}

@Override
public double getRollingResistance(double speed) {
speed = Math.abs(speed);
Expand All @@ -105,12 +92,12 @@ public double getRollingResistanceDeriv(double speed) {

@Override
public double getDeceleration() {
return -gamma;
return -constGamma;
}

@Override
public double getMaxBrakingForce(double speed) {
return gamma * inertia;
return constGamma * inertia;
}

/**
Expand Down Expand Up @@ -157,7 +144,7 @@ public static ImmutableRangeMap<Double, TractiveEffortPoint[]> createEffortCurve
* ======================================================== Constant rolling stocks and curves
* ===========================================================
*/
public static SimpleRollingStock build(double length, double gamma, GammaType gammaType) {
public static SimpleRollingStock build(double length, double constGamma) {
double trainMass = 850000; // in kilos
return new SimpleRollingStock(
length,
Expand All @@ -167,8 +154,7 @@ public static SimpleRollingStock build(double length, double gamma, GammaType ga
((0.008 * trainMass) / 100) * 3.6,
(((0.00012 * trainMass) / 100) * 3.6) * 3.6,
MAX_SPEED,
gamma,
gammaType);
constGamma);
}

public static final ImmutableRangeMap<Double, TractiveEffortPoint[]> LINEAR_EFFORT_CURVE_MAP =
Expand All @@ -177,9 +163,9 @@ public static SimpleRollingStock build(double length, double gamma, GammaType ga
public static final ImmutableRangeMap<Double, TractiveEffortPoint[]> HYPERBOLIC_EFFORT_CURVE_MAP =
createEffortCurveMap(MAX_SPEED, CurveShape.HYPERBOLIC);

public static final SimpleRollingStock SHORT_TRAIN = SimpleRollingStock.build(1, .5, GammaType.CONST);
public static final SimpleRollingStock SHORT_TRAIN = SimpleRollingStock.build(1, .5);

public static final SimpleRollingStock STANDARD_TRAIN = SimpleRollingStock.build(400, .5, GammaType.CONST);
public static final SimpleRollingStock STANDARD_TRAIN = SimpleRollingStock.build(400, .5);

public static final SimpleRollingStock MAX_DEC_TRAIN = SimpleRollingStock.build(400, .95, GammaType.MAX);
public static final SimpleRollingStock MAX_DEC_TRAIN = SimpleRollingStock.build(400, .95);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.squareup.moshi.Json;
import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.Moshi;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import fr.sncf.osrd.railjson.schema.common.Identified;
import java.util.Map;

Expand Down Expand Up @@ -58,8 +57,9 @@ public class RJSRollingStock implements Identified {
@Json(name = "comfort_acceleration")
public double comfortAcceleration = Double.NaN;

/** The braking deceleration coefficient can be the max or constant (depends on type field). */
public RJSGamma gamma = null;
/** The constant gamma braking coefficient used when NOT circulating under ETCS/ERTMS signaling system in m/s^2 */
@Json(name = "const_gamma")
public double constGamma = Double.NaN;

/**
* Inertia coefficient. The mass alone isn't sufficient to compute accelerations, as the wheels
Expand Down Expand Up @@ -87,17 +87,6 @@ public class RJSRollingStock implements Identified {
@Json(name = "supported_signaling_systems")
public String[] supportedSignalingSystems = new String[0];

public enum GammaType {
CONST,
MAX
}

@SuppressFBWarnings("UWF_NULL_FIELD")
public static final class RJSGamma {
public double value = Double.NaN;
public GammaType type = null;
}

@Override
public String getID() {
return name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ else if (!rjsRollingStock.railjsonVersion.equals(RJSRollingStock.CURRENT_VERSION
if (Double.isNaN(rjsRollingStock.comfortAcceleration))
throw OSRDError.newMissingRollingStockFieldError("comfort_acceleration");

if (rjsRollingStock.gamma == null) throw OSRDError.newMissingRollingStockFieldError("gamma");
if (Double.isNaN(rjsRollingStock.constGamma)) throw OSRDError.newMissingRollingStockFieldError("const_gamma");

if (Double.isNaN(rjsRollingStock.inertiaCoefficient))
throw OSRDError.newMissingRollingStockFieldError("inertia_coefficient");
Expand All @@ -85,12 +85,6 @@ else if (!rjsRollingStock.railjsonVersion.equals(RJSRollingStock.CURRENT_VERSION

var rollingResistance = parseRollingResistance(rjsRollingStock.rollingResistance);

var gammaType =
switch (rjsRollingStock.gamma.type) {
case MAX -> RollingStock.GammaType.MAX;
case CONST -> RollingStock.GammaType.CONST;
};

return new RollingStock(
rjsRollingStock.getID(),
rjsRollingStock.length,
Expand All @@ -103,8 +97,7 @@ else if (!rjsRollingStock.railjsonVersion.equals(RJSRollingStock.CURRENT_VERSION
rjsRollingStock.startUpTime,
rjsRollingStock.startUpAcceleration,
rjsRollingStock.comfortAcceleration,
rjsRollingStock.gamma.value,
gammaType,
rjsRollingStock.constGamma,
rjsRollingStock.loadingGauge,
modes,
rjsRollingStock.effortCurves.defaultMode,
Expand Down
30 changes: 7 additions & 23 deletions core/src/main/java/fr/sncf/osrd/train/RollingStock.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,8 @@ public final class RollingStock implements PhysicsRollingStock {
public final double B; // in newtons / (m/s)
public final double C; // in newtons / (m/s^2)

/**
* the kind of deceleration input of the train. It can be: a constant value the maximum possible
* deceleration value
*/
public final GammaType gammaType;

/** the deceleration of the train, in m/s^2 */
public final double gamma;
public final double constGamma;

/** the length of the train, in meters. */
public final double length;
Expand Down Expand Up @@ -128,12 +122,7 @@ public double getRollingResistanceDeriv(double speed) {

@Override
public double getMaxBrakingForce(double speed) {
return gamma * inertia;
}

@Override
public GammaType getGammaType() {
return gammaType;
return constGamma * inertia;
}

public record ModeEffortCurves(
Expand All @@ -160,9 +149,8 @@ protected record CurveAndCondition(TractiveEffortPoint[] curve, InfraConditions
public record CurvesAndConditions(
RangeMap<Double, TractiveEffortPoint[]> curves, RangeMap<Double, InfraConditions> conditions) {}

/** Returns Gamma */
public double getDeceleration() {
return -gamma;
return -constGamma;
}

/**
Expand Down Expand Up @@ -291,8 +279,7 @@ public RollingStock(
double startUpTime,
double startUpAcceleration,
double comfortAcceleration,
double gamma,
GammaType gammaType,
double constGamma,
RJSLoadingGaugeType loadingGaugeType,
Map<String, ModeEffortCurves> modes,
String defaultMode,
Expand All @@ -310,8 +297,7 @@ public RollingStock(
startUpTime,
startUpAcceleration,
comfortAcceleration,
gamma,
gammaType,
constGamma,
loadingGaugeType,
modes,
defaultMode,
Expand All @@ -335,8 +321,7 @@ public RollingStock(
double startUpTime,
double startUpAcceleration,
double comfortAcceleration,
double gamma,
GammaType gammaType,
double constGamma,
RJSLoadingGaugeType loadingGaugeType,
Map<String, ModeEffortCurves> modes,
String defaultMode,
Expand All @@ -354,8 +339,7 @@ public RollingStock(
this.startUpTime = startUpTime;
this.startUpAcceleration = startUpAcceleration;
this.comfortAcceleration = comfortAcceleration;
this.gamma = gamma;
this.gammaType = gammaType;
this.constGamma = constGamma;
this.mass = mass;
this.inertiaCoefficient = inertiaCoefficient;
this.modes = modes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ fun parseRawRollingStock(

val rollingResistance = parseRollingResistance(rawRollingStock.rollingResistance)

val gammaType = rawRollingStock.gamma.gammaType

return RollingStock(
"placeholder_name",
rawRollingStock.length.distance.meters,
Expand All @@ -45,8 +43,7 @@ fun parseRawRollingStock(
rawRollingStock.startupTime.seconds,
rawRollingStock.startupAcceleration,
rawRollingStock.comfortAcceleration,
rawRollingStock.gamma.value,
gammaType,
rawRollingStock.constGamma,
loadingGaugeType,
modes,
rawRollingStock.effortCurves.defaultMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import fr.sncf.osrd.api.api_v2.DirectionalTrackRange
import fr.sncf.osrd.api.api_v2.RangeValues
import fr.sncf.osrd.conflicts.TravelledPath
import fr.sncf.osrd.envelope_sim.PhysicsRollingStock.GammaType
import fr.sncf.osrd.railjson.schema.rollingstock.Comfort
import fr.sncf.osrd.railjson.schema.rollingstock.RJSEffortCurves.RJSModeEffortCurve
import fr.sncf.osrd.railjson.schema.rollingstock.RJSRollingResistance
Expand Down Expand Up @@ -66,7 +65,7 @@ class PhysicsRollingStockModel(
@Json(name = "startup_time") val startupTime: Duration,
@Json(name = "startup_acceleration") val startupAcceleration: Double,
@Json(name = "comfort_acceleration") val comfortAcceleration: Double,
val gamma: Gamma,
@Json(name = "const_gamma") val constGamma: Double,
@Json(name = "inertia_coefficient") val inertiaCoefficient: Double,
val mass: Long, // kg
@Json(name = "rolling_resistance") val rollingResistance: RJSRollingResistance,
Expand All @@ -75,11 +74,6 @@ class PhysicsRollingStockModel(
@Json(name = "raise_pantograph_time") val raisePantographTime: Duration?,
)

class Gamma(
@Json(name = "type") val gammaType: GammaType,
val value: Double,
)

class EffortCurve(
val modes: Map<String, RJSModeEffortCurve>,
@Json(name = "default_mode") val defaultMode: String,
Expand Down
9 changes: 0 additions & 9 deletions core/src/test/java/fr/sncf/osrd/train/TestTrains.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static fr.sncf.osrd.envelope_sim.SimpleRollingStock.createEffortSpeedCurve;

import com.google.common.collect.Lists;
import fr.sncf.osrd.envelope_sim.PhysicsRollingStock;
import fr.sncf.osrd.envelope_sim.SimpleRollingStock.CurveShape;
import fr.sncf.osrd.railjson.schema.rollingstock.Comfort;
import fr.sncf.osrd.railjson.schema.rollingstock.RJSLoadingGaugeType;
Expand Down Expand Up @@ -116,7 +115,6 @@ private static Map<String, RollingStock.ModeEffortCurves> createModeEffortCurves
0.05,
0.25,
0.5,
PhysicsRollingStock.GammaType.CONST,
RJSLoadingGaugeType.G1,
linearModeEffortCurves,
"thermal",
Expand All @@ -136,7 +134,6 @@ private static Map<String, RollingStock.ModeEffortCurves> createModeEffortCurves
0.05,
0.25,
0.5,
PhysicsRollingStock.GammaType.CONST,
RJSLoadingGaugeType.G1,
linearModeEffortCurves,
"thermal",
Expand All @@ -156,7 +153,6 @@ private static Map<String, RollingStock.ModeEffortCurves> createModeEffortCurves
0.05,
0.25,
0.5,
PhysicsRollingStock.GammaType.CONST,
RJSLoadingGaugeType.G1,
complexModeEffortCurves,
"thermal",
Expand All @@ -179,7 +175,6 @@ private static Map<String, RollingStock.ModeEffortCurves> createModeEffortCurves
0.05,
0.25,
0.95,
PhysicsRollingStock.GammaType.MAX,
RJSLoadingGaugeType.G1,
linearModeEffortCurves,
"thermal",
Expand All @@ -199,7 +194,6 @@ private static Map<String, RollingStock.ModeEffortCurves> createModeEffortCurves
0.05,
0.25,
0.5,
PhysicsRollingStock.GammaType.CONST,
RJSLoadingGaugeType.GC,
linearModeEffortCurves,
"thermal",
Expand All @@ -219,7 +213,6 @@ private static Map<String, RollingStock.ModeEffortCurves> createModeEffortCurves
0.05,
0.25,
0.5,
PhysicsRollingStock.GammaType.CONST,
RJSLoadingGaugeType.G1,
createModeEffortCurves(
MAX_SPEED, CurveShape.LINEAR, Map.of("25000V", new RollingStock.EffortCurveConditions[0])),
Expand All @@ -240,7 +233,6 @@ private static Map<String, RollingStock.ModeEffortCurves> createModeEffortCurves
0.05,
0.25,
0.5,
PhysicsRollingStock.GammaType.CONST,
RJSLoadingGaugeType.G1,
createModeEffortCurves(
MAX_SPEED, CurveShape.HYPERBOLIC, Map.of("thermal", new RollingStock.EffortCurveConditions[0])),
Expand All @@ -261,7 +253,6 @@ private static Map<String, RollingStock.ModeEffortCurves> createModeEffortCurves
0.05,
0.25,
0.5,
PhysicsRollingStock.GammaType.CONST,
RJSLoadingGaugeType.G1,
createModeEffortCurves(
44, CurveShape.HYPERBOLIC, Map.of("thermal", new RollingStock.EffortCurveConditions[0])),
Expand Down
Loading

0 comments on commit 1dbe992

Please sign in to comment.