Ports of the Engee Physical Modeling Language
|
Page in progress. |
In the physical modeling language Engee, ports are interfaces through which the physical component interacts with other blocks of the model. Through the port can be transmitted:
-
Physical quantities (voltage, pressure, temperature);
-
Control signals (e.g. numerical coefficients).
Ports of physical components (as well as the entire library Physical Modeling) can only be connected to other blocks of physical modeling of the same domain (for example, a port of translational mechanics with a port of translational mechanics of another block).
Types of ports
There are two types of ports in the physical modeling language Engee:
-
Non-directional ports (
@nodes) — are used to describe physical connections. They do not have a strict division into "Input" and "output": the flow can flow in any direction. With their help, real physical domains are modeled, for example:-
Electricity (voltage and current),
-
Translational mechanics (speed and force),
-
Heat (temperature and heat flow).
-
-
Directional ports (
@inputs,@outputs) — used to transmit signals. They always have a set direction: Input (@inputs) or exit (`@outputs`Such ports are most often used in control units where control or calculated values need to be transmitted.
Non-directional ports
Inside the component, such ports are declared via the construct @nodes.
@engeemodel Resistor begin
@parameters begin
R = 1.0, [unit = "Ohm"]
end
@nodes begin
p = EngeePhysicalFoundation.Electrical.Pin
n = EngeePhysicalFoundation.Electrical.Pin
end
@variables begin
v = 0.0, [unit = "V"]
i = 0.0, [unit = "A"]
end
@branches begin
i:(p.i, n.i)
end
@equations begin
v ~ p.v - n.v
v ~ R * i
end
end
Here:
-
@nodes— adds two electrical portspandn; -
@branches— formulates the rule of current conservation in the branch; -
@equations— sets Ohm’s law: the voltage across the resistor is equal to the product of resistance and current.
Directional ports
Signal Inputs and outputs are announced through constructions @inputs and @outputs.
@engeemodel GainBlock begin
@parameters begin
k = 2.0
end
@inputs begin
x = 0
end
@outputs begin
y = 0
end
@equations begin
y.u ~ k * x.u
end
end
Here:
-
The directed ports contain a variable
u, which represents the value of the signal; -
In the equations, you do not need to use the port itself, but a variable
uInside it:x.ufor the input signal,y.ufor the weekend; -
Input signal
x.umultiplied by the coefficientk; -
The result is transmitted to the output signal
y.u.
Such ports are convenient for mixed models, where some elements work with physical quantities, and some with control signals.
Potential and stream variables in undirected ports
Each undirected port has two types of associated variables:
-
Potential — values that are equated when connecting ports (potential, temperature, pressure, velocity, angular velocity). They do not require a special mark.
-
Streaming (
connect = Flow) — the transfer values between the components (current, heat flow, flow rate, force, moment), the sum of which is zero for all connected ports.
Example of declaring an electrical port:
@engeeconnector Pin2 begin
@variables begin
v = 2.0 # potential (potential variable)
i = 0.0, [connect = Flow] # current (flow variable)
end
end
Here:
-
v— potential value (voltage); -
i— flow value (current).