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

only bail out as instable when dt is small or error is somewhat controlled #692

Merged

Conversation

oscardssmith
Copy link
Contributor

Previously, we would run the instability check no matter how badly the integrator had controlled the error. This caused issues, especially for the first timestep where the dt chosen was fairly arbitrary. We could end up in a situation very easily where the first timestep was big enough that the step would result in incredibly large (or NaN) u values. This step would get rejected, but because the values were incorrectly really big, we would get killed by instability detection. This is silly because just shrinking the dt would have made it stable, but we didn't get a chance to do so.

function rober(du, u, p, t)
    y₁, y₂, y₃ = u
    k₁, k₂, k₃ = p
    du .= [-k₁ * y₁ + k₃ * y₂ * y₃,
    k₁ * y₁ - k₃ * y₂ * y₃ - k₂ * y₂^2,
    k₂ * y₂^2]
end
prob = ODEProblem(rober, [1.0,0.0,0.0],(0.0,1e5),(0.04,3e7,1e4))
solve(prob, Rodas5P()) #fails
solve(prob, Rodas5P(), dt=1e-3) #works

With this PR, we will only do the instability check in the first place if we either roughly have the error controlled or the dt is already pretty small.

Copy link

codecov bot commented May 15, 2024

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 41.40%. Comparing base (541e7fd) to head (ccf79ed).

Files Patch % Lines
src/integrator_interface.jl 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #692      +/-   ##
==========================================
- Coverage   41.42%   41.40%   -0.02%     
==========================================
  Files          55       55              
  Lines        4555     4557       +2     
==========================================
  Hits         1887     1887              
- Misses       2668     2670       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ChrisRackauckas ChrisRackauckas merged commit ed82867 into SciML:master May 15, 2024
30 of 42 checks passed
@oscardssmith oscardssmith deleted the reduce-instability-sensitivity branch May 15, 2024 19:13
@oscardssmith oscardssmith changed the title only bail out as instable when dt is small or error is somewhat conrtolled only bail out as instable when dt is small or error is somewhat controlled May 16, 2024
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

Successfully merging this pull request may close these issues.

2 participants