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

idklu solver for convert_to_casadi=True #1863

Closed
martinjrobins opened this issue Dec 17, 2021 · 5 comments · Fixed by #2002
Closed

idklu solver for convert_to_casadi=True #1863

martinjrobins opened this issue Dec 17, 2021 · 5 comments · Fixed by #2002
Assignees

Comments

@martinjrobins
Copy link
Contributor

Summary

The current idklu solver goes back to python whenever it needs to calculate the rhs, algebraic or event equations. It also runs very slow when using convert_to_casadi=True. This issue aims to develop a new idklu solver that directly calls casadi functions from C++, with ideally no memory copying to/from casadi arrays

Motivation

We want to get the superior event handling capabilities of the ida solvers with efficient casadi evaluation of equations

@martinjrobins martinjrobins self-assigned this Dec 17, 2021
martinjrobins added a commit that referenced this issue Jan 14, 2022
…ll solvers have access to casadi functions
martinjrobins added a commit that referenced this issue Jan 14, 2022
martinjrobins added a commit that referenced this issue Jan 14, 2022
martinjrobins added a commit that referenced this issue Jan 14, 2022
martinjrobins added a commit that referenced this issue Mar 2, 2022
martinjrobins added a commit that referenced this issue Mar 2, 2022
martinjrobins added a commit that referenced this issue Mar 2, 2022
martinjrobins added a commit that referenced this issue Mar 2, 2022
martinjrobins added a commit that referenced this issue Mar 3, 2022
martinjrobins added a commit that referenced this issue Mar 3, 2022
martinjrobins added a commit that referenced this issue Mar 3, 2022
martinjrobins added a commit that referenced this issue Mar 3, 2022
martinjrobins added a commit that referenced this issue Mar 7, 2022
martinjrobins added a commit that referenced this issue Mar 10, 2022
martinjrobins added a commit that referenced this issue Mar 10, 2022
martinjrobins added a commit that referenced this issue Mar 10, 2022
@valentinsulzer
Copy link
Member

A major addition here would be to look at the iterative solvers

Iterative solvers only start to outperform direct solvers at relatively large matrix sizes, right? (don't know how large)

@martinjrobins
Copy link
Contributor Author

Yes, iterative solvers can give speed benefits at the very large matrix sizes, as long as you have a decent preconditioner (i.e. a good approximation to the jacobian that you can solve easily).

martinjrobins added a commit that referenced this issue Mar 31, 2022
@martinjrobins martinjrobins mentioned this issue Mar 31, 2022
6 tasks
@martinjrobins
Copy link
Contributor Author

This is largely finished, see pr #2002, here is my todo list for subsequent issues:

  • we're allocating memory for return vectors in the solve, this could be done in solver setup
  • we initialise ida_mem and everything every time, could do this once when solver is created, or only on the 1st solve etc
  • create an options dict to pass to the solver, e.g. option to print solver stats, don't/do use jacobian
  • add option to use iterative solvers
  • add option to use other linear solvers in ida
  • add option to use dense jacobian
  • benchmarks for all of the above solver options
  • investigate if we need to densify the rhs_algebraic casadi evaluation, could it return a sparse vector?
  • investigate if constructing a new casadi function for the residual (rather than doing it manually in c++) is faster
  • investigate if constructing a new casadi function for the sensitivity calculations (rather than doing it manually in c++) is faster
  • we calculate consistent initial conditions at the start of the idklu solve, so we might not need to do it in the BaseSolver setup

martinjrobins added a commit that referenced this issue Mar 31, 2022
martinjrobins added a commit that referenced this issue Mar 31, 2022
martinjrobins added a commit that referenced this issue Apr 4, 2022
martinjrobins added a commit that referenced this issue Apr 4, 2022
martinjrobins added a commit that referenced this issue Apr 5, 2022
martinjrobins added a commit that referenced this issue Apr 5, 2022
martinjrobins added a commit that referenced this issue Apr 5, 2022
martinjrobins added a commit that referenced this issue Apr 6, 2022
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

Successfully merging a pull request may close this issue.

2 participants