Engee documentation

Integrator

Integration of the input signal.

integrator

Description

Block Integrator calculates the time integral of its input signal.

Block Integrator can be considered as a dynamic system with one state. The block behaviour is described by the following equations:

,

where

  • - is the input signal;

  • - output signal;

  • - state;

  • - initial state .

These equations describe the exact dependence of the output on the input in continuous time; numerical approximation methods are used to estimate them with finite accuracy. There are several types of solvers in Engee that implement different numerical integration methods to compute the output of a block. Each solver has its own advantages depending on the specific problem.

The selected solver calculates the output of the block Integrator at the current time step using the current input value and the state value at the previous time step. To do this, the block Integrator saves the output value at the current time step for usage by the solver at the next time step. The block also provides the solver with an initial state to calculate the state of the block at the start of the simulation. By default, the initial state value is 0. Using the block parameters window it is possible to set a different value of the initial state.

To create a fully discrete system it is recommended to use the block Discrete-Time Integrator.

Definition of initial states

You can define the initial states as parameters in the block dialogue box or enter them from an external signal:

  • To define initial states as a block parameter, specify Initial condition source as internal and enter a value in the Initial condition field.

  • To get initial conditions from an external source, specify Initial condition source as external. The optional input port appears below the input port.

If the integrator limits its output signal (see Integrator Limiting), the initial condition must be within the saturation limits of the integrator. If the initial state is outside the saturation limits of the block, the block displays an error message.

Integrator Limit

To ensure that the output does not exceed specified levels, select the Limit output checkbox and enter limits in the appropriate parameters fields. This action causes the block to function as a limited integrator. When the output reaches the limits, the integrator action is terminated.

You can change the limits during simulation, but you cannot turn integrator limits on or off. The block defines the output as follows:

  • When the integral is less than or equal to the Lower saturation limit, the output is held at the Lower saturation limit.

  • When the integral is between the Lower saturation limit and the Upper saturation limit, the output is held at the integral.

  • When the integral is greater than or equal to Upper saturation limit, the output signal is held at Upper saturation limit.

To generate a signal indicating when the state is limited, select the Show saturation port checkbox. The saturation port appears below the block output port.

integrator 2

The signal takes one of three values:

  • 1 indicates that the upper limit applies.

  • 0 indicates that the integral is unbounded.

  • -1 indicates that the lower limit applies.

When this checkbox is selected, the block has three zero crossings:

  • To determine when it enters the upper saturation limit.

  • To determine when it enters the lower saturation limit.

  • To determine when it leaves the saturation zone.

Resetting cyclic states

Some physical phenomena are cyclic, periodic, or rotational in nature. Modelling these phenomena involves integrating the rate of change of periodic or cyclic signals to obtain a state variable.

The disadvantage of this approach is that over long simulation times, the states representing the periodic or cyclic signals are integrated to very large values. In addition, calculating the sine or cosine of these signals takes increasingly longer time. Large values of the signals also negatively affect the performance and accuracy of the solver.

One approach to overcome this drawback is to reset the angular state to 0 when it reaches 2π (or to -π when it reaches π, for numerical symmetry) using additional algorithms in the model. This approach improves the accuracy of the sine and cosine calculations. But note that it leads to resetting the solver, which slows down the modelling for a variable step solver, especially in large models.

In order to prevent the solver from resetting when the output value is reset, the block Integrator contains a built-in state reset mechanism, which you can enable by checking the Wrap state checkbox in the block parameters dialogue box.

When you enable the Wrap state parameters, the block icon changes to indicate that cyclic state reset is enabled for the block.

When cyclic state reset is enabled, the state value is determined by the following expressions:

востальныхслучаях ,

where:

  • - is the lower limit of the state value;

  • - upper limit of the state value;

  • - result (state).

Resetting cyclic states has the following advantages:

  • Eliminates modelling instability when the model approaches large angles and large state values.

  • Reduces the number of solver resets during simulation, which reduces simulation time.

  • Eliminates large angle values, speeding up the computation of trigonometric functions over angular states.

  • Improves solver accuracy and performance and provides unlimited simulation time.

Reset state

