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

fix: set max time span to 1e16 for CoupledSDEs #230

Merged
merged 3 commits into from
Dec 2, 2024

Conversation

oameye
Copy link
Member

@oameye oameye commented Dec 1, 2024

For stochastic integrators, we can't have the timespan to be infinite because otherwise eps(Inf) is called in StochasticDiffEq. Instead, I have set it too 1e16. eps(Inf) is only called for non-adaptive timestep solvers.

https://github.com/SciML/StochasticDiffEq.jl/blob/9a28c57060980924d1fe040686f49c579ed9a1e2/src/integrators/integrator_utils.jl#L164-L167

At the moment, running trajectory with a non-adaptive time step solver fails:

using StatsBase: cov
diffeq_cov = (alg=EM(), abstol=1e-2, reltol=1e-2, dt=0.1)

Γ = [1.0 0.3; 0.3 1]
f(u, p, t) = [0.0, 0.0]
ds = CoupledSDEs(f, zeros(2), (); covariance=Γ, diffeq=diffeq_cov)
tr, _ = trajectory(ds, 1_000, Δt=0.1)
[1] (::Base.Math.var"#throw1#10")(x::Float64)
    @ Base.Math .\math.jl:1006
  [2] exponent
    @ .\math.jl:1009 [inlined]
  [3] eps
    @ .\float.jl:966 [inlined]
  [4] loopfooter!
    @ C:\Users\User\.julia\packages\StochasticDiffEq\NuzKA\src\integrators\integrator_utils.jl:167 [inlined]
  [5] step!
    @ C:\Users\User\.julia\packages\StochasticDiffEq\NuzKA\src\iterator_interface.jl:12 [inlined]
  [6] step!(::CoupledSDEs{false, 2, StochasticDiffEq.SDEIntegrator{…}, Tuple{}})
    @ StochasticSystemsBase C:\Users\User\.julia\packages\DynamicalSystemsBase\PJv07\ext\src\CoupledSDEs.jl:171
  [7] trajectory_continuous(ds::CoupledSDEs{…}, T::Int64; Dt::Float64, Δt::Float64, Ttr::Float64, accessor::Nothing, kw::@Kwargs{})
    @ DynamicalSystemsBase C:\Users\User\.julia\packages\DynamicalSystemsBase\PJv07\src\core\trajectory.jl:85
  [8] trajectory_continuous
    @ C:\Users\User\.julia\packages\DynamicalSystemsBase\PJv07\src\core\trajectory.jl:75 [inlined]
  [9] #trajectory#5
    @ C:\Users\User\.julia\packages\DynamicalSystemsBase\PJv07\src\core\trajectory.jl:44 [inlined]
 [10] trajectory
    @ C:\Users\User\.julia\packages\DynamicalSystemsBase\PJv07\src\core\trajectory.jl:36 [inlined]
 [11] trajectory(ds::CoupledSDEs{false, 2, StochasticDiffEq.SDEIntegrator{…}, Tuple{}}, T::Int64)
    @ DynamicalSystemsBase C:\Users\User\.julia\packages\DynamicalSystemsBase\PJv07\src\core\trajectory.jl:36
 [12] top-level scope
    @ c:\Users\User\Documents\Github\CriticalTransitions.jl\test\using CriticalTransitions.jl:9

@codecov-commenter
Copy link

codecov-commenter commented Dec 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.48%. Comparing base (6c98239) to head (8a78ba1).
Report is 35 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #230      +/-   ##
==========================================
+ Coverage   82.00%   86.48%   +4.47%     
==========================================
  Files          15       17       +2     
  Lines         717      932     +215     
==========================================
+ Hits          588      806     +218     
+ Misses        129      126       -3     

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

Copy link
Member

@Datseris Datseris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the value should be 1e16 or 1e11. Does this value matter at all?

@oameye
Copy link
Member Author

oameye commented Dec 1, 2024

For some reason if I take the value to be larger then 1e11 the tests which tests trajectory fail. I am not sure why. Seems to be something internal with the integrator.

Copy link
Member

@Datseris Datseris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, bump the patch version please so that i can tag a new release

@Datseris Datseris merged commit 7b7ac7a into JuliaDynamics:main Dec 2, 2024
2 checks passed
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.

3 participants