If you want to work with a brake curve, you can make use of the following physical identity for uniform acceleration:
velocity = sqrt(2 * acceleration * distance)where:
- velocity is the speed of the train (expressed in m/s),
- acceleration is the (in this case) deceleration of the train (expressed in m/s²),
- distance is the distance from the stop point to the train (expressed in m),
- and sqrt is the square root function.
All values used in the above formula should be positive. If you want to work with velocity expressed in km/h and acceleration in km/h/s, you can use:
velocity = sqrt(7.2 * acceleration * distance)Given the allowed velocity, you can easily check whether the train exceeds it, and then apply the brakes. This, however, is just a starting point. You might want to incorporate that the train can brake at different deceleration levels (brake notches) for a smoother braking performance.
For more information on uniform acceleration, you can also check out the formulas on the respective
Wikipedia page. I leave it to you (or to others) to develop this further.