Closed jilkoval closed 8 years ago
The gravity code needs to be synchronized with the bridge model_time after the collision:
gravity.evolve_model(t_collision_bridge)
The complete fixed while loop:
while t < t_end:
#gravity.evolve_model(t)
print " >> evolving >", t.in_(units.day), "n_particles =", len(gravity.particles)
gravity_with_bridge.evolve_model(t)
#print gravity.stopping_conditions.collision_detection.is_set()
if gravity.stopping_conditions.collision_detection.is_set():
t_collision_bridge = gravity_with_bridge.model_time
t_collision_gravity = gravity.model_time
n_particles_in_collision = 2*len(gravity.stopping_conditions.collision_detection.particles(0))
print " xx collision at", t_collision_gravity, "n_particles_in_collisions =", n_particles_in_collision
print " t_gravity=", gravity.model_time.in_(units.day), "t_bridge=", gravity_with_bridge.model_time.in_(units.day)
if n_particles_in_collision == 0:
print " !! only one particle in collision > break"
break
else:
print gravity.stopping_conditions.collision_detection.particles(0)
print gravity.stopping_conditions.collision_detection.particles(1)
gravity.particles.remove_particles(gravity.stopping_conditions.collision_detection.particles(0))
#gravity_with_bridge.particles.remove_particles(gravity.stopping_conditions.collision_detection.particles(0))
#print gravity.particles
if (t_collision_gravity > t_collision_bridge):
t=t_collision_gravity
else:
gravity.evolve_model(t_collision_bridge)
continue
t += dt
I am having troubles with collision_detection stopping condition while using bridge. After detecting a collision, I remove one of the colliding particles and evolve the system further, but the same collision is detected again. It seems to me that .collision_detection.is_set() is not set to False for the evolve_model after the first collision.
I might be missing something basic here however. Any comments welcome! Please see example code below (I tested several gravity codes, the same problem appears for all).