Skip to content

System of ODEs with units fails for me #27

@jchafe

Description

@jchafe

Solving a system ODEs using unitful fails:
Running:

`using DifferentialEquations, Unitful

function g(dydt, y, p, t)
dydt[1] = -p[1] / p[2] * sin(y[2])
dydt[2] = y[1]
end

tspan = (0.0u"s",4.0u"s")
Y0=[0. * u"rad/s", .5u"rad"]
p = [9.8u"m/s^2",1u"m"]
prob = ODEProblem(g,Y0, tspan,p)

#Pass to solvers
sol = solve(prob,Tsit5())
`

produces:

MethodError: no method matching Quantity{Float64,D,U} where U where D(::Int64)
Closest candidates are:
Quantity{Float64,D,U} where U where D(::T<:Number) where T<:Number at boot.jl:725
Quantity{Float64,D,U} where U where D(!Matched::Base.TwicePrecision) where T<:Number at twiceprecision.jl:243
Quantity{Float64,D,U} where U where D(!Matched::AbstractChar) where T<:Union{AbstractChar, Number} at char.jl:50

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions