You are on page 1of 1

close all

clc
L=600;
a=1000;
D=1;
f=0.02;
Vo=2.5;
tc=6;
tmax=12;
m=3.2;
Hr=80;
g=9.81;
dx=100;
dt=dx/a;
z=101.936;
R=0.1019;
G=0;
pt=(tc/dt)+1;

for j=1:7
H(j,1)=round((Hr-((f*(j-1)*dx*Vo^2)/(2*g*D))),3);

V(j,1)=round(Vo,3);
end
for i=2:pt
t=(i-1)*dt;
CD(1,i)=-H(2,i-1)+z*V(2,i-1)-R*V(2,i-1)^2;
H(1,i)=Hr;
V(1,i)=(CD(1,i)+H(1,i))/z;
for j=2:6
CI(j,i)=-H(j-1,i-1)-z*V(j-1,i-1)+R*(V(j-1,i-1)^2);
CD(j,i)=-H(j+1,i-1)+z*V(j+1,i-1)-R*V(j+1,i-1)^2;
H(j,i)=-(CI(j,i)+CD(j,i))/2;
V(j,i)=(CD(j,i)-CI(j,i))/(2*z);
end
CI(7,i)=-H(7-1,i-1)-z*V(7-1,i-1)+R*V(7-1,i-1)^2;
tao(i-1)=(1-(t/tc))^m;

x(i-1)=70;
E=0.0001;
for k=1:100
f(i-1)=(Vo*tao(i-1)*(sqrt(x(i-1)/80)))+(x(i-1)+CI(7,i))/z;
d(i-1)=(Vo*tao(i-1)/(2*sqrt(80)*sqrt(x(i-1))))+1/z;
x1(i-1)=x(i-1)-f(i-1)/d(i-1);
f(i-1)=(Vo*tao(i-1)*(sqrt(x1(i-1)/80)))+(x1(i-1)+CI(7,i))/z;
if abs(f(i-1))<=E
break
end
x(i-1)=x1(i-1);
end

H(7,i)=x(i-1);
V(7,i)=-(H(7,i)+CI(7,i))/z;
end