Hydraulic shock modelling¶
In this example, we will study how we can model hydraulic shock in a long pipe using the Isothermal Fluid (IL) library blocks.
The flow of fluid in the pipe is controlled by a valve. First, the control system smoothly opens the valve, increasing the flow velocity but keeping the flow stationary. Then, when the valve is closed abruptly (0.1 s), we can observe the effect of water hammer.
Model description¶
At the top level, the model is as follows:
A pipeline connects two reservoirs, the first of which has a pressure of 6 atmospheres. The liquid will flow into the second tank, which also has a constant pressure of 5 atmospheres.
Between the two 25 metre long pipes is the Sensors subsystem, where the flow and pressure sensors are located. To preserve the topology of the model, the plotting module is placed in a separate subsystem "Instruments". It is possible to filter the data there, but in this model we only multiply the total pressure in pascals by a constant to get readings in atmospheres.
The operation of the valve control unit depends on the state variable sqitching_mode
, which can take the value "Fast"
or "Slow"
. Rapidly shutting off the flow puts the system into a very active unsteady regime, which we will demonstrate.
switching_mode = "Fast";
To model the valve we use the block Variable Local Restriction (IL)
, the pipes are represented by the blocks Pipe (IL)
. To see the effect of hydro-impact, it is necessary that the pipe model allows to simulate compressibility and inertia of the fluid (by default pipes do not take into account inertia, it must be enabled in the settings of the block Pipe (IL)
).
Modelling of fast valve shut-off¶
In this variant of the model, the step function that defines the valve overlap is smoothed using the transfer function $\frac{1}{0.01 s + 1}$. As a result, we observe a rather sharp transient process.
# Установим модель в режим быстрого переключения
switching_mode = "Fast";
# Загрузим и запустим модель
modelName = "water_hammer"
model = modelName in [m.name for m in engee.get_all_models()] ? engee.open( modelName ) : engee.load( "$(@__DIR__)/$(modelName).engee");
data = engee.run( modelName )
And, as we can see on the graphs, after a long period of steady-state operation, the pipes start to experience sharp pressure jumps, and the mass of liquid transported fluctuates equally sharply between 3 and 5 kg/sec.
gr()
plot(
plot( data["p_f"].time, data["p_f"].value, leg=false, title="Массовый расход, кг/с" ),
plot( data["mdot"].time, data["mdot"].value, leg=false, title="Давление, атм" ),
layout=(2,1)
)
Modelling of slow valve closure¶
If we control the valve slowly enough (by smoothing the step with the transfer function $\frac{1}{s + 1}$), we observe a smooth transient.
# Установим модель в режим быстрого переключения
switching_mode = "Slow";
# Запустим другой вариант модели
data = engee.run( modelName )
gr()
plot(
plot( data["p_f"].time, data["p_f"].value, leg=false, title="Массовый расход, кг/с" ),
plot( data["mdot"].time, data["mdot"].value, leg=false, title="Давление, атм" ),
layout=(2,1)
)
Conclusion¶
We have obtained a fairly convincing demonstration of the effect of hydraulic shock using a minimum of auxiliary blocks. We have built a system with two variants of operation (fast and slow valve closure) and have output the dashboard through a separate subsystem, successfully using the blocks From
and Goto
.
To make the model more visual, more pipeline segments could be added and the pressure between them measured, or a damped tank could be modelled