Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collision handling sometimes fails #1

Open
ErwanH29 opened this issue Feb 17, 2024 · 0 comments
Open

Collision handling sometimes fails #1

ErwanH29 opened this issue Feb 17, 2024 · 0 comments

Comments

@ErwanH29
Copy link
Collaborator

ErwanH29 commented Feb 17, 2024

For simulations where the internal time-step is too large, the colliding particles will (at rare times) not flag the AMUSE collision stopping condition causing the integrator to break.

Small code to reproduce issue below:

from amuse.lab import *
from amuse.community.hermite.interface import Hermite
from amuse.community.Hermite_GRX.interface import HermiteGRX


converter = nbody_system.nbody_to_si(100 | units.MSun, 1 | units.pc)
bodies = new_plummer_model(3, convert_nbody=converter)
bodies.mass = 1 | units.MSun
bodies[0].mass *= 100
bodies.radius = 1 | units.RSun

converter = nbody_system.nbody_to_si(bodies.mass.sum(), 0.1|units.pc)
bodies.scale_to_standard(convert_nbody=converter)
bodies[-1].position = bodies[0].position + 0.1*bodies[-1].radius

tend = 1 | units.Myr
t = 0 | units.yr

gravity = Hermite(converter, number_of_workers=1)
gravity.particles.add_particles(bodies)

gravity = HermiteGRX(converter, number_of_workers = 1)
perturbations = ["1PN_Pairwise", "1PN_EIH", "2.5PN_EIH"]
gravity.parameters.perturbation = perturbations[0]
gravity.parameters.dt_param = 1e-1 #1e-4 detects, but not 1e-3
gravity.parameters.integrator = 'RegularizedHermite'
gravity.small_particles.add_particles(bodies[bodies.mass<bodies.mass.max()])
gravity.large_particles.add_particles(bodies[bodies.mass==bodies.mass.max()])

stopping_condition = gravity.stopping_conditions.collision_detection
stopping_condition.enable()

gravity.evolve_model(tend)
if stopping_condition.is_set():
      print("...Collision 
print(gravity.
STOP
gravity.stop()

Depending on the internal timestep, "...Collision Detected..." is outputted. This isn't replicated with Hermite who detects the collision no matter the internal timestep.

My current fix is not too elegant, and is the following:

line 5 of Pairwise1PNPerturbation.h: I've added #include "StoppingConditions.h";
line 14 of Pairwise1PNPerturbation.h: I've added StoppingConditions m_StoppingCond;
line 14 of Pairwise1PNPerturbation.h: I've added bool m_ConditionsSet;
line 45 of Pairwise1PNPerturbation::Pairwise1PNPerturbation.cpp in the Pairwise1PNPerturbation::CalculateAccelerations functions: I've added m_ConditionsSet = m_StoppingCond.Check(model);

line 166 of EIHPerturbation.cpp in the EIH2dot5PNPerturbation::CalculateAccelerations functions: I've added m_ConditionsSet = m_StoppingCond.Check(model);
line 373 of EIHPerturbation.cpp in the EIH1PNPerturbation::CalculateAccelerations functions: I've added m_ConditionsSet = m_StoppingCond.Check(model);

I haven't tested the change in performance nor if it affects any of the physics (this I doubt. MY current changes results in amuse.support.exceptions.AmuseException: Unable to add a particle, because it was already part of this set.

Other solution is simply changing the collision radius.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant