Ambipolar acceleration of ions in a magnetic nozzle