modification to SPH_gas to avoid problem with the np.arccos function