Skip to content

Parameter values can be supplied in the initial condition vector #2692

@TorkelE

Description

@TorkelE

MWE:

using ModelingToolkit, OrdinaryDiffEq, Plots

@variables t X(t)
@parameters p d
D = Differential(t)
eqs = [
    D(X) ~ p - d*X
]
@mtkbuild osys = ODESystem(eqs, t)

u0 = [X => 5.0, d => 0.2]
tspan = (0.0, 10.)
ps = [p => 5.0]
oprob = ODEProblem(osys, u0, tspan, ps)
sol = solve(oprob, Tsit5())
plot(sol)

image

If I then change d, this does have an effect on the result?

u0 = [X => 5.0, d => 0.5]
tspan = (0.0, 10.)
ps = [p => 5.0]
oprob = ODEProblem(osys, u0, tspan, ps)
sol = solve(oprob, Tsit5())
plot(sol)

image

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions