I have a more general question regarding Differential Equations, Control Systems, and Linearization. Thanks to Tamas_Papp
, ssfrr
, DrPapa
, ChrisRackauckas
, and longemen3000
for help in a previous thread on ‘ForwardDiff & “complicated” functions?’.
Systems in Control Engineering are often described as
[state space form, with obvious generalizations to DAEs, and other types of models. x is normally used for states, u for inputs, and p or \theta for parameters/constants.] Here, u is often considered a time function, but in (state) feedback control, u=u(x,t).
Differential Equations solvers assume that the input function u(x,t) already is specified, and that the differential equation is of form:
which is straightforward to set up by h(x,t;p) = f(x,u(x,t),t;p). This works fine with Julia’s DifferentialEquations package.
The ModelingToolkit.jl package has a tool for finding the Jacobian \frac{\partial h}{\partial x}, and I understand that with some tinkering, it is possible to find \frac{\partial f}{\partial u}. The previous thread also showed how I can find \frac{\partial f}{\partial x}, \frac{\partial f}{\partial u} via the ForwardDiff.jl package.
However, in “real life” control models, u would be implemented as function u(x,t). How do I then find the Jacobian \frac{\partial f}{\partial u}?
More concretely… Suppose I have the “trivial” model:
# Model with input function
function model(dx,x,p,t,u)
dx[1] = -p[1]*x[1] + p[2]*u(t)
end
To prepare this model for DifferentialEquations.jl, I introduce:
md(dx,x,p,t) = model(dx,x,p,t,u)
and then I define an input function, e.g.:
u(t) = t < 5 ? 0.0 : 1.0
(as an example; a step function).
Of course, I can go through my model and replace u(t)
with u
, do the linearization with ForwardDiff
, etc. And then reinsert u(t)
to do the actual simulation after I have found the Jacobians/linearized model (which is often used for controller design). But this seems error prone. And for more complex models, it seems to be a hazzle.
OR: will ForwardDiff.jl or ModelingToolkit.jl handle Jacobians when u in the function call model(dx,x,p,t,u)
actually is a function?