Constructions of the Engee physical Modeling language
|
Page in progress. |
In the physical modeling language Engee component is described by a set of block structures of the form @… begin … end. Constructs define parameters, variables, equations, ports, branches, annotations, and other structure of the future component. Below is an overview of the main language constructs and the key methods used within them.
Basic constructions
| Construction | Appointment | Example |
|---|---|---|
|
The parameters of the component that are set before launch. |
|
|
Variables calculated during the simulation. |
|
|
Equations describing behavior. |
|
|
Connection ports to physical domains. |
|
|
Binds the stream(s) of multiple ports to a common variable. |
|
|
Sub-components (hierarchy within the model). |
|
|
Non-symbolic parameters. They are usually used for indexes and dimensions of arrays. |
|
|
Intermediate variables that simplify expressions in equations. |
|
|
Input variables. |
|
|
Output variables. |
|
|
Changing metadata of parameters, variables, ports, and sub-components. |
|
|
The appearance of the block icon. |
|
|
Inheritance from an existing component. |
|
Metadata
Using metadata, you can set units of measurement, groups, priorities, visibility in the interface, etc. For more information, see the article Metadata of the Engee Physical Modeling Language.
Special functions for constructions with equations
-
assert(condition [, message [, action]])— checks.@equations begin assert(R >= 0.0) end -
connect(a, b, …)— connection of ports and sub-components.connect(R1.p, R2.n) -
domain_connect(a, b)— synchronization of environment parameters between ports within the same component (port variables are not connected).@equations begin domain_connect(n, p) end
Rules of operation of structures
-
All designs are designed as
@name begin … end. -
The order of the structures inside the physical component (in the code after
@engeemodel) it doesn’t matter — the language is declarative.For example, a variable can be used in an equation even before it is explicitly declared.:
@engeemodel Example begin @equations begin y ~ x^2 +1 # we use x, although it is declared below end @variables begin x = 0 y = 0 end end -
There may be several structures of the same type in one physical component (for example, several blocks
@equations). -
Constructions can be provided with metadata (for example,
group = "Parameters"), which apply to all objects declared in this construct. For example:@parameters [group = "Electrical Parameters"] begin R = 1.0, [unit = "Ohm", description = "Resistance"] v_nom = 230.0, [unit = "V", description = "Nominal voltage"] endIn this example, both parameters will be displayed in the group.
"Electrical Parameters". -
The visibility of parameters, variables, ports, and sub-components can be changed depending on the parameter values inside the conditions using the block
@annotations. For example:@parameters begin a::Bool = true b = 1, [gui = None] end if a @annotations begin b, [gui = Modify] end endIn this example, the behavior of metadata depends on the value of the parameter.
a:-
If
a = false, then the parameterbhidden in the interface (gui = None), -
If
a = true, then the parameterbdisplayed (gui = Modify).
-