@@ -70,8 +70,8 @@ struct NonLinModel{
7070end
7171
7272@doc raw """
73- NonLinModel{NT}(f::Function, h::Function, Ts, nu, nx, ny, nd=0; p=[], solver=RungeKutta(4) )
74- NonLinModel{NT}(f!::Function, h!::Function, Ts, nu, nx, ny, nd=0; p=[], solver=RungeKutta(4) )
73+ NonLinModel{NT}(f::Function, h::Function, Ts, nu, nx, ny, nd=0; <keyword arguments> )
74+ NonLinModel{NT}(f!::Function, h!::Function, Ts, nu, nx, ny, nd=0; <keyword arguments> )
7575
7676Construct a nonlinear model from state-space functions `f`/`f!` and `h`/`h!`.
7777
@@ -86,24 +86,20 @@ functions are defined as:
8686```
8787where ``\m athbf{x}``, ``\m athbf{y}``, ``\m athbf{u}``, ``\m athbf{d}`` and ``\m athbf{p}`` are
8888respectively the state, output, manipulated input, measured disturbance and parameter
89- vectors. If the dynamics is a function of the time, simply add a measured disturbance
90- defined as ``d(t) = t``. The functions can be implemented in two possible ways:
89+ vectors. As a mather of fact, the parameter argument `p` can be any Julia objects but use a
90+ mutable type if you want to change them later e.g.: a vector. If the dynamics is a function
91+ of the time, simply add a measured disturbance defined as ``d(t) = t``. The functions can be
92+ implemented in two possible ways:
9193
92941. **Non-mutating functions** (out-of-place): define them as `f(x, u, d, p) -> ẋ` and
9395 `h(x, d, p) -> y`. This syntax is simple and intuitive but it allocates more memory.
94962. **Mutating functions** (in-place): define them as `f!(ẋ, x, u, d, p) -> nothing` and
9597 `h!(y, x, d, p) -> nothing`. This syntax reduces the allocations and potentially the
9698 computational burden as well.
9799
98- `Ts` is the sampling time in second. `nu`, `nx`, `ny` and `nd` are the respective number of
99- manipulated inputs, states, outputs and measured disturbances. The keyword argument `p`
100- is the parameters of the model passed to the two functions. It can be any Julia objects but
101- use a mutable type if you want to change them later e.g.: a vector.
102-
103100!!! tip
104101 Replace the `d` or `p` argument with `_` in your functions if not needed (see Examples below).
105102
106- A 4th order [`RungeKutta`](@ref) solver discretizes the differential equations by default.
107103The rest of the documentation assumes discrete dynamics since all models end up in this
108104form. The optional parameter `NT` explicitly set the number type of vectors (default to
109105`Float64`).
@@ -115,6 +111,20 @@ form. The optional parameter `NT` explicitly set the number type of vectors (def
115111
116112See also [`LinModel`](@ref).
117113
114+ # Arguments
115+ - `f::Function` or `f!`: state function.
116+ - `h::Function` or `h!`: output function.
117+ - `Ts`: sampling time of in second.
118+ - `nu`: number of manipulated inputs.
119+ - `nx`: number of states.
120+ - `ny`: number of outputs.
121+ - `nd=0`: number of measured disturbances.
122+ - `p=[]`: parameters of the model (any type).
123+ - `solver=RungeKutta(4)`: a [`DiffSolver`](@ref) object for the discretization of continuous
124+ dynamics, use `nothing` for discrete-time models (default to 4th order [`RungeKutta`](@ref)).
125+ - `jacobian=AutoForwardDiff()`: an `AbstractADType` backend when [`linearize`](@ref) is
126+ called, see [`DifferentiationInterface` doc](@extref DifferentiationInterface List).
127+
118128# Examples
119129```jldoctest
120130julia> f!(ẋ, x, u, _ , p) = (ẋ .= p*x .+ u; nothing);
0 commit comments