Simulation of the formation of the PS-1 spheromak