Block Methods
The following Block methods are available for CT basic blocks:
The init() method is called only at the beginning or restart of an experiment. The init() method can be used to specify code for initializing the block, e.g. to model the start-up behavior of a model or to initialize state variables (e.g. resetContinuousState(x,5.3)). Initialization values derived from calculation statements have to be explicitly assigned using the init() method.
The terminate() method is executed at the end of the experiment. The terminate() method can be used to specify code for finishing a block, e.g. to model the shutdown behavior of the system.
Ordinary differential equations (ODE) have to be specified in the derivatives() method. If the model structure changes during the simulation (e.g. in a model with moving masses that simulates static and dynamic friction), the structure change can be controlled with the usual control structures (if(...) then... else...).
update() is executed in the granularity of the external communication interval dT. Values required only at this granularity (also communication with the experiment environment) can be calculated using this method.
The directOutputs() method includes all output equations with direct pass-through that directly depend on inputs. As they directly depend on inputs that in turn may depend on nondirectOutputs(), this method is executed after nondirectOutputs().
The nondirectOutputs() method includes all output equations with nondirect pass-through (i.e. those not directly depending on inputs).
Within the dependentParameters() method, equations are specified for parameters that depend on other parameters. This method is only executed if a parameter has been changed during the simulation experiment (asynchronous execution when changed). This reduces the calculation time.
EXAMPLE m_vehicle = m_empty + m_payload
The vehicle mass is recalculated in the dependentParameters() method only if the payload changes in the experiment.
Within the stateEvents() method, it is possible to model state- and time-dependent discontinuities. This method is evaluated at the end of each consistent integration step. Discrete state equations must be specified in the stateEvents() method.
The events() method can be used to process asynchronous software and hardware interrupts. This method is not executed time-synchronously but asynchronously when the corresponding event occurs.
