From 1dbe9927fb6162d9810c1c5f2ab536218f8825be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Etienne=20Bougu=C3=A9?= Date: Wed, 27 Nov 2024 13:39:27 +0100 Subject: [PATCH] editoast, front, core: remove gamma type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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é --- .../envelope_sim/PhysicsRollingStock.java | 8 ---- .../envelope_sim/TrainPhysicsIntegrator.java | 3 +- .../osrd/envelope_sim/SimpleRollingStock.java | 34 ++++---------- .../schema/rollingstock/RJSRollingStock.java | 17 ++----- .../parser/RJSRollingStockParser.java | 11 +---- .../java/fr/sncf/osrd/train/RollingStock.java | 30 +++--------- .../standalone_sim/RollingStockParser.kt | 5 +- .../standalone_sim/SimulationRequest.kt | 8 +--- .../java/fr/sncf/osrd/train/TestTrains.java | 9 ---- editoast/editoast_models/src/tables.rs | 4 +- .../editoast_schemas/src/rolling_stock.rs | 14 +++--- .../src/rolling_stock/gamma.rs | 18 ------- .../src/rolling_stock/towed_rolling_stock.rs | 5 +- .../down.sql | 12 +++++ .../up.sql | 15 ++++++ editoast/openapi.yaml | 47 ++++++++----------- editoast/src/core/simulation.rs | 8 ++-- editoast/src/models/fixtures.rs | 11 +---- editoast/src/models/rolling_stock_model.rs | 8 ++-- editoast/src/models/towed_rolling_stock.rs | 8 ++-- .../src/tests/example_rolling_stock_1.json | 5 +- ...xample_rolling_stock_2_energy_sources.json | 5 +- .../src/tests/example_rolling_stock_3.json | 5 +- .../tests/example_towed_rolling_stock_1.json | 5 +- .../stdcm/test_1/stdcm_core_payload.json | 5 +- editoast/src/views/rolling_stock/form.rs | 7 ++- editoast/src/views/rolling_stock/light.rs | 7 ++- editoast/src/views/rolling_stock/towed.rs | 14 ++---- front/public/locales/en/rollingstock.json | 2 +- front/public/locales/fr/rollingstock.json | 2 +- front/src/common/api/generatedEditoastApi.ts | 14 ++---- .../RollingStockCardDetail.tsx | 4 +- .../RollingStockSelector/sampleData.ts | 5 +- front/src/modules/rollingStock/consts.ts | 6 +-- .../helpers/__tests__/utils.spec.ts | 12 ++--- .../src/modules/rollingStock/helpers/utils.ts | 7 +-- front/src/modules/rollingStock/types.ts | 4 +- .../rollingStock/dual-mode_rolling_stock.json | 5 +- .../rollingStock/fast_rolling_stock.json | 5 +- .../improbable_rolling_stock.json | 5 +- .../rollingStock/rollingstockDetails.json | 4 +- .../rollingStock/slow_rolling_stock.json | 5 +- .../osrd_schemas/rolling_stock.py | 14 +----- .../electric_rolling_stock.json | 5 +- .../rolling_stocks/fast_rolling_stock.json | 5 +- .../fast_rolling_stock_high_gamma.json | 5 +- .../short_fast_rolling_stock.json | 5 +- .../short_slow_rolling_stock.json | 5 +- .../rolling_stocks/slow_rolling_stock.json | 5 +- 49 files changed, 151 insertions(+), 301 deletions(-) delete mode 100644 editoast/editoast_schemas/src/rolling_stock/gamma.rs create mode 100644 editoast/migrations/2024-11-27-101658_remove_rolling_stock_gamma_type/down.sql create mode 100644 editoast/migrations/2024-11-27-101658_remove_rolling_stock_gamma_type/up.sql diff --git a/core/envelope-sim/src/main/java/fr/sncf/osrd/envelope_sim/PhysicsRollingStock.java b/core/envelope-sim/src/main/java/fr/sncf/osrd/envelope_sim/PhysicsRollingStock.java index 522715da9f4..806c435fce8 100644 --- a/core/envelope-sim/src/main/java/fr/sncf/osrd/envelope_sim/PhysicsRollingStock.java +++ b/core/envelope-sim/src/main/java/fr/sncf/osrd/envelope_sim/PhysicsRollingStock.java @@ -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); @@ -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 - } } diff --git a/core/envelope-sim/src/main/java/fr/sncf/osrd/envelope_sim/TrainPhysicsIntegrator.java b/core/envelope-sim/src/main/java/fr/sncf/osrd/envelope_sim/TrainPhysicsIntegrator.java index 58e68ff3c88..c949932a547 100644 --- a/core/envelope-sim/src/main/java/fr/sncf/osrd/envelope_sim/TrainPhysicsIntegrator.java +++ b/core/envelope-sim/src/main/java/fr/sncf/osrd/envelope_sim/TrainPhysicsIntegrator.java @@ -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; diff --git a/core/envelope-sim/src/testFixtures/java/fr/sncf/osrd/envelope_sim/SimpleRollingStock.java b/core/envelope-sim/src/testFixtures/java/fr/sncf/osrd/envelope_sim/SimpleRollingStock.java index 5f66d981476..ac5c98b0473 100644 --- a/core/envelope-sim/src/testFixtures/java/fr/sncf/osrd/envelope_sim/SimpleRollingStock.java +++ b/core/envelope-sim/src/testFixtures/java/fr/sncf/osrd/envelope_sim/SimpleRollingStock.java @@ -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; @@ -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; @@ -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 @@ -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); @@ -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; } /** @@ -157,7 +144,7 @@ public static ImmutableRangeMap 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, @@ -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 LINEAR_EFFORT_CURVE_MAP = @@ -177,9 +163,9 @@ public static SimpleRollingStock build(double length, double gamma, GammaType ga public static final ImmutableRangeMap 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); } diff --git a/core/osrd-railjson/src/main/java/fr/sncf/osrd/railjson/schema/rollingstock/RJSRollingStock.java b/core/osrd-railjson/src/main/java/fr/sncf/osrd/railjson/schema/rollingstock/RJSRollingStock.java index 346da7d17fb..168f4cb3ba4 100644 --- a/core/osrd-railjson/src/main/java/fr/sncf/osrd/railjson/schema/rollingstock/RJSRollingStock.java +++ b/core/osrd-railjson/src/main/java/fr/sncf/osrd/railjson/schema/rollingstock/RJSRollingStock.java @@ -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; @@ -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 @@ -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; diff --git a/core/src/main/java/fr/sncf/osrd/railjson/parser/RJSRollingStockParser.java b/core/src/main/java/fr/sncf/osrd/railjson/parser/RJSRollingStockParser.java index 0062118cb42..1115183af2b 100644 --- a/core/src/main/java/fr/sncf/osrd/railjson/parser/RJSRollingStockParser.java +++ b/core/src/main/java/fr/sncf/osrd/railjson/parser/RJSRollingStockParser.java @@ -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"); @@ -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, @@ -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, diff --git a/core/src/main/java/fr/sncf/osrd/train/RollingStock.java b/core/src/main/java/fr/sncf/osrd/train/RollingStock.java index e586f213ae1..0dc704b887b 100644 --- a/core/src/main/java/fr/sncf/osrd/train/RollingStock.java +++ b/core/src/main/java/fr/sncf/osrd/train/RollingStock.java @@ -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; @@ -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( @@ -160,9 +149,8 @@ protected record CurveAndCondition(TractiveEffortPoint[] curve, InfraConditions public record CurvesAndConditions( RangeMap curves, RangeMap conditions) {} - /** Returns Gamma */ public double getDeceleration() { - return -gamma; + return -constGamma; } /** @@ -291,8 +279,7 @@ public RollingStock( double startUpTime, double startUpAcceleration, double comfortAcceleration, - double gamma, - GammaType gammaType, + double constGamma, RJSLoadingGaugeType loadingGaugeType, Map modes, String defaultMode, @@ -310,8 +297,7 @@ public RollingStock( startUpTime, startUpAcceleration, comfortAcceleration, - gamma, - gammaType, + constGamma, loadingGaugeType, modes, defaultMode, @@ -335,8 +321,7 @@ public RollingStock( double startUpTime, double startUpAcceleration, double comfortAcceleration, - double gamma, - GammaType gammaType, + double constGamma, RJSLoadingGaugeType loadingGaugeType, Map modes, String defaultMode, @@ -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; diff --git a/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/standalone_sim/RollingStockParser.kt b/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/standalone_sim/RollingStockParser.kt index ec8b05d298c..6b1f94e2a83 100644 --- a/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/standalone_sim/RollingStockParser.kt +++ b/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/standalone_sim/RollingStockParser.kt @@ -31,8 +31,6 @@ fun parseRawRollingStock( val rollingResistance = parseRollingResistance(rawRollingStock.rollingResistance) - val gammaType = rawRollingStock.gamma.gammaType - return RollingStock( "placeholder_name", rawRollingStock.length.distance.meters, @@ -45,8 +43,7 @@ fun parseRawRollingStock( rawRollingStock.startupTime.seconds, rawRollingStock.startupAcceleration, rawRollingStock.comfortAcceleration, - rawRollingStock.gamma.value, - gammaType, + rawRollingStock.constGamma, loadingGaugeType, modes, rawRollingStock.effortCurves.defaultMode, diff --git a/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/standalone_sim/SimulationRequest.kt b/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/standalone_sim/SimulationRequest.kt index 06b445618d1..af6fe7db860 100644 --- a/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/standalone_sim/SimulationRequest.kt +++ b/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/standalone_sim/SimulationRequest.kt @@ -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 @@ -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, @@ -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, @Json(name = "default_mode") val defaultMode: String, diff --git a/core/src/test/java/fr/sncf/osrd/train/TestTrains.java b/core/src/test/java/fr/sncf/osrd/train/TestTrains.java index e59413d59b6..d9b73c9a8f8 100644 --- a/core/src/test/java/fr/sncf/osrd/train/TestTrains.java +++ b/core/src/test/java/fr/sncf/osrd/train/TestTrains.java @@ -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; @@ -116,7 +115,6 @@ private static Map createModeEffortCurves 0.05, 0.25, 0.5, - PhysicsRollingStock.GammaType.CONST, RJSLoadingGaugeType.G1, linearModeEffortCurves, "thermal", @@ -136,7 +134,6 @@ private static Map createModeEffortCurves 0.05, 0.25, 0.5, - PhysicsRollingStock.GammaType.CONST, RJSLoadingGaugeType.G1, linearModeEffortCurves, "thermal", @@ -156,7 +153,6 @@ private static Map createModeEffortCurves 0.05, 0.25, 0.5, - PhysicsRollingStock.GammaType.CONST, RJSLoadingGaugeType.G1, complexModeEffortCurves, "thermal", @@ -179,7 +175,6 @@ private static Map createModeEffortCurves 0.05, 0.25, 0.95, - PhysicsRollingStock.GammaType.MAX, RJSLoadingGaugeType.G1, linearModeEffortCurves, "thermal", @@ -199,7 +194,6 @@ private static Map createModeEffortCurves 0.05, 0.25, 0.5, - PhysicsRollingStock.GammaType.CONST, RJSLoadingGaugeType.GC, linearModeEffortCurves, "thermal", @@ -219,7 +213,6 @@ private static Map createModeEffortCurves 0.05, 0.25, 0.5, - PhysicsRollingStock.GammaType.CONST, RJSLoadingGaugeType.G1, createModeEffortCurves( MAX_SPEED, CurveShape.LINEAR, Map.of("25000V", new RollingStock.EffortCurveConditions[0])), @@ -240,7 +233,6 @@ private static Map createModeEffortCurves 0.05, 0.25, 0.5, - PhysicsRollingStock.GammaType.CONST, RJSLoadingGaugeType.G1, createModeEffortCurves( MAX_SPEED, CurveShape.HYPERBOLIC, Map.of("thermal", new RollingStock.EffortCurveConditions[0])), @@ -261,7 +253,6 @@ private static Map createModeEffortCurves 0.05, 0.25, 0.5, - PhysicsRollingStock.GammaType.CONST, RJSLoadingGaugeType.G1, createModeEffortCurves( 44, CurveShape.HYPERBOLIC, Map.of("thermal", new RollingStock.EffortCurveConditions[0])), diff --git a/editoast/editoast_models/src/tables.rs b/editoast/editoast_models/src/tables.rs index db0a4992c0d..7eed84b3b62 100644 --- a/editoast/editoast_models/src/tables.rs +++ b/editoast/editoast_models/src/tables.rs @@ -448,7 +448,7 @@ diesel::table! { startup_time -> Float8, startup_acceleration -> Float8, comfort_acceleration -> Float8, - gamma -> Jsonb, + const_gamma -> Float8, inertia_coefficient -> Float8, #[max_length = 255] base_power_class -> Nullable, @@ -695,7 +695,7 @@ diesel::table! { startup_acceleration -> Float8, inertia_coefficient -> Float8, rolling_resistance -> Jsonb, - gamma -> Jsonb, + const_gamma -> Float8, version -> Int8, #[max_length = 255] label -> Varchar, diff --git a/editoast/editoast_schemas/src/rolling_stock.rs b/editoast/editoast_schemas/src/rolling_stock.rs index a805f15c644..721788d29d8 100644 --- a/editoast/editoast_schemas/src/rolling_stock.rs +++ b/editoast/editoast_schemas/src/rolling_stock.rs @@ -1,6 +1,3 @@ -mod gamma; -pub use gamma::Gamma; - mod effort_curves; pub use effort_curves::ConditionalEffortCurve; pub use effort_curves::EffortCurve; @@ -41,7 +38,6 @@ use std::collections::HashMap; editoast_common::schemas! { effort_curves::schemas(), energy_source::schemas(), - gamma::schemas(), loading_gauge_type::schemas(), rolling_stock_metadata::schemas(), rolling_resistance::schemas(), @@ -66,7 +62,9 @@ pub struct RollingStock { pub startup_acceleration: f64, /// In m/s² pub comfort_acceleration: f64, - pub gamma: Gamma, + // The constant gamma braking coefficient used when NOT circulating + // under ETCS/ERTMS signaling system in m/s^2 + pub const_gamma: f64, pub inertia_coefficient: f64, /// In kg pub mass: f64, @@ -77,9 +75,11 @@ pub struct RollingStock { pub power_restrictions: HashMap, #[serde(default)] pub energy_sources: Vec, - /// The time the train takes before actually using electrical power (in seconds). Is null if the train is not electric. + /// The time the train takes before actually using electrical power (in seconds). + /// Is null if the train is not electric. pub electrical_power_startup_time: Option, - /// The time it takes to raise this train's pantograph in seconds. Is null if the train is not electric. + /// The time it takes to raise this train's pantograph in seconds. + /// Is null if the train is not electric. #[serde(default)] pub raise_pantograph_time: Option, pub supported_signaling_systems: RollingStockSupportedSignalingSystems, diff --git a/editoast/editoast_schemas/src/rolling_stock/gamma.rs b/editoast/editoast_schemas/src/rolling_stock/gamma.rs deleted file mode 100644 index c323a9079f0..00000000000 --- a/editoast/editoast_schemas/src/rolling_stock/gamma.rs +++ /dev/null @@ -1,18 +0,0 @@ -use derivative::Derivative; -use serde::Deserialize; -use serde::Serialize; -use utoipa::ToSchema; - -editoast_common::schemas! { - Gamma, -} - -#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize, ToSchema, Derivative)] -#[serde(deny_unknown_fields)] -#[derivative(Hash)] -pub struct Gamma { - #[serde(rename = "type")] - pub gamma_type: String, - #[derivative(Hash(hash_with = "editoast_common::hash_float::<3,_>"))] - pub value: f64, -} diff --git a/editoast/editoast_schemas/src/rolling_stock/towed_rolling_stock.rs b/editoast/editoast_schemas/src/rolling_stock/towed_rolling_stock.rs index 5f210f8fab4..4f549d59a15 100644 --- a/editoast/editoast_schemas/src/rolling_stock/towed_rolling_stock.rs +++ b/editoast/editoast_schemas/src/rolling_stock/towed_rolling_stock.rs @@ -1,4 +1,3 @@ -use super::Gamma; use super::RollingResistancePerWeight; #[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)] @@ -16,5 +15,7 @@ pub struct TowedRollingStock { pub startup_acceleration: f64, pub inertia_coefficient: f64, pub rolling_resistance: RollingResistancePerWeight, - pub gamma: Gamma, + /// The constant gamma braking coefficient used when NOT circulating + /// under ETCS/ERTMS signaling system in m/s^2 + pub const_gamma: f64, } diff --git a/editoast/migrations/2024-11-27-101658_remove_rolling_stock_gamma_type/down.sql b/editoast/migrations/2024-11-27-101658_remove_rolling_stock_gamma_type/down.sql new file mode 100644 index 00000000000..f73e42dcf76 --- /dev/null +++ b/editoast/migrations/2024-11-27-101658_remove_rolling_stock_gamma_type/down.sql @@ -0,0 +1,12 @@ +ALTER TABLE rolling_stock +RENAME COLUMN const_gamma TO gamma; + +ALTER TABLE rolling_stock +ALTER COLUMN gamma SET DATA TYPE jsonb USING json_object('type' : 'CONST', 'value' : gamma); + + +ALTER TABLE towed_rolling_stock +RENAME COLUMN const_gamma TO gamma; + +ALTER TABLE towed_rolling_stock +ALTER COLUMN gamma SET DATA TYPE jsonb USING json_object('type' : 'CONST', 'value' : gamma); diff --git a/editoast/migrations/2024-11-27-101658_remove_rolling_stock_gamma_type/up.sql b/editoast/migrations/2024-11-27-101658_remove_rolling_stock_gamma_type/up.sql new file mode 100644 index 00000000000..890d1203a1b --- /dev/null +++ b/editoast/migrations/2024-11-27-101658_remove_rolling_stock_gamma_type/up.sql @@ -0,0 +1,15 @@ +-- Remove rolling_stock.gamma.type +-- and rename rolling_stock.gamma.value to rolling_stock.const_gamma +ALTER TABLE rolling_stock +ALTER COLUMN gamma SET DATA TYPE float8 USING float8(gamma['value']); + +ALTER TABLE rolling_stock +RENAME COLUMN gamma TO const_gamma; + +-- Remove towed_rolling_stock.gamma.type +-- and rename towed_rolling_stock.gamma.value to towed_rolling_stock.const_gamma +ALTER TABLE towed_rolling_stock +ALTER COLUMN gamma SET DATA TYPE float8 USING float8(gamma['value']); + +ALTER TABLE towed_rolling_stock +RENAME COLUMN gamma TO const_gamma; diff --git a/editoast/openapi.yaml b/editoast/openapi.yaml index 173ff46f20d..505c30eca5f 100644 --- a/editoast/openapi.yaml +++ b/editoast/openapi.yaml @@ -6224,18 +6224,6 @@ components: default: -1.0 distribution: $ref: '#/components/schemas/AllowanceDistribution' - Gamma: - type: object - required: - - type - - value - properties: - type: - type: string - value: - type: number - format: double - additionalProperties: false GeoJson: oneOf: - $ref: '#/components/schemas/GeoJsonPoint' @@ -6924,7 +6912,7 @@ components: - startup_time - startup_acceleration - comfort_acceleration - - gamma + - const_gamma - inertia_coefficient - mass - rolling_resistance @@ -6939,14 +6927,15 @@ components: comfort_acceleration: type: number format: double + const_gamma: + type: number + format: double effort_curves: $ref: '#/components/schemas/LightEffortCurves' energy_sources: type: array items: $ref: '#/components/schemas/EnergySource' - gamma: - $ref: '#/components/schemas/Gamma' id: type: integer format: int64 @@ -8704,7 +8693,7 @@ components: - startup_time - startup_acceleration - comfort_acceleration - - gamma + - const_gamma - inertia_coefficient - base_power_class - mass @@ -8724,6 +8713,9 @@ components: comfort_acceleration: type: number format: double + const_gamma: + type: number + format: double effort_curves: $ref: '#/components/schemas/EffortCurves' electrical_power_startup_time: @@ -8734,8 +8726,6 @@ components: type: array items: $ref: '#/components/schemas/EnergySource' - gamma: - $ref: '#/components/schemas/Gamma' id: type: integer format: int64 @@ -8859,7 +8849,7 @@ components: - startup_time - startup_acceleration - comfort_acceleration - - gamma + - const_gamma - inertia_coefficient - mass - rolling_resistance @@ -8874,6 +8864,9 @@ components: comfort_acceleration: type: number format: double + const_gamma: + type: number + format: double effort_curves: $ref: '#/components/schemas/EffortCurves' electrical_power_startup_time: @@ -8886,8 +8879,6 @@ components: type: array items: $ref: '#/components/schemas/EnergySource' - gamma: - $ref: '#/components/schemas/Gamma' inertia_coefficient: type: number format: double @@ -10626,13 +10617,14 @@ components: - startup_acceleration - inertia_coefficient - rolling_resistance - - gamma + - const_gamma properties: comfort_acceleration: type: number format: double - gamma: - $ref: '#/components/schemas/Gamma' + const_gamma: + type: number + format: double id: type: integer format: int64 @@ -10681,13 +10673,14 @@ components: - startup_acceleration - inertia_coefficient - rolling_resistance - - gamma + - const_gamma properties: comfort_acceleration: type: number format: double - gamma: - $ref: '#/components/schemas/Gamma' + const_gamma: + type: number + format: double inertia_coefficient: type: number format: double diff --git a/editoast/src/core/simulation.rs b/editoast/src/core/simulation.rs index a9a61ad2811..0627d28fece 100644 --- a/editoast/src/core/simulation.rs +++ b/editoast/src/core/simulation.rs @@ -2,7 +2,6 @@ use std::collections::BTreeMap; use std::collections::HashMap; use editoast_schemas::rolling_stock::EffortCurves; -use editoast_schemas::rolling_stock::Gamma; use editoast_schemas::rolling_stock::RollingResistance; use editoast_schemas::rolling_stock::RollingStock; use editoast_schemas::rolling_stock::TowedRollingStock; @@ -52,7 +51,10 @@ pub struct PhysicsConsist { #[derivative(Hash(hash_with = "editoast_common::hash_float::<5,_>"))] /// In m/s² pub comfort_acceleration: f64, - pub gamma: Gamma, + #[derivative(Hash(hash_with = "editoast_common::hash_float::<5,_>"))] + /// The constant gamma braking coefficient used when NOT circulating + /// under ETCS/ERTMS signaling system in m/s^2 + pub const_gamma: f64, #[derivative(Hash(hash_with = "editoast_common::hash_float::<5,_>"))] pub inertia_coefficient: f64, /// Mass of the rolling stock in kg @@ -226,7 +228,7 @@ impl From for PhysicsConsist { startup_time: (traction_engine.startup_time * 1000.0).round() as u64, startup_acceleration, comfort_acceleration, - gamma: traction_engine.gamma, + const_gamma: traction_engine.const_gamma, inertia_coefficient, rolling_resistance, power_restrictions: traction_engine.power_restrictions.into_iter().collect(), diff --git a/editoast/src/models/fixtures.rs b/editoast/src/models/fixtures.rs index aee9ddae9d2..2f32e11255d 100644 --- a/editoast/src/models/fixtures.rs +++ b/editoast/src/models/fixtures.rs @@ -12,7 +12,6 @@ use editoast_schemas::infra::InfraObject; use editoast_schemas::infra::RailJson; use editoast_schemas::primitives::OSRDObject; use editoast_schemas::rolling_stock::EffortCurves; -use editoast_schemas::rolling_stock::Gamma; use editoast_schemas::rolling_stock::LoadingGaugeType; use editoast_schemas::rolling_stock::RollingResistance; use editoast_schemas::rolling_stock::RollingResistancePerWeight; @@ -239,10 +238,7 @@ pub fn create_towed_rolling_stock() -> TowedRollingStock { B: 0.01, // In N/(m/s) C: 0.0002, // In N/(m/s)² }, - gamma: Gamma { - gamma_type: "CONST".to_string(), - value: 1.0, - }, + const_gamma: 1.0, railjson_version: "3.4".to_string(), } } @@ -261,10 +257,7 @@ pub fn create_simple_rolling_stock() -> RollingStock { electrical_power_startup_time: None, raise_pantograph_time: None, energy_sources: vec![], - gamma: Gamma { - gamma_type: "CONST".to_string(), - value: 1.0, - }, + const_gamma: 1.0, locked: false, metadata: None, power_restrictions: HashMap::new(), diff --git a/editoast/src/models/rolling_stock_model.rs b/editoast/src/models/rolling_stock_model.rs index 555f4f5ba3a..43fcda323d6 100644 --- a/editoast/src/models/rolling_stock_model.rs +++ b/editoast/src/models/rolling_stock_model.rs @@ -5,7 +5,6 @@ use std::collections::HashMap; use editoast_derive::Model; use editoast_schemas::rolling_stock::EffortCurves; use editoast_schemas::rolling_stock::EnergySource; -use editoast_schemas::rolling_stock::Gamma; use editoast_schemas::rolling_stock::LoadingGaugeType; use editoast_schemas::rolling_stock::RollingResistance; use editoast_schemas::rolling_stock::RollingStock; @@ -49,8 +48,7 @@ pub struct RollingStockModel { pub startup_time: f64, pub startup_acceleration: f64, pub comfort_acceleration: f64, - #[model(json)] - pub gamma: Gamma, + pub const_gamma: f64, pub inertia_coefficient: f64, #[schema(required)] pub base_power_class: Option, @@ -155,7 +153,7 @@ impl From for RollingStock { startup_time: rolling_stock_model.startup_time, startup_acceleration: rolling_stock_model.startup_acceleration, comfort_acceleration: rolling_stock_model.comfort_acceleration, - gamma: rolling_stock_model.gamma, + const_gamma: rolling_stock_model.const_gamma, inertia_coefficient: rolling_stock_model.inertia_coefficient, mass: rolling_stock_model.mass, rolling_resistance: rolling_stock_model.rolling_resistance, @@ -183,7 +181,7 @@ impl From for RollingStockModelChangeset { .startup_time(rolling_stock.startup_time) .startup_acceleration(rolling_stock.startup_acceleration) .comfort_acceleration(rolling_stock.comfort_acceleration) - .gamma(rolling_stock.gamma) + .const_gamma(rolling_stock.const_gamma) .inertia_coefficient(rolling_stock.inertia_coefficient) .mass(rolling_stock.mass) .rolling_resistance(rolling_stock.rolling_resistance) diff --git a/editoast/src/models/towed_rolling_stock.rs b/editoast/src/models/towed_rolling_stock.rs index f6dc7ce4745..12c458efb2d 100644 --- a/editoast/src/models/towed_rolling_stock.rs +++ b/editoast/src/models/towed_rolling_stock.rs @@ -1,5 +1,4 @@ use editoast_derive::Model; -use editoast_schemas::rolling_stock::Gamma; use editoast_schemas::rolling_stock::RollingResistancePerWeight; use editoast_schemas::rolling_stock::TowedRollingStock; use serde::Deserialize; @@ -31,8 +30,7 @@ pub struct TowedRollingStockModel { pub inertia_coefficient: f64, #[model(json)] pub rolling_resistance: RollingResistancePerWeight, - #[model(json)] - pub gamma: Gamma, + pub const_gamma: f64, pub version: i64, } @@ -49,7 +47,7 @@ impl From for TowedRollingStock { startup_acceleration: model.startup_acceleration, inertia_coefficient: model.inertia_coefficient, rolling_resistance: model.rolling_resistance, - gamma: model.gamma, + const_gamma: model.const_gamma, } } } @@ -66,6 +64,6 @@ impl From for Changeset { .startup_acceleration(towed_rolling_stock.startup_acceleration) .inertia_coefficient(towed_rolling_stock.inertia_coefficient) .rolling_resistance(towed_rolling_stock.rolling_resistance) - .gamma(towed_rolling_stock.gamma) + .const_gamma(towed_rolling_stock.const_gamma) } } diff --git a/editoast/src/tests/example_rolling_stock_1.json b/editoast/src/tests/example_rolling_stock_1.json index a314861dd2a..376b33a5456 100644 --- a/editoast/src/tests/example_rolling_stock_1.json +++ b/editoast/src/tests/example_rolling_stock_1.json @@ -10,10 +10,7 @@ "name": "fast_rolling_stock", "mass": 900000.0, "loading_gauge": "G1", - "gamma": { - "value": 0.5, - "type": "CONST" - }, + "const_gamma": 0.5, "rolling_resistance": { "type": "davis", "A": 5400, diff --git a/editoast/src/tests/example_rolling_stock_2_energy_sources.json b/editoast/src/tests/example_rolling_stock_2_energy_sources.json index 1c9e716556d..01c1723ccf7 100644 --- a/editoast/src/tests/example_rolling_stock_2_energy_sources.json +++ b/editoast/src/tests/example_rolling_stock_2_energy_sources.json @@ -10,10 +10,7 @@ "name": "other_rolling_stock", "mass": 50000.0, "loading_gauge": "G2", - "gamma": { - "value": 0.6, - "type": "MAX" - }, + "const_gamma": 0.6, "rolling_resistance": { "type": "davis", "A": 200, diff --git a/editoast/src/tests/example_rolling_stock_3.json b/editoast/src/tests/example_rolling_stock_3.json index c0b0d9fba8a..cadb79c09d5 100644 --- a/editoast/src/tests/example_rolling_stock_3.json +++ b/editoast/src/tests/example_rolling_stock_3.json @@ -11,10 +11,7 @@ "name": "other_rolling_stock", "mass": 50000.0, "loading_gauge": "G2", - "gamma": { - "value": 0.6, - "type": "MAX" - }, + "const_gamma": 0.6, "rolling_resistance": { "type": "davis", "A": 200, diff --git a/editoast/src/tests/example_towed_rolling_stock_1.json b/editoast/src/tests/example_towed_rolling_stock_1.json index 3867e6c3fd2..39e638a1ac7 100644 --- a/editoast/src/tests/example_towed_rolling_stock_1.json +++ b/editoast/src/tests/example_towed_rolling_stock_1.json @@ -15,8 +15,5 @@ "B": 200, "C": 12 }, - "gamma": { - "value": 0.5, - "type": "CONST" - } + "const_gamma": 0.5 } diff --git a/editoast/src/tests/small_infra/stdcm/test_1/stdcm_core_payload.json b/editoast/src/tests/small_infra/stdcm/test_1/stdcm_core_payload.json index 5202d7712f5..4fcee27abdc 100644 --- a/editoast/src/tests/small_infra/stdcm/test_1/stdcm_core_payload.json +++ b/editoast/src/tests/small_infra/stdcm/test_1/stdcm_core_payload.json @@ -93,10 +93,7 @@ "startup_time": 25, "startup_acceleration": 0.03, "comfort_acceleration": 0.08, - "gamma": { - "type": "CONST", - "value": 0.5 - }, + "const_gamma": 0.5, "inertia_coefficient": 1.2, "mass": 132000, "rolling_resistance": { diff --git a/editoast/src/views/rolling_stock/form.rs b/editoast/src/views/rolling_stock/form.rs index b52c9911736..32cacfef05e 100644 --- a/editoast/src/views/rolling_stock/form.rs +++ b/editoast/src/views/rolling_stock/form.rs @@ -2,7 +2,6 @@ use std::collections::HashMap; use editoast_schemas::rolling_stock::EffortCurves; use editoast_schemas::rolling_stock::EnergySource; -use editoast_schemas::rolling_stock::Gamma; use editoast_schemas::rolling_stock::LoadingGaugeType; use editoast_schemas::rolling_stock::RollingResistance; use editoast_schemas::rolling_stock::RollingStockMetadata; @@ -31,7 +30,7 @@ pub struct RollingStockForm { pub startup_time: f64, pub startup_acceleration: f64, pub comfort_acceleration: f64, - pub gamma: Gamma, + pub const_gamma: f64, pub inertia_coefficient: f64, pub mass: f64, pub rolling_resistance: RollingResistance, @@ -67,7 +66,7 @@ impl From for Changeset { .startup_time(rolling_stock.startup_time) .startup_acceleration(rolling_stock.startup_acceleration) .comfort_acceleration(rolling_stock.comfort_acceleration) - .gamma(rolling_stock.gamma) + .const_gamma(rolling_stock.const_gamma) .inertia_coefficient(rolling_stock.inertia_coefficient) .mass(rolling_stock.mass) .rolling_resistance(rolling_stock.rolling_resistance) @@ -103,7 +102,7 @@ impl From for RollingStockForm { startup_time: value.startup_time, startup_acceleration: value.startup_acceleration, comfort_acceleration: value.comfort_acceleration, - gamma: value.gamma, + const_gamma: value.const_gamma, inertia_coefficient: value.inertia_coefficient, mass: value.mass, rolling_resistance: value.rolling_resistance, diff --git a/editoast/src/views/rolling_stock/light.rs b/editoast/src/views/rolling_stock/light.rs index 756656c136b..893b4f0b1a2 100644 --- a/editoast/src/views/rolling_stock/light.rs +++ b/editoast/src/views/rolling_stock/light.rs @@ -8,7 +8,6 @@ use editoast_models::DbConnection; use editoast_models::DbConnectionPoolV2; use editoast_schemas::rolling_stock::EffortCurves; use editoast_schemas::rolling_stock::EnergySource; -use editoast_schemas::rolling_stock::Gamma; use editoast_schemas::rolling_stock::LoadingGaugeType; use editoast_schemas::rolling_stock::ModeEffortCurves; use editoast_schemas::rolling_stock::RollingResistance; @@ -220,7 +219,7 @@ struct LightRollingStock { startup_time: f64, startup_acceleration: f64, comfort_acceleration: f64, - gamma: Gamma, + const_gamma: f64, inertia_coefficient: f64, mass: f64, rolling_resistance: RollingResistance, @@ -244,7 +243,7 @@ impl From for LightRollingStock { startup_time, startup_acceleration, comfort_acceleration, - gamma, + const_gamma, inertia_coefficient, base_power_class, mass, @@ -269,7 +268,7 @@ impl From for LightRollingStock { startup_time, startup_acceleration, comfort_acceleration, - gamma, + const_gamma, inertia_coefficient, mass, rolling_resistance, diff --git a/editoast/src/views/rolling_stock/towed.rs b/editoast/src/views/rolling_stock/towed.rs index 0c47b0c1660..5b6d278d838 100644 --- a/editoast/src/views/rolling_stock/towed.rs +++ b/editoast/src/views/rolling_stock/towed.rs @@ -17,7 +17,6 @@ use diesel_async::scoped_futures::ScopedFutureExt as _; use editoast_authz::BuiltinRole; use editoast_derive::EditoastError; use editoast_models::DbConnectionPoolV2; -use editoast_schemas::rolling_stock::Gamma; use editoast_schemas::rolling_stock::RollingResistancePerWeight; use editoast_schemas::rolling_stock::ROLLING_STOCK_RAILJSON_VERSION; use serde::Deserialize; @@ -60,7 +59,7 @@ struct TowedRollingStock { startup_acceleration: f64, inertia_coefficient: f64, rolling_resistance: RollingResistancePerWeight, - gamma: Gamma, + const_gamma: f64, } impl From for TowedRollingStock { @@ -77,7 +76,7 @@ impl From for TowedRollingStock { startup_acceleration: towed_rolling_stock.startup_acceleration, inertia_coefficient: towed_rolling_stock.inertia_coefficient, rolling_resistance: towed_rolling_stock.rolling_resistance, - gamma: towed_rolling_stock.gamma, + const_gamma: towed_rolling_stock.const_gamma, } } } @@ -105,7 +104,7 @@ pub struct TowedRollingStockForm { pub startup_acceleration: f64, pub inertia_coefficient: f64, pub rolling_resistance: RollingResistancePerWeight, - pub gamma: Gamma, + pub const_gamma: f64, } impl From for Changeset { @@ -121,7 +120,7 @@ impl From for Changeset { .startup_acceleration(towed_rolling_stock_form.startup_acceleration) .inertia_coefficient(towed_rolling_stock_form.inertia_coefficient) .rolling_resistance(towed_rolling_stock_form.rolling_resistance) - .gamma(towed_rolling_stock_form.gamma) + .const_gamma(towed_rolling_stock_form.const_gamma) } } @@ -380,10 +379,7 @@ mod tests { "B": 100.0, "C": 10.0, }, - "gamma": { - "type": "CONST", - "value": 1.0, - }, + "const_gamma": 1.0, }); let request = app diff --git a/front/public/locales/en/rollingstock.json b/front/public/locales/en/rollingstock.json index e7853a1af6b..e87a4bfbe39 100644 --- a/front/public/locales/en/rollingstock.json +++ b/front/public/locales/en/rollingstock.json @@ -48,7 +48,7 @@ "ressourcesNotFound": "Resources not found" }, "family": "Family", - "gammaValue": "Timetable deceleration", + "constGamma": "Timetable deceleration", "grouping": "Clustering", "inertiaCoefficient": "Factor of inertia", "legend": "Legend", diff --git a/front/public/locales/fr/rollingstock.json b/front/public/locales/fr/rollingstock.json index 0160e36d1a7..02ed54ad56c 100644 --- a/front/public/locales/fr/rollingstock.json +++ b/front/public/locales/fr/rollingstock.json @@ -49,7 +49,7 @@ "ressourcesNotFound": "Ressources introuvables" }, "family": "Famille", - "gammaValue": "Décélération horaire", + "constGamma": "Décélération horaire", "grouping": "Regroupement", "inertiaCoefficient": "Coefficient d'inertie", "legend": "Légende", diff --git a/front/src/common/api/generatedEditoastApi.ts b/front/src/common/api/generatedEditoastApi.ts index 30f89a0b3bf..889d28bba84 100644 --- a/front/src/common/api/generatedEditoastApi.ts +++ b/front/src/common/api/generatedEditoastApi.ts @@ -2678,10 +2678,6 @@ export type EnergySource = max_input_power: SpeedDependantPower; max_output_power: SpeedDependantPower; }; -export type Gamma = { - type: string; - value: number; -}; export type RollingStockMetadata = { detail: string; family: string; @@ -2706,9 +2702,9 @@ export type RollingStockSupportedSignalingSystems = string[]; export type LightRollingStock = { base_power_class?: string | null; comfort_acceleration: number; + const_gamma: number; effort_curves: LightEffortCurves; energy_sources: EnergySource[]; - gamma: Gamma; id: number; inertia_coefficient: number; length: number; @@ -2894,10 +2890,10 @@ export type EffortCurves = { export type RollingStock = { base_power_class: string | null; comfort_acceleration: number; + const_gamma: number; effort_curves: EffortCurves; electrical_power_startup_time: number | null; energy_sources: EnergySource[]; - gamma: Gamma; id: number; inertia_coefficient: number; length: number; @@ -2921,11 +2917,11 @@ export type RollingStock = { export type RollingStockForm = { base_power_class: string | null; comfort_acceleration: number; + const_gamma: number; effort_curves: EffortCurves; /** The time the train takes before actually using electrical power (in seconds). Is null if the train is not electric. */ electrical_power_startup_time?: number | null; energy_sources?: EnergySource[]; - gamma: Gamma; inertia_coefficient: number; length: number; loading_gauge: LoadingGaugeType; @@ -3359,7 +3355,7 @@ export type RollingResistancePerWeight = { }; export type TowedRollingStock = { comfort_acceleration: number; - gamma: Gamma; + const_gamma: number; id: number; inertia_coefficient: number; label: string; @@ -3373,7 +3369,7 @@ export type TowedRollingStock = { }; export type TowedRollingStockForm = { comfort_acceleration: number; - gamma: Gamma; + const_gamma: number; inertia_coefficient: number; label: string; length: number; diff --git a/front/src/modules/rollingStock/components/RollingStockCard/RollingStockCardDetail.tsx b/front/src/modules/rollingStock/components/RollingStockCard/RollingStockCardDetail.tsx index 829a44b54dc..cc72d9be553 100644 --- a/front/src/modules/rollingStock/components/RollingStockCard/RollingStockCardDetail.tsx +++ b/front/src/modules/rollingStock/components/RollingStockCard/RollingStockCardDetail.tsx @@ -106,9 +106,9 @@ export default function RollingStockCardDetail({ {rs.inertia_coefficient} - {t('gammaValue')} + {t('constGamma')} - {rs.gamma.value} + {rs.const_gamma} m/s² diff --git a/front/src/modules/rollingStock/components/RollingStockSelector/sampleData.ts b/front/src/modules/rollingStock/components/RollingStockSelector/sampleData.ts index 3853786bac3..4db527c2474 100644 --- a/front/src/modules/rollingStock/components/RollingStockSelector/sampleData.ts +++ b/front/src/modules/rollingStock/components/RollingStockSelector/sampleData.ts @@ -49,10 +49,7 @@ const ROLLING_STOCK_SAMPLE_DATA: RollingStockWithLiveries = { startup_time: 25, startup_acceleration: 0.03, comfort_acceleration: 0.08, - gamma: { - type: 'CONST', - value: 0.5, - }, + const_gamma: 0.5, inertia_coefficient: 1.2, mass: 132000, rolling_resistance: { diff --git a/front/src/modules/rollingStock/consts.ts b/front/src/modules/rollingStock/consts.ts index b7cc6081840..ebd2972afad 100644 --- a/front/src/modules/rollingStock/consts.ts +++ b/front/src/modules/rollingStock/consts.ts @@ -70,7 +70,7 @@ export const RS_REQUIRED_FIELDS = Object.freeze({ startupAcceleration: 0, comfortAcceleration: 0, startupTime: 0, - gammaValue: 0.01, + constGamma: 0.01, inertiaCoefficient: 1, rollingResistanceA: newRollingStockValues.rollingResistanceA, rollingResistanceB: newRollingStockValues.rollingResistanceB, @@ -100,7 +100,7 @@ export enum RollingStockEditorParameter { startupAcceleration = 'startupAcceleration', electricalPowerStartupTime = 'electricalPowerStartupTime', comfortAcceleration = 'comfortAcceleration', - gammaValue = 'gammaValue', + constGamma = 'constGamma', inertiaCoefficient = 'inertiaCoefficient', loadingGauge = 'loadingGauge', basePowerClass = 'basePowerClass', @@ -217,7 +217,7 @@ export const RS_SCHEMA_PROPERTIES: readonly SchemaProperty[] = [ side: 'middle', }, { - title: 'gammaValue', + title: 'constGamma', type: 'number', min: 0.01, max: 2, diff --git a/front/src/modules/rollingStock/helpers/__tests__/utils.spec.ts b/front/src/modules/rollingStock/helpers/__tests__/utils.spec.ts index 1305e44b47b..bfea1adbc1a 100644 --- a/front/src/modules/rollingStock/helpers/__tests__/utils.spec.ts +++ b/front/src/modules/rollingStock/helpers/__tests__/utils.spec.ts @@ -42,7 +42,7 @@ describe('checkRollingStockFormValidity', () => { 'startupAcceleration', 'comfortAcceleration', 'startupTime', - 'gammaValue', + 'constGamma', 'inertiaCoefficient', 'rollingResistanceA', 'rollingResistanceB', @@ -56,7 +56,7 @@ describe('checkRollingStockFormValidity', () => { startupAcceleration: 0, comfortAcceleration: 0, startupTime: 0, - gammaValue: 0.01, + constGamma: 0.01, inertiaCoefficient: 1, rollingResistanceA: { max: 20, min: 0, unit: 'kN', value: 0 }, rollingResistanceB: { max: 0.5, min: 0, unit: 'kN/(km/h)', value: 0 }, @@ -87,7 +87,7 @@ describe('checkRollingStockFormValidity', () => { 'startupAcceleration', 'comfortAcceleration', 'startupTime', - 'gammaValue', + 'constGamma', 'inertiaCoefficient', 'rollingResistanceA', 'rollingResistanceB', @@ -103,7 +103,7 @@ describe('checkRollingStockFormValidity', () => { startupAcceleration: 0, comfortAcceleration: 0, startupTime: 0, - gammaValue: 0.01, + constGamma: 0.01, inertiaCoefficient: 1, rollingResistanceA: { max: 20, min: 0, unit: 'kN', value: 0 }, rollingResistanceB: { max: 0.5, min: 0, unit: 'kN/(km/h)', value: 0 }, @@ -133,7 +133,7 @@ describe('checkRollingStockFormValidity', () => { 'startupAcceleration', 'comfortAcceleration', 'startupTime', - 'gammaValue', + 'constGamma', 'inertiaCoefficient', 'rollingResistanceA', 'rollingResistanceB', @@ -149,7 +149,7 @@ describe('checkRollingStockFormValidity', () => { startupAcceleration: 0, comfortAcceleration: 0, startupTime: 0, - gammaValue: 0.01, + constGamma: 0.01, inertiaCoefficient: 1, rollingResistanceA: { max: 20, min: 0, unit: 'kN', value: 0 }, rollingResistanceB: { max: 0.5, min: 0, unit: 'kN/(km/h)', value: 0 }, diff --git a/front/src/modules/rollingStock/helpers/utils.ts b/front/src/modules/rollingStock/helpers/utils.ts index f70c3f7d63d..92a37422d1f 100644 --- a/front/src/modules/rollingStock/helpers/utils.ts +++ b/front/src/modules/rollingStock/helpers/utils.ts @@ -92,7 +92,7 @@ export const getRollingStockEditorDefaultValues = ( startupTime: rollingStockData.startup_time, startupAcceleration: rollingStockData.startup_acceleration, comfortAcceleration: rollingStockData.comfort_acceleration, - gammaValue: rollingStockData.gamma.value, + constGamma: rollingStockData.const_gamma, inertiaCoefficient: rollingStockData.inertia_coefficient, loadingGauge: rollingStockData.loading_gauge, rollingResistanceA: { @@ -155,10 +155,7 @@ export const rollingStockEditorQueryArg = ( startup_time: data.startupTime, startup_acceleration: data.startupAcceleration, comfort_acceleration: data.comfortAcceleration, - gamma: { - type: 'CONST', - value: data.gammaValue, - }, + const_gamma: data.constGamma, inertia_coefficient: data.inertiaCoefficient, mass: handleUnitValue({ unit: 'kg', value: data.mass.value }, data.mass, data.mass) as number, // Back-end needs value in kg. rolling_resistance: { diff --git a/front/src/modules/rollingStock/types.ts b/front/src/modules/rollingStock/types.ts index 45c00182361..c2552eeea0a 100644 --- a/front/src/modules/rollingStock/types.ts +++ b/front/src/modules/rollingStock/types.ts @@ -31,7 +31,7 @@ export type RollingStockParametersValidValues = { startupTime: number; startupAcceleration: number; comfortAcceleration: number; - gammaValue: number; + constGamma: number; inertiaCoefficient: number; loadingGauge: LoadingGaugeType; rollingResistanceA: MultiUnitsParameter; @@ -71,7 +71,7 @@ export type RollingStockParametersValues = { startupTime?: number; startupAcceleration?: number; comfortAcceleration?: number; - gammaValue?: number; + constGamma?: number; inertiaCoefficient?: number; loadingGauge: 'G1' | 'G2' | 'GA' | 'GB' | 'GB1' | 'GC' | 'FR3.3' | 'FR3.3/GB/G2' | 'GLOTT'; rollingResistanceA?: MultiUnitsParameter; diff --git a/front/tests/assets/rollingStock/dual-mode_rolling_stock.json b/front/tests/assets/rollingStock/dual-mode_rolling_stock.json index ad82df229ee..b1ae9ac0940 100644 --- a/front/tests/assets/rollingStock/dual-mode_rolling_stock.json +++ b/front/tests/assets/rollingStock/dual-mode_rolling_stock.json @@ -419,10 +419,7 @@ "startup_time": 12.0, "startup_acceleration": 0.06, "comfort_acceleration": 0.54, - "gamma": { - "type": "CONST", - "value": 0.5 - }, + "const_gamma": 0.5, "inertia_coefficient": 1.05, "base_power_class": "5", "mass": 900000.0, diff --git a/front/tests/assets/rollingStock/fast_rolling_stock.json b/front/tests/assets/rollingStock/fast_rolling_stock.json index f2588c5e17d..1f29a13ba86 100644 --- a/front/tests/assets/rollingStock/fast_rolling_stock.json +++ b/front/tests/assets/rollingStock/fast_rolling_stock.json @@ -98,10 +98,7 @@ "startup_time": 15.0, "startup_acceleration": 0.03, "comfort_acceleration": 0.09, - "gamma": { - "type": "CONST", - "value": 1.5 - }, + "const_gamma": 1.5, "inertia_coefficient": 1.09, "base_power_class": "9", "mass": 190400.0, diff --git a/front/tests/assets/rollingStock/improbable_rolling_stock.json b/front/tests/assets/rollingStock/improbable_rolling_stock.json index 139c2134f31..330ed578da7 100644 --- a/front/tests/assets/rollingStock/improbable_rolling_stock.json +++ b/front/tests/assets/rollingStock/improbable_rolling_stock.json @@ -917,10 +917,7 @@ "startup_time": 10.0, "startup_acceleration": 0.05, "comfort_acceleration": 0.25, - "gamma": { - "type": "CONST", - "value": 0.5 - }, + "const_gamma": 0.5, "inertia_coefficient": 1.05, "base_power_class": "5", "mass": 900000.0, diff --git a/front/tests/assets/rollingStock/rollingstockDetails.json b/front/tests/assets/rollingStock/rollingstockDetails.json index e2853f219bf..b038f13c8e0 100644 --- a/front/tests/assets/rollingStock/rollingstockDetails.json +++ b/front/tests/assets/rollingStock/rollingstockDetails.json @@ -17,7 +17,7 @@ { "id": "startupAcceleration", "value": 0.1 }, { "id": "comfortAcceleration", "value": 1 }, { "id": "inertiaCoefficient", "value": 1 }, - { "id": "gammaValue", "value": 1 }, + { "id": "constGamma", "value": 1 }, { "id": "basePowerClass", "value": 7 }, { "id": "rollingResistanceA-input", "value": 15, "isNumeric": true }, { "id": "rollingResistanceB-input", "value": 0.3, "isNumeric": true }, @@ -41,7 +41,7 @@ { "id": "startupAcceleration", "value": 0.11 }, { "id": "comfortAcceleration", "value": 0.99 }, { "id": "inertiaCoefficient", "value": 1.3 }, - { "id": "gammaValue", "value": 1.1 }, + { "id": "constGamma", "value": 1.1 }, { "id": "basePowerClass", "value": 6 }, { "id": "rollingResistanceA-input", "value": 13, "isNumeric": true }, { "id": "rollingResistanceB-input", "value": 0.23, "isNumeric": true }, diff --git a/front/tests/assets/rollingStock/slow_rolling_stock.json b/front/tests/assets/rollingStock/slow_rolling_stock.json index 5780ba27818..3939a1a5d76 100644 --- a/front/tests/assets/rollingStock/slow_rolling_stock.json +++ b/front/tests/assets/rollingStock/slow_rolling_stock.json @@ -57,10 +57,7 @@ "startup_time": 22.0, "startup_acceleration": 0.03, "comfort_acceleration": 0.09, - "gamma": { - "type": "CONST", - "value": 0.6 - }, + "const_gamma": 0.6, "inertia_coefficient": 1.3, "base_power_class": "8", "mass": 75000.0, diff --git a/python/osrd_schemas/osrd_schemas/rolling_stock.py b/python/osrd_schemas/osrd_schemas/rolling_stock.py index bded0160225..fc4adf59637 100644 --- a/python/osrd_schemas/osrd_schemas/rolling_stock.py +++ b/python/osrd_schemas/osrd_schemas/rolling_stock.py @@ -85,16 +85,6 @@ def check_default_mode(self): return self -class GammaType(str, Enum): - CONST = "CONST" - MAX = "MAX" - - -class Gamma(BaseModel, extra="forbid"): - type: GammaType - value: PositiveFloat - - class RollingStockLivery(BaseModel): name: str = Field(max_length=255) @@ -207,7 +197,7 @@ class RollingStock(BaseModel, extra="forbid"): startup_time: NonNegativeFloat = Field(description="The time the train takes before it can start accelerating in s") startup_acceleration: NonNegativeFloat = Field(description="The maximum acceleration during startup in m/s^2") comfort_acceleration: NonNegativeFloat = Field(description="The maximum operational acceleration in m/s^2") - gamma: Gamma = Field(description="The max or const braking coefficient in m/s^2") + const_gamma: NonNegativeFloat = Field(description="The constant gamma braking coefficient used when NOT circulating under ETCS/ERTMS signaling system in m/s^2") inertia_coefficient: NonNegativeFloat = Field(description="The coefficient of inertia") mass: NonNegativeFloat = Field(description="The mass of the train, in kg") rolling_resistance: RollingResistance = Field(description="The formula to use to compute rolling resistance") @@ -242,7 +232,7 @@ class TowedRollingStock(BaseModel, extra="forbid"): startup_acceleration: NonNegativeFloat = Field(description="The maximum acceleration during startup in m/s^2") inertia_coefficient: NonNegativeFloat = Field(description="The coefficient of inertia") rolling_resistance: RollingResistance = Field(description="The formula to use to compute rolling resistance") - gamma: Gamma = Field(description="The max or const braking coefficient in m/s^2") + const_gamma: NonNegativeFloat = Field(description="The constant gamma braking coefficient used when NOT circulating under ETCS/ERTMS signaling system in m/s^2") if __name__ == "__main__": diff --git a/tests/data/rolling_stocks/electric_rolling_stock.json b/tests/data/rolling_stocks/electric_rolling_stock.json index 8dc8e8a4b83..876f8925f46 100644 --- a/tests/data/rolling_stocks/electric_rolling_stock.json +++ b/tests/data/rolling_stocks/electric_rolling_stock.json @@ -10,10 +10,7 @@ "name": "electric_rolling_stock", "mass": 900000, "loading_gauge": "G1", - "gamma": { - "value": 0.5, - "type": "CONST" - }, + "const_gamma": 0.5, "rolling_resistance": { "type": "davis", "A": 5400, diff --git a/tests/data/rolling_stocks/fast_rolling_stock.json b/tests/data/rolling_stocks/fast_rolling_stock.json index 64fc792f79e..860417c2ec7 100644 --- a/tests/data/rolling_stocks/fast_rolling_stock.json +++ b/tests/data/rolling_stocks/fast_rolling_stock.json @@ -10,10 +10,7 @@ "name": "fast_rolling_stock", "mass": 900000, "loading_gauge": "G1", - "gamma": { - "value": 0.5, - "type": "CONST" - }, + "const_gamma": 0.5, "rolling_resistance": { "type": "davis", "A": 5400, diff --git a/tests/data/rolling_stocks/fast_rolling_stock_high_gamma.json b/tests/data/rolling_stocks/fast_rolling_stock_high_gamma.json index 6dbce1d3ebb..7cac0306f4a 100644 --- a/tests/data/rolling_stocks/fast_rolling_stock_high_gamma.json +++ b/tests/data/rolling_stocks/fast_rolling_stock_high_gamma.json @@ -10,10 +10,7 @@ "name": "fast_rolling_stock_high_gamma", "mass": 900000, "loading_gauge": "G1", - "gamma": { - "value": 0.95, - "type": "CONST" - }, + "const_gamma": 0.95, "rolling_resistance": { "type": "davis", "A": 5400, diff --git a/tests/data/rolling_stocks/short_fast_rolling_stock.json b/tests/data/rolling_stocks/short_fast_rolling_stock.json index fb98a595fc3..f6ff59d6d17 100644 --- a/tests/data/rolling_stocks/short_fast_rolling_stock.json +++ b/tests/data/rolling_stocks/short_fast_rolling_stock.json @@ -10,10 +10,7 @@ "name": "short_fast_rolling_stock", "mass": 900000, "loading_gauge": "G1", - "gamma": { - "value": 0.5, - "type": "CONST" - }, + "const_gamma": 0.5, "rolling_resistance": { "type": "davis", "A": 5400, diff --git a/tests/data/rolling_stocks/short_slow_rolling_stock.json b/tests/data/rolling_stocks/short_slow_rolling_stock.json index 07642ffb7d2..800512c61e7 100644 --- a/tests/data/rolling_stocks/short_slow_rolling_stock.json +++ b/tests/data/rolling_stocks/short_slow_rolling_stock.json @@ -10,10 +10,7 @@ "name": "short_slow_rolling_stock", "mass": 900000, "loading_gauge": "G1", - "gamma": { - "value": 0.5, - "type": "CONST" - }, + "const_gamma": 0.5, "rolling_resistance": { "type": "davis", "A": 5400, diff --git a/tests/data/rolling_stocks/slow_rolling_stock.json b/tests/data/rolling_stocks/slow_rolling_stock.json index b58b6a95ead..7e6352d056c 100644 --- a/tests/data/rolling_stocks/slow_rolling_stock.json +++ b/tests/data/rolling_stocks/slow_rolling_stock.json @@ -10,10 +10,7 @@ "name": "slow_rolling_stock", "mass": 900000, "loading_gauge": "G1", - "gamma": { - "value": 0.5, - "type": "CONST" - }, + "const_gamma": 0.5, "rolling_resistance": { "type": "davis", "A": 5400,