The unit resets its state to the initial state by an external signal. The reset trigger type is determined by the External reset parameters. If a value other than `none' is selected, the block has a reset port with the reset trigger type labelled next to it.

Reset Trigger Types

The External reset parameters allows you to define the attribute of the reset signal that is the reset trigger. The following triggers are possible:

  • rising - resets the state when the reset signal passes an edge, i.e. rises from a negative or zero value to a positive value.

  • falling - resets the state when the reset signal passes the cutoff, i.e. falls from a positive value to zero or negative value.

  • either - resets the state when the reset signal goes up or down, i.e. changes from zero to a non-zero value, from a non-zero value to zero, or changes sign.

  • level - resets and holds the output in the initial state until the reset signal is equal to zero, i.e. different from zero at the current time step or changes from a non-zero value at the previous time step to zero at the current time step.

  • level hold - resets the output signal to the initial state when the reset signal is different from zero.

The reset port has a direct input. If a block output signal is fed back into this port, either directly or through a series of direct-input blocks, an algebraic loop is produced. Use the block status port Integrator to feedback the block output without creating an algebraic loop.

About the status port

Selecting the Show state port checkbox in the block parameters dialogue box Integrator causes an additional output port, the state port, to appear at the top of the integrator block.

integrator 1

The output of the status port is the same as the output of the block’s standard output port, except in the following case. If the block is reset at the current time step, the status port output represents the value that would have appeared on the standard block output if the block had not been reset.

The output of the status port appears earlier in the time step than the output of the integrator block output port. Use the status port to open algebraic circuits in these simulation scenarios:

  • Self-aligned integrators (see Creating Self-Aligned Integrators).

  • State transfer from one enabled subsystem to another (see Transferring states between enabled subsystems).

Creating self-resetting integrators

The block state port Integrator helps you avoid an algebraic loop when creating an integrator that resets itself based on the value of its output data. Consider the following model.

This model attempts to create a self-setting integrator by feeding the integrator output subtracted from 1 back into the integrator’s reset port. However, the model creates an algebraic loop. To calculate the integrator block output, the software must know the value of the block reset signal, and vice versa. Since these two values are interdependent, the software cannot determine either value. Therefore, an error message appears when attempting to model or update this model.

The following model uses the integrator state port to avoid the occurrence of an algebraic loop.

In this version, the value of the reset signal depends on the value of the state port. The value of the state port is available earlier in the current time step than the value of the output port of the integrator block. Consequently, can determine whether the block should be reset before calculating the block output, thus avoiding an algebraic loop.

Transfer of states between enabled subsystems

The state port helps to avoid the occurrence of an algebraic loop when transferring state between two enabled subsystems. Consider, for example, the following model.

Enabled subsystems A and B contain the following blocks:

Subsystem A Subsystem B

In this model, a constant input signal drives two enabled subsystems that integrate the signal. A pulse generator generates an enable signal that alternates execution between the subsystems. The Enabled port of each subsystem is set to reset, which causes the subsystem to reset its integrator when it becomes active. Resetting the integrator causes the integrator to read the value of its initial state port. The initial state port of the integrator in each subsystem is connected to the output port of the integrator in the other subsystem.

This interconnection is intended to provide continuous integration of the input signal while alternating execution between the two subsystems. However, the connection creates an algebraic loop. To compute the output data A, one must know the output data B, and vice versa. Since the outputs are interdependent, it is not possible to compute the output values. Therefore, an error message appears when trying to model or update this model.

This version of the same model uses the state port of the integrator to avoid creating an algebraic loop during state transfer.

Enabled subsystems A and B contain the following blocks:

Subsystem A Subsystem B

In this model, the initial state of the integrator in A depends on the value of the state port of the integrator in B, and vice versa. The values of the state ports are updated earlier in the time step of the simulation than the values of the output ports of the integrator. Hence, it is possible to calculate the initial state of any integrator without knowing the final output value of another integrator.

Selecting all options

When you select all parameters, the block icon looks as follows.

Ports

Input

Port_1 - input signal
scalar | vector | matrix

The signal to be integrated.

Data types: Float64

External Reset - reset the state to the initial state
scalar | vector | matrix

Resetting the block state to the set initial state by external signal. See section [Сброс состояния].

Dependencies

To use this port, select the External Reset checkbox.

Data types: Float64 Bool

x0 - initial state
scalar | vector | matrix

The initial state of the block set by an external signal. See section [Определение начальных состояний].

Dependencies

To use this port, set the Initial Conditions parameters to external.

Data types: Float64

Output

Port_1 - output signal
scalar | vector | matrix

Integration result.

Data types: Float64

Port_2 - sign of output signal limitation
-1 | 0 | 1

A saturation output signal, specified as a scalar, vector, or matrix, that indicates when the output signal is limited by an upper or lower saturation limit.

  • If the integral is limited at the Upper saturation limit level, the output signal is 1.

  • If the integral is limited at the Lower saturation limit, the output signal is -1.

  • If the integral is between these limits, the output signal is 0. For more information, see Integrator Limit.

Data types: Float64

Port_3 - state
scalar | vector | matrix

Outputs the state of the block. For more information, see About the status port.

Dependencies

To use this port, select the Show state port parameters check box.

Data types: Float64

Parameters

External reset - reset state to initial state
none (by default) | rising | falling | either | level | level hold

Specify the type of trigger to be used for the external reset signal.

  • rising - resets the state when the reset signal passes the edge.

  • falling - resets the state when the reset signal passes the slice.

  • either - resets the state when the reset signal is rising or falling (passing an edge or a slice).

  • level - resets and holds the output in the initial state when the reset signal is different from zero at the current time step or changes from a non-zero value at the previous time step to zero at the current time step.

  • level hold - resets the output to the initial state when the reset signal is different from zero at the current time step.

Usage in program code

Block parameter

ExternalReset

Values

none | rising | falling | either | level | level hold

By default

none

Initial condition source - selection of initial condition source
Internal (By default) | external

Select the initial condition source:

  • internal - get initial states from the Initial condition parameters.

  • external - receiving initial states from an external source through the x0 input port.

Dependencies

The internal value enables usage of the Initial condition parameters in the simulation.

The external value disables usage of the Initial condition parameters and enables the x0 input port.

Usage in program code

Block parameter

InitialConditionSource

Values

internal | external

By default

internal

Initial condition - initial condition
0.0 (by default) | scalar | vector | matrix

Initial state of the block Integrator.

Dependencies

To use this parameter, set the Initial condition source parameters to internal.

Usage in program code

Block parameter

InitialCondition

By default

0

Limit output - restriction of block output values to the specified range
off (by default) | on

Limit the block output to a value between the Lower saturation limit and Upper saturation limit parameters.

  • Checking this box limits the block output to a value between the Lower saturation limit and Upper saturation limit parameters.

  • Unchecking this box does not limit the block output to a value between Lower saturation limit and Upper saturation limit.

Dependencies

Selecting this option enables the Lower saturation limit and Upper saturation limit parameters.

Usage in program code

Block parameter

LimitOutput

Values

off | on

By default

off

Upper saturation limit - upper limit for integral
inf (by default) | scalar | vector | matrix

Specify the upper limit for an integral as a scalar, vector, or matrix. You must specify a value between the parameters Output minimum and Output maximum.

Dependencies

To use this parameters, select the Limit output checkbox.

Usage in program code

Block parameter

UpperSaturationLimit

Values

scalar | вектор | матрица

By default

inf

Lower saturation limit - lower limit for integral
-inf (by default) | scalar | vector | matrix

Specify the lower limit for an integral as a scalar, vector, or matrix. You must specify a value between the parameters Output minimum and Output maximum.

Dependencies

To use this parameters, select the Limit output checkbox.

Usage in program code

Block parameter

LowerSaturationLimit

Values

scalar | вектор | матрица

By default

−inf

Wrap state - reset cyclic states
off (by default) | on

Reset cyclic states between parameters Wrapped state upper value and Wrapped state lower value. Enabling this parameter reduces the number of solver resets, improves the performance and accuracy of calculations, and increases the allowable simulation time for rotational and cyclic states.

If you specify Wrapped state upper value as inf and Wrapped state lower value as -inf, no reset will occur.

Dependencies

Selecting this parameter allows you to set the parameters Wrapped state upper value and Wrapped state lower value.

Usage in program code

Block parameter

WrapState

Values

off | on

By default

off

Wrapped state upper value - upper limit for resetting cyclic states
pi (by default) | scalar | vector

Upper limit of the block output signal (for resetting cyclic states).

Dependencies

This parameter is used when Wrap state is enabled.

Usage in program code

Block parameter

WrappedStateUpperValue

Values

2*pi

By default

pi

Wrapped state lower value - lower limit for resetting cyclic states
-pi (by default) | scalar | vector

Lower limit of the block output signal (for resetting cyclic states).

Dependencies

This parameter is used when Wrap state is enabled.

Usage in program code

Block parameter

WrappedStateLowerValue

Values

0

By default

−pi

Show saturation port - enable output saturation port
off (by default) | on

Select this check box to add a saturation output port to the block. When you clear this check box, the block does not have a saturation output port.

Dependencies

Selecting this parameter enables the saturation output port.

Usage in program code

Block parameter

ShowSaturationPort

Values

off | on

By default

off

Show state port - enable state output port
off (by default) | on

Select this checkbox to add a state output port to the block. When you clear this check box, the block does not have a status output port.

Dependencies

Selecting this parameter enables the status output port.

Usage in program code

Block parameter

ShowStatePort

Values

off | on

By default

off