-
-
Notifications
You must be signed in to change notification settings - Fork 232
Closed
Description
Related to #998. If you declare the independent variable as a parameter instead of a variable, it's usually not a problem. However, if the independent variable is then captured in the parameters list, it leads to an error message (ERROR: ArgumentError: Sym{Real, Base.ImmutableDict{DataType, Any}}[t] are missing from the variable map.
) suggesting that you need to provide an initial/fixed value for t
. However, if you do that, then you shadow the independent variable with a parameter, as far as any inhomogenous equations are concerned. That leads to incorrect output (ie, assuming t
is 0 for all times.)
using ModelingToolkit, DifferentialEquations
pars = @parameters((A, t)) #Maybe this is the erroneous line?
vars = @variables((u2(t), u1(t)))
der = Differential(t)
eqs = [
der(u1) ~ u2,
0 ~ u2 - A * t,
]
sys = ODESystem(eqs,t,vars,pars)
params = Dict(
A => 12.0,
t => 0.0, #Or maybe this is the problem?
)
initialValues = [
u1 => 0.0,
u2 => 0.0,
]
sys_simple = structural_simplify(sys)
tspan = (0.0, 1.0)
problem = ModelingToolkit.ODEProblem(reducedSystem , initialValues, tspan, params)
sol = solve(problem, Rodas5()) #Result is all zeros
Possible resolutions:
- Assert that the independent variable is not in the set of parameters
- Make the error message for missing parameter values and/or initial values more specific
- Change the substitution process so that the independent variable cannot be shadowed?
Metadata
Metadata
Assignees
Labels
No labels