from __future__ import division
import math
import sympy
from sympy import symbols,diff,solve
#Initializing the variables
mu = 0.9;
rho = 1260;
g = 9.81;
x = 45; #theta in degrees
P1 = 250 * 10**3;
P2 = 80* 10**3;
Z1 = 1;
Z2 = 0; # datum
U = -1.5;
Y = 0.01;
#Calculations
gradP1 = P1+ rho*g*Z1;
gradP2 = P2+ rho*g*Z2;
DPstar = (gradP1-gradP2)*math.sin(math.radians(x))/(Z1-Z2);
A = U/Y; # Coefficient U/Y for equation 10.6
B = DPstar/(2*mu) # Coefficient dp*/dx X(1/2mu) for equation 10.6
y = symbols('y')
v = round((A + B*Y),1)*y -round(B)*y**2
duBYdy = diff(v,y);
tau = 0.9*duBYdy;
stagPnts = solve(duBYdy,y)
ymax=stagPnts[0] #value of y where derivative vanishes.;
umax = (A + B*Y)*ymax + B*ymax**2; # Check the value there is slight mistake in books answer
def u(y):
z = (A + B*Y)*y -B*y**2;
return diff(z,y)
def dif(y):
return round((A + B*Y)) -2*round(B)*y
taumax=abs(mu*dif(Y))
print "velocity distribution :",v
print "shear stress distribution :",mu*dif(y)
print "maximum flow velocity (m/s) :",round(umax,2)
print "Maximum Shear Stress (kN/m^2):",(round(taumax)/1000)
print
from __future__ import division
import math
#Initializing the variables
mu = 0.9;
rho = 1260;
d = 0.01;
Q = 1.8/60*10**-3; #Flow in m**3 per second
l = 6.5;
ReCrit = 2000;
#Calculations
A = (math.pi*d**2)/4;
MeanVel = Q/A;
Re = rho*MeanVel*d/mu/10; # Check properly the answer in book there is something wrong
Dp = 128*mu*l*Q/(math.pi*d**4)
Qcrit = Q*ReCrit/Re*10**3;
print "Pressure Loss (kN/m2) :",round(Dp/1000,0)
print "Maximum Flow rate (litres/s) :",round(Qcrit,0)
from __future__ import division
import math
#Initializing the variables
mu = 1.14*10**-3;
rho = 1000;
d = 0.04;
Q = 4*10**-3/60; #Flow in m**3 per second
l = 750;
ReCrit = 2000;
g = 9.81;
k = 0.00008; # Absolute Roughness
#Calculations
A = (math.pi*d**2)/4;
MeanVel = Q/A;
Re = rho*MeanVel*d/mu;
Dp = 128*mu*l*Q/(math.pi*d**4);
hL = Dp/(rho*g);
f = 16/Re;
hlDa = 4*f*l*MeanVel**2/(2*d*g); # By Darcy Equation
Pa = rho*g*hlDa*Q;
#Part(b)
Q = 30*10**-3/60; #Flow in m**3 per second
MeanVel = Q/A;
Re = rho*MeanVel*d/mu;
RR = k/d; # relative roughness
f = 0.008 #by Moody diagram for Re = 1.4 x 10**4 and relative roughness = 0.002
hlDb = 4*f*l*MeanVel**2/(2*d*g); # By Darcy Equation
Pb = rho*g*hlDb*Q;
print "!---- Case (a) ----!\n","Head Loss(mm) :",round(hlDa*1000,1)
print "Power Required (W) :",round(Pa,4)
print "\n!---- Case (b) ----!\n","Head Loss(m) :",round(hlDb,2)
print "Power Required (W) :",round(Pb,0)
from __future__ import division
import math
#Initializing the variables
w = 4.5;
d = 1.2 ;
C = 49;
i = 1/800;
#Calculations
A = d*w;
P = 2*d + w;
m = A/P;
v = C*(m*i)**0.5;
Q = v*A;
print "Mean Velocity (m/s):",round(v,2)
print "Discharge (m3/s) :",round(Q,2)
from __future__ import division
import sympy
from sympy import symbols
#Initializing the variables
r,R = symbols('r R')
#Calculations
rbyR=round((1-(49/60)**7),3)
r = (rbyR)*R
#Result
print "radius at which actual velocity is equal to mean velocity is",r
from __future__ import division
import math
#Initializing the variables
d1 = 0.140;
d2 = 0.250;
DpF_DpR = 0.6; #Difference in head loss when in forward and in reverse direction
K = 0.33 #From table
g = 9.81;
#Calculations
ratA = (d1/d2)**2;
v =(DpF_DpR*2*g/((1-ratA)**2-K))**0.5;
print "Velocity (m/s):",round(v,2)