How to draw a velocity curve from Engine power, weight and traction? Not sure if this is the right forum but I would like to plot a velocity curve of a train, starting at 0km/h and accelerating up to a max speed.  
The data I have for the locomotive engines are:


*

*Power in kW

*Traction in kN

*Weight in tonnes (1000kg)

*Max speed in km/h


It would also be nice to include a load (of wagons) in the formula.
The data I have for wagons are only their weight in tonne (1000kg).  
I know there might be more variables but this is all data I have available.
EDIT
This isn't a homework assignment! It is for a game manager to Train Fever and the described parameters are the only data available.
 A: This sounds like a homework question (edit below with more info once you explained that it isn't a homework question), so I'm just going to give hints.
First of all, notice that power can be written as
$P = Fv$
So if the engine power is fixed then at very low speed it can develop very high force.  But the maximum force is dictated by static friction, which is probably what you are describing as "traction".  So, below some speed the train's acceleration is limited by the maximum static friction (which is constant).  Above this speed it is limited by the power since in this regime as $v$ increases the maximum force  developed by the engine decreases.
So the v(t) curve will have two parts: a low speed part with constant acceleration, and a higher speed part with constant power.  These will have different functional forms in terms of time.
What is the source of the maximum speed?  Do you have information about drag forces?  If not then I don't know how you would factor in a maximum speed.  If you do have information about drag forces then you should be able to calculate a maximum speed using them.  But if you are supposed to include drag forces then your v(t) curve becomes much harder to solve for.
Later edit once it was clear that it wasn't a homework problem.
So, the train accelerates because the the wheels exert a frictional force forward.  This frictional force will be limited by the coefficient of static friction.  So, if the friction force is at its maximum value (if the engine throttled up any higher the wheels would just slip) Newton's 2nd law says (if the train is on a flat surface so the normal force is $mg$)
$ma = \mu_s mg$
where $m$ is the mass of the train, $\mu_s$ is the static friction coefficient.  Look up $\mu_s$ for steel on steel.  So this just means that when the static friction is maximum the acceleration is
$a = \mu_s g$
Note that this is constant.  Let's call this constant acceleration which is achieved at low speed $a_l$.  So the $v(t)$ curve will, for low speed, be just
$v(t) = a_l t$
which is a straight line.  The frictional force is just $f_s = \mu_s mg$ and is a constant.  But, notice that the maximum power is set by the engine.  Let's call it $P_{max}$.  As the train speeds up the power $P = f_s v$ will increase.  But this means eventually it will equal $P_{max}$.  After this time the force decreases (the engine can't do enough work to keep the acceleration at the same rate at these higher speeds).  So above this speed, neglecting air drag
$f_s = ma = \frac{P_{max}}{v}$
This is a differential equation since $a = dv/dt$.  So, if the time when $P = P_{max}$ for the first time is called $t_c$, and the speed at that moment is $v_c$ we will have
$\int_{v_c}^v v' dv' = \frac{P_{max}}{m} \int_{t_c}^t dt'$
which can be solved to yield a $v(t)$ valid after $t_c$.
Now, neglecting drag is not a good approximation, but it makes the integral much easier.  But if we neglect drag then the train has no maximum speed since we get $v \sim \sqrt{t}$, which grows without bound.  So, if all of the above is clear try adding drag in to get a more realistic answer.
A: If you have traction then you can assume the acceleration as a function of speed is $$ a = \frac{P}{m v} - \alpha - \beta\, v^2 $$
where:


*

*$P$ is the power output

*$m$ is the total moving mass

*$v$ is the current speed

*$\alpha$ a coefficient to model friction

*$\beta$ a coefficient to model drag


At this point,  friction is ignored with $\alpha=0$. With the inclusion of friction, things get complicated fast. You would need to know the minimum torque to break loose and start moving.
If you know the top speed $v_{top}$ then you can estimate $\beta$ as $$ \beta = \frac{P_{max}}{m v_{top}^3}$$
So the differential equation to be solved is
$$ a = \frac{{\rm d}v}{{\rm d}t} = \frac{ P}{m \,v} - \frac{P_{max} v^2}{m v_{top}^3} $$
You can find a solution is you know the speed $v_1$ at which full power can be applied without loss of traction. Set $P=P_{max}$ and integrate the following:
$$\begin{aligned}
 x  = \int \limits_{v_1}^{v} \frac{v}{a}\; {\rm d}v & = \int \limits_{v_1}^{v} \frac{m\, v^2\,v_{top}^3}{P_{max}(v_{top}^3-v^3)}\; {\rm d}v \\
 &= \frac{m\,v_{top}^3}{3 \,P_{max}} \ln \left( \frac{v_{top}^3-v_1^3}{v_{top}^3-v^3} \right) \end{aligned}$$
