zwicker-group / py-pde

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

Add method for making directional derivatives to GridClasses #368

Closed david-zwicker closed 1 year ago

david-zwicker commented 1 year ago

We often need directional derivatives, particularly in Cartesian coordinates. It might be useful to add a make_directional_derivative method to CartesianGrid, which would basically serve as a wrapper to pde.grids.operators.cartesian._make_derivative. Typical arguments would allow specifying the axis, the order of the derivative (currently supporting 1 and 2), and maybe extra arguments to distinguish forward and backward derivatives.

This problem came up multiple times in the Discussions, e.g., in #199 and #364.

david-zwicker commented 1 year ago

Alternatively, we could also extend the existing method make_operator and make_operator_no_bc to support d_dx and similar functions directly. This would probably be more intuitive (and might even simplify the PDE class).

david-zwicker commented 1 year ago

We might also add a method to grid classes that return what operators are defined.