In [1]:

```
import math
#calculate The depth of the water under the brigde and the depth of water upstream
Q=400.; ## m^3/s
b2=20.; ## m
g=9.81; ## m/s^2
b1=25.; ## m
h2=(Q/b2/math.sqrt(g))**(2./3.);
## Since energy is conserved
## h1 + u1^2/2g = h2 +u2^2/2g = h2 + h2/2 = 3h2/2
## h1 + 1/2*g*(Q/(b1h1))^2 = 3*h2/2;
## h1^3-5.16*h1^2+13.05 = 0;
## By solving this cubic equation
h1=4.52; ## m
print'%s %.1f %s'%(" The depth of the water under the brigde =",h2,"m")
print'%s %.2f %s'%(" the depth of water upstream =",h1,"m")
```

In [2]:

```
import math
#calculate Rate of flow
w=0.04; ## thickness of block in m
d=0.07; ## depth of liquid in m
b=0.4; ## m
g=9.81; ## m/s^2
H=d-w;
Q=1.705*b*H**(3/2.);
u1=Q/d/b;
h=u1**2/(2.*g);
H1=H+h;
Q1=1.705*b*H1**(3/2.);
print'%s %.4f %s'%("Rate of flow =",Q1," m^3/s")
```

In [3]:

```
import math
#calculate depth of water at the throat and the new flow rate and the Froude number at the throat and flow rate
h1=0.45; ## m
g=9.81; ## m/s^2
b1=0.8; ## m
h2=0.35; ## m
b2=0.3; ## m
print("the flow rate")
Q=math.sqrt((h1-h2)*2*g/(-(1./(h1*b1)**2)+(1./(h2*b2)**2)));
print'%s %.3f %s'%("Flow rate =",Q,"m^3/s")
print(" the Froude number at the throat")
Fr2=Q/(math.sqrt(g)*b2*h2**(3/2.));
print'%s %.3f %s'%("The Froude number at the throat =",Fr2,"")
print("the depth of water at the throat")
## (h1/h2)^(3) + 1/2*(b2/b1)^2 = 3/2*(h1/h2)^2
## The solution for the above eqn is as follows
## (h1/h2) = 0.5 + cos(2arcsin(b2/b1)/3)
## h1/h2=1.467
h2_new=h1/1.467;
print'%s %.3f %s'%("Depth of water at the throat =",h2_new,"m")
print("the new flow rate")
w=math.sqrt(g)*b2*h2_new**(3/2.);
print'%s %.3f %s'%("New flow rate =",Q,"m^3/s")
```

In [4]:

```
import math
#calculate depth
Q=8.75; ## m^3/s
w=5.; ## m
n=0.0015;
s=1./5000.;
## Q/(w*h0) = u = m^(2/3)*i^(1/2)/n = 1/0.015*(w*h0/(w+2*h0))^(2/3)*sqrt(s);
## Solution by trial gives h0
h0=1.8; ## m
q=1.75;
g=9.81;
hc=(q**2/g)**(1/3); ## critical depth
print'%s %.1f %s'%("Depth =",h0,"m")
```

In [5]:

```
import math
#calculate wave length
g=9.81; ## m/s^2
T=5.; ## s
h=4.; ## m
## lambda=g*T^2/(2*%pi)*tanh(2*%pi*h/lambda1);
## by trial method , we get
lambda1=28.04;
D=g*T**2/(2*math.pi)*math.tanh(2*math.pi*h/lambda1);
print'%s %.1f %s'%("Wavelength =",D,"m")
```

In [6]:

```
import math
#calculate phase velocity and wave length
g=9.81; ## m/s^2
T=12; ## s
c=g*T/(2*math.pi);
D=c*T;
print"%s %.1f %s"%("Phase velocity =",c,"m/s")
print"%s %.1f %s"%("Wavelength =",D,"m")
```

In [7]:

```
import math
#Estimate the time elapsed since the waves were generated in a storm occurring 800 km out to sea and Estimate the depth at which the waves begin to be significantly influenced by the sea bed as they approach the shore
c=18.74; ## m/s
lambd=225.; ## m
print("Estimate the time elapsed since the waves were generated in a storm occurring 800 km out to sea. ")
x=800.*10**3.; ## m
cg=c/2.;
t=x/cg;
print"%s %.1f %s"%("time elapsed =",t/3600.,"hours")
print("Estimate the depth at which the waves begin to be significantly influenced by the sea bed as they approach the shore.")
h1=lambd/2.;
h2=lambd/(2.*math.pi)*math.atanh(0.99);
print"%s %.1f %s %.1f %s"%("The answers show that h lies in the range between about",h2,"m , ",h1, "m")
```