amusecode / amuse

Astrophysical Multipurpose Software Environment. This is the main repository for AMUSE
http://www.amusecode.org
Apache License 2.0
158 stars 99 forks source link

Bridge and stopping conditions #563

Closed rieder closed 2 years ago

rieder commented 4 years ago

When using Bridge and stopping conditions in one or more of the bridged systems, it is important to consider what happens when codes stop. Stopping conditions can cause a code to stop somewhere during its requested timestep, which would interfere with Bridge. I am not sure how this is done properly at the moment.

E.g., what would be the correct way of handling the following:

system = Bridge()
system.add_system(gravity, (hydro,))
system.add_system(hydro, (gravity,))

dt = 1 | nbody_system.time
system.evolve_system(system.model_time + dt)

(stopping condition of hydro's density detection, gravity's collision detection or something else causes it to stop somewhere in between) Bridge's system is (by default at least) kick(dt/2) drift(dt) kick(dt/2). Stopping happens during drift, but has the second kick been called at this point? If so, it would have happened at an incorrect stage I think. If not, how do we make this kick happen?

ipelupessy commented 4 years ago

I think the recomendation is if you need stopping conditions for a given code, write a gravity code class that wraps that code and handles its stopping condition..such that it finishes the evolve_model step

rieder commented 4 years ago

Thanks, I think that's probably the best option.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 28 days if no further activity occurs. Thank you for your contributions.

ipelupessy commented 2 years ago

solution proposed seems to be accpeted, closing