@@ -70,8 +70,8 @@ struct NonLinModel{
70
70
end
71
71
72
72
@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> )
75
75
76
76
Construct a nonlinear model from state-space functions `f`/`f!` and `h`/`h!`.
77
77
@@ -86,24 +86,20 @@ functions are defined as:
86
86
```
87
87
where ``\m athbf{x}``, ``\m athbf{y}``, ``\m athbf{u}``, ``\m athbf{d}`` and ``\m athbf{p}`` are
88
88
respectively 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:
91
93
92
94
1. **Non-mutating functions** (out-of-place): define them as `f(x, u, d, p) -> ẋ` and
93
95
`h(x, d, p) -> y`. This syntax is simple and intuitive but it allocates more memory.
94
96
2. **Mutating functions** (in-place): define them as `f!(ẋ, x, u, d, p) -> nothing` and
95
97
`h!(y, x, d, p) -> nothing`. This syntax reduces the allocations and potentially the
96
98
computational burden as well.
97
99
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
-
103
100
!!! tip
104
101
Replace the `d` or `p` argument with `_` in your functions if not needed (see Examples below).
105
102
106
- A 4th order [`RungeKutta`](@ref) solver discretizes the differential equations by default.
107
103
The rest of the documentation assumes discrete dynamics since all models end up in this
108
104
form. The optional parameter `NT` explicitly set the number type of vectors (default to
109
105
`Float64`).
@@ -115,6 +111,20 @@ form. The optional parameter `NT` explicitly set the number type of vectors (def
115
111
116
112
See also [`LinModel`](@ref).
117
113
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
+
118
128
# Examples
119
129
```jldoctest
120
130
julia> f!(ẋ, x, u, _ , p) = (ẋ .= p*x .+ u; nothing);
0 commit comments