Skip to content

Variable is not a function of independent variable error for trivial example #1880

@oameye

Description

@oameye

I am trying out the ModelingToolkit.jl package and I get this weird error when defing the classical harmonic oscillator with the following code

using ModelingToolkit,
@variables t x(t)
@parameters ω₀
Dₜ = Differential(t)
@named sys = ODESystem([Dₜ(Dₜ(x)) + ω₀^2*x ~ 0])

It produces the error

ArgumentError: Variable x(t) is not a function of independent variable (ω₀^2)*x(t).

I do not understand the where the error comes from. Just putting the second term on the other side gets rid of the error, i.e.

using ModelingToolkit,
@variables t x(t)
@parameters ω₀
Dₜ = Differential(t)
@named sys = ODESystem([Dₜ(Dₜ(x)) ~ - ω₀^2*x])

runs just fine. My apologies if this error comes from my lack of understanding how the package must be used.

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