Built-in Variable Time

The built-in variable time represents the current simulation time point, and is implictly defined as:

input Real time(final quantity = "Time", final unit = "s");

time is only available in models and blocks, and not e.g. in functions. time can for example be used to trigger an event at a specific point in time. In the following example we have a variable x with an initial value of 1.0. At the time point 0.5s the when-equation is triggered, and the equation x = 2.0 becomes active. Note that the event happens at the time point 0.5s, not after 0.5s of simulation (unless the simulation started at 0s).

time is not available in functions since Modelica functions are mathematical functions, i.e. the same input should always give the same output. This means that time is not allowed to be accessed inside a function, but it can still be passed as a function argument: