Engee documentation

Ports of the Physical Modeling Language Engee

In the language of physical modeling Engee ports are interfaces through which the physical component interacts with other blocks of the model. The following data can be transmitted through the port:

  • Physical quantities (voltage, pressure, temperature);

  • Control signals (for example, 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

In the language of physical modeling Engee There are two types of ports:

  • Non-directional ports (@nodes) — are used to describe physical connections. They do not have a strict division into "entrance" and "exit": the flow can flow in any direction. They are used to model real physical domains, for example:

    • Electricity (voltage and current);

    • Translational mechanics (speed and force);

    • Heat (temperature and heat flow).

  • Directional ports (@inputs, @outputs) — are used to transmit signals. They always have a set direction: entrance (@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 ports p and n;

  • @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.

Below are the built-in Engee types of non-directional ports. Use these ports to connect your component to blocks from the library. Engee.

Physical domain Port type Port Variables

Single-phase electricity

EngeePhysicalFoundation.Electrical.Pin

v — potential

i — current (streaming)

Three-phase electricity

EngeeElectrical.ThreePhasePort

v — potential (vector of 3 elements)

i — current (streaming, vector of 3 elements)

Magnetism

EngeePhysicalFoundation.Magnetic.Port

mmf — magnetomotive force

Phi — magnetic flux (streaming)

Heat

EngeePhysicalFoundation.Thermal.Port

T — temperature

Q — heat flow (streaming)

Translational mechanics

EngeePhysicalFoundation.Mechanical.Translational.Flange

v — speed

F — power (streaming)

Rotational mechanics

EngeePhysicalFoundation.Mechanical.Rotational.Flange

w — angular velocity

T — torque (streaming)

Isothermal liquid

EngeePhysicalFoundation.IsothermalLiquid.Port

p — pressure

mdot — mass flow (streaming)

Heat-conducting liquid

EngeePhysicalFoundation.ThermalLiquid.Port

p — pressure

T — temperature

mdot — mass flow (streaming)

Phi — energy flow (streaming)

Gas

EngeePhysicalFoundation.Gas.Port

p — pressure

T — temperature

mdot — mass flow (streaming)

Phi — energy flow (streaming)

Humid air

EngeePhysicalFoundation.MoistAir.Port

p — pressure

T — temperature

q — specific humidity

x_g — mass fraction of impurity gas

mdot — mass flow (streaming)

Phi — energy flow (streaming)

mdot_w — mass flow of water vapor (streaming)

mdot_g — mass flow rate of impurity gas (flow)

Source of humidity and impurity gases

EngeePhysicalFoundation.MoistAir.SourcePort

T — temperature

q — specific humidity

x_g — mass fraction of impurity gas

Phi — energy flow (streaming)

mdot_w — mass flow of water vapor (streaming)

mdot_g — mass flow rate of impurity gas (flow)

Two-phase liquid

EngeePhysicalFoundation.TwoPhaseFluid.Port

p — pressure

u — specific internal energy

mdot — mass flow (streaming)

Phi — energy flow (streaming)

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. u Inside it: x.u for the input signal, y.u for the weekend;

  • The input signal x.u multiplied by the coefficient k;

  • 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 streaming variables in non-directional ports

Each non-directional 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 any special marking.

  • 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                    # потенциал (потенциальная переменная)
        i = 0.0, [connect = Flow]  # ток (потоковая переменная)
    end
end

Here:

  • v — potential value (voltage);

  • i — the flow value (current).