Skip to content

ODEProblem(harmonic_eq...) has to have type parameter #452

@oameye

Description

@oameye
@variables ω₀ γ λ α ω t x(t)

natural_equation = d(d(x, t), t) + γ * d(x, t) + (ω₀^2 - λ * cos(2 * ω * t)) * x + α * x^3
diff_eq = DifferentialEquation(natural_equation, x)

add_harmonic!(diff_eq, x, ω);

harmonic_eq = get_harmonic_equations(diff_eq)
using StaticArrays

param = (ω₀ => 1.0, γ =>0.01, λ => 0.15, α => 1.0, ω => 1.0)

ODEProblem(harmonic_eq, [1.0, 0.0], (0, 100), param)
No methods were found for the model function passed to the equation solver.
The function `f` needs to have dispatches, for example, for an ODEProblem
`f` must define either `f(u,p,t)` or `f(du,u,p,t)`. For more information
on how the model function `f` should be defined, consult the docstring for
the appropriate `AbstractSciMLFunction`.

Offending function: f

Stacktrace:
 [1] isinplace(f::HarmonicEquation, inplace_param_number::Int64, fname::String, iip_preferred::Bool; has_two_dispatches::Bool, isoptimization::Bool, outofplace_param_number::Int64)
   @ SciMLBase ~/.julia/packages/SciMLBase/JxpZc/src/utils.jl:254
 [2] isinplace (repeats 2 times)
   @ ~/.julia/packages/SciMLBase/JxpZc/src/utils.jl:246 [inlined]
 [3] ODEProblem(f::HarmonicEquation, u0::Vector{Float64}, tspan::Tuple{Int64, Int64}, p::NTuple{5, Pair{Num, Float64}}; kwargs::@Kwargs{})
   @ SciMLBase ~/.julia/packages/SciMLBase/JxpZc/src/problems/ode_problems.jl:198
 [4] ODEProblem(f::HarmonicEquation, u0::Vector{Float64}, tspan::Tuple{Int64, Int64}, p::NTuple{5, Pair{Num, Float64}})
   @ SciMLBase ~/.julia/packages/SciMLBase/JxpZc/src/problems/ode_problems.jl:197
ODEProblem{false}(harmonic_eq, [1.0, 0.0], (0, 100), param) #works

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions