Engee documentation
Notebook

Pipeline pressure control using the Chart block

In this example, we will create a control logic for regulating the pipeline pressure. To create the algorithm, we will use the Chart block of the finite state machine library.

The principle of operation

A detailed description of the pipeline model is provided in the example along 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 management.

The structural diagram of the model is presented below, as well as in the model hydro_control_chart.engee.

hydro_control_chart--1724956899773.png

We need to maintain the pressure in the Volume unit. The pressure change is due to accidental leakage. For pressure measurement, a ** Pressure sensor** is present in the circuit. The pressure must be maintained according to the setpoint.

Control logic

To the entrance of the block The controller receives two signals: the setpoint and the value from the sensor. The signal from the output of the Controller is sent to the input of the Valve unit. This signal determines the cross-sectional area.

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

  • In the state of low if the difference is negative and exceeds the specified threshold. In this case, we minimize the cross-sectional area of the cathode hole.;
  • In the state of up if the difference is positive and greater than the set threshold. We set the maximum cross-sectional area;
  • If the error is within the threshold value, we remain in the initial state.
hydro_control_chart--1724953338268.png

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

Defining the function to load and run the model

Run the cell with the code to generate the model launch function.

In [ ]:
function start_model_engee()
    try
        engee.close("hydro_control_chart", force=true) # closing the model
        catch err # if there is no model to close and engee.close() is not executed, it will be loaded after catch.
            m = engee.load("$(@__DIR__)/hydro_control_chart.engee") # loading the model
        end;

    try
        engee.run(m) # launching the model
        catch err # if the model is not loaded and engee.run() is not executed, the bottom two lines after catch will be executed.
            m = engee.load("$(@__DIR__)/hydro_control_chart.engee") # loading the model
            engee.run(m) # launching the model
        end
end
Out[0]:
start_model_engee (generic function with 1 method)

Getting simulation results

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

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

Let's write the programmed signals into a variable simout. And convert them into an array of data.

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

We will 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

Visualization of the received data

In [ ]:
using Plots
plot(control_signal[:,1], control_signal[:,2], label="Setpoint")
plot!(pressure[:,1], pressure[:,2], label="Pressure sensor")
Out[0]:

At the 5th second of the simulation, the set pressure increased to 120 kPa. The pipeline pressure reached the setpoint at about 10 seconds and was in the area of the set threshold 100 Pa.

Conclusion

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