NSSM – Nonlinear State-Space Model

Block SymbolLicensing group: MODEL
PIC

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

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)

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-Kutta

8 ....

Implicit Euler

9 ....

Implicit Euler(more iteration)

10 ...

2nd order Adams-Moulton implicit

11 ...

2nd order Adams-Moulton implicit (more iterations)

12 ...

3rd order Adams-Moulton implicit

13 ...

3nd order Adams-Moulton implicit (more iterations)

14 ...

2nd order RadauIIA implicit

15 ...

2nd order RadauIIA implicit (more iterations)

16 ...

3rd order RadauIIA implicit

17 ...

3rd order RadauIIA implicit (more iterations)

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)

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