from __future__ import division
from scipy.misc import derivative
x=.5 #initial value
xnew=0
e=1
while e>10**-4:
x=xnew
def Fa(x):
y=x**3-5*x+1# #defining fn
return y
der=derivative(Fa,x) #differentiating the fn
xnew=x-Fa(x)/der
e=abs(xnew-x)
print "the root of the eqn is",xnew
from __future__ import division
from scipy.misc import derivative
from sympy import symbols, sqrt,log
ff=symbols('ff')
meu=1.79*10**-5
rough=.0000015 #roughness
dia=.004
e_by_D=rough/dia
rho=1.23
v=50 #velocity of air
l=1
Re=(rho*v*dia)/meu #Reynold's number
ffnew=0.01
e=1
t1=e_by_D/3.7 #term 1 of eqn.
t2=2.51/Re #term 2 of eqn.
print "the Reynolds no. is",Re
while e>1e-6:
fff=ffnew
ff=symbols('ff')
t3=sqrt(ff)
y=1/t3+2*log(t1+t2/t3)/2.3
fdash=y.diff().subs(ff,fff)# #f'(ff)
ffnew=fff-y.subs(ff,fff)/fdash#
e=abs(fff-ffnew)
print "the fanning friction factor is",fff
delta_p=(fff*l*v**2*rho)/(2*dia) #pressure drop
print "the pressure drop in pascals is",delta_p
from __future__ import division
from scipy.misc import derivative
from math import log,sqrt
P=2*101325 #given data
T=298.15
M=28.97*10**-3
R=8.314
rho=(P*M)/(R*T)
rho_p=1000
dia=1.2*10**-4
ep=.42 #void fraction
sph=.88
meu=1.845*10**-5
t1=1.75*rho*(1-ep)/(sph*dia*ep**3) #these are the terms of the function.
t2=150*meu*(1-ep)**2/(sph**2*dia**2*ep**3)
t3=(1-ep)*(rho_p-rho)*9.8
vnew=0.1
e1=1
while e1>1e-6:
v=vnew
def Fb(v):
y=t1*v**2+t2*v-t3 #defining fn
return y
vdash=derivative(Fb,v) #differentiating the fn
vnew=v-Fb(v)/vdash
e1=abs(vnew-v)
print "the minimum fluidisation velocity in m/s is",v
from __future__ import division
from scipy.misc import derivative
from math import log,sqrt
dia=2*10**-3
P=101325 #given data
T=298.15
M=28.89*10**-3
R=8.314
rho=(P*M)/(R*T)
rho_oil=900
meu=1.85*10**-5
Re_oil_by_v=rho*dia/meu
vnew=0.1
e=1
while e>1e-6:
v=vnew
Re_oil=Re_oil_by_v*v
Cd=24*(1+.15*Re_oil**.687)/Re_oil
vnew=sqrt(4*(rho_oil-rho)*9.81*dia/(3*Cd*rho))
e=abs(vnew-v)
print "the terminal velocity in m/s is",v
from __future__ import division
from scipy.misc import derivative
from math import log,sqrt,exp,sin,cos
xnew=0.1
ynew=0.5
e1=1
e2=1
while e1>1e-6 and e2>1e-6:
x=xnew
y=ynew
y1=exp(x)+x*y-1
d_fx=exp(x)+y
d_fy=x
y2=sin(x*y)+x+y-1
d_gx=y*cos(x*y)+1
d_gy=x*cos(x*y)+1
t1=(y2*d_fy)
t2=(y1*d_gy)
D1=d_fx*d_gy-d_fy*d_gx
delta_x=(t1-t2)/D1
t3=(y1*d_gx)
t4=(y2*d_fx)
delta_y=(t3-t4)/D1
xnew=x+delta_x
ynew=y+delta_y
e1=abs(x-xnew)
e2=abs(y-ynew)
print "the values of x and y respectively are",x,y
print "such small value of x can be considered as zero."
from __future__ import division
from scipy.misc import derivative
from math import log,sqrt
xnew=0.1
ynew=0.5
e1=1
e2=1
while e1>10**-6 and e2>10**-6:
x=xnew
y=ynew
y1=3*x**3+4*y**2-145
d_fx=9*x**2
d_fy=8*y
y2=4*x**2-y**3+28
d_gx=8*x
d_gy=-3*y**2
D2=d_fx*d_gy-d_gx*d_fy
delta_x=(y2*d_fy-y1*d_gy)/D2
delta_y=(y1*d_gx-y2*d_fx)/D2
xnew=x+delta_x
ynew=y+delta_y
e1=abs(xnew-x)
e2=abs(ynew-y)
print "the values of x and y are respectively",x,y