open channel flow with variable bottom slope
TRANSCRIPT
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
1/30
BUDAPEST UNIVERSITY OF TECHNOLOGY AND ECONOMICSDEPARTMENT OF HYDRODYNAMIC SYSTEMS
MECHANICAL ENGINEERING AND MODELING (MSC)
2010/2011SPRING SEMESTER
UNSTEADY FLOW IN PIPE NETWORKS
Open Channel Flow with
Variable Bottom Slope
Documentation
Name: Lszl ARANY (H8QF9G)Tams BAKONYI (PCDSEN)
Supervisor:Csaba HS, PhD
Date: 10. 05. 2011
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
2/30
2
I. INTRODUCTION
The main task of this project was to simulate an open channel flow with variable bottom
slope by using the method of characteristics (MoC) with the help of MATLAB. The final
simulation has been reached throughout two main simulation steps.
Firstly, a simpler wave pool problem had been simulated in order to introduce the
operating of the basic equations of method of characteristics and its boundary conditions and
the usability of MATLAB in these kinds of problems.
In the second step, the final simulation of the open channel flow having variable bottom
slope had been done as an additional extension of the previous program code with somevariations in it. The detailed explanation of the simulations can be seen later.
II. METHOD OF CHARACTERISTICSTwo equations governing the flow are the continuity and the equation of motion.
Continuity equationcan be written as follows:
0
x
vy
x
yv
t
y, (1)
in whichy [m] corresponds to the height of the water level at the a actual position;
v[m/s] corresponds to the velocity of the flow.
Equation of motionhas this form:
vvDx
zga
x
yg
x
vv
t
vx
2
, (2)
in which on the RHS the three source terms (denoted by S) are shown that are arising fromthe acceleration, variable bottom slope and the flow friction, respectively.
The third important connection shows the relationship between the actual height of water
level (y) and the velocity of the pressure wave (c [m/s]):
g
cy
2
ygc . (3)
After substituting the previous equation (3) into (1) and multiplying byg the following
equation is given:
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
3/30
3
02
22
x
vc
x
cv
t
c. (4)
Having used this expressiont
cc
t
c
2
2
and divided by cthe following equation is given:
022
x
vc
x
cv
t
c. (5)
In the next step the continuity equation is multiplied byc
gand the equation of motion is
added to it:
Sx
vc
x
cv
x
cc
x
vvcv
t
222 . (6)
By rearranging the terms the two final equations are given:
Scvx
cvcvt
22 , (7)
Scvx
cvcvt
22 . (8)
In which:
cv 2 , (9)
cv 2 . (10)
Further valid notations are:
xcv
tDt
D, (11)
xcv
tDt
D. (12)
With the help of the notations used in (9-12) the following equations can be written in this
form:
SDt
D
, (13)
SDt
D
. (14)
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
4/30
4
According to the main equations of method of characteristics (13 and 14) the following
relationships and the relating figures (Fig. 1-3) are shown below.
Fig. 1: Method of characteristics
Fig. 2: Context of and
Fig. 3: Desired and given parameters
R
i
L
i
jS
t
1
L
i
L
i
jS
t
1
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
5/30
5
The foundation of method of characteristics assumes that there are lines from grid-points
on which the values of certain quantities (here the velocity vand c) are changing by means of
a known context. In this case the changing of and are given, which only depend on v
and cbased on (9, 10).The expressions refer to changing of cv, and cv, are illustrated in Figure 2. It can
be observed that the change of the value of cv, (or cv, ) during one step t on a
given line is equal to the source terms (S) given in the starting point of the given line. The
given line can be defined by its slope (m).
In Figure 1 it can be seen that each grid-point at the known time level can have two slopes
having the expressions:
Slopes from left denoted by red:cvt
xdtdxmL
1 . (15)
Slopes from left denoted by purple:cvt
x
dt
dxmR
1. (16)
Thus, in each grid point and in each time step two variables are looked for:
The actual velocity:
s
mv ;
The actual height of water level my , which is expressed by the pressure wave
velocity
s
mc using Eq. (3): my
s
mg
s
mc
2
.
Thus, if the value of vand care known in a certain grid-point at the known time level, the
two slopes starting from this grid-point are also known because the slopes depend on only v
and cin the point.
However, our desired points (where the values of vand cshould be known in the next
numerical step) are given by their positions according to the numerical square-grid. In Figure
1 this desired point is the grid-point having the coordinates 1, ij .
The first main task of the method of characteristics is to find the point from which the
starting right-handed (or so left-handed) slope accurately intersects the desired point in the
unknown time level. In Figure 1-3 point Left denoted by L is the point that has the left
handed-slope accurately intersecting the desired point 1, ij . In Figure 1-3 point Right
denoted by R is the point that has the right handed-slope that accurately intersecting the
desired point 1, ij . The x position of the pointLand R (in Fig. 3 denoted byL
X andR
X )
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
6/30
6
have to be determined for every inner space grid-point. Grid-points lying on the side boundary
of the calculation zone will be discussed later.
The slopes are only known at the known time step (step i in the Figure 1-3) because at
this time level the values of vand care known in each grid point and thus we know all of the
slopes because the slopes only depend on vand c(Eqs.(15) and (16)). However, if we know
the values of vand c in each grid point at a certain time level (so if we know all the slopes
also), we can approximate the values of vand c in every xposition between the grid points
also, with the help of simple linear interpolation. This approximation using linear
interpolation between the grid points gives quite accurate results and good stability properties.
On the whole, we are looking for thexcoordinates of point L(eft) and R(ight) RL xx and
whose slopes are intersecting each other accurately in the desired point at the next time
level, here it is the point 1, ij .
In MATLAB there is a helpful command for this position-seeking action called
interp1().
Explanation of MATLAB command interp1(, , )
The command interp1(x1, x2, x3) requires three variables in itself. The necessary
parameters for understanding are depicted in Figure 4 and 5 shown below.
Fig. 4: Explanation of command interp1()
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
7/30
7
Fig. 5: Explanation of command interp1()(2)
In Figure 4 and 5, jx denotes the xcoordinate of the lines started from jx after t .
The following equation can be written:
tcvxx jjjj
. (17)
In Figure 4 and 5, jx denotes the xcoordinate of the lines started from jx after t .
The following equation can be written:
tcvxx jjjj . (18)
We are seeking RL xx and , with the help of interp1 we can give it by this command:
First case: ))(,,(interp1 ixxxx jjL . (comm1)
The first variable required by the command is defined by Eq. (17) and (18) for both the
left-handed and right-handed slopes. In this case this is denoted by jx .
The second variable is thex-coordinate of the actual known grid point. In this case this is
denoted by jx .
The third variable is the next desired point where the characteristic line should arrive
at. In this case this is denoted by )(ix and means the point 1, ij .
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
8/30
8
Second case: ))(,,(interp1 ixxxx jjR . (comm2)
The first variable required by the command is defined by Eq. (17) and (18) for both the left-
handed and right-handed slopes. In this case this is denoted by jx .
The second variable is thex-coordinate of the actual known grid point. In this case this is
denoted by jx .
The third variable is the next desired point where the characteristic line should arrive
at. In this case this is denoted by )(ix and means the point 1, ij .
Thus, by means of command interp1()the soughtx-coordinates of the points L(eft) and
R(ight) can be defined. If RL xx and are known the values of v and c at these RL xx and
coordinates can also be defined by using linear interpolation from the encircling known gridpoint. This interpolations can be also performed by the interp1()command as follows:
),,(interp1 LjjL xvxv , (comm3)
),,(interp1 LjjL xcxc , (comm4)
),,(interp1 RjjR xvxv , (comm5)
),,(interp1 RjjR xcxc . (comm6)
Having known the values ofL
v ,L
c ,R
v andR
c (and thus the slopes also), an equation
system can be derived for the desired point where the slopes intersect each other to determine
the sought variables 1ijv ,1i
jc (at the next time step).
Since the characteristic line starting from point L(eft) and the characteristic line
starting from point R(ight) intersect each other in point 1, ij , the following equation
system is given to determine 1ijv and1i
jc .
Equation of (see Fig. 2):
L
i
L
i
jS
t
1. (19)
Equation of (see Fig. 2):
R
i
L
i
jS
t
1. (20)
From Eqs. (19) and (20) the following system has this form:
L
i
L
i
j St 1 ;
.1
R
i
R
i
j St (21)
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
9/30
9
Considering Eqs. (9) and (10) and the source term is assumed to be
vvDdx
dzgS
2
,(because the acceleration term in the source term is not present in this
problem) the system (21) changes its form as follows:
iL
i
LL
i
L
i
L
i
j
i
j vvDdx
dzgtcvcv
222
11 ; (22)
iR
i
RR
i
R
i
R
i
j
i
j vvDdx
dzgtcvcv
222
11 . (23)
From Eqs. (22) and (23) it can be observed that we have only two unknowns: 1ijv and1i
jc .
The sum of the Eq.(22) and (23) gives an expression for 1ijv :
iR
iR
R
iR
iR
iL
iL
L
iL
iL
ij vv
Ddxdzgtcvvv
Ddxdzgtcvv
22
222 1 ;
iR
i
R
i
L
i
LRL
i
R
i
L
i
R
i
L
i
j vvD
vvDdx
dzg
dx
dzgtccvvv
22222
1 ;
iR
i
R
i
L
i
LRL
i
R
i
L
i
R
i
L
i
j vvD
vvDdx
dzg
dx
dzgtccvvv
2222
2
11 (24)
After subtracting Eq.(23) from (22) an expression for1i
jc can be obtained:
iR
i
RR
i
R
i
R
i
L
i
LL
i
L
i
L
i
j
i
j vvDdx
dzgtcvvv
Ddx
dzgtcvcc
22
2222
11
iR
i
R
i
L
i
LRL
i
R
i
L
i
R
i
L
i
j vvD
vvDdx
dzg
dx
dzgtccvvc
22224
1
iR
i
R
i
L
i
LRL
i
R
i
L
i
R
i
L
i
j vvD
vvDdx
dzg
dx
dzgtccvvc
2222
4
11 (25)
The water level height at point 1, ij can be directly expressed from 1ijc based on
Eq.(3):
2
1
2222
16
1
iR
i
R
i
L
i
LRL
i
R
i
L
i
R
i
L
i
j vvD
vvDdx
dzg
dx
dzgtccvv
gy
(26)
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
10/30
10
Boundary conditions
At the boundaries the calculation of the variables is changed a bit. At the boundary of
computational domain one of the sought variables are directly known by means of the type of
boundary condition. In our case, by the apropos of the wave pool and the variable bottomslope problems two different types of boundary condition were arisen (known water level
height and known velocity at the boundary).
1.) Known water level height at the front boundary (1
y is known in every time step)
If the water level height is known, the velocity of pressure waves (1c ) is also known due
to Eq.(3).
Fig. 6: Front boundary condition with given water level height
In this case, we are only interested in the characteristic lines of and the interpolation
into the point R(ight). Since1c is given in every time step, the calculation is reduced only for
1v in every time step.
Here, the following equation can be written to express
1
1
i
v :
R
i
R
i St 11 ;
iR
i
RR
i
R
i
R
iivv
Ddx
dzgtcvcv
222
1
1
1
1
;
iR
i
RR
i
R
i
R
iivv
Ddx
dzgtcvygv
222
1
1
1
1
iR
i
RR
ii
R
i
R
i vvDdx
dzgtygcvv
222 11
1
1
. (27)
1
1
iy is known in every time step!
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
11/30
11
2.) Known water level height at the end boundary (Ny is known in every time step)
If the water level height is known, the velocity of pressure waves (Nc ) is also known due
to Eq.(3).
Fig. 7: End boundary condition with given water level height
In this case, we are only interested in the characteristic lines of and the interpolation
into the point L(eft). SinceNc is given in every time step, the calculation is reduced only for
Nv in every time step.
Here, the following equation can be written to express 1iNv :
L
i
L
i
N St 1 ;
iL
i
LL
i
L
i
L
i
N
i
N vvDdx
dzgtcvcv
222 11
;
iL
i
LL
i
N
i
L
i
L
i
N vvDdx
dzgtccvv
222 11
iL
i
LL
i
N
i
L
i
L
i
N vvDdx
dzgtygcvv
222 11
. (28)
1iNy is known in every time step!
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
12/30
12
3.) Known velocity at the front boundary (1v is known in every time step)
If the velocity is known, the parameter looked for is the pressure wave velocity1c (and
the water level height1
y ) at the boundary.
Fig. 8: Front boundary condition with given velocity
The equations are the same like in the previous cases, but here the sought variable is the1
1
i
y throughout1
1
i
c .
R
i
R
i St 11 ;
iR
i
RR
i
R
i
R
iivv
Ddx
dzgtcvcv
222
1
1
1
1
;
;2
22 111
1
iR
i
RR
ii
R
i
R
i vvDdx
dzgtvcvc
;2
22
1 11
1
1
iR
i
RR
ii
R
i
R
i vvDdx
dzgtvcvc
.2
24
12
1111
iRiR
R
iiRiRi vvDdx
dzgtvcv
gy
(28)
1
1
iv is known in every time step!
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
13/30
13
4.) Known velocity at the end boundary (Nv is known in every time step)
If the velocity is known, the parameter looked for is the pressure wave velocityNc (and
the water level heightNy ) at the boundary.
Fig. 9: End boundary condition with given velocity
The equations are the same like in the previous cases, but here the sought variable is the
1iNy throughout
1iNc .
LiLiN St 1 ;
iL
i
LL
i
L
i
L
i
N
i
N vvDdx
dzgtcvcv
222 11
;
iL
i
LL
i
N
i
L
i
L
i
N vvDdx
dzgtvcvc
222 11
;
iL
i
LL
i
N
i
L
i
L
i
N vvDdx
dzgtvcvc
22
2
1 11 ;
2
11
22
4
1
iL
i
LL
i
N
i
L
i
L
i
N vvDdx
dzgtvcv
gy
. (29)
1iNv is known in every time step!
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
14/30
14
III. WAVE POOLPROBLEMThe problem is illustrated in Figure 10.
Fig. 10: Schematic figure of the wave pool
Given a wave pool with its dimensions:
Length: mL 10 ,
Width: mB 10 ,
Initial water level height on both boundaries: myyy N 110 .
The number of grid points is denoted byN.
Consequently, the distance between the grid points:
1
N
Ldx . (30)
In this problem, there is no variable bottom slope; no acceleration and no flow
friction are assumed, so the source term (denoted by S) is completely zero.
Due to the previous assumption the equations derived in Chapter II could be significantly
simplified here.
The main simplification can be noticed from Eqs.(19) and (20). The simplified equations
show that the value of cv 2 and cv 2 are constants along the characteristic lines.
i
L
i
j
i
L
i
j
L
i
L
i
j
tS
t
1
11
0 (31)
i
R
i
j
i
R
i
j
R
i
R
i
j
tS
t
1
11
0 (32)
Henceforward, for the sake of simplicity: is denoted by1
K : 1K (33)
is denoted by 2K : 2K (34)
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
15/30
15
Innerspace points:
The innerspace points (N=2N-1) are calculated by the method of characteristics
introduced in Chapter II. However, in this problem we have more simplified equations than in
Chapter II due to the absent of source terms.X-coordinates of the actual L(eft) and the R(ight)
points are approximated by the command interp1(), and the actual variable values at these
points (Lv , Lc , Rv and Rc ) are also interpolated by means of interp1()(see later in the
program code). But, in this case the value of1
K and2
K are constant along the slopes.
Thus, for the next desired point, where the slopes starting from L(eft) and R(ight) intersect
each other, the following equation system is given:
11
1 22 ij
i
j
i
L
i
L cvKcv , (35)
112 22
ij
ij
iR
iR cvKcv . (36)
Since, the values of1
K and 2K are known at the time level i , adding and subtracting of
Eqs. (35) and (36) gives an expression for 1ijv ,
1ijc and
1ijy :
2
211 KKv ij
, (37)
4
211 KKc ij
, (38)
g
KKy ij
16
2
211. (39)
Boundary conditions:
Front boundary: At the front boundary we have a wave excitation that means a given
water level height in every time step. The excitation is harmonic, and is expressed by the
following equation (Figure 10). Index 1 is referring to the first grid point.
)sin(01 twayy (40)
Here, only the velocity is needed to calculate at the front boundary. Figure 6 relates to this
boundary condition (see Chapter II).
The equations are:
1
1
1
12 22 iiiR
i
R cvKcv , (41)
1
1
11 ygcc ii . (42)
From (41) and (42) the new velocity can be obtained as follows:
121
1 2 ygKvi
(43)
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
16/30
16
End boundary: At the front boundary we have static wall on which the velocity is always
zero. Thus, we have a velocity boundary condition, regarding to Figure 9. IndexNis referring
to the last grid point.
0
Nv (44)Here, only the water level is needed to calculate at the end boundary.
The equations are:
11
1 22 iN
i
N
i
L
i
L cvKcv , (45)
01 iNi
N vv . (46)
From (45) and (46) the new velocity can be obtained as follows:
2
11 Kci
N
, (46)
g
Ky iN
4
2
11. (47)
Having known the equations (37),(39), (40), (43), (44) and (47) we can calculate the
desired yand vvalues for all the points (innerspace points and the two boundaries) for the
next time step.
IV. WAVE POOL PROBLEM MATLAB CODEWITH EXPLANATION
The program has five major parts. In the first part the general information, initial
conditions and constant parameters are given. The second part of the program, called Main
loop, consists of the plotting and the definitions of functions using the method of
characteristics for the innerspace and boundary points. The third part describes the accurate
and necessary equations for the calculation of the new values of v and y for the innerspace
points. These values will be recalled in the Main loop. The 4thpart describes the accurate and
necessary equations for the calculation of the new values of vandyfor at the front boundary.
The 5thpart of the program describes the accurate and necessary equations for the calculation
of the new values of v and y for at the end boundary. These boundary values will be also
recalled in the Main loop.
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
17/30
17
Explanation of MATLAB command li nspace(0, L, N)
It divides the distance between 0andLintoNequal parts and stores the point coordinates in a
vector.
functionhullammedence %name of the function
clear all, clc, clf
globaldtglobalwa
% PARS, definition of the constants characterising the problempars.L=10; % wave pool lengthpars.B=10; %wave pool widthpars.N=31; %number of grid pointspars.g=9.81; %gravity
omega=2; %frequency of the wave excitationxgrid=linspace(0,pars.L,pars.N); % dividing of the bottom of wave pool (see formerfor the command explanation)wa=0.2; % amplitude of the excitation
% Simulation timetmax=50; % simulation time in secdt=0.05;% setting of the time stept=0; % beginning of the simulationPauseTime=0.0001;
% Initial Conditionsy0=1; % initial water levelv0=0; % initial water velocityy=y0*ones(1,pars.N); % initial water level vectorv=v0*ones(1,pars.N); % initial velocity vectorynew=y; % new water level vectorvnew=v; % new velocity vector
% Main loop
whilet
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
18/30
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
19/30
19
% Calculation of v(alpha), c(alpha), v(beta), c(beta), linear interpolation to theL(eft) and the R(ight) points
cia=interp1(x,c,x_innen_alpha); %see (comm4)via=interp1(x,v,x_innen_alpha); %see (comm3)cib=interp1(x,c,x_innen_beta); %see (comm6)
vib=interp1(x,v,x_innen_beta); %see (comm5)
% Computing the constant k valuesk1=via+2*cia; % definition of K1 see Eq.(35)k2=vib-2*cib;% definition of K2 see Eq.(36)
% Calculation of the new y and v valuesvnew(i)=(k1+k2)/2; % see Eq.(37)ynew(i)=(k1-k2)^2/(16*g);% see Eq.(39)
end
end
functionvf=BC_front(y,v,yy,pars) % definition of the function of method ofcharacteristics for the Front Boundary Condition
globaldt
% Variables at the frontm1f=0;m2f=0;Xf=0;Kf=0;N=pars.N; %number of grid pointsg=pars.g;dx=pars.L/(pars.N-1);x=linspace(0,pars.L,pars.N); %resolutionc=(g*y).^0.5; %see Eq.(3)
x_beta=x+(v-c)*dt; % equation for the x-position of the appropriate R(ight) point ,seeEq.(18)x_innen_beta=interp1(x_beta,x,0); %linear interpolation of x-coordinate of the R(ight)
point where the x-coordinate of the desired point is zero (third variable in thecommand), see (comm2)
% linear interpolation to the R(ight) point (pressure wave velocity and the velocity)ci=interp1(x,c,x_innen_beta); %see(comm6)vi=interp1(x,v,x_innen_beta); %see(comm5)
% v and c at the determined positionVXf=vi; %another notationCXf=ci; %another notation
% The constant K value at the frontKf=VXf-2*CXf; %see Eq.(41)
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
20/30
20
% Return value of the functionvf=Kf+2*sqrt(g*yy); %see Eq.(43)
end
functionye=BC_end(y,v,vv,pars)% definition of the function of method of
characteristics for the End Boundary Conditionglobaldt
% Variables at the endN=pars.N;g=pars.g;dx=pars.L/(pars.N-1);L=pars.L;x=linspace(0,pars.L,pars.N);c=(g*y).^0.5; %see Eq.(3)
xi=L; % defining the position, we are at the position L, so at the end of the wave
pool
x_alpha=x+(v+c)*dt; % equation for the x-position of the appropriate L(eft) point,see Eq.(17)
x_innen_alpha=interp1(x_alpha,x,xi);%linear interpolation of x-coordinate of theL(eft) point where the x-coordinate of the desired point is xi defined as L (thirdvariable in the command), see (comm1)
% linear interpolation to the L(eft) point (pressure wave velocity and the velocity)ci=interp1(x,c,x_innen_alpha);%see(comm4)vi=interp1(x,v,x_innen_alpha);%see(comm3)
% v and c at the determined positionVXe=vi;%another notationCXe=ci; %another notation
% The constant K value at the endKe=VXe+2*CXe;%see Eq.(45)
% Return value of the functionye=Ke^2/(4*g);%see Eq.(47)
end
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
21/30
21
V. VARIABLE BOTTOM SLOPE PROBLEMThe problem is illustrated in Figure 11. Constant water level heights are given at both
boundaries (can be different water levels) and the initial water level can be seen in Figure 11.
After the first time step the initial water level will change and waves will propagate for the
left-hand side and the right-hand side. The variable bottom slope is approximated as a x2sin
function.
Fig. 11: Open channel flow with variable bottom slope
In this problem, we consider the source term (S) that consists of the flow friction term and
the term arising from the variable bottom slope. Thus, we need the same equations derived in
Chapter II.
The dimensions of the pool remain the same like in the case of the wave pool.
The governing equations are:
i
L
i
LL
i
L
i
j
L
i
L
i
jvv
Ddxdzg
tS
t 2
11
; (48)
i
R
i
RR
i
R
i
j
R
i
R
i
jvv
Ddx
dzg
tS
t 2
11
. (49)
In this kind of problems, the flow friction part fS in the source term are usually
approximated by the Mannings friction rule.
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
22/30
22
The Mannings friction rule says:
3/42
2
2 hf
RA
nQQvv
DS
, (50)
In which: vAQ - Volume flow rate
sm
3
; (51)
01.0n - Mannings constant; (52)
Bg
cByA
2
- Actual cross-section 2m (53)
P
ARh - Hydraulic radius m (54)
gcByBP
2
22 - Wetted perimeter for rectangular channel m (55)
The other source term arisen due to the bottom slope is denoted bylS and defined as a
xH 2sin function, whereHmeans the amplitude of the function.
Thus the whole source term (S) has this form:
3/42
2
h
flRA
nQQ
dx
dzgSSS
. (56)
In this program the variable bottom slope is generated between the coordinates L0 and
L0+LS with the maximum height ofH with this function (Fig.11). This function satisfies the
requirements.
2
0sin)(
LS
LxHxz (57)
From Eq.(57):
LSLS
Lx
LS
LxH
dx
dzgSl
0cos
0sin2 (58)
For the sake of stability a control cycle is applied in the program code for the time step
selection. The aim of this selection is to control the Courant-number to be smaller than one.
Thus, the flow doesnt traverse spatially more than one complete grid (with the dimension dx)
during one time step. This criterion is very important from the point of view of stability.
For the time step it can be written:
cv
t
dx
. (59)
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
23/30
23
From Eq.(59) the selection criterion for the time step can be derived with a safety factor C
as follows:
Cygv
dxC
cv
dxt
(60)
Innerspace points: The equations for the new vandy values are the same as derived in
Chapter II., but having applied the Mannings friction rule the following equations can be
obtained:
3/42
2
3/42
2
1 222
1
hRR
RR
hLL
LL
RL
i
R
i
L
i
R
i
L
i
jRA
nQQ
RA
nQQ
dx
dzg
dx
dzgtccvvv (61)
(62)
Boundary conditions:
Front boundary: At the front boundary we have a constant water level height in every
time step. Here, only the velocity is needed to calculate at the front boundary. Figure 6 relates
to this boundary condition (see Chapter II).
The following equation is valid in this case:
3/42
2
1
1
1
1 22hRR
RR
R
ii
R
i
R
i
RA
nQQdxdzgtygcvv . (63)
1
1
iy is known in every time step!
End boundary: At the end boundary we have a constant water level height in every time
step. Here, only the velocity is needed to calculate at the end boundary. Figure 7 relates to this
boundary condition (see Chapter II).
The following equation is valid in this case:
3/42
2
11 22hLL
LL
L
i
N
i
L
i
L
i
NRA
nQQ
dx
dzgtygcvv . (64)
1iNy is known in every time step!
2
3/42
2
3/42
2
1 2216
1
hRR
RR
hLL
LL
RL
iR
iL
iR
iL
ij
RAnQQ
RAnQQ
dxdzg
dxdzgtccvv
gy
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
24/30
24
VI. VARIABLE BOTTOM SLOPE PROBLEMMATLAB CODE WITH EXPLANATION
The program has almost the same structure like the previous one. The time step selection
is added into the Main loop and the additional source terms appear in the code.
functionhullammedenceclear all, clc, clf%definition of the global parameters
globaldt % time stepglobalwa % amplitude of excitation
globalbottom % bottom curveglobaldzodx % dz/dx vector
% PARSpars.L=10; % structurepars.B=10; % width of the tankpars.N=40; % spatial resolutionpars.dx=pars.L/(pars.N-1); % distance between two nodespars.g=9.81; % gravitational constantpars.manning=0.01; % Mannings constantomega=5; % frequency of excitation
wa=0.7; % amplitude of excitationxgrid=linspace(0,pars.L,pars.N); % x coordinate vector
%Parameters of the bottom slopepars.L0=2; % Vector element at which the sine square beginspars.LS=7; % Width of the sine square (in elements)pars.H=0.5; % Height of the sine square (in meters)% Initial Conditionsy1=5; % water level at the fronty2=5; %water level at the end
v0=0; % initial water velocity
% Generating the bottom slopebottom=zeros(1,pars.N); % The initial bottom height is set to zerodzodx=zeros(1,pars.N); % The initial bottom slope derivative is set to zero
L0=pars.L0;LS=pars.LS;H=pars.H;
fori=1:length(bottom)
xxx=xgrid(i);ifxxx>L0 && xxx
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
25/30
25
bottom(i)=H*(sin(pi*(xxx-L0)/LS))^2; % bottom sine square generated, seeEq.(57)
dzodx(i) =H*2*sin(pi*(xxx-L0)/LS)*cos(pi*(xxx-L0)/LS)*pi/LS; % bottom slopederivative generated, see Eq.(58)
%fprintf('\n x=%5.3f, sin(...)=%5.3f',xxx,sin(pi*(xxx-L0)/LS));
endend
% Simulation timetmax=50; %total simulation timet=0;C=0.9; % safety factor (0..1) for time step selection , see Eq.(60)
ford=0:pars.N-1;y(d+1)=y1-d*pars.dx/pars.L*(y1-y2);disp(d*pars.dx/pars.L*(y1-y2));
end
v=v0*ones(1,pars.N); % initial velocity vectory=y+bottom;% initial water levelynew=y; % new water level vectorvnew=v; % new velocity vector
% Main loopwhilet
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
26/30
26
vf=BC_front(y,v,yf,pars);%Function of method of characteristics for the FrontBoundary Condition, It will be accurately defined later.
ynew(1)=yf;% Recalling of the new y value at the first grid pointvnew(1)=vf;% Recalling of the new v value at the first grid point
% Assigns values to y(2)...y(N-1) and v(2)...v(N-2)[ynew,vnew]=moc_step(y,v,dt,pars,ynew,vnew);% definition of the function of
method of characteristics for the innerspace points
% End Boundary Conditionye=y2; % definition of the end water level height given by y2ve=BC_end(y,v,ye,pars);%Function of method of characteristics for the End
Boundary Condition, It will be accurately defined later.ynew(pars.N)=ye;% Recalling of the new y value at the last grid pointvnew(pars.N)=ve;% Recalling of the new v value at the last grid point
% Close stepy=ynew;v=vnew;t=t+dt; %go to the next time step
%fprintf('\nOverall energy: %5.3e',sum(y+v.^2/2/pars.g));
z=abs(v)-(pars.g*y).^0.5; %if the velocity is higher than the sound velocity, the flowis supersonic
if(max(z)>0)error('Szuperszonikus aramlas, ilyet nem tudok.');
end
end
end
function[ynew,vnew]=moc_step(y,v,dt,pars,ynew,vnew)% definition of the functionof method of characteristics for the innerspace points% defining the constant parametersN=pars.N;
g=pars.g;B=pars.B;m=pars.manning;dx=pars.L/(pars.N-1);H=pars.H;L0=pars.L0;LS=pars.LS;
fori=2:(N-1)% for only the innerspace points N=2N-1
x=linspace(0,pars.L,pars.N);%resolution of the x-axis
c=(g*y).^0.5;% defining the connection between the pressure wave velocity andthe water height level (see Eq.(3))
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
27/30
27
x_alpha=x+(v+c)*dt;%see Eq.(17)x_beta=x+(v-c)*dt;%see Eq.(18)xi=x(i);% the x-coordinate of the i-th grid point will be xi
% The position of the slopes running inx_innen_alpha=interp1(x_alpha,x,xi);linear interpolation of x-coordinate of the
L(eft) point, see (comm1)x_innen_beta=interp1(x_beta,x,xi);%linear interpolation of x-coordinate of the
R(ight) point, see (comm2)
% Calculation of v(alpha), c(alpha), v(beta), c(beta)cl=interp1(x,c,x_innen_alpha);%see (comm4)(left)vl=interp1(x,v,x_innen_alpha);%see (comm3)(left)cr=interp1(x,c,x_innen_beta);%see (comm6)(right)vr=interp1(x,v,x_innen_beta);%see (comm5)(right)
% Bottom slope source termsifx_innen_beta>L0 && x_innen_betaL0 && x_innen_alpha
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
28/30
28
% Calculation of the new y and v valuesvnew(i)=1/2*(vl+vr+2*cl-2*cr+dt*(Sl+Sr+Sfl+Sfr));% see Eq.(61)ynew(i)=1/(16*g)*(vl-vr+2*cl+2*cr+dt*(Sl-Sr+Sfl-Sfr))^2;% see Eq.(62)
endend
functionvf=BC_front(y,v,yy,pars)% definition of the function of method ofcharacteristics for the Front Boundary Condition
globaldt
% Variables at the front
N=pars.N;g=pars.g;dx=pars.L/(pars.N-1);B=pars.B;m=pars.manning;L0=pars.L0;LS=pars.LS;H=pars.H;
x=linspace(0,pars.L,pars.N);%resolutionc=(g*y).^0.5;%see Eq.(3)
% Interpolationx_beta=x+(v-c)*dt;% equation for the x-position of the appropriate R(ight) point ,seeEq.(18)x_innen_beta=interp1(x_beta,x,0);%linear interpolation of x-coordinate of the R(ight)point where the x-coordinate of the desired point is zero (third variable in thecommand), see (comm2)
% linear interpolation to the R(ight) point (pressure wave velocity and the velocity)cr=interp1(x,c,x_innen_beta);%see(comm6)
vr=interp1(x,v,x_innen_beta);%see(comm5)
%Source term at the frontifx_innen_beta>L0 && x_innen_beta
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
29/30
29
Pr=B+2*cr^2/g;%wetted perimeter for rectangular channel from right Eq.(55)Qr=Ar*vr;%volume flow rate (right) Eq.(51)Rhr=Ar/Pr;%hydraulic radius (right) Eq.(54)Sfr=-Qr*abs(Qr)*m^2/(Ar^2*Rhr^(4/3));%Mannings friction rule (right) Eq.(50)
% Return value of the function, the calculation of the new velocity at the frontboundaryvf=2*sqrt(yy*g)+vr-2*cr+dt*(Sr+Sfr); %see Eq.(63)
end
functionve=BC_end(y,v,ye,pars)% definition of the function of method ofcharacteristics for the End Boundary Condition
globaldt
% Variables at the endN=pars.N;g=pars.g;dx=pars.L/(pars.N-1);L=pars.L;B=pars.B;m=pars.manning;L0=pars.L0;LS=pars.LS;H=pars.H;
x=linspace(0,pars.L,pars.N);%resolutionc=(g*y).^0.5;%see Eq.(3)
% Interpolationxi=L; % defining the position, we are at the position L, so at the end of the poolx_alpha=x+(v+c)*dt;% equation for the x-position of the appropriate L(eft) point ,seeEq.(17)x_innen_alpha=interp1(x_alpha,x,xi);%linear interpolation of x-coordinate of theL(eft) point where the x-coordinate of the desired point is xi defined as L (thirdvariable in the command), see (comm1)
%linear interpolation to the L(eft) point (pressure wave velocity and the velocity)cl=interp1(x,c,x_innen_alpha);%see(comm4)vl=interp1(x,v,x_innen_alpha);%see(comm3)
%Source term at the frontifx_innen_alpha>L0 && x_innen_alpha
-
8/14/2019 Open Channel Flow with Variable Bottom Slope
30/30
% Friction source termsAl=cl^2/g*B;% flow cross-section from left Eq.(53)Pl=B+2*cl^2/g;%wetted perimeter for rectangular channel from left Eq.(55)Ql=Al*vl;%volume flow rate (left) Eq.(51)Rhl=Al/Pl;%hydraulic radius (left) Eq.(54)
Sfl=-Ql*abs(Ql)*m^2/(Al^2*Rhl^(4/3));%Mannings friction rule (left) Eq.(50)
% Return value of the function, the calculation of the new velocity at the endboundaryve=vl+2*cl-2*sqrt(g*ye)+dt*(Sl+Sfl); %see Eq.(64)
end