Longitudinal dynamics of trains—a non-smooth approach