Open eerovaher opened 6 years ago
the pattern we prefer for this is to construct the time dependent potential as a gravity code class with an evolve_model method. This evolve just changes the time variable (by changing the time parameter) of the model - conceptually the coupling between active particles and potential becomes like that between two dynamic codes that way..for an example see the examples/galaxie directory, where this is implemented for a timedependent potential of the milky way with bar and spiral arm patterns..
Not a fix within AMUSE, but note that galpy
now allows any analytical potential (including time-dependent ones) to be converted to an AMUSE format and used within the AMUSE framework:
https://galpy.readthedocs.io/en/v1.5.0/potential.html#new-in-v1-5-conversion-to-amuse-potentials
So if you can implement your use case using galpy potentials (or define your own, which is pretty easy, since you only need the Python implementation), this should do the trick here.
Thanks @jobovy! That looks great!
NEMO's potential descriptors are analytical and also allow a time-dependent component, but we separate rotation along the Z axis in a different way. Pattern speed is constant and passed to the inipotential() routine, whereas time is passed as an independent parameter to the actual potential() calculator. Example in the familiar Plummer sphere is here: https://github.com/teuben/nemo/blob/master/src/orbit/potential/data/plummer.c
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.
i don't like a stale bot... that way you will loose sight of long standing but ignored issues. Of course after a few years your code looks in great shape, no issue left ;-)
We can pin issues where needed :). And feature requests (if so labeled) won't get the 'stale' treatment.
maybe I should request a pinbot then :)
Is your feature request related to a problem? Please describe. The ability to create time dependent analytic potentials would be helpful for running N-body simulations, as it would allow to very easily implement potentials that rotate or decay in time.
Describe the solution you'd like The easiest solution seems to require the following changes 1) In
amuse/couple/bridge.py
classGravityCodeInField
the methodkick_with_field_code()
would need to be2) In
amuse/ext/static_potentials.py
classAbstract_Potential
the methodget_acceleration_at_point()
should acceptt
with a default value such ast=0|units.s
as an additional argument and pass it to the abstract methodget_potential_at_point()
.Describe alternatives you've considered Right now time dependent potentials can be implemented by changing the parameters of the analytic potential from the main script, but this needs to be done every time the potential is called. Implementing this proposal would allow to specify the time dependence when the potential is defined without having to explicitly demand that the potential gets properly updated every time it is needed.
Additional context If the analytic potential being implemented is not time dependent, then the implemented
get_potential_at_point()
method can simply ignore the additional time argument.