- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code generation contains Differential
when equations contain variable time parameter
#3480
Comments
One problem here is that if julia> @component function FilteredInput(; name, x0=0, T=0.1)
params = @parameters begin
k(t) = x0
T = T
end
vars = @variables begin
x(t) = k
dx(t) = 0
end
systems = []
eqs = [
D(x) ~ dx
D(dx) ~ (k - x)/T
]
return ODESystem(eqs, t, vars, params; systems, name)
end
julia> @mtkbuild sys = FilteredInput()
julia> ModelingToolkit.observed(sys)
Equation[] since then MTK has no reason to make Furthermore, if you intend for |
Making parameter derivatives zero should handle this? |
We do need to make sure that when a parameter is a function, say a datainterpolation, that we still handle that case correctly. |
"handle"... if the derivative is zero then there's no need to have the parameter depend on time. If the parameter truly does vary with time it's wrong to just assume that the derivative is zero. |
Well the issue here is that discrete variables and parameter functions need to do this separately. |
In both cases is it wrong to assume that the derivative is zero. A discrete-time variable that is piecewise constant has an ill-defined derivative (in the non-distribution sense at least) at the time point when it changes value, if the model is such that it depends on this derivative, the model is probably wrong. If the parameter is a function of time and MTK knows the derivative of this function it is fine, otherwise erroring is the only reasonable option. |
See also #2823 (from #2823 (comment) and below). A good solution to this issue would probably also solve that issue. |
Take the following
gives...
Note the
Differential(t)(k(t)))
which cannot be computed.Manifest:
The text was updated successfully, but these errors were encountered: