Engee documentation
Notebook

Hydraulic system modelling

This example will demonstrate the modelling of a hydraulic cylinder assembled from the blocks of the base library.

image.png

The figure shows a schematic diagram of the model. The pump model directs the flow $Q$, generating a pressure $p1$, under the influence of which the laminar flow $q1ex$ flows to the outlet. The control valve models turbulent flow through a variable area orifice. This flow, $q12$, forms an intermediate pressure, $p2$, which undergoes a subsequent drop in the line connecting it to the actuator cylinder. The pressure in the cylinder, $p3$, moves the piston, which is under the force of the spring, bringing it to the x position.

Schematic of the model in Engee:

single_hydraulic_cylinder_simulation_1707475635711.png

At the pump outlet, the flow is divided into two components: the leakage flow and the flow to the control valve. We model the leakage flow, $q1ex$, as a laminar flow (see equation block 1).

In [ ]:
Pkg.add(["CSV"])
In [ ]:
cd( @__DIR__ ) # Переместимся в каталог, где лежит текущий скрипт
homePath = string(@__DIR__)
Out[0]:
"/user/start/examples/base_simulation/single_hydraulic_cylinder_simulation"

Equation block 1

$$Q = q_{12} + q_{1ex}$$

$$q_{1ex} = C_2 \cdot p_1 $$

$$p_1 = \frac{(Q - q_{12})}{C_2}$$

where:

  • $Q$ - pump flow
  • $q_{12}$ - flow to the control valve
  • $q_{1ex}$ - leakage flow
  • $C_2$ - flow coefficient

The turbulent flow through the control valve is modelled. The function $sgn$ and the module allow the flow in both directions to be considered (see equation block 2).

Equation block 2

$$q_{12}= C_d \cdot A \cdot \text{sgn}(p_1-p_2) \cdot \sqrt{\frac{2}{\rho}|p_1-p_2|}$$ Where:

  • $q_{12}$ - flow through the control valve
  • $C_d$ - flow coefficient through the orifice
  • $A$ - orifice area
  • $p_2$ - pressure after the control valve
  • $\rho$ - liquid density

The fluid pressure in the cylinder is increased by this flow. The compressibility of the fluid has also been modelled (see equation block 3).

Equation block 3

$$ \frac{dp_3}{dt}= \frac{\beta}{V_3} \left(q_{12} - A_c \frac{dx}{dt}\right) $$ $$ V_3 = V_{30} + A_c \cdot x $$

Where:

  • $V_3$ - volume of liquid at pressure $p_3$,
  • $dp_3/dt$ - time rate of pressure change in the cylinder,
  • $\beta$ - volume modulus of elasticity of liquid,
  • $V_{30}$ - volume of liquid in the piston at $x = 0$,
  • $A_c$ - cross-sectional area of the cylinder

The masses of the piston and spring were not considered due to the large hydraulic forces. Equation block 4 calculates the balance of forces on the piston.

Equation block 4

$$ x= p_3\frac{A_c}{K} $$ $$ \frac{dx}{dt}= \frac{dp_3}{dt} \frac{A_c}{K} $$ $$ q_{23}=q_{12}=C_1 \left( p_2 - p_3 \right) $$ $$ p_2= p_3 + \frac{q_{12}}{C_1} $$

Where:

  • $K$ - spring stiffness
  • $C_1$ - laminar flow coefficient

Pump" subsystem

Double-click on the subsystem "Pump" to open the pump model. It calculates the delivery pressure depending on the flow rate of the pump itself and the flow rate of the system components downstream. A one-dimensional table defines the flow data as a function of time. The model calculates the pressure $p1$, as specified in Equation Block 1. Since $Qout = q12$ is a direct function of $p1$ (through the control valve), an algebraic loop is formed. Setting the initial pressure value, $p10$, provides a more efficient solution.

single_hydraulic_cylinder_simulation_1707296300526_2.png

Valve/Hydraulic cylinder" subsystem

Double-click on the subsystem "Valve/Hydraulic cylinder" to open the control valve and hydraulic cylinder models. The system of differential algebraic equations models the pressure rise in the cylinder with the pressure $p3$, which appears as a derivative in equation block 3. If we neglect the mass of the piston, its position and spring force are directly proportional to $p3$, and its velocity is directly proportional to the time derivative of $p3$. The intermediate pressure $p2$ is the sum of $p3$ and the pressure drop due to flow from the valve into the cylinder (Equation Box 4).

