import math
#variable initialisation
d1=0.15 #diameter of section A in m
Q=0.05 #discharge in m^3/s
d2=0.30 #diameter of section B in m
Z1=100 #elevation at section A in m
Z2=107 #elevation at section B in m
p1=30 #pressure at section A in kPa
H_L=2 #energy loss in the pipe
g=9.81
#calculation
A1=(math.pi/4)*(d1*d1) #calculating area for section A
V1=round(Q/A1,3) #calculating volume
A2=(math.pi/4)*(d2*d2) #calculating area for section B
V2=round(Q/A2,4) #calculating volume
ga=round(998*g/1000,2) #unit length of water in kN/m^3
#By,Bernuolli equation
#when the flow is from A to B,taling the pressure as zero
p2=round((((p1/ga)+((V1*V1)/(2*g))+Z1)-(((V2*V2)/(2*g))+Z2+H_L))*ga,2) #calculating pressure
print "(i)p2=",p2,"kPa(guage)"
#when the flow is from B to A,taking pressure as zero
b=(p1/ga)+((V1*V1)/(2*g))+Z1
a=(((V2*V2/(2*g)))+Z2)-H_L
p2=round((b-a)*ga,2) #calculating pressure
print "(ii)p2=",p2,"kPa(guage)"
#variable initialisation
p1=0 #pressure in kPa
V1=0 #Velocity in m/s
p3=0 #pressure in kPa
Z3=20 #elevation at section 3 in m
H=4 #head in the tank in m
d=25 #diameter in mm
D=100 #Diameter of pipe in mm
g=9.81 #gravity
RD_oil=0.8 #relative density in kg/m^3
#Calculation
#By continuity ctiterion,V2(math.pi/4)(D**2)=V3(math.pi/4)(d**2)=Q
#Applying Bernoullis equation to points 1 and 2 with centre line of pipe as datum and pressure as zero
#V2=(d/D)**2*V3
#Using this equation,(p1/ga)+(V1**2)/(2*g)+Z1)=(p3/ga)+((V3**2)/(2*g))+Z3+H_L
#H=V3**2/2g+20*V2**2/2g
#H_L=20*V2**2/(2*g) #given loss of pipe
V3=round(((2*g*H)/(Z3*((d/D)**4)+1))**(1/2),4)#Velocity in the pipe
Q=(math.pi/4)*((d/1000)**2)*(V3)*1000 #Discharge
print "Q=",round(Q,4),"L/s"
V2=round((d/D)**2*V3,4)
H_L=round(Z3*V2**2/(2*g),4) #Loss of head in the pipe
#Applying Bernoulli equation to points 1 and 2,
#(p1/ga)+(V1**2)/(2*g)+Z1)=(p3/ga)+((V3**2)/(2*g))+Z3+H_L
ga=round(RD_oil*998*(g/1000),3)
p2=round((H-(((V2**2)/(2*g))+p3+H_L)),4) #Pressure at the base of the nozzle
print "p2=",round(p2*ga,3),"kPa"
import math
#variable initialisation
d=0.30 #diameter in m
d1=0.15 #diameter in m
S=13.6 #relative density of mercury
g=9.81 #gravity
Q=0.120 #discharge in L/s
#Calculation
#by continuity creiterion,
V1=round(Q/((math.pi/4)*(d*d)),4)
V2=round(Q/((math.pi/4)*(d1*d1)),4)
#Considering the elevation of section 1 as datum,
#by assumption ((p1-p2)/ga) is taken as a
#a=(S-1)*h
#By,Bernoulli equation for points 1 and 2
#a-0.8=((v2^2-V1^2)/2g)
h=((V2**2-V1**2)/(2*g))/(S-1)
print "h=",round(h*100,01),"cm" #calculating magnitude
print "Deflection:The manometer limb connected to section 1 will be having smaller column of mercury than the other limb"
import math
#variable initialisation
p_A=4 #vapour prssure in kPa(abs)
p1=95.48 #atmospheric pressure in kPa
p2=95.48 #atmospheric pressure in kPa
g=9.81 #gravity
Z1=1.5 #elevation at section 1 in m
Z_A=0 #elevation at section A in m
ga=9.79 #unit length of water in kN/m^3
V1=0 #volume of section 1
#Calculation
#by applying Bernoullis equation to points 1 and A
#formula is,(p1/ga)+(V1**2)/(2*g)+Z1)=(pA/ga)+((V_A**2)/(2g))+Z_A
V_A=round(math.sqrt((((p1/ga)+(V1**2)/(2*g)+Z1)-(p_A/ga)+Z_A)*2*g),2)
V2=round(V_A/2,2)
print "V2=",V2,"m/s"
#by applying Bernoullis equation to points 1 and 2,with datum at point 2,
#(p1/ga)+(V1**2)/(2*g)+Z1)=(p2/ga)+((V_A**2)/(2g))+Z_A
c=(p1/ga)+((V1**2)/(2*g))+Z1
e=(p2/ga)+(V2**2)/(2*g)
L=e-c #Calculating length of pipe
print"L=",round(L,2),"m"
import math
#variable initialisation
Q=0.015 #discharge in m^3/s
d=0.05 #diameter in m
V1=0 #volume in m/s
Z1=0 #elevation at section 1 in m
Z2=3.00 #elevation at section 2 in m
H_L=1.5 #Energy loss due to friction in m
p2=0 #pressure
ga=9.79 #unit length of water in kN/m^3
g=9.81 #gravity
#Calculation
V2=(Q*4)/(math.pi*(d**2))
#By applying Bernoullis equation to points 1 and 2,
#(p1/ga)+(V1**2)/(2*g)+Z1)=(p2/ga)+((V2**2)/(2g))+Z2
p1=(((p2/ga)+((V2**2)/(2*g))+Z2)+H_L-((V1**2)/(2*g)+Z1))*ga
print "p1=",round(p1,2),"kPa" #Calculating air pressure
import math
from sympy import integrate,symbols,ln
#Variable Initialisation
x, y,z,c,r,r1,r2=symbols("x y z c r r1 r2")
b=0.4 #breadth in m
V0=2 #volume in m/s
r2=1.2 #radius in m
r1=0.8 #radius in m
g=9.81 #gravity
#Calculation
q=integrate(c/r, r) #Integrating v
s=q.subs(r,r2/r1)
C=(b*V0)/ln(r2/r1) #Finding C
V1=C/r1
print "V1=",round(V1,3),"m/s" #Velocity at the inner wall
V2=C/r2
print "V2=",round(V2,3),"m/s" #velocity at the outer wall
#Since the flow is irrotational,Bernoullis theorem can be applied across streamlines.
#(p1/ga)+(V1**2)/(2*g)+Z1)=(pb/ga)+((V2**2)/(2*g))+Z2
PD=(V1**2-V2**2)/(2*g)
print "The difference in pressure head between outer and inner wall is",round(PD,3),"m"
import math
#variable initialisation
Q=0.8 #discharge in m^3/s
r=0.45 #radius in m
Z1=40 #elevation at section 1 in m
Z2=0 #elevation at section 2 in m
P1=0 #power at section 1 in m
V1=0 #volume at section 1 in m
ga=9.79 #unit length of water in kN/m^3
g=9.81 #gravity
H_L=10 #frictional loss
eta=0.85 #turbine efficiency
#Calculation
#(i)Water friction loss is neglected:
V2=round(Q/((math.pi/4)*(r**2)),2)
#Applying Bernoullis equation to points 1 and 2
#(p1/ga)+(V1**2)/(2*g)+Z1)=(pb/ga)+((V2**2)/(2*g))+Z2
H_T=round(((P1/ga)+(V1**2)/(2*g)+Z1)-(((V2**2)/(2*g))+Z2),2) #Calculating heat extracted by the turbine
print"P=",round(ga*Q*H_T,1),"kW" #power extracted by the turbine
print "(ii)when loses are included:"
#Applying Bernoullis equation to points 1 and 2
H_T=round(((P1/ga)+(V1**2)/(2*g)+Z1)-(((V2**2)/(2*g))+H_L+Z2),2)
Pn=ga*Q*H_T*eta #power output of the turbine
print "Pn=",round(Pn,1),"kW"
import math
#variable initialisation
Q=0.060 #discharge in m^3/s
a=60 #pumping water rate from tank in L/s
r1=0.15 #radius in m
r2=0.10 #radius in m
ga=9.79 #unit length of water in kN/m^3
P=10 #power delivered by the pump in kW
P_c=0 #power delivered by section b in m
V_c=0 #volume in m
Z_c=3 #elevation at section c in m
Z_b=3 #elevation at section b in m
H_L=1.2 #heat delivered in m
g=9.81 #gravity
#Calculation
V_a=round(Q/((math.pi/4)*(r1**2)),3)
V_b=round(Q/((math.pi/4)*(r2**2)),3)
#by applying power delivered formula,P=ga*Q*H_p
H_p=round(P/(Q*ga),2) #calculating heat delivered by the pump
#By applying Bernoullis equation between C and A
P_a=round((((P_c/ga)+((V_c**2)/(2*g))+Z_c)-((V_a**2)/(2*g)))*ga,4)
print "P_a=",round(P_a,3),"kPa" #Calculating pressure at A
#By applying Bernoullis equation between C and B with level at A as datum,
#(pc/ga)+(Vc**2)/(2*g)+Zc)=(pb/ga)+((Vb**2)/(2g))+Zb
P_b=round((((P_c/ga)+((V_c**2)/(2*g))+Z_c+H_p)-(((V_b**2)/(2*g))+Z_b+H_L))*ga-0.01,2) #Calculating pressure at B
print "P_b=",P_b,"kPa"
print "when loses are considered:"
s=((P_c/ga)+((V_c**2)/(2*g))+Z_c+H_p)-(((V_b**2)/(2*g))+(Z_b+H_L)+(2*((V_b**2)/(2*g))))
print "P_b=",round((s*ga),1),"kPa" #Calculating pressure at B
import math
#variable initialisation
Q=0.5 #discharge in m^3/s
r=0.4 #radius in m
r1=0.6 #radius in m
P_a=30.0 #pressure head at the upstream of turbine in m
P_b=-4 #pressure head at the point B in draft tube in m
Z_a=2 #elevation at section A in m
Z_b=0 #elevation at section B in m
g=9.81 #gravity
eta=0.90 #turbine efficiency
ga=9.79 #unit length of water in kN/m^3
#Calculation
V_a=round(Q/((math.pi/4)*(r**2)),2)
V_b=round(Q/((math.pi/4)*(r1**2)),3)
#Applying Bernoullis equation to points A and B
#(P_a/ga)+(V_a**2)/(2*g)+Z_a)=(P_b/ga)+((V_b**2)/(2*g))+Z_b+H_t
H_T=round(((P_a)+(V_a**2)/(2*g)+Z_a)-((P_b)+((V_b**2)/(2*g))+Z_b)#calculating heat extracted
,2)
P=round(ga*Q*H_T*eta,2) #Calculating power
print "Answer given in the book is wrong.It is,"
print "P=",P,"kW"
import math
#variable initialisation
Q=0.20 #Discharge in m^3/s
r=0.25 #radius at point 1 in m
r1=0.35 #radius at point 2 in m
P1=120 #pressure head at the upstream of turbine in m
ga=9.79 #unit length of water in kN/m^3
alpha_1=1.1 #kinetic energy correction factors for section 1
Z1=25 #elevation at section 1 in m
alpha_2=1.5 #kinetic energy correction factors for section 2
Z2=20 #elevation at section 2 in m
g=9.81 #gravity
#Calculation
V1=round(Q/((math.pi/4)*(r**2)),3)
V2=round((Q/((math.pi/4)*(r1**2))),3)
#Applying Bernoullis equation to points 1 and 2
#(P1/ga)+(V1**2)/(2*g)+Z1)=(P2/ga)+((V2**2)/(2*g))+Z2+H_L
#given H_L is,
H_L=round((1.2*(V1-V2)**2)/(2*g),3) #calculating frictional loss
P2=round((((P1/ga)+alpha_1*((V1**2)/(2*g))+Z1)-(alpha_2*((V2**2)/(2*g))+Z2+H_L)),3)
print "P2=",round(P2*ga,2),"kPa"