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

Failed ODE does not return the expected retcode #283

Open
gustavoheiden opened this issue Sep 28, 2020 · 4 comments
Open

Failed ODE does not return the expected retcode #283

gustavoheiden opened this issue Sep 28, 2020 · 4 comments

Comments

@gustavoheiden
Copy link

Although my ODE is failing by "Error test failures occurred too many times during one internal time step", the integrator.retcode still returned "Success".

After some debugging I found that in if block (line 1477) the integrator.flag is changing from -3 to 0 after evaluating line

integrator(integrator.u, integrator.t, Val{1})

In my local code, I performed this change in order to get the correct retcode from my failed ODE:
if integrator.opts.save_end && (isempty(integrator.sol.t) || integrator.sol.t[end] != integrator.t) && integrator.flag == 0

I hope that helps returning a more accurate error.

@ChrisRackauckas
Copy link
Member

I'm not quite sure what you mean here. Could you share a bit more?

@gustavoheiden
Copy link
Author

gustavoheiden commented Oct 20, 2020

I'll try to explain.
Let's assume the solver returned "error test failed too many times", so we get integrator.flag = -3

Even though we have a failed EDO, the algorithm access this if block

if integrator.opts.save_end &&
(isempty(integrator.sol.t) || integrator.sol.t[end] != integrator.t)
save_value!(integrator.sol.u, integrator.u, uType, integrator.sizeu)
push!(integrator.sol.t, integrator.t)
if integrator.opts.dense
integrator(integrator.u, integrator.t, Val{1})
save_value!(integrator.sol.interp.du, integrator.u, uType, integrator.sizeu)
end
end

Moreover, if you opt for a dense save, the evaluation of line 1482 integrator(integrator.u, integrator.t, Val{1}) changes the state of integrator.flag to 0 (which means success)

That's why I opened this issue, we shouldn't evaluate integrator after its flag < 0, because it can change it to a success state.

@ChrisRackauckas
Copy link
Member

Ahh, indeed that's odd and should get fixed.

@gustavoheiden
Copy link
Author

I added && integrator.flag == 0 to assure only a success is able to access that if block

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

No branches or pull requests

2 participants