Add init_particles function to assign particle ids.