Hello,
I have an error occur while running an ODE. It didn’t error 3-4 days ago, and I think DifferentialEquations.jl
and Sundails.jl
had an update in the meantime, so I will need to adjust my code. I think the error is coming from Sundials
based on
MethodError: no method matching unsafe_convert(::Type{Ptr{Int32}}, ::Base.RefValue{Int64})
Closest candidates are:
unsafe_convert(!Matched::Type{Ptr{Nothing}}, ::Base.RefValue{T}) where T at refvalue.jl:30
unsafe_convert(::Type{T}, !Matched::T) where T<:Ptr at essentials.jl:393
unsafe_convert(::Type{P}, !Matched::Ptr) where P<:Ptr at essentials.jl:394
...
in top-level scope at Creating clearance graphs.jl:58
in collect at base\array.jl:665
in iterate at base\generator.jl:47
in #112 at base\none
in run_one_foodweb_no_pristine at test for clearance comparison error.jl:113
in collect at base\array.jl:665
in iterate at base\generator.jl:47
in at base\none
in apply_clearance at test for clearance comparison error.jl:79
in at DiffEqBase\gzrxg\src\solve.jl:104
in #solve#453 at DiffEqBase\gzrxg\src\solve.jl:106
in solve_up##kw at DiffEqBase\gzrxg\src\solve.jl:110
in #solve_up#454 at DiffEqBase\gzrxg\src\solve.jl:116
in solve_call##kw at DiffEqBase\gzrxg\src\solve.jl:69
in #solve_call#450 at DiffEqBase\gzrxg\src\solve.jl:96
in at Sundials\mWUX7\src\common_interface\solve.jl:10
in __solve##kw at Sundials\mWUX7\src\common_interface\solve.jl:10
in __solve##kw at Sundials\mWUX7\src\common_interface\solve.jl:10
in __solve##kw at Sundials\mWUX7\src\common_interface\solve.jl:10
in __solve##kw at Sundials\mWUX7\src\common_interface\solve.jl:10
in #__solve#22 at Sundials\mWUX7\src\common_interface\solve.jl:12
in solve! at Sundials\mWUX7\src\common_interface\solve.jl:1190
in get_iters! at Sundials\mWUX7\src\common_interface\solve.jl:1159
in CVodeGetNumSteps at Sundials\mWUX7\src\API\cvodes.jl:188
I don’t know what is being converted that is unsafe. I also don’t know how to make a MWE for this as I use a few files to define what goes into the differential equation. Is there anything obvious? Alternatively, is there a way to revert to a previous version of Sundials
or DifferentialEquations
?
function apply_clearance(bioS, clearance_V_type, target_species)
p = (D, S, K, v, r, X, num_nutrient, num_plant, num_animal, num_vessel_types, bm, foodWeb, b, q, ω, c, h, e, target_species, catch_max, b0V, μ, elasticity, clearance_V_type)
function condition(out, u, t, integrator)
out .= bioS[1:(end-1)] .- 1e-6
end
function affect!(integrator, event_index)
integrator.bioS[event_index] = 0.0
end
extinction_cb = VectorContinuousCallback(condition,affect!,length(bioS[1:(end-1)]))
fishing_prob = ODEProblem(dBdT,bioS,tspan,p)
fishing_sol = solve(fishing_prob, save_everystep=false, alg = CVODE_BDF(), abstol=1e-6,reltol=1e-3, callback=extinction_cb)
end