Engee documentation
Notebook

Simulation of pipeline pressure control

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

How the model works

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

Through Valve 1, liquid flows from the Source unit to the Volume unit. In turn, a pressure sensor ** is connected to it, from which the signal is sent to the control system, represented by an adder, a setpoint sensor and a PID controller.

Model diagram:

liquid_pressure_regulator--1725958617592.png

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

To the right of the Volume block, along the path of fluid movement, there is a block Leakage, which is, like Valve 1, a controlled throttle.

Block Leakage creates some "accidental" leakage of liquid from the simulated pipeline.

The liquid passing through this unit eventually enters the Discharge, which is described by an infinite reservoir with a set pressure.

Boundary conditions

  1. The pressure in the source is always maintained at 151.3 kPa.
  2. In the tank, which characterizes 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.

Defining 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;

Extracting site temperature data from the simout variable and writing it to variables:

In [ ]:
result = simout;
res = collect(result)
Out[0]:
14-element Vector{WorkspaceArray}:
 WorkspaceArray{Float64}("liquid_pressure_regulator/Клапан 1.port_a.p")
 WorkspaceArray{Float64}("liquid_pressure_regulator/Клапан 1.restriction_area_in")
 WorkspaceArray{Float64}("liquid_pressure_regulator/Клапан 1.rho_a")
 WorkspaceArray{Float64}("liquid_pressure_regulator/Задатчик.1")
 WorkspaceArray{Float64}("liquid_pressure_regulator/Клапан 1.mdot_a")
 WorkspaceArray{Float64}("liquid_pressure_regulator/Сумматор.1")
 WorkspaceArray{Float64}("liquid_pressure_regulator/Клапан 1.delta_p")
 WorkspaceArray{Float64}("liquid_pressure_regulator/Клапан 1.rho_b")
 WorkspaceArray{Float64}("liquid_pressure_regulator/Клапан 1.Vdot_a")
 WorkspaceArray{Float64}("liquid_pressure_regulator/Клапан 1.port_b.p")
 WorkspaceArray{Float64}("liquid_pressure_regulator/Клапан 1.mdot_b")
 WorkspaceArray{Float64}("liquid_pressure_regulator/Датчик давления.1")
 WorkspaceArray{Float64}("liquid_pressure_regulator/PID-регулятор.1")
 WorkspaceArray{Float64}("liquid_pressure_regulator/Клапан 1.Vdot_b")

Recording of setpoint and pressure sensor signals in variables:

In [ ]:
control_signal = collect(res[4])
pressure = collect(res[12])
Out[0]:
10001×2 DataFrame
9976 rows omitted
Rowtimevalue
Float64Float64
10.0100000.0
20.011.00783e5
30.021.01528e5
40.031.00949e5
50.041.01504e5
60.051.00924e5
70.061.00693e5
80.071.00127e5
90.0899619.1
100.0999082.9
110.198723.7
120.1198441.9
130.1298267.5
999099.891.20968e5
999199.91.20968e5
999299.911.20967e5
999399.92120966.0
999499.931.20965e5
999599.941.20964e5
999699.951.20964e5
999799.961.20963e5
999899.971.20962e5
999999.981.20961e5
1000099.991.20961e5
10001100.01.2096e5

Visualization 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, a simulation of a physical object with an automatic control system was demonstrated. The transition time is about 15 seconds, the pressure stabilizes within acceptable limits, and minor fluctuations are associated with fluid leakage from the pipeline.