Transient simulation of two-phase flows in pipes