The control valve subsystem calculates the flow through the orifice (Equation block 2). It uses the inlet and outlet pressures of the orifice and a variable area as inputs.

single_hydraulic_cylinder_simulation_1707297894902_2.png

Determination of hydraulic system parameters and initial conditions:

The system parameters and initial conditions are defined in the code cell:

In [ ]:
A = 0.01
Ac = 0.001
Beta = 700000000
C1 = 2.50000000000000e-08
C2 = 3.00000000000000e-09
Cd = 0.610000000000000
F20 = 0
I = 100
K = 20500
V30 = 2.000000000000000e-05
V2 = 1.250000000000000e-05
V1 = 1.250000000000000e-05
rho = 800
Qmax = 0.005000000000000
p10 = 4.166666666666667e+06
M = 2500
m = 1.000000000000000e-03
L = 1.500000000000000
KA = 0.030000000000000;
Cdsqrt = Cd*sqrt(2/rho);
AcK = Ac/K
C1_1 = 1/C1
C2_1 = 1/C2
Ac2K = Ac^2/K;
Sample_Time = 0.0001;

**The code cell must be executed before running the simulation.

Run and load the model:

This code cell uses methods to interact with the control flow of the programme, try/catch:

In [ ]:
try
    engee.close("single_hydraulic_cylinder_simulation", force=true) # закрытие модели 
    catch err # в случае, если нет модели, которую нужно закрыть и engee.close() не выполняется, то будет выполнена её загрузка после catch
        m = engee.load("$(@__DIR__)/single_hydraulic_cylinder_simulation.engee") # загрузка модели
    end;
In [ ]:
try
    engee.run(m, verbose=true) # запуск модели
    catch err # в случае, если модель не загружена и engee.run() не выполняется, то будут выполнены две нижние строки после catch
        m = engee.load("$(@__DIR__)/single_hydraulic_cylinder_simulation.engee") # загрузка модели
        engee.run(m, verbose=true) # запуск модели
    end
Building...
Progress 0%
Progress 0%
Progress 5%
Progress 10%
Progress 15%
Progress 20%
Progress 25%
Progress 30%
Progress 35%
Progress 40%
Progress 45%
Progress 50%
Progress 55%
Progress 60%
Progress 65%
Progress 70%
Progress 75%
Progress 80%
Progress 85%
Progress 90%
Progress 95%
Progress 100%
Out[0]:
Dict{String, DataFrame} with 3 entries:
  "p3" => 1001×2 DataFrame…
  "p2" => 1001×2 DataFrame…
  "p1" => 1001×2 DataFrame

Load and visualise data from the simulation.

Reading csv files with data on pressure changes at different sections of the hydraulic system, with subsequent conversion into dataframe and matrix:

In [ ]:
using DataFrames, Plots, CSV # подключение библиотек
p1 = Matrix(CSV.read("p1.csv", DataFrame)); #загрузка данных об изменении давления на выходе насоса
p2 = Matrix(CSV.read("p2.csv", DataFrame)); #загрузка данных об изменении давления после регулирующего клапана
p3 = Matrix(CSV.read("p3.csv", DataFrame)); #загрузка данных об изменении давления в цилиндре

Connecting backend - method of displaying graphics:

In [ ]:
plotlyjs()
Out[0]:
Plots.PlotlyJSBackend()

Drawing a graph describing the pressure changes in the sections of the hydraulic system:

In [ ]:
plot(p1[:,1], p1[:,2], label="Изменение давления на выходе насоса")
plot!(p2[:,1], p2[:,2], label="Изменение давления после регулирующего клапана")
plot!(p3[:,1], p3[:,2], label="Изменение давления в цилиндре")
Out[0]:

At the beginning of the simulation, the control valve has zero orifice area, which then increases to $1*10^{-4}$ sq.m. throughout the simulation duration of 0.1 seconds. When the valve is closed, the entire pump flow is converted to leakage.

When the valve opens, the pressures $p2$ and $p3$ increase while $p1$ decreases in response to the increase in flow. When pump flow stops, the spring and piston act as a hydraulic accumulator and $p3$ continuously decreases. The behaviour changes as flow from the pump is restored.

Conclusion:

This example demonstrated the simulation of a hydraulic system assembled from a library of basic blocks. The simulation data was loaded, preprocessed and visualised using the functions of the called libraries.

Blocks used in example