PyRates
PyRates copied to clipboard
Code generation for partial derivatives of the vectorfield
In its current state, PyRates generates code for a backend-specific function that evaluates the right-hand-side of a differential equation system $\dot y = f(y, \theta, t)$. In many cases, partial derivatives of $f(y, \theta, t)$ can help to apply numerical algorithms to the DE system. For example, the Jacobian $J_{ij} = \frac{\partial f_i}{\partial y_j}$ can be required for certain gradient-based parameter optimization problems, and the partial derivatives $\frac{\partial f_i}{\partial \theta_j}$ can be used to improve the accuracy and speed of parameter continuation algorithms.
As a new feature, I suggest to leverage the sympy-based parser of PyRates to analytically find these partial derivatives, if possible, and generate additional code that implements functionals $g(f, y, \theta)$ that compute the partial derivatives based on the current state and vectorfield of the system.