102 Computational Modelling in Hydraulic and Coastal Engineering
Computer code 5.3
% Example 5.3 Unsteady Flow in Rectangular Open Channel of
Variable Width
% h = Flow depth [m];
% B = Channel width [m];
% S = Bed slope;
% C = Chezy coefficient of friction [m^(1/2)/s];
% Qin = Inflow hydrograph [m^3/s];
% Dx = Spatial step [m];
% Dt = Time step [s];
% nx = Number of spatial steps;
% nt = Number of time steps;
% dt = Time step of the inflow hydrograph [s];
% ntot = Number of time steps of the inflow hydrograph;
clc; clear all; close all;
% Input data;
g=9.81;
S=0.0004;
C=40;
Dx=1000;
Dt=5;
nx=46;
nt=50000;
Qin=2000;
ntot=50000;
% Import of filevw.mat: Channel widths;load filevw.mat
load filevw.mat
b=B(:);
% Initial conditions;
for i=1:nx
h(i)=0.1;
hmax(i)=0;
u(i)=0;
end
k=0;
% Main program;
for k=1:nt
k=k+1;
% Calculation of linearly changing inflow hydrograph;
Q(1)=Qin-Qin*k/ntot;
if k-ntot>0
Q(1)=0;
end
% Calculation of the velocity and discharge;
for i=2:nx-1
if h(i-1)-0.02<0
u(i)=0;
Computer code 5.3
% Example 5.3 Unsteady Flow in Rectangular Open Channel of
Variable Width
% h = Flow depth [m];
% B = Channel width [m];
% S = Bed slope;
% C = Chezy coefficient of friction [m^(1/2)/s];
% Qin = Inflow hydrograph [m^3/s];
% Dx = Spatial step [m];
% Dt = Time step [s];
% nx = Number of spatial steps;
% nt = Number of time steps;
% dt = Time step of the inflow hydrograph [s];
% ntot = Number of time steps of the inflow hydrograph;
clc; clear all; close all;
% Input data;
g=9.81;
S=0.0004;
C=40;
Dx=1000;
Dt=5;
nx=46;
nt=50000;
Qin=2000;
ntot=50000;
% Import of filevw.mat: Channel widths;load filevw.mat
load filevw.mat
b=B(:);
% Initial conditions;
for i=1:nx
h(i)=0.1;
hmax(i)=0;
u(i)=0;
end
k=0;
% Main program;
for k=1:nt
k=k+1;
% Calculation of linearly changing inflow hydrograph;
Q(1)=Qin-Qin*k/ntot;
if k-ntot>0
Q(1)=0;
end
% Calculation of the velocity and discharge;
for i=2:nx-1
if h(i-1)-0.02<0
u(i)=0;
