Solution (source code)

= Solution

In the frame following the turn, the outward inertial <force> $mv^2/R$ acts at height $h$ and tends to unload the inner rail. The two upward <normal forces> satisfy
$$
N_{\mathrm{out}}+N_{\mathrm{in}}=mg,\qquad\frac d2(N_{\mathrm{out}}-N_{\mathrm{in}})=\frac{mv^2h}{R}.
$$
The second equation is <moment balance> about the midpoint between the rails. Thus
$$
N_{\mathrm{in}}=\frac{mg}{2}-\frac{mv^2h}{Rd},\qquad N_{\mathrm{out}}=\frac{mg}{2}+\frac{mv^2h}{Rd}.
$$
Full contact requires a nonnegative inner <normal force>. Its limiting value is zero, giving the <toppling speed on level rails>
$$
\boxed{v_0=\sqrt{\frac{gRd}{2h}}.}
$$
For strictly positive contact force on both rails, $v<v_0$. This ideal result assumes level rails, negligible suspension motion and enough lateral contact force to follow the curve; lateral sliding could impose a different limit.