heyoka icon indicating copy to clipboard operation
heyoka copied to clipboard

Does heyoka support external dynamic input of the ODE system?

Open gaowutong opened this issue 1 year ago • 1 comments

Hello and thanks for this great project!

I notice that heyoka supports runtime parameters in its expression system. But what if the parameters has different values at different time steps? How can I handle this?

This is common in many cases. A particular scenario is propagating It requires to read planeteary ephemeris data and get the position of some planets at each time step to compute their perturbations. But it seems heyoka compiles the expression at the beginning and does not allow to change it during integration.

gaowutong avatar May 11 '24 07:05 gaowutong

Hi @gaowutong

You can change the values in the parameters array at any time you want. The parameters array is accessible from a taylor_adaptive object via member functions such as get_pars() (for read-only access), get_pars_data() (for read-write access) and others, see here:

https://github.com/bluescarni/heyoka/blob/master/include/heyoka/taylor.hpp#L549

For instance, you can change the values in the parameters array at the end of each timestep via a step callback, explained here:

https://bluescarni.github.io/heyoka/tut_adaptive.html#time-limited-propagation

Another option is to use the event detection system - specifically, a terminal event which stops the integration whenever you need to change the parameters' values via an event callback:

https://bluescarni.github.io/heyoka/tut_events.html#terminal-events

Please let me know if you need further help/explanations.

bluescarni avatar May 12 '24 07:05 bluescarni

@gaowutong will be closing this report for now, please re-open if needed.

bluescarni avatar Jun 13 '24 20:06 bluescarni