Skip to content

Commit

Permalink
fixup! core: add etcs loa logic to etcs braking simulator
Browse files Browse the repository at this point in the history
Signed-off-by: Erashin <[email protected]>
  • Loading branch information
Erashin committed Jan 17, 2025
1 parent 33bf431 commit f95b0b1
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 85 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
package fr.sncf.osrd.envelope_sim.etcs

/**
* Formulas are found in `SUBSET-026-3v400.pdf` from the file at
* https://www.era.europa.eu/system/files/2023-09/index004_-_SUBSET-026_v400.zip and in
* `SUBSET-041_v400.pdf` from the file at
* https://www.era.europa.eu/system/files/2023-09/index014_-_SUBSET-041_v400.pdf
*/

/**
* National Default Value: permission to inhibit the compensation of the speed measurement accuracy.
* See Subset referenced in ETCSBrakingSimulator: table in Appendix A.3.2.
* See Subset 026: table in Appendix A.3.2.
*/
const val qNvinhsmicperm = false

/**
* Estimated acceleration during tBerem, worst case scenario (aEst2 is between 0 and 0.4), expressed
* in m/s². See Subset referenced in ETCSBrakingSimulator: §3.13.9.3.2.9.
* in m/s². See Subset 026: §3.13.9.3.2.9.
*/
const val aEst2 = 0.4

/** See Subset referenced in ETCSBrakingSimulator: table in Appendix A.3.1. */
/** See Subset 026: table in Appendix A.3.1. */
const val dvEbiMin = 7.5 / 3.6 // m/s
const val dvEbiMax = 15.0 / 3.6 // m/s
const val vEbiMin = 110.0 / 3.6 // m/s
Expand All @@ -22,23 +29,41 @@ const val tDriver = 4.0 // s
const val mRotatingMax = 15.0 // %
const val mRotatingMin = 2.0 // %

/** See https://www.era.europa.eu/system/files/2023-09/index014_-_SUBSET-041_v400.pdf: §5.3.1.2. */
/** See Subset 041: §5.3.1.2. */
const val vUraMinLimit = 30 / 3.6 // m/s
const val vUraMaxLimit = 500 / 3.6 // m/s
const val vUraMin = 2 / 3.6 // m/s
const val vUraMax = 12 / 3.6 // m/s

/** See Subset 041: §5.3.1.2. */
fun vUra(speed: Double): Double {
return if (speed <= 30 / 3.6) 2 / 3.6
// vUra(30km/h) = 2km/h & vUra(500km/h) = 12km/h with a linear interpolation in between
// this gives the following equation : y = (x + 64) / 47, still in km/h
else ((speed + 64) / 47) / 3.6
return interpolateLinearSpeed(speed, vUraMinLimit, vUraMaxLimit, vUraMin, vUraMax)
}

/** See Subset referenced in ETCSBrakingSimulator: §3.13.9.3.2.10. */
/** See Subset 026: §3.13.9.3.2.10. */
fun vDelta0(speed: Double): Double {
return if (!qNvinhsmicperm) vUra(speed) else 0.0
}

/** See Subset referenced in ETCSBrakingSimulator: §3.13.9.2.3. */
/** See Subset 026: §3.13.9.2.3. */
fun dvEbi(speed: Double): Double {
return if (speed <= vEbiMin) dvEbiMin
else if (speed < vEbiMax)
(dvEbiMax - dvEbiMin) / (vEbiMax - vEbiMin) * (speed - vEbiMin) + dvEbiMin
else dvEbiMax
return interpolateLinearSpeed(speed, vEbiMin, vEbiMax, dvEbiMin, dvEbiMax)
}

/**
* The linear curve is the following: below minSpeedLimit = minSpeed, above maxSpeedLimit =
* maxSpeed, in between is a linear curve. This method takes a speed input and converts it
* accordingly.
*/
private fun interpolateLinearSpeed(
speed: Double,
minSpeedLimit: Double,
maxSpeedLimit: Double,
minSpeed: Double,
maxSpeed: Double
): Double {
return if (speed <= minSpeedLimit) minSpeed
else if (speed < maxSpeedLimit)
(maxSpeed - minSpeed) / (maxSpeedLimit - minSpeedLimit) * (speed - minSpeedLimit) + minSpeed
else maxSpeed
}
Loading

0 comments on commit f95b0b1

Please sign in to comment.