$$ \begin{aligned} t &= \int \limits_{v_1}^{v} \frac{1}{a}\; {\rm d}v = \int \limits_{v_1}^{v} \frac{m\, v\,v_{top}^3}{P_{max}(v_{top}^3-v^3)}\; {\rm d}v \\
 &  = \frac{m v_{top}^2}{6 P_{max}} \left( 2\sqrt{3} ( \tan^{-1}\left(\frac{\eta_1}{\sqrt{3}}\right)-\tan^{-1}\left(\frac{\eta}{\sqrt{3}}\right) + \ln \left( \frac{(\eta^2+3)(\eta_1-3)^2}{(\eta_1^2+3)
 (\eta-3)^2 } \right) \right) \\
 & \eta = 1+\frac{2\,v}{v_{top}} \\
 & \eta_1 = 1+\frac{2\,v_1}{v_{top}} \\
\end{aligned}$$
So you have the curves of time $t$ and distance $x$ as a function of speed $v$. Plot them for $v=v_1 \ldots v_{top}$.
Now I have done the hard part. You can figure out the parts where it is traction limited. Use $ a = a_{T} - \beta v^2 $ in a similar manner. Based on the max (traction) acceleration $a_{T} = \frac{\rm traction}{m}$ you can find the transition speed $v_1$ such that $a_{T} = \frac{P_{max}}{m v_1}$.
A: I decided to give my answer too as I feel there exists better solution to use differential equations in programs than solving them mathematically.
Newton's law of motion says that total force equals change in momentum. For that left side is the change of momentum and right side includes all forced acting on train.
$\frac{d}{dt}(m*v)=min(P/v,\mu_{t}*F_{n}) - \mu*F_{n} - C_{sd}*v^2 - m*g*sin(\theta)$
I explain each component and why they are part of equation


*

*$\frac{d}{dt}(m*v)$ is change of momentum that we can use to solve time depend velocity and position information. If mass is constant (we can assume it for a train) then you can simplify it to $m*\frac{dv}{dt}=m*\frac{d^2x}{dt^2}$. But the last form as second derivative of position is unlikely to simplify solving the equation or using numerical approximation.

*$min(P/v,\mu_{t}*F_{n})$ is engine power creating forward force (work is $W=F*x$ and power is $P=W/t$ which results to $P=F*x/t=F*v$). At slow speeds full engine power can't be used because available traction is less which would result to wheel spin. $\mu_{t}*F_{n}=F_{traction}$

*$\mu*F_{n}$ is rolling friction opposing movement. This component is large in slow speed (<~100kph) while small in large speeds when compared aerodynamic drag. Normal force is constant in most simple cases. It should be function based on many variables like hill incline, height above sea level and aerodynamic downforce.

*$C_{sd}*v^2$ is simplified version of aerodynamic drag equation where drag coefficient is product of multiple variables  ($C_{sd}=0.5*\rho*A*C_{d}$)

*$m*g*sin(\theta)$ is effect of hill incline to the motion because of gravitational force. I used constants in my equation but depending on case all of variables there can be functions. Mass of moving object can vary (extreme example is rocket), gravitational field depends on height above or below sea level and $\theta$ is incline of hill that obviously changes when object moves in real world. Downhill needs to use negative angle to produce positive force.


Solving that equation without CAS (computer algebra system) because pretty hard. But we can simplify it enough that we can solve special cases which helps us to solve some of constants.
We can assume that either friction or aerodynamic drag is dominating force depending on speed and shape. Good rule of thump is that you should simulate top speeds under 100kph with only friction opposing movement on flat terrain.
At top speed we have situation where full engine power produces exactly same amount of force as opposing forces total.


*

*$0=\frac{P_{max}}{v_{top}}-\mu*F_{n} \Leftrightarrow \frac{P_{max}}{v_{top}*F_{n}} = \mu $ where $P_{max}$, $v_{top}$ and $F_{n}$ are easy to measure empirically. This is slow speed motion equation that ignores drag was simpler solution.

*$0=\frac{P_{max}}{v_{top}}-C_{sd}*v_{top}^2$ which allows simple empirical approximation for aerodynamic drag coefficient.


This is highly simplified approach to solving motion equation parameters which can result to fairly large approximation errors if friction and drag forces are about equal or you choose to ignore larger one. To solve both friction and drag terms you would need acceleration measurements from two different speeds to solve two unknown coefficients.
Now at last to the solving part. As you are planing on writing code it is much simpler to use differential equation directly in a numeric approximation that try to solve it.
Good simple method reads current speed, normal force, height and incline information from state variables. It then can calculate snapshot force information and apply changes as simple linear approximation. This method is called euler method [https://en.wikipedia.org/wiki/Euler_method]. But you must careful with linear approximation resulting to minor errors that are very visible to user.
First possible very visible errors are speed going above maximum speed and then again slowing under maximum speed. User is likely to notice that speed meter jumps up and down instead of staying stable at stop speed. Second easy error to make is to let speed go to negative when applying breaks which would results similar speed fluctuation around zero instead of keeping object stationary.
Euler method has relatively large errors. Large errors require very small simulation step if wanting very accurate values. There has been multiple improved methods that add a bit more calculation per step but offer much more accurate results. First method is improved euler that uses euler calculation to find approximate average position for time step. It then uses speed, position etc for approximate average position to calculate forces that often results to much smaller errors but costs a bit more calculation per simulation step. I didn't spot it in wikipedia when I quickly looked but it is part of Adam's calculus course book.
If even improved euler method doesn't produce accurate enough results for simulation time step there is even better approximation schemes. RK4 [https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods] allows reduced approximation error without increasing simulation steps. 
I assume that most games uses Euler method as it provides good enough approximation that players can't see difference between reality when timesteps are around $\frac{1}{60}s$. But most physics simulation software are likely to choose RK4 or similar method that provides much more accurate approximation with relatively small increase of computation cost.
