NSSM – Nonlinear State-Space Model
Block SymbolLicensing group: MODEL
Function Description
The block provides a solution to a nonlinear continuous-time state-space model in the form of
or its discrete-time counterpart
defined as . The equation
is discretized into a form ,
where
is sampling period of the NSSM block. The method used for discretization (i.e. a method to
numerically solve the vector differential equation) depends on the solver parameter . Various
methods for numerical integration are implemented including one step methods (like
Runge-Kutta, Euler), multistep methods (Adams-Bashforth), and also implicit methods
(Adams-Moulton). It is possible to choose different method order for each kind to find a
suitable precision vs computational time trade-off. The block does not support variable step
algorithms (the time-step for the solver is always the same as the execution period of the task
where the block is inserted).
The non-linear-vector function must be implemented in the REXLANG block that is connected to the NSSM block in a special way. The input funcRef of the NSSM block must be connected to the output y0 of the REXLANG block and the output y0 can not be used internally in the code/script of the REXLANG block. The outputs x, f and df of the NSSM block must be connected to the inputs of the REXLANG block. These inputs must be processed in the REXLANG code as an input array. The main function of the REXLANG block must set the value of into the f vector (e.g. into the input array, where f is connected) and the matrix into the af matrix.
The NSSM block calls the main-function of the REXLANG block when needed for numerical integration of the differential equation system (for example the Runge-Kutta method performs 4 calls in each execution period with different x-vector values). The REXLANG block should be disabled in the schematics of the algorithm to prevent its execution REXYGEN system itself. If the REXLANG must be executed by REXYGEN (e.g. for compute output function ), it is recommended to connect the output cmd of the NSSM block into input of the REXLANG block to distinguish between calling by the NSSM block () and calling by REXYGEN system ().
Notes:
- computation of the is necessary for implicit methods only (explicit methods do not use it).
- size of the vector x (and also f, df) is defined by the size of the vector x0. The size should be changed by reset only (the RST input).
- solver=1: discrete signalizes a discrete-time state space model with the functions f and h designating the right side of the corresponding difference equation. This mode does not require numerical integration and the algorithm reduces to the execution of the code in the connecnted REXLANG block; the mode is used mainly for symmetry with the EKF block.
- for NSSM connecting the output cmd is necessary, because cmd>0 indicate number of measurement and REXLANG must return , .
Inputs
funcRef | Cooperating REXLANG block reference | Reference |
u | Input vector of the model | Reference |
RST | Block reset | Bool |
HLD | Hold | Bool |
x0 | Initial state vector | Reference |
Parameters
nmax | Allocated size of output matrix (total number of items) 5 10000 20 | Long (I32) |
solver | Numeric integration method 2 | Long (I32) |
|
|
|
Outputs
x | Model state vector | Reference |
y | Model output vector | Reference |
cmd | Cooperating REXLANG block requested function | Long (I32) |
f | Vector reference set by cooperating REXLANG block | Reference |
df | Matrix reference set by cooperating REXLANG block | Reference |
err | Error code (0 is OK, see SystemLog for details) | Long (I32) |
[Previous] [Back to top] [Up] [Next]
2023 © REX Controls s.r.o., www.rexygen.com