-
-
Notifications
You must be signed in to change notification settings - Fork 589
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
Issue 853 casadi safe #956
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #956 +/- ##
===========================================
+ Coverage 97.34% 97.36% +0.02%
===========================================
Files 222 222
Lines 11622 11689 +67
===========================================
+ Hits 11313 11381 +68
+ Misses 309 308 -1
Continue to review full report at Codecov.
|
question: at the moment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For dt_max
, I think the most consistent thing would be to make it 1 (or 1/2 or 1/4), and assume that the user has chosen a good timescale, but also offer it as an option. (but for battery models the timescale doesn't change with current so it's not failsafe ...)
Can you leave old safe mode as an option (e.g. "old safe")? I think the sensitivity formulation will be closest to that
I also couldn't find the test where you don't suppress stderr - I wanted to see "regularity check": False or "show_eval_warnings": False can do that for you (annoyingly, there's a different options dictionary for when you create the solver and when you call it, and I don't know which you should pass to)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great now, thanks @rtimms !
# Make sure t_eval is monotonic | ||
if (np.diff(t_eval) < 0).any(): | ||
raise pybamm.SolverError("t_eval must increase monotonically") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same check is performed on line 589
thanks, just need to fix a problem where sometimes casadi gets stuck doing |
Maybe some kind of timeout? https://medium.com/@chaoren/how-to-timeout-in-python-726002bf2291 |
Description
Changes the behaviour of casadi "safe" mode. Instead of creating a new integrator for each
dt
int_eval
(which scales badly with the number of points int_eval
), it now integrates in larger "global" timesteps and checks if an event has been triggered. If an event is triggered in some interval[t, t+dt]
then the earliest event time is found by a root finding algorithm and the state at that time is found by interpolation. The solution is then truncated and returned up to the event time.Fixes #853
Type of change
Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.
Key checklist:
$ flake8
$ python run-tests.py --unit
$ cd docs
and then$ make clean; make html
You can run all three at once, using
$ python run-tests.py --quick
.Further checks: