Skip to content

MethodError in time-dependent ODE (Duffing oscillator) #115

@mforets

Description

@mforets

The problem seems to be due to the presence of the time variable in the right-hand side of the ODEs using validated_integ2 (the example works with validated_integ).

using ReachabilityAnalysis, Plots

@taylorize function duffing!(du, u, p, t)
    local α = -1.0
    local β = 1.0
    local δ = 0.3
    local γ = 0.37

    x, v = u
    f = γ * cos* t)

    du[1] = u[2]
    du[2] = - α*x - δ*v - β*x^3 + f
end

ω = 1.2
T = 2*pi / ω
X0 = Singleton([1.0, 0.0])  BallInf(zeros(2), 0.1)
prob = @ivp(x' = duffing!(x), x(0)  X0, dim=2);

# uses validated_integ2
sol = solve(prob, tspan=(0.0, 20*T), alg=TMJets());

MethodError: no method matching Float64(::Taylor1{Float64})
Closest candidates are:
  (::Type{T})(::T) where T<:Number at boot.jl:760
  (::Type{T})(::AbstractChar) where T<:Union{AbstractChar, Number} at char.jl:50
  (::Type{T})(::Base.TwicePrecision) where T<:Number at twiceprecision.jl:243
  ...

Stacktrace:
  [1] convert(#unused#::Type{Float64}, x::Taylor1{Float64})
    @ Base ./number.jl:7
  [2] promote(a::TaylorModels.TaylorModel1{TaylorN{Float64}, Float64}, b::Taylor1{Float64})
    @ TaylorModels ~/.julia/dev/TaylorModels/src/promotion.jl:85
  [3] +(b::TaylorModels.TaylorModel1{TaylorN{Float64}, Float64}, a::Taylor1{Float64})
    @ TaylorSeries ~/.julia/packages/TaylorSeries/tveWm/src/arithmetic.jl:114
  [4] duffing!
    @ ./In[71]:13 [inlined]
  [5] duffing!(du::Vector{TaylorModels.TaylorModel1{TaylorN{Float64}, Float64}}, u::Vector{TaylorModels.TaylorModel1{TaylorN{Float64}, Float64}}, p::Nothing, t::Taylor1{Float64})
    @ Main ./none:0
  [6] picard_iteration(f!::typeof(duffing!), dx::Vector{TaylorModels.TaylorModel1{TaylorN{Float64}, Float64}}, xTM1K::Vector{TaylorModels.TaylorModel1{TaylorN{Float64}, Float64}}, params::Nothing, t::Taylor1{Float64}, x0::Vector{TaylorModels.TaylorModelN{2, Float64, Float64}}, box::IntervalBox{2, Float64}, #unused#::Val{true})
    @ TaylorModels ~/.julia/dev/TaylorModels/src/validatedODEs.jl:642
  [7] _validate_step!(xTM1K::Vector{TaylorModels.TaylorModel1{TaylorN{Float64}, Float64}}, f!::Function, dx::Vector{TaylorModels.TaylorModel1{TaylorN{Float64}, Float64}}, x0::Vector{TaylorModels.TaylorModelN{2, Float64, Float64}}, params::Nothing, x::Vector{Taylor1{TaylorN{Float64}}}, t::Taylor1{Float64}, box::IntervalBox{2, Float64}, dof::Int64, rem::Vector{IntervalArithmetic.Interval{Float64}}, abstol::Float64, δt::Float64, sign_tstep::Int64, E::Vector{IntervalArithmetic.Interval{Float64}}, E′::Vector{IntervalArithmetic.Interval{Float64}}, polv::Vector{Taylor1{TaylorN{Float64}}}, low_ratiov::Vector{Float64}, hi_ratiov::Vector{Float64}, adaptive::Bool, minabstol::Float64; ε::Float64, δ::Float64, validatesteps::Int64, extrasteps::Int64)
    @ TaylorModels ~/.julia/dev/TaylorModels/src/validatedODEs.jl:696
  [8] validated_integ2(f!::typeof(duffing!), X0::IntervalBox{2, Float64}, t0::Float64, tf::Float64, orderQ::Int64, orderT::Int64, abstol::Float64, params::Nothing; parse_eqs::Bool, maxsteps::Int64, absorb::Bool, adaptive::Bool, minabstol::Float64, validatesteps::Int64, ε::Float64, δ::Float64, absorb_steps::Int64)
    @ TaylorModels ~/.julia/dev/TaylorModels/src/validatedODEs.jl:826
  [9] post(alg::TMJets21b{Float64, ZonotopeEnclosure}, ivp::InitialValueProblem{BlackBoxContinuousSystem{typeof(duffing!)}, MinkowskiSum{Float64, Singleton{Float64, Vector{Float64}}, BallInf{Float64, Vector{Float64}}}}, timespan::IntervalArithmetic.Interval{Float64}; Δt0::IntervalArithmetic.Interval{Float64}, kwargs::Base.Iterators.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:tspan, :alg), Tuple{Tuple{Float64, Float64}, TMJets21b{Float64, ZonotopeEnclosure}}}})
    @ ReachabilityAnalysis ~/.julia/dev/ReachabilityAnalysis/src/Algorithms/TMJets/TMJets21b/post.jl:36
 [10] solve(::InitialValueProblem{BlackBoxContinuousSystem{typeof(duffing!)}, MinkowskiSum{Float64, Singleton{Float64, Vector{Float64}}, BallInf{Float64, Vector{Float64}}}}; kwargs::Base.Iterators.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:tspan, :alg), Tuple{Tuple{Float64, Float64}, TMJets21b{Float64, ZonotopeEnclosure}}}})
    @ ReachabilityAnalysis ~/.julia/dev/ReachabilityAnalysis/src/Continuous/solve.jl:61
 [11] top-level scope
    @ In[71]:23
 [12] eval
    @ ./boot.jl:360 [inlined]
 [13] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
    @ Base ./loading.jl:1094

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions