Closed ryanwhite1 closed 4 months ago
In writing this I'd actually thought of a solution! The solution was to check for ejections in a separate function called on in the heartbeat function instead of checking in the additional forces function. I feel a bit silly, but I'll close this for posterity!
Your solution is absolutely correct. You can't remove particles in the force functions. You can only do it once per timestep in the heartbeat function. Congrats to finding the solution yourself! 😉
Hi all,
I'm having problems with removing particles from a simulation within an additional forces function. What I'm trying to do is remove a particle if its eccentricity is larger than some critical value (0.8 in my case). I won't attach my exact code here (unless requested) as my function is quite long and the code overall relies on data from external scripts, but here is a rough outline of what I'm doing:
The problem is that if a particle at index
i
is ejected, all particles from indexi
onwards are removed from the simulation and I'm not sure why. I'm not very confident with C programming hence why I'm hesitant to label this a bug yet instead of my bad programming. I could probably think of a work around to avoid ejecting particles in the additional forces function, but I'd like to know if there is an obvious error in what I'm doing! I'm happy to give more info as needed :)Environment
Physics I'm simulating migration of massive particles within a custom accretion disk. I've non-dimensionalised all of my units so that the characteristic length and timescales are ~1. I'm simulating on the order of 10^1 particles, and for ~10^5 time units. I'm also using the IAS15 integrator.