Engee documentation

Variables of the Engee Physical Modeling Language

Page in progress.

In the physical modeling language Engee, variables describe the states and intermediate quantities that participate in the equations of the physical component. Unlike regular Julia, Engee variables are supplemented with metadata (units of measurement, priorities, visibility in the interface, etc.) and data type/form (scalar, vector, matrix).

Continuous variables

Continuous variables are the main calculated values of the model. They are declared using the construct @variables and participate in the system of equations. For example:

@variables begin
    x = 0.0
    y = 1.5
end

Features @variables:

  • Each variable needs to be set to an initial value (for example, x = 0.0).

  • These variables are displayed in the interface and can participate in setting the initial conditions and signal recordings signal logging 1.

Intermediate variables

Intermediate variables are declared using the construct @intermediates and they differ from the usual ones in that the calculation equation is immediately set for them. For example:

@variables begin
    x = 0.0
    y = 1.5
end

@intermediates begin
    z = x^2 + y
end

Features @intermediates:

  • There is no need to write a separate equation for such variables — the expression is indicated immediately after =.

  • They are not displayed in the component settings window, but they can be record signal logging 1.

  • Such variables help to simplify symbolic analysis and speed up the work of the solver.

  • They are used for convenience when it is necessary to express the intermediate result of calculations, but not to store it as a separate state.

If you need to set the initial value and priority of a variable, then use @variables. For calculations without an initial state, it is preferable to use @intermediates.

Discrete event variables

Discrete event variables are variables that change only when events occur and do not change their value between them. They are used to describe the logic of switching, state fixation and other discrete processes in the model.

In the physical modeling language Engee, such variables are declared as ordinary @variables, but with metadata event = true. This makes it clear to the system that the variable should be updated only when events are triggered.:

@variables begin
    state_real = 5.0, [event=true]
    state::Bool = false, [event = true]
end

The type of discrete variables by default — Real, but explicit typing is allowed as Int or Bool.

Intermediate (@intermediates) and the usual continuous variables (@variables without event=true) are recalculated all the time, and event—based ones are recalculated only when the event is triggered.

More information about the use of these variables is written in the article Engee Physical Modeling Language Events.