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

Post-solve Hermite interpolation in Sundials solvers #4419

Closed
MarcBerliner opened this issue Sep 5, 2024 · 2 comments · Fixed by #4464
Closed

Post-solve Hermite interpolation in Sundials solvers #4419

MarcBerliner opened this issue Sep 5, 2024 · 2 comments · Fixed by #4464
Assignees
Labels

Comments

@MarcBerliner
Copy link
Member

Description

This will give higher accuracy interpolation for observables after solving the system of equations.

Motivation

No response

Possible Implementation

No response

Additional context

No response

@MarcBerliner MarcBerliner self-assigned this Sep 5, 2024
@martinjrobins
Copy link
Contributor

martinjrobins commented Sep 13, 2024

@MarcBerliner can you add more details on how you see this working? At the moment the Solution object and all its post-processing is very separate from the solvers, but it sounds like this would couple the two? What if the idaklu solver or sundials is not installed? Is sundials the best thing to use here or we could store the derivative info in Solution and use some other python library that has hermite interpolation (https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.CubicHermiteSpline.html#scipy.interpolate.CubicHermiteSpline).

@MarcBerliner
Copy link
Member Author

MarcBerliner commented Sep 13, 2024

@MarcBerliner can you add more details on how you see this working? At the moment the Solution object and all its post-processing is very separate from the solvers, but it sounds like this would couple the two? What if the idaklu solver or sundials is not installed? Is sundials the best thing to use here or we could store the derivative info in Solution and use some other python library that has hermite interpolation (https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.CubicHermiteSpline.html#scipy.interpolate.CubicHermiteSpline).

Within the ODE/DAE solve, this will add a hermite_interpolation option that if true, saves the yp and ySp terms. We can save these with the Solution objects as we do with the all_ys and whatnot. The flow of information from solution -> processed variables will be the same. Writing a cubic hermite interpolation script is not too difficult, so I plan on writing this in C++. I think it only makes sense to do this for SundialsSolver.

At the moment, observing model or output variables is really slow because we're running a python for-loop over each time series value. I plan on making a "batch observable" function in C++ which will speed up all the post-solve interpolation, both for linear and Hermite interpolation.

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

Successfully merging a pull request may close this issue.

2 participants