Modeling in the CTDE domain

The CTDE domain supports all the modeling features that are found in other domains. Models are represented by block diagrams; the block diagrams are assembled, the domain supports all the modeling features and model-building commands that are available in other domains.

The domain supports both continuous and discrete signals, but a direct connection between ports of different types is not allowed. Primitives in the Discrete to Continuous library convert discrete signals into continuous signals; primitives in the Continuous to Discrete library convert continuous signals into discrete signals.

Vectorial continuous signals

Continuous signals are vectors of real numbers. Many primitives can operate on vectorial inputs. For example, the Add primitive can add an arbitrary number of vectors. The vectors can be of arbitrary width, but must all be the same size. The system checks to ensure that vector widths are consistent before the simulation starts.

Usage of vectorial signals often simplifies models and speeds up simulation. For example, the Spring-Mass System is modeled using a StateSpace primitive that operates on vectorial signals.

Spring-Mass model using vectorial signals and a StateSpace Block

Simulation algorithm

The simulator is divided into a Discrete-Event and a Continuous-Time component much like the model structure. These parts interact as follows:

At a given time in the simulation interval the simulator starts in Discrete Event mode. The Discrete-Event scheduler processes all events with the current time stamp. When all events have been processed, the simulator shifts to continuous mode. In this mode, the trajectory of the continuous states is approximated by a numerical ODE solver. At the time of the next scheduled discrete event, execution shifts back to the Discrete-Event scheduler.

Detection and processing of state events requires special treatment. In the graphical model representation used in the CTDE domain, state event conditions are modeled as Blocks, called state event generators. Since state event conditions depend on continuous variables, they must be handled in the continuous part of the simulator. After each step of the ODE solver, the state event generator blocks are queried to determine if a state event occurred during the current step. If this is the case, this integration step has to be rejected. Integration will be repeated with adjusted step sizes until the event condition is met with sufficient accuracy. When this occurred, the simulator immediately changes into the Discrete-Event mode and executes the action triggered by the state event as an ordinary discrete event.