-
-
Notifications
You must be signed in to change notification settings - Fork 214
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
Make CheckInit the default initialization algorithm for DAEs (breaking) #2514
base: master
Are you sure you want to change the base?
Conversation
This currently doesn't work--is too eager to trigger the error. |
Now, in At least as far as the MWE from #2513 is concerned, this would mean that even if you pass a consistent initial condition (so that initialization isn't necessary) and an "algorithm" like An alternative I see is to, instead, do the check and throw the error in the methods of |
I think the right approach here is probably to make the |
I'm not sure. Most DAE solvers do just default to BrownBasic. I would be fine with doing this change in OrdinaryDiffEq v7 if the error message in CheckInit is improved to explain this. |
Speaking as a user, I often work with a system where I often don't make any attempt to have u0 be a consistent initial condition (because I would have to solve a nonlinear equation to do so), and I'm willing to accept an extra dependency for the convenience of not needing to specify an initialization algorithm every time. (But if I've misunderstood, and the Rosenbrock methods only need NonlinearSolve for the initialization, it would be nice to cut down precompilation time by leaving that out.) But there is definitely a logic to defaulting to CheckInit, so I wouldn't mind as long as the error message that CheckInit throws on inconsistent conditions provides some clear guidance about what has changed and how to set the algorithm to BrownFullBasicInit or NoInit If we go that route, there will need to be an export for |
Yeah those should get exported. It's kind of a historical accident that they do not.
Yes, its error just needs to clearly say:
|
On further reflection, I think I (as a user) would probably prefer to get an error message that suggests
|
No, that's not how it works. If you don't initialize correctly, it is more than likely that your next step is either unstable or the method is non-convergent. You can have a small error in the starting algebraic variable lead to an O(1) global error in the DAE solve, it's simply unbounded. You are required to start from a consistent state to have any sense of theoretical convergence involved at all, so using NoInit means we give zero guarantee on accuracy. That cannot be a default, it's only an internal for implementing other algorithms that then chain other initializations. It's not really meant to be used by users as a true initialization method, instead they should CheckInit.
Are there identical ones? Usually they are rather different code?
If we do a global CheckInit default, then it would make sense to use the results of that. |
OrdinaryDiffEq.jl/lib/OrdinaryDiffEqCore/src/initialize_dae.jl Lines 55 to 105 in ce43d57
Strictly speaking, there are 4 methods here; a 2x2 dispatch on ODEProblem vs DAEProblem and isinplace true vs false. There are differences between ODEProblem and DAEProblem, but after replacing
That makes sense--my intuition was incorrectly informed by the too-simple MWE I have been testing with, which produces correct answers even with an incorrect initial condition. So
|
Yes. What is left here? I'm a bit confused as to the current state. |
I'm partly waiting to let #2521 proceed, because that affects where this code should land: if I'm still uncertain of a couple things:
|
good news: #2521 just proceeded :) |
Yes, SciMLBase should export it. Solvers always reexport SciMLBase, so that would cover it. |
Yeah it's really a feel thing. I think it's the way to go since that's the only way we could ever do the reduced dependencies, and so as long as that error message is really nice I think that would be good. I think down the line it's better, since right now what we do is assume "I know your algebraic variable initial conditions are just guesses", which could be a wrong take (and I've gotten some questions about "why did it change this initial condition? That's not correct!"). The error would explain the routes you can take, and making it explicit "please ignore my initial condition on all algebraic variables and use them as guesses" is really safer. We didn't go that way at the start because we thought it might be too hard for most users to do the initialization stuff, so we fully automated it, but now I think a very informative error message is a better idea instead of making an implicit assumption. |
Just opened SciML/SciMLBase.jl#886 to export CheckInit and add an informative error as discussed here. So now, what this pull request does is:
This is now a breaking change. Appropriate tests have not been added yet, and documentation will need to be updated as well. What this pull request doesn't do any more is provide an error message as originally suggested in #2513. So should there be a separate pull request providing that information for |
Alright, so this should go with the OrdinaryDiffEq v7 |
It should now already be included by the SciMLBase part? |
This would be fine pre v7 |
The original error in #2513 that prompted this pull request was that, if ODENonlinearSolve is not imported, Is it worth splitting this pull request in two, one for the breaking change that fixes things elegantly (7.0) and another for the non-breaking stuff plus an informative error message (<7.0)? |
Yes |
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
Re: discussion in #2513 , here is a (first-time-contributor, inexperienced) attempt at implementing the solution @ChrisRackauckas suggested.