*2.1. Train Dynamics Model*

At every time step the train position *s*(*t*), speed *v*(*t*) and acceleration *a*(*t*) are determined by using Newton's second law Equations (1)–(5),

$$\frac{ds}{dt} = v(t),\tag{1}$$

$$\frac{dv}{dt} = a(t),\tag{2}$$

$$a(t) = \frac{F\_m(\mathbf{t}) - F\_b(\mathbf{t}) - F\_r(\mathbf{v}) - F\_{\mathcal{S}}(\mathbf{s})}{\rho m},\tag{3}$$

$$s(t\_0) = s\_{0\prime} \ s(t\_f) = s\_{f\prime} \tag{4}$$

$$
v(t\_0) = v\_{0\prime} \ v(t\_f) = v\_{f\prime} \tag{5}$$

where *m* is the train mass, ρ is the dimensionless rotating mass factor, *Fr* (*v*) is the running resistance and *Fg*(*s*) are the forces that affect the train due to the track geometry. *Fm*(*t*) is the engine traction force and *Fb*(*t*) is the braking force. *t*0, *tf* , *s*0, *sf* , *v*<sup>0</sup> and *vf* are the initial and final times, positions and speeds of the train, respectively.

The engine traction force *Fm*(*t*) is bounded by a maximum traction curve that depends on the speed of the train. The braking force *Fb*(*t*) has two components: the electrical or regenerative and the pneumatic brakes. The regenerative brake is limited by a maximum electrical braking curve; if the train needs to brake it will use pneumatic brake to complement the electrical when the electrical one is saturated. The manual driving module computes both forces at every simulation time step to control the train dynamics considering the driving commands while obeying speed limits and stopping the train at the stopping points. In neutral zones, a minimum braking effort is applied to feed the auxiliary systems using regenerative energy.

The running resistance *Fr*(*v*) depends quadratically on the train speed and it is modelled by the Davis formula (Equation (6)):

$$F\_T(\upsilon) = A + B\upsilon + T\_f \mathbb{C}\upsilon^2 \tag{6}$$

where *A*, *B* and *C* are the Davis formula coefficients. *Tf* is a factor that models the impact of tunnels on the running resistance and it modifies the quadratic term. It is equal to one when the train is outside a tunnel and greater otherwise.

The considered forces on the train due to the track geometry, *Fg*(*s*), are those due to the track grades and curves:

$$F\_{\mathcal{S}}(s) = mgp(s) + mg\frac{K}{R(s)}\tag{7}$$

where *m* is the mass of the train; *g* is the gravity acceleration; *p*(*s*) and *R*(*s*) are the averages of the grades and curve radius respectively affecting the train in the position *s*. *K* is a constant that depends on the gauge of the track which units are the same as *R*(*s*) (meters). The gauge in the considered lines is standard UIC (Internal Union of Railways) gauge, 1.435 m, and *K* = 600. Notice that the force due to curves is modelled as an equivalent grade.
