News:

SimuTranslator
Make Simutrans speak your language.

Braking rates and differential equations

Started by jamespetts, September 21, 2011, 11:34:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jamespetts

I am hoping to implement a realistic approximation of braking distance calculation in the next version of Experimental (brake performance is highly relevant to the maximum speed of rail vehicles and the capacity of railways), but my limited mathematical ability does not stretch to writing C++ code to solve differential equations of the sort required to calculate braking distances (see here for an explanation of those equations). What I need is a formula for converting speed, weight, brake force and rolling/air resistance into a braking distance. I should be grateful for any suggestions or pointers as to how to go about this task; integrating this into the Simutrans code should then be fairly straightforward.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

ath

The train decelarates due to two forces: Breaking force and drag.
I assume that the vehicles will have a constant breaking force F_B.
The drag force is   F_D = C*v^2  ,  where v is the velocity,  C = 0.5*A*d,   A is the projected area of the front of the vehicle, and d is the drag coefficient. C is therefore a constant for each vehicle. The factor d  describes how airodynamically sophisticated the vehicle is. Wikipedia has a list : http://en.wikipedia.org/wiki/Drag_coefficient

According to Newton's law, the forces relate with the velocity by the differential equation

sum(F) = -F_B-F_D= m* dv/dt   (Forces are in opposite direction of velocity)

This leads to the differential equation

-F_B - C*v^2 = m*dv/dt

Separation of variables and integration:

\int (1/m)dt  = -\int (1/(F_B+C*v^2)dv)

Solving this equation yields

t_1 - t_0 = -m*(1/sqrt(F_B*C))*arctan( sqrt(C)*v_1/sqrt(F_B) )  + m*(1/sqrt(F_B*C))*arctan( sqrt(C)*v_0/sqrt(F_B) )

Here, t_0 is the current time, v_0 is the current velocity, and v_1 is the velocity the vehicle will have reached at time t_1.

This means that the time t necessary to come to a full halt (v_1 = 0) is given by

t = m*(1/sqrt(F_B*C))*arctan( sqrt(C)*v_0/sqrt(F_B) )

Hope this helps

jamespetts

Ath,

thank you very much indeed - that is most helpful. And welcome to the forums! One or two questions from a mathematical dunce, if I may: the current physics code in Experimental for accelerating (braking is not currently governed by physics equations) already has values for the drag coefficient from mechanical friction and from air resistance, rather than calculating air resistance based on the front area and a factor of aerodynamic sophistication. How would these two factors be combined to calculate C?

Secondly, I am more interested in the distance taken to come to a halt than the time, since I need to be able to calculate when the train should start to brake, by calculating how many tiles from the designated stopping point that braking should start. Is there a way of re-arranging the equation in order to give this datum?

Thank you again for all your help.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

ӔO

#3
you should be able to calculate distance from a more simple equation of
d = vt + (1/2)at^2

d= distance (m)
v= initial velocity (m/s)
t= time (s)
a= acceleration (m/s/s)

a will be a negative number, because it's deceleration.

v= 10m/s
t= 10s
a= -1.0m/s^2

d= 50m to stop.
http://www.wolframalpha.com/input/?i=d+%3D+10*10+%2B+%281%2F2%29%28-1.0%2910^2+


could someone double check that? my physics is a bit rusty.
My Sketchup open project sources
various projects rolled up: http://dl.dropbox.com/u/17111233/Roll_up.rar

Colour safe chart:

jamespetts

AEO,

thank you for that: but how do I calculate "a" from brake force?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Milko

#5
Hello

Brake force [N] = mass [kg] * acceleration [m/s/s]

In theory, every train has its own braking force.

Giuseppe

ath

@AEO:
your formula assumes that the deceleration is constant, which is not true if you consider drag.

@James:
- How is the mechanical friction modeled? The same way as drag ( proportional to v^2) ? Then you could just combine both mechanical friction and air drag into one coefficient C and use the same formula
- Isn't the braking force much larger than the drag terms for almost all velocities -> then you could use AEO's formula with a = F_B/m and save yourself a lot of hassle
- From the formula I gave before, you can derive the distance taken to come to a halt by
1. rearrange the equation so that it reads  v_1 = ...
2. With v_1 = dx/dt  (x is the distance traveled), integrate the equation
The result for the distance x is (no guarantee that this is correct, but it's close):

x = -m/C*ln(cos(atan(sqrt(C/F_B)*v_0)))

Another point to consider is that the maximum braking force depends on the maximum friction force between the ground and the wheels of the vehicle, which scales linearly with the weight of the vehicle. Therefore, an empty train should have the same deceleration as a fully loaded train, given that its braking capacity is limited by the friction of the wheels (which is definitely true for cars, as everyone with ABS knows).


ӔO

It might be a bit more complicated to calculate maximum braking force for a train, since many train cars don't have brakes and instead rely on a brake van and engine to provide the stopping power. Most modern trains have air brakes through the entire train, but older ones don't always have this feature.


another thought, how would running down or up a hill be calculated?
My Sketchup open project sources
various projects rolled up: http://dl.dropbox.com/u/17111233/Roll_up.rar

Colour safe chart:

Bernd Gabriel

So you are planning to add a figure to the vehicles if not yet done?

In the convoy code I made a brake force assuption, which should be replaced by a given value.

I could add the distance calculation to the convoy code.
The journey is the reward!

jamespetts

Thank you all for your helpful replies. Bernd, yes, indeed, I am planning to add a figure for brake force to vehicles in Kn (0 being for an unbraked vehicle). If you are able to add a calculation of braking distance for any given convoy, that would be excellent. I had thought of asking you, but was reluctant since you had done so much work already; but if you are willing to do that, I should be delighted.

Incidentally, where in the physics code is the (assumed) brake force parameter used? Currently, I think, physics is not used for braking (although it would be better if it was, but that can only be done if the point at which the vehicles need to start braking can be identified accurately).
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Bernd Gabriel

convoy_t::calc_move() if convoy is too fast (e.g. hill-down) assumes up to 5 times stronger brakes than starting force (--> is_braking = true).

OK. I will do it.
The journey is the reward!

jamespetts

Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

fbfree

If you need to calculate the amount of distance required to break when on a gradient, the easiest calculation is one based on the energy that must be dissipated.

Energy dissipated = Kinetic Energy of the train + Difference in gravitation potential energy of the train when initiating braking.
braking force * braking distance = train mass * (1/2 * (train speed)^2 + 9.8 m/s^2 * (elevation at start of braking - station elevation) )

Unfortunately, the elevation at the start of braking is dependent on the braking distance, but either a slope estimation or an iterative method would work. 

I'm not sure that specifying the maximum breaking force that a train can deliver is the most accurate way to model transit operations.  A subway car, bus, or commuter train might accelerate and decelerate quite comfortably at 1.2 m/s^2, but this would severely upset a dining car that would not want to decelerate any faster than about 0.5m/s^2.  A maximum acceleration for a given type of rail vehicle may be more suitable, at least for modern transit stock.