import math
#variable initialization
#bulk modulus of elasticity for water in MPa
k_w=2.22E+3
k_c=1.50E+3
k_g=9.58E+2
rho=998 #density in kg/m^3
RD_c=0.8 #relative density of crude oil
RD_g=0.68 #relative density of gasolene
#solution
C=math.sqrt((k_w*10**6)/rho) #for water
print "C=",round(C,1),"m/s"
C=math.sqrt((k_c*10**6)/(RD_c*rho)) #for crude oil
print "C=",round(C,1),"m/s"
C=math.sqrt((k_g*10**6)/(RD_g*rho)) #for gasolene
print "C=",int(C),"m/s"
import math
#variable initialization
E=2.07E+5 #pressure in steel pipe
K=1.43E+3 #Bulk modulus in MPa
t=2 #thickness in cm
D=2.5 #diameter in m
RD=0.80 #relative density
rho=998 #density in m/s^2
#solution
D=D*100 #converting D to cm
E=E*(10**6) #converting MPa to Pa
K=K*(10**6) #converting MPa to Pa
#velocity of pressure wave
C=(math.sqrt(K/(rho*RD)))*(math.pow(1/(1+((D/t)*(K/E))),1/2))
print "C=",round(C,1),"m/s"
#variable initialisation
k=2.2E9 #Bulk modulus in MPa
rho=998 #relative density
V2=1.0 #velocity in m/s
V1=4.0 #Decreased velocity in m/s
#calculation
del_V=-(V2-V1)
C=(k/rho)**(1/2) #change of pressure surge
delP_h=(rho*C*del_V)
print "delP_h="'%4.3E' % delP_h,"which is ",round(delP_h/1000000,3),"MPa"
import math
#variable initialization
E=1.0E+11 #modulus of elasticity
K=2.0E+9 #Bulk modulus in Pa
t=1.25 #thickness in mm
D=0.9 #diameter in m
rho=998 #density in kg/m^3
L=1000 #length in m
V=2.60 #velocity in m/s
g=9.81 #gravity in m/s^2
#solution
D=D*100 #converting D to cm
#velocity of pressure wave
C=(math.sqrt(K/(rho)))*(math.pow(1/(1+((D/t)*(K/E))),1/2))
#with Pressure rise,
del_V=0-V #calculating del_V
h_h=-(C*del_V)/g #Water Wammer Head
print "h_W=",round(h_h,1),"m"
#variable initialisation
k=2.1E9 #Bulk modulus in MPa
rho=998 #relative density
V2=0 #velocity in m/s
V1=2.1 #Decreased velocity in m/s
D=60 #Diameter in cm
t=1.2 #thickness in cm
E=2.1E11 #modulus of elasticity
#calculation
del_V=-(V2-V1)
c=(k/rho)**(1/2) #By neglecting the elasticity of pipe material velocity,
delP_h=(rho*c*del_V) #water hammer pressure rise
print "delP_h="'%4.3E' % delP_h,"which is ",round(delP_h/1000000,3),"MPa"
#By considering the elasticity of pressure material,
C=(((1/(1+(D/t)*(k/E))))**(1/2))*c
delP_h=(rho*C*del_V)
print "delP_h="'%4.3E' % delP_h,"which is ",round(delP_h/1000000,3),"MPa"
import math
#variable initialization
E=2.10E+11 #modulus of elasticity
K=1.43E+9 #Bulk modulus in Pa
t=80 #thickness in mm
D=80 #diameter in cm
RD=0.8 #relative density for kerosene
rho=998 #density in m/s^2
L=1000 #length in m
#solution
D=D*10 #converting D to mm
#velocity of pressure wave
C=(math.sqrt(K/(rho*RD)))*(math.pow(1/(1+((D/t)*(K/E))),1/2))
To=(2*L)/C
print "Hence maximum time for a sudden closure is",round(To,3),"s"
import math
#variable initialisation
L=100 #length in m
C=1430 #Sonic velocity in m/s
v=0.5 #Velocity in m/s
D=0.5 #Diameter in m
rho=998 #relative density
T=1 #time in second
#Calculation
T0=round((2*L)/C,2) #Critical time
V=round(v/((math.pi/.4)*(D**2)),4)
Ph=rho*C*V
print "Ph=",round(Ph/1000,2),"kPa"
Pvsc=rho*L*V/T #P|ressure rise
print "Pvsc=",round(Pvsc/1000,2),"kPa"
import math
#variable initialisation
k=2.11E9 #Bulk modulus in MPa
rho=998 #relative density
V2=0 #velocity in m/s
V1=2.1 #Decreased velocity in m/s
D=60 #Diameter in cm
t=1.5 #thickness in cm
E=1.041E11 #modulus pf elasticity
del_V=-3.0 #change in volume
T=2.00 #pressure rise
L=800 #length
#calculation
c=int((k/rho)**(1/2))
C=round((((1/(1+(D/t)*(k/E))))**(1/2))*c,3) #Velocity of pressure wave
T0=round((2*L)/C,2)
Ph=-rho*C*del_V #T=1.25,Hence,water hammer pressure
print "(a)Ph=",round(Ph/1000000,3),"MPa"
Phs=(T0/T)*Ph #Pressure rise at the valve
print "(b)Phs=",round(Phs/1000000,3),"MPa"
print "(c)Ph=",round(Ph/1000000,3),"MPa"
import math
#variable initialisation
k=2.10E9 #Bulk modulus in Pa
rho=998 #relative density
D=400 #Diameter in cm
t=10 #thickness in cm
E=2.11E11 #modulus pf elasticity
V2=0.5 #Volume 1
V1=3.0 #Volume 2
T=5.00 #pressure rise
L=2500 #length
Pstatic=9.79*250 #Pressure
#calculation
c=((k/rho)**(1/2))
C=round((((1/(1+(D/t)*(k/E))))**(1/2))*c,4) #Velocity of pressure wave
T0=round((2*L)/C,3)
del_V=V2-V1 #change in volume
Ph=-rho*C*del_V #T=1.25,Hence,water hammer pressure
Phs=((T0/T)*Ph)/1000 #Pressure rise at the valve
Pt=Pstatic+Phs
print "Pt=",int(round(Pt,0)),"kPa" #Total pressure at the valve end
import math
#variable initialization
K=2.2E+3 #bulk modulus in MPa
rho=998 #density in kg/m^3
L=3500 #length in m
Vo=0.8 #velocity in m/s
T=4.0 #closure in s
#solution
C=round(math.sqrt((K*10**6)/rho),1) #velocity of pressure wave
To=(2*L)/C #critical time
#T=4.0 s,the closure is rapid.
Ph=(rho*C*Vo)/(10**6) #water hammer pressure
print "Ph=",round(Ph,3),"MPa"
#length of the pipe affected by peak pressure
Xo=L-((C*T)/2)
print "Xo=",Xo,"m"
import math
#variable initialisation
k=1.52E9 #Bulk modulus in Pa
rho=998 #relative density
D=200 #Diameter in cm
t=10 #thickness in cm
E=2.11E11 #modulus pf elasticity
T=1.25 #pressure rise
L=1000 #length
Pstatic=9.79*250 #Pressure
Rd=0.8 #Relative density
Q=0.040 #discharge
#calculation
c=((k/(Rd*rho))**(1/2))
C=round((((1/(1+(D/t)*(k/E))))**(1/2))*c,4) #Velocity of pressure wave
V0=Q/((math.pi/4)*((D/1000)**2))
T0=round((2*L)/C,3)
Ph=rho*Rd*C*V0 #T=1.25,Hence,water hammer pressure
alpha_a=(Ph*D/(2*t))/1000
print "alpha_a=",round(alpha_a/1000000,4),"kN/mm^2" #Convert into mm
import math
#variable initialisation
k=1E9 #Bulk modulus in Pa
rho=998 #relative density
D=300 #Diameter in cm
t=3 #thickness in cm
E=2.14E11 #modulus pf elasticity
T=1.25 #pressure rise
L=1000 #length
Pstatic=9.79*250 #Pressure
Rd=0.82 #Relative density
Q=0.100 #discharge
Sh=160 #Static head in m
alpha_w=1.0E5 #stress value
#calculation
c=((k/(Rd*rho))**(1/2))
C=round((((1/(1+(D/t)*(k/E))))**(1/2))*c,4) #Velocity of pressure wave
V0=round(Q/((math.pi/4)*((D/1000)**2)),2)
T0=round((2*L)/C,3)
Ph=round((rho*Rd*C*V0)/1000,2) #water hammer pressure
Ps=Sh*(9.79*Rd) #Static pressure
P=Ps+Ph #Total pressure
alpha_a=(Ph*D/(2*t))/1000
#As working stress is lower than alpha_w value,valve must be closed with time T>T0
Pt=alpha_w*2*t/(D)
Phw=Pt-Ps #Allowable hammer pressure in the closure
T=T0*(Ph/Phw)
#Since this value <1.5,the assumption of slow closure is O.K.
print "Minimum time of closure Tm=",round(T,2),"s"