Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jacobian matrix for ODE solvers #375

Open
lsptrsn opened this issue Feb 16, 2024 · 2 comments
Open

Jacobian matrix for ODE solvers #375

lsptrsn opened this issue Feb 16, 2024 · 2 comments

Comments

@lsptrsn
Copy link

lsptrsn commented Feb 16, 2024

Hello,

is it possible to extract the Jacobian matrix for the ODE solvers (I mean specifically Kvaerno5)?

Many thanks in advance.

@patrick-kidger
Copy link
Owner

Which Jacobian do you want specifically?

To be precise: given an ODE dy/dt = f(y), then the nth implicit Runge--Kutta stage solves for the u_n such that

F_n(u_n) = 0

where

F_n(u_n) = u_n - f(y0 + (Σ_i a_i u_i + a_n u_n) dt)

given value y0 at the start of a step of length dt, with Butcher tableau entries a_i. (Assuming I haven't made a typo anyway.)

The implicit solvers used for this problem work by computing the Jacobian dF_n/du_n. SDIRK and ESDIRK solvers (like Kvaerno5) would usually evaluated this just once at y0. (DIRK solvers would usually evaluate it again every stage.) Is this the Jacobian you're after?

If so then at least within the code then the function F_n is given here.

Computing this Jacobian is something that is offloaded to the choice of root finder. (e.g. Kvaerno5().root_finder) At least for the default diffrax.VeryChord root finder, then the Jacobian is computed here and is thus available as state.linear_state[0], although that exact location is a private implementation detail. You could grab that by wrapping the root-finder and intercepting it in the root-finder's init method.

Does that answer your question?

@lsptrsn
Copy link
Author

lsptrsn commented Feb 23, 2024

That answers my question. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants