Engee documentation
Notebook

Modelling of pipeline pressure control

This example demonstrates the modelling of pressure control in a pipeline.

Working principle of the model

The pipeline is described by blocks of the physical modelling library, in particular, the Volume block is responsible for its volume.

Through Valve 1 the liquid flows from Source to Volume. This in turn is connected to a Pressure sensor, from which the signal is fed to the control system represented by an adder, a setpoint adjuster and a PID controller.

Schematic diagram of the model:

liquid_pressure_regulator_1725958617592.png

The PID controller sends a control signal to Valve 1 to open or close, providing pressure regulation.

To the right of the Volume block, in the fluid path, is the Leak block, which is, like Valve 1, a controlled throttle.

The Leak block creates some "random" fluid flow from the simulated pipeline.

The fluid passing through this block eventually enters the Discharge, which is described by an infinite reservoir with a given pressure.

Boundary conditions

  1. At the source, the pressure is always maintained at 151.3 kPa.
  2. In the reservoir, which characterises the space where the liquid is discharged through a leak, the pressure is always 50 kPa.

Initial conditions:

  1. The initial pressure in the pipeline is 100 kPa.
  2. The setpoint signal is 100000, which in the context of regulation means 100 kPa.

Define the function to load and run the model:

In [ ]:
function start_model_engee()
    try
        engee.close("liquid_pressure_regulator", force=true) # закрытие модели 
        catch err # в случае, если нет модели, которую нужно закрыть и engee.close() не выполняется, то будет выполнена её загрузка после catch
            m = engee.load("$(@__DIR__)/liquid_pressure_regulator.engee") # загрузка модели
        end;

    try
        engee.run(m) # запуск модели
        catch err # в случае, если модель не загружена и engee.run() не выполняется, то будут выполнены две нижние строки после catch
            m = engee.load("$(@__DIR__)/liquid_pressure_regulator.engee") # загрузка модели
            engee.run(m) # запуск модели
        end
end
Out[0]:
start_model_engee (generic function with 1 method)

Running the simulation

In [ ]:
try
    start_model_engee() # запуск симуляции с помощью специальной функции, реализованной выше
    catch err
    end;

Selecting the temperature data of the plots from the simout variable and writing them to variables:

In [ ]:
sleep(5)
result = simout;
res = collect(result)
Out[0]:
28-element Vector{WorkspaceArray}:
 WorkspaceArray("liquid_pressure_regulator/Step.1")
 WorkspaceArray("liquid_pressure_regulator/Клапан 1.port_a.p")
 WorkspaceArray("liquid_pressure_regulator/Утечка.rho_b")
 WorkspaceArray("liquid_pressure_regulator/Утечка.Vdot_b")
 WorkspaceArray("liquid_pressure_regulator/Утечка.restriction_area_in.u")
 WorkspaceArray("liquid_pressure_regulator/Клапан 1.rho_a")
 WorkspaceArray("liquid_pressure_regulator/Add.1")
 WorkspaceArray("liquid_pressure_regulator/Утечка.mdot_b")
 WorkspaceArray("liquid_pressure_regulator/Утечка.port_b.p")
 WorkspaceArray("liquid_pressure_regulator/Утечка.Vdot_a")
 WorkspaceArray("liquid_pressure_regulator/Клапан 1.port_b.mdot")
 WorkspaceArray("liquid_pressure_regulator/Клапан 1.mdot_a")
 WorkspaceArray("liquid_pressure_regulator/Клапан 1.restriction_area_in.u")
 ⋮
 WorkspaceArray("liquid_pressure_regulator/PID Controller.1")
 WorkspaceArray("liquid_pressure_regulator/Клапан 1.Vdot_a")
 WorkspaceArray("liquid_pressure_regulator/Клапан 1.port_b.p")
 WorkspaceArray("liquid_pressure_regulator/Утечка.delta_p")
 WorkspaceArray("liquid_pressure_regulator/Утечка.mdot_a")
 WorkspaceArray("liquid_pressure_regulator/Утечка.rho_a")
 WorkspaceArray("liquid_pressure_regulator/Клапан 1.mdot_b")
 WorkspaceArray("liquid_pressure_regulator/Утечка.port_a.mdot")
 WorkspaceArray("liquid_pressure_regulator/Датчик давления.1")
 WorkspaceArray("liquid_pressure_regulator/Утечка.port_a.p")
 WorkspaceArray("liquid_pressure_regulator/Утечка.port_b.mdot")
 WorkspaceArray("liquid_pressure_regulator/Клапан 1.Vdot_b")

Writing the setpoint and pressure sensor signals to variables:

In [ ]:
control_signal = collect(res[1])
pressure = collect(res[25])
Out[0]:

10,001 rows × 2 columns

timevalue
Float64Float64
10.0100000.0
20.011.00048e5
30.021.00097e5
40.031.00145e5
50.041.00132e5
60.05100176.0
70.061.00164e5
80.071.00166e5
90.081.00155e5
100.091.00144e5
110.1100134.0
120.111.00123e5
130.121.00113e5
140.131.00103e5
150.141.00092e5
160.151.00082e5
170.161.00072e5
180.171.00061e5
190.181.00051e5
200.191.00041e5
210.21.00031e5
220.211.00022e5
230.221.00012e5
240.231.00002e5
250.2499992.2
260.2599982.6
270.2699973.0
280.2799963.5
290.2899954.0
300.2999944.6

Visualisation of simulation results

In [ ]:
using Plots
plot(control_signal[:,1], control_signal[:,2], label="Задатчик", linewidth=3)
plot!(pressure[:,1], pressure[:,2], label="Датчик давления", linewidth=3)
Out[0]:

Conclusion:

In this example, modelling of a physical object with an automatic control system has been demonstrated. The transient time is about 15 s, the pressure stabilises within acceptable limits, its minor fluctuations are related to the leakage of liquid from the pipeline.