I’m having trouble with the updated DifferentialEquations Package (v6.15.0) and it’s dependency DiffEqBase (v6.50.9). I was recently working in a previous version Differential Equations (v6.12.0) and DiffEqBase (v6.25.0). The parameters I put into DiffEqBase.ODEProblem do not seem to get passed down to DiffEqBase.solve like they did in the older version. How can I pass the parameters through in the newest package version? Example below, which works with the older versions, but doesn’t work with the newer package versions.
using DifferentialEquations
struct params
x::Float64
MJD::Float64
end
function in_params(y,MJD)
return params(y,MJD)
end
p = in_params(2,5)
u0 = 1.
tspan = (1.,2.)
f(u,p,t) = u + p.x
prob=DiffEqBase.ODEProblem(f, u0, tspan, p=p)
dt = 1
sol = DiffEqBase.solve(prob, dt = dt, adaptive=false, Euler())
The stacktrace error I receive is below:
**ERROR:** LoadError: type NullParameters has no field x
Stacktrace:
[1] **getproperty(** ::DiffEqBase.NullParameters, ::Symbol **)** at **./Base.jl:33**
[2] **f(** ::Float64, ::DiffEqBase.NullParameters, ::Float64 **)** at **/PathToFile/sandbox/test.jl:19**
[3] **(::ODEFunction{false,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing})(** ::Float64, ::Vararg{Any,N} where N **)** at **/PathToFile/.julia/packages/DiffEqBase/T5smF/src/diffeqfunction.jl:248**
[4] **initialize!(** ::OrdinaryDiffEq.ODEIntegrator{Euler,false,Float64,Nothing,Float64,DiffEqBase.NullParameters,Float64,Float64,Float64,Array{Float64,1},ODESolution{Float64,1,Array{Float64,1},Nothing,Nothing,Array{Float64,1},Array{Array{Float64,1},1},ODEProblem{Float64,Tuple{Float64,Float64},false,DiffEqBase.NullParameters,ODEFunction{false,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Symbol,params,Tuple{Symbol},NamedTuple{(:p,),Tuple{params}}},DiffEqBase.StandardODEProblem},Euler,OrdinaryDiffEq.InterpolationData{ODEFunction{false,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Float64,1},Array{Float64,1},Array{Array{Float64,1},1},OrdinaryDiffEq.EulerConstantCache},DiffEqBase.DEStats},ODEFunction{false,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},OrdinaryDiffEq.EulerConstantCache,OrdinaryDiffEq.DEOptions{Float64,Float64,Float64,Float64,typeof(DiffEqBase.ODE_DEFAULT_NORM),typeof(LinearAlgebra.opnorm),CallbackSet{Tuple{},Tuple{}},typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN),typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE),typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK),DataStructures.BinaryHeap{Float64,DataStructures.LessThan},DataStructures.BinaryHeap{Float64,DataStructures.LessThan},Nothing,Nothing,Int64,Tuple{},Tuple{},Tuple{}},Float64,Float64,Nothing,OrdinaryDiffEq.DefaultInit}, ::OrdinaryDiffEq.EulerConstantCache **)** at **/PathToFile/.julia/packages/OrdinaryDiffEq/tVsYE/src/perform_step/fixed_timestep_perform_step.jl:47**
[5] **__init(** ::ODEProblem{Float64,Tuple{Float64,Float64},false,DiffEqBase.NullParameters,ODEFunction{false,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Symbol,params,Tuple{Symbol},NamedTuple{(:p,),Tuple{params}}},DiffEqBase.StandardODEProblem}, ::Euler, ::Tuple{}, ::Tuple{}, ::Tuple{}, ::Type{Val{true}}; saveat::Tuple{}, tstops::Tuple{}, d_discontinuities::Tuple{}, save_idxs::Nothing, save_everystep::Bool, save_on::Bool, save_start::Bool, save_end::Bool, callback::Nothing, dense::Bool, calck::Bool, dt::Int64, dtmin::Nothing, dtmax::Float64, force_dtmin::Bool, adaptive::Bool, gamma::Int64, abstol::Nothing, reltol::Nothing, qmin::Int64, qmax::Int64, qsteady_min::Int64, qsteady_max::Int64, qoldinit::Int64, fullnormalize::Bool, failfactor::Int64, beta1::Nothing, beta2::Nothing, maxiters::Int64, internalnorm::typeof(DiffEqBase.ODE_DEFAULT_NORM), internalopnorm::typeof(LinearAlgebra.opnorm), isoutofdomain::typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN), unstable_check::typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK), verbose::Bool, timeseries_errors::Bool, dense_errors::Bool, advance_to_tstop::Bool, stop_at_next_tstop::Bool, initialize_save::Bool, progress::Bool, progress_steps::Int64, progress_name::String, progress_message::typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), userdata::Nothing, allow_extrapolation::Bool, initialize_integrator::Bool, alias_u0::Bool, alias_du0::Bool, initializealg::OrdinaryDiffEq.DefaultInit, kwargs::Base.Iterators.Pairs{Symbol,params,Tuple{Symbol},NamedTuple{(:p,),Tuple{params}}} **)** at **/PathToFile/.julia/packages/OrdinaryDiffEq/tVsYE/src/solve.jl:403**
[6] **#__solve#379** at **/PathToFile/.julia/packages/OrdinaryDiffEq/tVsYE/src/solve.jl:4** [inlined]
[7] **solve_call(** ::ODEProblem{Float64,Tuple{Float64,Float64},false,DiffEqBase.NullParameters,ODEFunction{false,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Symbol,params,Tuple{Symbol},NamedTuple{(:p,),Tuple{params}}},DiffEqBase.StandardODEProblem}, ::Euler; merge_callbacks::Bool, kwargs::Base.Iterators.Pairs{Symbol,Integer,Tuple{Symbol,Symbol},NamedTuple{(:dt, :adaptive),Tuple{Int64,Bool}}} **)** at **/PathToFile/.julia/packages/DiffEqBase/T5smF/src/solve.jl:92**
[8] **solve_up(** ::ODEProblem{Float64,Tuple{Float64,Float64},false,DiffEqBase.NullParameters,ODEFunction{false,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Symbol,params,Tuple{Symbol},NamedTuple{(:p,),Tuple{params}}},DiffEqBase.StandardODEProblem}, ::Nothing, ::Float64, ::DiffEqBase.NullParameters, ::Euler; kwargs::Base.Iterators.Pairs{Symbol,Integer,Tuple{Symbol,Symbol},NamedTuple{(:dt, :adaptive),Tuple{Int64,Bool}}} **)** at **/PathToFile/.julia/packages/DiffEqBase/T5smF/src/solve.jl:114**
[9] **#solve#460** at **/PathToFile/.julia/packages/DiffEqBase/T5smF/src/solve.jl:102** [inlined]
[10] top-level scope at **/PathToFile/test.jl:23**
[11] **include(** ::String **)** at **./client.jl:439**
[12] top-level scope at **REPL[26]:1**
in expression starting at /PathToFile/test.jl:23
I’ve tried following and comparing the two versions using the debugger but can’t seem to make sense of the outputs of the intermediate functions in the package. I’ve also started going through the documentation for the package, but am not really sure where to look to solve this specific issue. As I’m fairly new to Julia, happy to take suggestions on how to tackle something like this in the future as well.
Thanks!