Development and validation of a new code for longitudinal train dynamics simulation