diff options
Diffstat (limited to 'Problems_In_Fluid_Flow/ch2.ipynb')
-rw-r--r-- | Problems_In_Fluid_Flow/ch2.ipynb | 481 |
1 files changed, 481 insertions, 0 deletions
diff --git a/Problems_In_Fluid_Flow/ch2.ipynb b/Problems_In_Fluid_Flow/ch2.ipynb new file mode 100644 index 00000000..b825a760 --- /dev/null +++ b/Problems_In_Fluid_Flow/ch2.ipynb @@ -0,0 +1,481 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2 : pipe flow of gasses and gas liquid mixtures\n" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 2.1 page no : 27" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# find pressure maintained at compressor\n", + "\n", + "from scipy.optimize import fsolve\n", + "from math import *\n", + "\n", + "# Initialization of Variable\n", + "pi = 3.1428\n", + "mmm = 16.04/1000 #molar mass of methane\n", + "mV = 22.414/1000 #molar volume\n", + "R = 8.314\n", + "mu = 1.08/10**5\n", + "r = 4.2/100 #radius\n", + "rr = 0.026/2/r #relative roughness\n", + "Pfinal = 560.*1000.\n", + "tfinal = 273+24\n", + "l = 68.5\n", + "m = 2.35 #mass flow rate\n", + "\n", + "#calculation\n", + "A = pi*r**2\n", + "A = round(A*10.**5)/10.**5\n", + "rho = mmm/mV\n", + "rho24 = mmm*Pfinal*273/mV/101.3/tfinal #density at 24'C\n", + "u = m/rho24/A\n", + "Re = u*rho24*2*r/mu\n", + "\n", + "#from graph\n", + "phi = 0.0032\n", + "#for solving using fsolve we copy numerical value of constant terms\n", + "#using back calculation\n", + "#as pressure maintained should be more than Pfinal so guessed value is Pfinal\n", + "\n", + "def eqn(x):\n", + " y = m**2/A**2*log(x/Pfinal)+(Pfinal**2-x**2)/2/R/tfinal*mmm+4*phi*l/2/r*m**2/A**2\n", + " return y\n", + "x = fsolve(eqn,560*10**3)\n", + "print \"pressure maintained at compressor in (kN/m**2):\",x[0]/1000\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "pressure maintained at compressor in (kN/m**2): 960.06917347\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 2.2 pageno : 29" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "find\n", + "ratio of Pw/P1\n", + "maximum velocity in (m/s)\n", + "maximum mass flow rate in(kg/s)\n", + "heat taken up to maintain isothermal codition(J/s)\n", + "crtical pressure ratio in adiabatic condition\n", + "velocity at adiabatic condition in (m/s)\n", + "mass flow rate at adiabatic condition in (kg/s)\n", + "temperature of discharging gas in (Celcius)\n", + "'''\n", + "\n", + "from math import *\n", + "from numpy import *\n", + "from scipy.optimize import fsolve\n", + "\n", + "# Initialization of Variable\n", + "M = 28.8/1000\n", + "mu = 1.73/10**5\n", + "gamm = 1.402\n", + "P1 = 107.6*10**3\n", + "V = 22.414/1000\n", + "R = 8.314\n", + "temp = 285.\n", + "d = 4./1000\n", + "rr = 0.0008\n", + "phi = 0.00285\n", + "l = 68.5 \n", + "\n", + "#calculation\n", + "#constant term of equation\n", + "#part1\n", + "\n", + "a = 1.-8*phi*l/d #constant term in deff\n", + "def f(x):\n", + " return log(x**2)-x**2+2.938\n", + " \n", + "x = fsolve(f,1)\n", + "print x\n", + "z = 1./x[0]\n", + "z = round(z*1000.)/1000\n", + "print \"ratio of Pw/P1 : %.4f\"%z\n", + "\n", + "#part2\n", + "Pw = z*P1\n", + "nuw = V*P1*temp/Pw/M/273.\n", + "Uw = sqrt(nuw*Pw)\n", + "print \"maximum velocity in (m/s): %.4f\"%Uw\n", + "\n", + "#part3\n", + "Gw = pi*d**2/4*Pw/Uw\n", + "print \"maximum mass flow rate in(kg/s): %.4f\"%Gw\n", + "\n", + "#part4\n", + "G = 2.173/1000\n", + "J = G*Uw**2/2\n", + "print \"heat taken up to maintain isothermal codition(J/s): %.4f\"%J\n", + "\n", + "#part5\n", + "nu2 = 2.79 #found from graph\n", + "nu1 = R*temp/M/P1\n", + "P2 = P1*(nu1/nu2)**gamm\n", + "print \"crtical pressure ratio in adiabatic condition: %.4f\"%(P2/P1)\n", + "\n", + "#part6\n", + "Uw = sqrt(gamm*P2*nu2)\n", + "print \"velocity at adiabatic condition in (m/s): %.4f\"%Uw\n", + "\n", + "#part7\n", + "Gw = pi*d**2/4*Uw/nu2\n", + "print \"mass flow rate at adiabatic condition in (kg/s): %.4f\"%Gw\n", + "\n", + "\n", + "#part8\n", + "#polynomial in T of the form ax**2+bx+c = 0\n", + "c = gamm/(gamm-1)*P1*nu1+.5*Gw**2/pi**2/d**4*16*nu1**2\n", + "b = gamm/(gamm-1)*R/M\n", + "a = .5*Gw**2/pi**2/d**4*16*(R/M/P2)**2\n", + "y = poly1d([a,b,-c],False)\n", + "T2 = roots(y)\n", + "print \"temperature of discharging gas in (Celcius) : %.4f\"%(T2[1]-273)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "[ 1.0268468]\n", + "ratio of Pw/P1 : 0.9740\n", + "maximum velocity in (m/s): 295.6723\n", + "maximum mass flow rate in(kg/s): 0.0045\n", + "heat taken up to maintain isothermal codition(J/s): 94.9841\n", + "crtical pressure ratio in adiabatic condition: 0.1629\n", + "velocity at adiabatic condition in (m/s): 261.8257\n", + "mass flow rate at adiabatic condition in (kg/s): 0.0012\n", + "temperature of discharging gas in (Celcius) : -46.3847" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n" + ] + }, + { + "output_type": "stream", + "stream": "stderr", + "text": [ + "/usr/lib/python2.7/dist-packages/scipy/optimize/minpack.py:227: RuntimeWarning: The iteration is not making good progress, as measured by the \n", + " improvement from the last ten iterations.\n", + " warnings.warn(msg, RuntimeWarning)\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 2.3 pageno : 35" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "find\n", + "new estimate assumed\n", + "mass flow rate of steam through pipe\n", + "pressure of pipe at downstream end in\n", + "temperature of steam emerging from pipe\n", + "'''\n", + "\n", + "from scipy.optimize import fsolve \n", + "import math \n", + "\n", + "# Initialization of Variable\n", + "\n", + "#1 refer to initial condition\n", + "R=8.314\n", + "P1=550.*10**3\n", + "T1=273.+350\n", + "M=18./1000\n", + "d=2.4/100\n", + "pi=3.1428\n", + "A=pi*d**2./4\n", + "gamm=1.33\n", + "roughness=0.096/1000/d\n", + "l=0.85\n", + "phi=0.0035 #assumed value of friction factor\n", + "\n", + "#calculation\n", + "nu1=R*T1/M/P1\n", + "Pw=0.4*P1 #estimation\n", + "nuw=(P1/Pw)**0.75*nu1\n", + "enthalpy=3167*1000.\n", + "Gw=math.sqrt(enthalpy*A**2/(gamm*nuw**2/(gamm-1)-nu1**2/2-nuw**2/2))\n", + "def eqn(x):\n", + " return math.log(x/nu1)+(gamm-1)/gamm*(enthalpy/2*(A/Gw)**2*(1/x**2-1/nu1**2)+0.25*(nu1**2/x**2-1)-.5*math.log(x/nu1))+4*phi*l/d\n", + "\n", + "x=fsolve(eqn,0.2)\n", + "\n", + "if x[0] != nuw:\n", + " print \"we again have to estimate Pw/P1\"\n", + " print \"new estimate assumed as 0.45\"\n", + " Pw=0.45*P1 #new estimation\n", + " nuw=(P1/Pw)**0.75*nu1\n", + " # & we equalise nu2 to nuw\n", + " nu2=nuw \n", + " Gw=math.sqrt(enthalpy*A**2/(gamm*nuw**2/(gamm-1)-nu1**2./2-nuw**2./2))\n", + " print \"mass flow rate of steam through pipe kg/s): %.2f\"%(Gw) \n", + " #part 2\n", + " print \"pressure of pipe at downstream end in (kPa):\",Pw/1000\n", + "else:\n", + " print \"our estimation is correct\"\n", + "\n", + "#part3\n", + "enthalpyw=2888.7*1000. #estimated from steam table\n", + "Tw=math.sqrt((enthalpy-enthalpyw+.5*Gw**2/A**2*nu1**2)*2*A**2/Gw**2/R**2*M**2*Pw**2)\n", + "print \"temperature of steam emerging from pipe in (Celcius): %.4f\"%(Tw-273)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "we again have to estimate Pw/P1\n", + "new estimate assumed as 0.45\n", + "mass flow rate of steam through pipe kg/s): 0.46\n", + "pressure of pipe at downstream end in (kPa): 247.5\n", + "temperature of steam emerging from pipe in (Celcius): 209.9420\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 2.4 pageno : 39" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "find\n", + "pressure at nozzle throat\n", + "diameter required at nozzle throat\n", + "sonic velocity at throat\n", + "'''\n", + "\n", + "import math \n", + "\n", + "# Initialization of Variable\n", + "M=28.05/1000\n", + "gamm=1.23\n", + "R=8.314\n", + "atm=101.3*1000\n", + "P1=3.*atm\n", + "\n", + "#calculation\n", + "P2=P1*(2./(gamm+1))**(gamm/(gamm-1))\n", + "print \"pressure at nozzle throat (kPa): %.4f\"%(P2/1000.)\n", + "\n", + "#part2\n", + "temp=273.+50\n", + "nu1=R*temp/P1/M\n", + "G=18. #mass flow rate\n", + "nu2=nu1*(P2/P1)**(-1/gamm)\n", + "A=G**2*nu2**2*(gamm-1)/(2*gamm*P1*nu1*(1-(P2/P1)**((gamm-1)/gamm)))\n", + "d=math.sqrt(4*math.sqrt(A)/math.pi)\n", + "print \"diameter required at nozzle throat in (cm) : %.4f\"%(d*100)\n", + "#part3\n", + "vel=math.sqrt(2*gamm*P1*nu1/(gamm-1)*(1-(P2/P1)**((gamm-1)/gamm)))\n", + "print \"sonic velocity at throat in(m/s): %.4f\"%vel\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "pressure at nozzle throat (kPa): 169.7903\n", + "diameter required at nozzle throat in (cm) : 18.8847\n", + "sonic velocity at throat in(m/s): 324.9787\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 2.5 page no : 41" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# find height of manometer\n", + "\n", + "import math \n", + "\n", + "# Initialization of Variable\n", + "T=273.+15\n", + "rho=999.\n", + "rhom=13559. #density of mercury\n", + "g=9.81\n", + "P2=764.3/1000*rhom*g\n", + "R=8.314\n", + "M=16.04/1000\n", + "d=4.5/1000.\n", + "A=math.pi*d**2/4.\n", + "G=0.75/1000 #mass flow rate\n", + "delP=(1-math.exp(R*T*G**2./2/P2**2/M/A**2))*P2\n", + "h=-delP/rho/g\n", + "print \"height of manometer in (cm) %.4f\"%(h*100)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "height of manometer in (cm) 16.7941\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 2.6 page no : 44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "find\n", + "both liquid phase and solid phase \n", + "required pressure drop per unit length\n", + "'''\n", + "\n", + "import math \n", + "\n", + "# Initialization of Variable\n", + "rhol=931.\n", + "mu=1.55/10000 #viscosity of water\n", + "Vsp=0.6057 #specific volume\n", + "T=273+133.\n", + "mug=1.38/100000 #viscosity of steam\n", + "P=300*1000.\n", + "d=0.075\n", + "Gg=0.05 #mass flow gas phase\n", + "Gl=1.5 #mass flow liquid phase\n", + "A=math.pi*d**2./4\n", + "rho = 999.\n", + "#calculation\n", + "rhog=1./Vsp\n", + "rhog=round(rhog*1000)/1000.\n", + "velg=Gg/A/rhog\n", + "velg=round(velg*100)/100.\n", + "Reg=rhog*velg*d/mug\n", + "\n", + "#using chart\n", + "phig=0.00245 #friction factor gas phase\n", + "l=1\n", + "delPg=4*phig*velg**2*rhog/d\n", + "\n", + "#consider liquid phase\n", + "vell=Gl/A/rho\n", + "Rel=rho*vell*d/mu\n", + "if Rel>4000 and Reg>4000:\n", + " print \"both liquid phase and solid phase in turbulent motion\"\n", + " #from chart\n", + "\n", + "PHIg=5.\n", + "delP=PHIg**2.*delPg\n", + "print \"required pressure drop per unit length in (Pa) : %.4f\"%delP\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "both liquid phase and solid phase in turbulent motion\n", + "required pressure drop per unit length in (Pa) : 253.8050\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file |