zwicker-group / py-pde

Python package for solving partial differential equations using finite differences.
https://py-pde.readthedocs.io
MIT License
402 stars 51 forks source link

How to apply a forcing term ? #407

Closed ReHoss closed 1 year ago

ReHoss commented 1 year ago

Hi, I would like to apply control on PDEs using your library.

To do so, I would like to apply a forcing term to the pde for a small dt.

A workaround I just found is to redefine at each control time step the evolution_rate method with the new computed forcing term in the RHS and then integrate again for a small dt ?

Thank you for your consideration,

EDIT: Sorry it might be better to move this issue into the discussion section...

david-zwicker commented 1 year ago

I'm not sure what you're trying to achieve. If you use the python/numpy interface, your evolution_rate method can of course depend on additional parameters. If you also want to use the numba interface things are more tricky since we currently do not support external parameters.

ReHoss commented 1 year ago

I'd like to use the python interface to implement d_x(t)/dt = F(x(t)) + u(t), with F = KPZ for instance. Where u(t) is recomputed every dt by a neural network for instance (feedback control).

david-zwicker commented 1 year ago

What prevents you from simply implementing $u(t)$ in evolution_rate?