from __future__ import division
import math
#variable initialisation
Q=450 #discharge in L/s
D1=6 #diameter in cm
D2=9 #diameter in cm
g=9.81 #gravity
p1=20 #pressure at upstream of the expansion in kN/m^3
ga=9.79 #relative density in kg/m^3
#Calculation
Q=(Q/60)/1000 #coverting into m^3/s
V1=round(Q/((math.pi/4)*((D1/100)**2)),3) #Velocity before expansion
V2=round(V1*(((D1/100)/(D2/100))**2),3) #Velocity downstream of the expansion
H_L=round(((V1-V2)**2)/(2*g),3)
#By energy equation:
#(p1/ga)+(V1**2)/(2*g)+Z1)=(p2/ga)+((V2**2)/(2*g))+Z2
#As Z1=Z2
p2=round(((p1/ga)+(V1**2)/(2*g)-((V2**2)/(2*g))-H_L)*ga,2)
print "p2=",p2,"kPa"
import math
#variable initialisation
L1=1800 #length of pipe1
L2=1200 #length of pipe 2
L3=600 #length of pipe 3
D1=50 #diameter of pipe 1 in cm
D2=40 #diameter of pipe 2 in cm
D3=30 #diameter of pipe 3 in cm
De=40 #Equivalent length of pipe in cm
#Calculation
#It's assumed that f is same for all pipes.
D1=D1/100
D2=D2/100 #Converting into m
D3=D3/100
De=De/100
Le=round(((L1/(D1**5))+(L2/(D2**5))+(L3/(D3**5)))*(De**5),1)
print "(i)Le=",Le,"m"
Le=3600 #assumed equivalent length of pipe in m
De=round(((Le/((L1/(D1**5))+(L2/(D2**5))+(L3/(D3**5))))**(1/5))*100,2)
print "(ii)De=",De,"cm"
#when three pipes in parallel
#h_f1=h_f2=h_f3=h_fe
#assume a=(V2/V1),b=(V3/V1),c=Ve/V1
a=round(math.sqrt((L1*D2)/(L2*D1)),4)
b=round(math.sqrt((L1*D3)/(L3*D1)),4)
#Total discharges is given by,Q0=(0.546)*(math.pi/4)*V1
#Qe=(math.pi/4)*(D1/100)**2)*Ve
#for an equivalent pipe,Q0=Qe,so equating,
c=((0.546)/((D1/100)**2))/10000
#Ve/V1=math.sqrt(L1/Le)
Le=L1/c**2
print "(iii)Le=",round(Le,2),"m"
print "Using Alternative method,"
De=0.50 #discharge in m
a=round(((((D1**5)/L1)**(1/2))+(((D2**5)/L2)**(1/2))+(((D3**5)/L3)**(1/2))),4)
Le=((De**5)**(1/2))/a
print "Le=",round(Le**2,2),"m"
import math
#variable initialisation
D1=10 #Diameter of pipe AB in cm
D2=16 #Diameter of pipe BC in cm
g=9.81 #gravity
f=0.02 #value of pipe AB
f1=0.018 #Value of pipe BC
#Calculation
#(i)entrance loss h_L1=0.5 V^2/2g
#(ii)loss at expansion:
#Equating, math.pi/4 *D1^2*V1=math.pi/4 *D2^2*V2
#we get,h_eL=0.3714(V1^2)/(2*g)
#(iii)he=V2^2/(2*g)
#Total loss H_L=6.300(V1**2)/(2*g)
H_L=10 #taking H_L as 10m,
V1=math.sqrt((H_L*2*g)/(6.300))
V2=(((D1/100)/(D2/100))**2)*(V1)
Q=(math.pi/4)*((D1/100)**2)*(V1) #Calculating discharge
print "Q=",round(Q*1000,1),"L/s" #Converting from m^3/s into L/s
#taking Q=15 L/s
Q=15/1000 #Converting into m^3/s
V1=Q/((math.pi/4)*(D1/100))
H_L=6.300*((V1**2)/(2*g)) #Difference in reservoir elevations
print "H_L=",round(H_L*100,3),"m"
import math
#variable initialisation
fb=0.018 #friction factor
Lb=100 #length of pipe b in m
D2=12 #diameter of the pipe b in cm
D1=15 #diameter of the pipe 1 in cm
fa=0.018 #friction factor
La=150 #length of pipe 1 in cm
#Calculation
#Since the discharges are same in both the pipes,
#AaVa=AbVb
#math.pi/4*(D1**2)*Va=math.pi/4*(D2**2)*(Vb)
#Vb=((D1/D2)**2)*Va=1.5625Va
#let the loss in the value be Kl*Va**2/2*g
#Head losses in both pipes are the same
D1=D1/100 #Converting into m
D2=D2/100
#(fa*La*Va^2/2gDa)+K_L*(Va^2/2g)=(fbLbVb^2/2gDb)
#calculating value of the valve coefficient
K_L=(fb*Lb*(((D1/D2)**2)**2)/(D2))-((fa*La)/(D1))
print "K_L=",round(K_L,2)
import math
#variable initialisation
f=0.02 #friction factor
L=1000 #length of pipe in m
h_f=16 #water surface elevation in m
g=9.81 #gravity
D=15 #diameter in cm
L1=600 #length in m
p2=10.3 #atmospherric pressure in m(abs)
Z2=100 #elevation of the upstream in m
Z1=98 #elevation in m
ga=9.79 #density in kg/m^3
p=20.00 #pressure in kPa
#Calculation
D=D/100
V=round(math.sqrt((h_f*(2*g*D))/(f*L)),3)
Q=round(((math.pi/4)*(D**2)*(V))*1000,1)
#Head loss upto the summit=h_f1
h_f1=round(((f*L1)/(2*g*D))*(V**2),1)
#By energy equation between upstream reservoir water surface and the summit.
#(p1/ga)+(V1**2)/(2*g)+Z1)=(p2/ga)+((V**2)/(2*g))+Z2
p1=((p2+Z2)-((V**2)/(2*g)+Z1+h_f1))*ga
print "(a)p1=",round(p1,2),"kPa"
#By energy equation,
a=p2+Z2
b=(p/ga)+Z1 #Calculating volume V1
V1=math.sqrt((a-b)/(1+((f*L1)/(2*g*D))))
Q1=(math.pi/4)*(D**2)*(V1) #Calculating discharge
print "(b)Q1=",round(Q1*1000,1),"L/s"
import math
#variable initialisation
D=50 #diameter in cm
f=0.019 #friction factor
L=1000 #length in m
H=100 #head at the inlet in m
g=9.81 #gravity
ga=9.79 #density in kg/m^3
#Calculation
D=D/100
#For the condition of maximum power,the diameter of the nozzle,
d=round(((D**5)/(2*f*L))**(1/4)*100,2)
h_f=round(H/3,2) #Head loss
V=math.sqrt(((h_f*2*g*D))/(f*L))
Q=round((math.pi/4)*(D**2)*V,4) #Discharge
Pm=ga*Q*(2/3)*H #Maximum power
print "Pm=",round(Pm,1),"kW"
import math
#variable initialisation
EL_p=100 #length of pipe
EL_a=95 #Length of pipe a
EL_c=110 #Length of pipe c
D1=15 #Diameter in cm
D2=12 #Diameter in cm
Q=0.02 #discharge
f1=f2=0.02 #force
L1=20 #Length in m
g=9.81 #gravity
L2=300 #Length in m
ga=9.79 #density
Ph=10 #atmospheric pressure head in m
#Calculation
r=(D1/2)/100 #Calculating radius
Hs=EL_c-EL_a #Static head
V1=Q/((math.pi/4)*((D1/100)**2)) #Velcoity in the suction pipe
V2=V1*(D1/D2)**2 #Velocity in the delivery pipe
hf1=(f1*L1*(V1**2))/(D1/100*2*g) #Head loss in the suction pipe
hL1=0.5*((V1**2)/(2*g)) #Inlet loss
hf2=(f2*L2*(V2**2))/(D2/100*2*g) #friction loss in the delivery pipe
hL2=((V2**2)/(2*g)) #Loss at exit
TL=hf1+hf2+hL1+hL2 #Total loss
Hf=Hs+TL #Heat delivered by pump
P=ga*Q*Hf #Power delivered
print "P=",round(P,2),"kW"
#(b)By energy equation between resorviour A and pump B
#Ps=pressure at the suction side of the pump
a=(V1**2)/(2*g)
Ps=(Ph+(EL_a-(EL_p+a+hf1+hL1)))*ga
print "Ps=",round(Ps,2),"kPa(abs)"