Engee documentation
Notebook

Pipeline pressure control using Chart unit

In this example we will create control logic for pipeline pressure control. To create the algorithm we will use the Chart block of the finite automata library.

Working principle

Detailed description of the pipeline model is considered in the example on the following path:/user/start/examples/physmod/liquid_pressure_regulator. In this case we will briefly describe the model and focus on the points necessary for control.

The structure diagram of the model is presented below and also in the model hydro_control_chart.engee.

hydro_control_chart_1724956899773.png

We need to maintain the pressure in the Volume block. The change in pressure is due to accidental leakage. There is a Pressure Sensor in the circuit to measure the pressure. The pressure needs to be maintained according to the Setting.

Control logic

The Controller inputs two signals: setpoint and sensor value. The signal from the Controller output is input to the Valve. This signal determines the cross-sectional area.

The Chart block of the Controller contains three states. In the initial state, the difference between the set pressure and the measured pressure is determined. Then three transitions are possible.

  • To the state low, if the difference is negative and exceeds the set threshold. In this case we minimise the cross-sectional area of the orifice;
  • To the state up, if the difference is positive and exceeds the set threshold. Set the maximum cross-sectional area;
  • If the error is within the requested value, we stay in the initial state.

hydro_control_chart_1724953338268.png

Let's run the model and plot the graphs to evaluate the results.

Defining the function to load and run the model

Start the code cell to generate the function to run the model.

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

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

Obtaining modelling results

Let's run the simulation of the model using the function generated above.

In [ ]:
try
    start_model_engee()
    catch err
    end;

Let's write the logged signals to the variable simout. And convert them into a data array.

In [ ]:
result = simout;
res = collect(result)
Out[0]:
2-element Vector{WorkspaceArray}:
 WorkspaceArray("hydro_control_chart/Датчик давления.1")
 WorkspaceArray("hydro_control_chart/Уставка.1")

Let's write the values from the pressure sensor and the setpoint value to the variables.

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

2,001 rows × 2 columns

timevalue
Float64Float64
10.0100000.0
20.01100000.0
30.02100000.0
40.03100000.0
50.04100000.0
60.05100000.0
70.06100000.0
80.07100000.0
90.08100000.0
100.09100000.0
110.1100000.0
120.11100000.0
130.12100000.0
140.13100000.0
150.14100000.0
160.15100000.0
170.16100000.0
180.17100000.0
190.18100000.0
200.19100000.0
210.2100000.0
220.21100000.0
230.22100000.0
240.23100000.0
250.24100000.0
260.25100000.0
270.26100000.0
280.27100000.0
290.28100000.0
300.29100000.0

Visualisation of the obtained data

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

At 5 seconds into the simulation, the setpoint pressure increased to 120 kPa. The pipeline pressure reached the setpoint pressure at approximately 10 seconds and was around the set threshold $\pm$ 100 Pa.

Conclusion

In this example we have demonstrated pressure control in a pipeline using the control logic implemented in the Chart block.