You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug 🐞
Hello the question was first posted here
I have repeated it below.
ODE solver does not consider the parameter to be dynamic. Instead fixes the value to be at t=0 Expected behavior
The chosen parameter should change over t and should affect the solution to the ODE.
Minimal Reproducible Example 👇
using ModelingToolkit, DifferentialEquations
using ModelingToolkit: t_nounits as t, D_nounits as D
functiontest(;name)
vars =@variablesbeginx(t)
end
para =@parametersbeginα(t)
end
eqs = [
D(x) ~ α
]
ODESystem(eqs,t,vars,para,name=name)
end@named model =test()
sys =structural_simplify(model)
para = [sys.α =>cos(t)]
u0 = [sys.x =>1]
tspan = (0,2π)
prob =ODEProblem(sys,u0,tspan,para)
sol =solve(prob)
Error & Stacktrace ⚠️
No error
Environment (please complete the following information):
Dynamic parameters work differently from variables. In order to do that, you need to create a callable parameter of the form (param ::FuncType)(..) and then call param(t) inside the equations:
using ModelingToolkit, DifferentialEquations
using ModelingToolkit: t_nounits as t, D_nounits as D
functiontest(;name)
vars =@variablesbeginx(t)
end
para =@parametersbegin
(α ::Function)(..)
end
eqs = [
D(x) ~α(t)
]
ODESystem(eqs,t,vars,para,name=name)
end@named model =test()
sys =structural_simplify(model)
para = [sys.α => cos] # the input must be the function
u0 = [sys.x =>1]
tspan = (0,2π)
prob =ODEProblem(sys,u0,tspan,para)
sol =solve(prob)
Describe the bug 🐞
Hello the question was first posted here
I have repeated it below.
ODE solver does not consider the parameter to be dynamic. Instead fixes the value to be at
t=0
Expected behavior
The chosen parameter should change over
t
and should affect the solution to the ODE.Minimal Reproducible Example 👇
Error & Stacktrace⚠️
No error
Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
Additional context
The text was updated successfully, but these errors were encountered: