# How is train speed calculated in OpenRails?

I have been playing OpenRails Train SImulator recently and I thought i made my own train(which i did), then the physics part came up. It required me to fill in a lot of parameters, like braking, sanders, and of course, engine. Now the engine part is confusing me, it requires me to enter:

Mass(KG), Max Power(kW), Max Force(kN), Continuous Force(kN), and Max Velocity(mph).

Now the Mass, MaxForce and MaxContinousForce is easy to find, but what about the rest? In order for me to know more about what i am doing, i would like to know how the speed in the game is calculated using all these values? Because i thought the speed of the train was only calculated using the MaxForce and the Mass value, but all these values seem to have some connection as if one of those listed values is changed, speed is different. So how would I calculate the speed of a train using these parameters(What is/are the formula('s)? And how are the horsepower values and force values related to each other in terms of final speed?(As again, i though kW didn't matter in speed)

Can someone explain me?

Thanks!

Edit: So mainly what i want to know is: Is the calculation of speed in general affected by horsepower/kW(does it have anything to do with speed/force at all?)

• how would anybody know what the game is doing? – agentp Jan 18 '18 at 17:35
• Do you enter things like height & width of the train ? – Solar Mike Jan 18 '18 at 17:40
• I am not asking specificly how the game is doing it(but the game is opensource, so thats how somebody could know) but i i am asking how you in general would calculate the speed with these values. I did enter height and width of the train, why? – Tim Leijten Jan 18 '18 at 19:14
• The power produced by the engine once at the driving wheels is dissipated in two ways : rolling resistance and air resistance. – Solar Mike Jan 19 '18 at 7:34

Let's put aside this specific game, and just say we want to calculate the speed of some generic vehicle. I think that will answer what you are really trying to get at. Our vehicle is going to obey Newtons\'s second law $F=ma$, force = mass times acceleration. So, let's add up all of the forces that act on the train. The main ones will be the driving force from the engine, and then rolling resistance and air drag as pointed out by @SolarMike. Let's ignore rolling resistance to simplify the problem, and just look at the others. So

$F_{engine} + F_{drag} = ma$.

Now, we know from wikipedia, that $F_{drag} \propto v^2$, where $v$ is the velocity. To simplify the discussion, I'll lump all of the constants into just one, so $F_{drag}=-Cv^2$, where the minus sign is indicating that the drag force is in the opposite direction of the applied engine force. So at this point we have:

$F_{engine} - Cv^2 = ma$.

Now, what is the formula for the engine? Well, it's complicated and will depend on your specific engine. If you have a transmission, it will depend on what gear you are in. But two important points: it is dependent on speed, and above a certain speed it will start to decrease with speed. i.e. as you go faster and faster, the engine is producing less torque. You can find some real engine curves here, but for this discussion, let's oversimplify it a lot and just assume a linear relationship $F_{engine}=A-Bv$. So now we have:

$A-Bv - Cv^2 = ma$.

So, imagine your train starts at v=0. The left hand side is positive, so acceleration is positive and your train speeds up. Now it has some velocity. The left hand side is still positive, but less than before. The engine is producing less force, and the air drag is acting against us. So the train continues to accelerate, but not as much. Finally, at some speed, the left hand side will be zero. The air drag will have increased to the point where the force produced by the engine exactly equals the air drag. At this point, acceleration is zero. The train has reached its top speed.