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

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

Open
mforets opened this issue May 22, 2021 · 3 comments
Open

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

mforets opened this issue May 22, 2021 · 3 comments

Comments

@mforets
Copy link
Contributor

mforets commented May 22, 2021

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
@mforets mforets changed the title MethodError in time-dependent ODE MethodError in time-dependent ODE (Duffing oscillator) May 22, 2021
@lbenet
Copy link
Member

lbenet commented May 28, 2021

Just to notify that, with a minor change in duffing! (have as a local variable ω = 1.2), with current master, I can't reproduce this issue.

@lbenet
Copy link
Member

lbenet commented May 28, 2021

Can you send me the info of the version of the package you are using?

@mforets
Copy link
Contributor Author

mforets commented Jun 24, 2021

Here is smaller example that raises a similar issue:

@taylorize function f!(dx, x, p, t)
    dx[1] = -x[1] * sin(t)
end

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

No branches or pull requests

2 participants