NSSM – Nonlinear State-Space Model

Block SymbolLicensing group: MODEL
Qt SVG Document Exported by REXYGEN Studio funcRef u RST HLD x0 x cmd f df err NSSM

Function Description
The block provides a solution to a nonlinear continuous-time state-space model in the form of

dxdt = f(x,u),y = h(x,u)

or its discrete-time counterpart defined as

x(k + 1) = f(x(k),u(k)),y(k) = h(x(k),u(k)).

The equation is discretized into a form

x(t) = F(x(t T),u(t)),

where T 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 f(x,u) 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 f(x,u) into the f vector (e.g. into the input array, where f is connected) and the matrix df(x,u)dx 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 y = h(x,u) ), 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 (cmd = 0) and calling by REXYGEN system (cmd = 1).

Notes:

  • computation of the df(x,u)dx 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 connected 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 f = h(x,u), df = dh(x,u)dx.

This block does not propagate the signal quality. More information can be found in the 1.4 section.

Input

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

Parameter

nmax

Allocated size of output matrix (total number of items)   5  10000 20

Long (I32)

solver

Numeric integration method  2

Long (I32)

1 ....

Discrete equation

2 ....

Euler (1st order)

3 ....

2nd order Adams-Bashforth

4 ....

3rd order Adams-Bashforth

5 ....

4th order Adams-Bashforth

6 ....

5th order Adams-Bashforth

7 ....

4th order Runge-Kutha

8 ....

implicit Euler

9 ....

implicit Euler(more iteration)

10 ...

2nd order Adams-Multon implicit

11 ...

2nd order Adams-Multon implicit (more iteration)

12 ...

3rd order Adams-Multon implicit

13 ...

3nd order Adams-Multon implicit (more iteration)

14 ...

2nd order RadauIIA implicit

15 ...

2nd order RadauIIA implicit (more iteration)

16 ...

17 ...

18 ...

19 ...

Output

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)

2024 © REX Controls s.r.o., www.rexygen.com