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

Updates for casadi 3.6 #2858

Closed
valentinsulzer opened this issue Apr 5, 2023 · 10 comments · Fixed by #2920
Closed

Updates for casadi 3.6 #2858

valentinsulzer opened this issue Apr 5, 2023 · 10 comments · Fixed by #2920
Assignees
Labels
difficulty: medium Will take a few days priority: high To be resolved as soon as possible

Comments

@valentinsulzer
Copy link
Member

Release notes: https://github.com/casadi/casadi/releases/tag/3.6.0

Will add as found

  • time grid points should be passed when creating interpolator instead of when solving
  • rootfinder errors
@valentinsulzer
Copy link
Member Author

I don't know how to fix the failing sensitivity test so skipping for now, @martinjrobins @jsbrittain could you take a look at this?

@martinjrobins martinjrobins self-assigned this Apr 18, 2023
@martinjrobins
Copy link
Contributor

sure, this is also reported in #2789 (comment).

@valentinsulzer
Copy link
Member Author

I think it might be a different error here

@martinjrobins
Copy link
Contributor

Did PR #2883 fix the problem? I just tried test_sensitivities on spm, spme and dfn with idaklu solver and it seemed to work ok.

@valentinsulzer
Copy link
Member Author

If you can remove this and the tests still pass then I'm happy

def test_sensitivities(self):
# skip sensitivities test for now as it is failing with casadi 3.6
pass

@martinjrobins
Copy link
Contributor

ahh ok, I wasn't aware you'd added that

@martinjrobins
Copy link
Contributor

martinjrobins commented Apr 27, 2023

near as I can figure this is the problem. Say you have a model like this

$$\frac{du}{dt} = -u$$

$$ v = a * u $$

$$ u(0) = 1$$

$$ v(0) = 1$$

For $a=1$, sundials calculates the initial condition for $s = \frac{dv}{da}$ as $s(0) = [0, 0]$, presumably because v(0) does not depend on $a$, but if you correctly write the initial condition for $v$ as:

$$\frac{du}{dt} = - u$$

$$ v = a * u $$

$$ u(0) = 1$$

$$ v(0) = a$$

For $a=1$ this is the same equations, but then sundials finds the initial condition should be $s(0) = [0, 1]$. Not exactly sure what the expected behaviour is really, or why sundials isn't calculating the correct ic for $s$ even when you don't give the correct symbolic form for $v(0)$

Note the problem is only for the initial condition, as soon as you start integrating the solution becomes correct

@valentinsulzer
Copy link
Member Author

$s(0) = [0, 1]$ is the correct initial condition in the second case, right?

@martinjrobins
Copy link
Contributor

s(0)=[0,1] is the correct initial condition in the second case, right?

yup, and I believe it should be for the 1st as well, so that is why I'm a bit confused that the calcic function in sundials (ie. calculate consistent initial conditions) isn't finding it, it just returns [0, 0] for the 1st and [0, 1] for the 2nd.

@martinjrobins
Copy link
Contributor

ahh ok. You have to call IDAGetSens after IDACalcIC in order for the solution to actually show up in your sensitivity vector..... fixed now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: medium Will take a few days priority: high To be resolved as soon as possible
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants