@@ -53,8 +53,12 @@ class NETRAINSIMCORE_EXPORT Train : public QObject {
5353private:
5454 /* * Holds the number of trains in the simulator. */
5555 static unsigned int NumberOfTrainsInSimulator;
56- /* * (Immutable) the default desired deceleration rate */
57- static constexpr double DefaultDesiredDecelerationRate = 0.2 ;
56+ /* * (Immutable) minimum desired deceleration to prevent infinite safe gaps (m/s^2) */
57+ static constexpr double MinDesiredDeceleration = 0.05 ;
58+ /* * Fraction of emergency braking used for normal service braking.
59+ * 0.5 = 50% of max brake force (Karwatzki physical maximum).
60+ * Typical: 0.35 heavy haul, 0.5 freight, 0.65 passenger. */
61+ static constexpr double DefaultServiceBrakingFactor = 0.5 ;
5862 /* * (Immutable) the default reaction time of the train operator */
5963 static constexpr double DefaultOperatorReactionTime = 1.0 ;
6064 /* * (Immutable) the default switch of the train behaviour if no energy source */
@@ -71,14 +75,12 @@ class NETRAINSIMCORE_EXPORT Train : public QObject {
7175public:
7276
7377 /* *
74- * (Immutable) the speed of sound in m / s, this is an approximation of the brackes back
75- * propagation
78+ * (Immutable) brake pipe pressure wave propagation speed in m/s.
79+ * Measured ~250 m/s for service braking on freight (Qiao 2018).
7680 */
77- static constexpr double speedOfSound = 343 .0 ;
81+ static constexpr double brakePipePropagationSpeed = 250 .0 ;
7882 /* * (Immutable) gravitational acceleration */
7983 const double g = 9.8066 ;
80- /* * The desired decceleration value */
81- double d_des;
8284 /* * the perception reaction time of the train operator. */
8385 double operatorReactionTime;
8486 /* * Total length of the train */
@@ -273,15 +275,12 @@ class NETRAINSIMCORE_EXPORT Train : public QObject {
273275 * @param locomotives The locomotives.
274276 * @param cars The cars.
275277 * @param optimize True to optimize.
276- * @param desiredDecelerationRate_mPs (Optional) The desired deceleration rate m ps.
277278 * @param operatorReactionTime_s (Optional) The operator reaction time s.
278279 * @param stopIfNoEnergy (Optional) True to stop if no energy.
279- * @param isRunnigOffGrid (Optional) True if is runnig off grid, false if not.
280280 * @param maxAllowedJerk_mPcs (Optional) The maximum allowed jerk m pcs.
281281 */
282282 Train (int simulatorID, string id, Vector<int > trainPath, double trainStartTime_sec, double frictionCoeff,
283283 Vector<std::shared_ptr<Locomotive>> locomotives, Vector<std::shared_ptr<Car>> cars, bool optimize,
284- double desiredDecelerationRate_mPs = DefaultDesiredDecelerationRate,
285284 double operatorReactionTime_s = DefaultOperatorReactionTime,
286285 bool stopIfNoEnergy = DefaultStopIfNoEnergy,
287286 double maxAllowedJerk_mPcs = DefaultMaxAllowedJerk,
@@ -344,6 +343,20 @@ class NETRAINSIMCORE_EXPORT Train : public QObject {
344343 */
345344 double getMinFollowingTrainGap ();
346345
346+ /* *
347+ * @brief Gets the speed-dependent desired deceleration rate.
348+ *
349+ * @details Computes comfortable braking deceleration for the
350+ * car-following safe gap calculation. Sums per-vehicle shoe braking
351+ * forces (Karwatzki model), divides by total train mass, then scales
352+ * by DefaultBrakingComfortFactor to convert from physical maximum
353+ * to a desired comfortable rate.
354+ *
355+ * @param speed The current train speed in m/s.
356+ * @returns The desired deceleration in m/s^2.
357+ */
358+ double getDesiredDeceleration (double speed);
359+
347360 /* *
348361 * @brief set the current links the train is spanning
349362 * @param newLinks
0 commit comments