Issue 976 casadi extrapolate warning#1315
Issue 976 casadi extrapolate warning#1315brosaplanella merged 17 commits intopybamm-team:developfrom
Conversation
|
thanks @brosaplanella looks good! my only question is should we also raise a warning/error when extrapolation occurs with the other solvers? |
Codecov Report
@@ Coverage Diff @@
## develop #1315 +/- ##
========================================
Coverage 98.10% 98.11%
========================================
Files 272 272
Lines 15290 15339 +49
========================================
+ Hits 15001 15050 +49
Misses 289 289
Continue to review full report at Codecov.
|
valentinsulzer
left a comment
There was a problem hiding this comment.
Looks good to me, maybe @rtimms wants to take another look though
rtimms
left a comment
There was a problem hiding this comment.
Looks good to me, thanks!
I was wondering if we should make all the solvers give at least a warning when you extrapolate. At the moment e.g. the scipy solver only stops for the terminal events (as expected), but should we also check and warn if extrapolation has occurred so that users are aware and can check if they trust the results. Maybe this should be a separate issue though.
|
@rtimms Sorry, you are totally right. I had in mind adding the warning for the other solvers, but I wanted first to check if this made sense or not. I have tried what happens with IDAKLU and Scikits DAE solvers and they take a very long time when there is extrapolation. For example, if you try this with model = pybamm.lithium_ion.DFN()
param = pybamm.ParameterValues(chemistry=pybamm.parameter_sets.Chen2020)
ci = param["Initial concentration in positive electrode [mol.m-3]"]
param["Initial concentration in positive electrode [mol.m-3]"] = 0.8 * ci
sim = pybamm.Simulation(
model,
parameter_values=param,
solver=my_solver,
)
sim.solve()In this case, should I add the warning or should I add an error? Note that I will implement the warnings anyway in issue #989 so we can change our minds later. |
|
IMO a warning would be good. At least that way you get the solution back and can make sure it makes sense (and check how much you extrapolated by). Happy to leave this for another issue though and get this PR merged. |
|
Cool, then I will add the warnings on this PR. |
Description
When an interpolant is created from data, a new type of event (
INTERPOLANT_EXTRAPOLATION) is added to ensure that we can catch when extrapolation occurs. This is particularly important in CasADI as you get a lot of warnings that are not very insightful.I haven't managed to remove all these warnings as, before hitting the event and raising the error, the integration step where extrapolation happens takes place. However, I don't know how to get rid of them if we can't catch the CasADI warnings.
Fixes #976
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 docsand then$ make clean; make htmlYou can run all three at once, using
$ python run-tests.py --quick.Further checks: