diff options
Diffstat (limited to 'Fluid_mechanics_by_Pao/Chapter_8.ipynb')
-rwxr-xr-x | Fluid_mechanics_by_Pao/Chapter_8.ipynb | 802 |
1 files changed, 802 insertions, 0 deletions
diff --git a/Fluid_mechanics_by_Pao/Chapter_8.ipynb b/Fluid_mechanics_by_Pao/Chapter_8.ipynb new file mode 100755 index 00000000..76c114d3 --- /dev/null +++ b/Fluid_mechanics_by_Pao/Chapter_8.ipynb @@ -0,0 +1,802 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:f292d23876c88421bcfc8b761169402a2885837db02032e303215ae83f2c5cf5"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 8 - Fluid compressibility and incompressible flow"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1 - Pg 323"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the initial and final volumes. Also, calculate the final temperature of the gas\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "pi=14.7 #psia\n",
+ "pf=50. #psia\n",
+ "cp=0.240 #Btu/lb R\n",
+ "cv=0.170 #Btu/lb R\n",
+ "J=778\n",
+ "T=60+459.6 #R\n",
+ "#calculations\n",
+ "R=J*(cp-cv)\n",
+ "k=cp/cv\n",
+ "gam=pi*144./(R*T)\n",
+ "V=1/gam\n",
+ "Vf=V*math.pow((pi/pf),(1/k))\n",
+ "Tf=T*(pf*Vf/(pi*V))\n",
+ "#results\n",
+ "print '%s %.2f %s' %(\"Initial volume =\",V,\"ft^3\")\n",
+ "print '%s %.2f %s' %(\"\\n Final volume =\",Vf,\"cu ft\")\n",
+ "print '%s %.1f %s' %(\"\\n Final temperature =\",Tf,\" R\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Initial volume = 13.37 ft^3\n",
+ "\n",
+ " Final volume = 5.62 cu ft\n",
+ "\n",
+ " Final temperature = 742.6 R\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2 - Pg 325"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the pressure difference across the pipe\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "ratio=0.99\n",
+ "E=3.19e5 #lb/in^2\n",
+ "#calculations\n",
+ "pd=-E*math.log(ratio)\n",
+ "#ersults\n",
+ "print '%s %d %s' %(\"Pressure difference =\",pd,\"psi\")\n",
+ "print '%s' %(\"The answers are a bit different from textbook due to rounding off error\")"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Pressure difference = 3206 psi\n",
+ "The answers are a bit different from textbook due to rounding off error\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3 - Pg 329"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the speed of test plane\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "k=1.4\n",
+ "g=32.2 #ft/s^2\n",
+ "R=53.3 #ft-lb/lb R\n",
+ "T=389.9 #R\n",
+ "Nm=2\n",
+ "#calculations\n",
+ "c=math.sqrt(k*g*R*T)\n",
+ "V=Nm*c*3600/5280.\n",
+ "#results\n",
+ "print '%s %.1f %s' %(\"Speed of test plane =\",V,\"mph\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Speed of test plane = 1319.9 mph\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4a - Pg 337"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the velocity at section 2\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "T1=584.6 #R\n",
+ "g=32.2 #ft/s^2\n",
+ "k=1.4\n",
+ "R=53.3 #ft-lb/lb R\n",
+ "V1=600 #ft/s\n",
+ "T2=519.6 #R\n",
+ "#calculations\n",
+ "Nm1=V1/(math.sqrt(k*g*R*T1))\n",
+ "Nm22= ((1+ (k-1)/2 *Nm1*Nm1)/(T2/T1) -1)*(2/(k-1))\n",
+ "Nm2=math.sqrt(Nm22)\n",
+ "V2=Nm2*math.sqrt(k*g*R*T2)\n",
+ "#results\n",
+ "print '%s %d %s' %(\"Velocity at section 2 =\",V2,\"ft/s\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Velocity at section 2 = 1068 ft/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4b - Pg 337"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the pressure difference between two stations\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "T1=584.6 #R\n",
+ "g=32.2 #ft/s^2\n",
+ "k=1.4\n",
+ "R=53.3 #ft-lb/lb R\n",
+ "V1=600 #ft/s\n",
+ "T2=519.6 #R\n",
+ "pa=14.7 #psi\n",
+ "p1=50 #psia\n",
+ "#calculations\n",
+ "Nm1=V1/(math.sqrt(k*g*R*T1))\n",
+ "Nm22= ((1+ (k-1)/2 *Nm1*Nm1)/(T2/T1) -1)*(2/(k-1))\n",
+ "Nm2=math.sqrt(Nm22)\n",
+ "pr=math.pow(((1+ (k-1)/2 *Nm1*Nm1)/(1+ (k-1)/2 *Nm2*Nm2)),(k/(k-1)))\n",
+ "p2=pr*(p1+pa)\n",
+ "dp=p1+pa-p2\n",
+ "#results\n",
+ "print '%s %.1f %s' %(\"Pressure difference between two stations =\",dp,\"psi\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Pressure difference between two stations = 21.9 psi\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4c - Pg 338"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the area ratio\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "T1=584.6 #R\n",
+ "g=32.2 #ft/s^2\n",
+ "k=1.4\n",
+ "R=53.3 #ft-lb/lb R\n",
+ "V1=600 #ft/s\n",
+ "T2=519.6 #R\n",
+ "#calculations\n",
+ "Nm1=V1/(math.sqrt(k*g*R*T1))\n",
+ "Nm22= ((1+ (k-1)/2 *Nm1*Nm1)/(T2/T1) -1)*(2/(k-1))\n",
+ "Nm2=math.sqrt(Nm22)\n",
+ "Ar= Nm1/Nm2 *math.pow(((1+ (k-1)/2 *Nm2*Nm2)/(1+ (k-1)/2 *Nm1*Nm1)),((k+1)/(2*(k-1))))\n",
+ "#results\n",
+ "print '%s %.3f' %(\"Area ratio = \",Ar)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Area ratio = 0.754\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4d - Pg 338"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the density of air at both the stations\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "T1=584.6 #R\n",
+ "g=32.2 #ft/s^2\n",
+ "k=1.4\n",
+ "R=53.3 #ft-lb/lb R\n",
+ "V1=600 #ft/s\n",
+ "T2=519.6 #R\n",
+ "pa=14.7 #psi\n",
+ "p1=50 #psia\n",
+ "#calculations\n",
+ "Nm1=V1/(math.sqrt(k*g*R*T1))\n",
+ "Nm22= ((1+ (k-1)/2 *Nm1*Nm1)/(T2/T1) -1)*(2/(k-1))\n",
+ "Nm2=math.sqrt(Nm22)\n",
+ "pr=math.pow(((1+ (k-1)/2 *Nm1*Nm1)/(1+ (k-1)/2 *Nm2*Nm2)),(k/(k-1)))\n",
+ "p2=pr*(p1+pa)\n",
+ "rho1=(p1+pa)*144./(g*R*T1)\n",
+ "rho2=p2*144./(g*R*T2)\n",
+ "#results\n",
+ "print '%s %.5f %s' %(\"Density of air at station 1 =\",rho1,\"slug/ft^3\")\n",
+ "print '%s %.5f %s' %(\"\\n Density of air at station 2 =\",rho2,\"slug/ft^3\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Density of air at station 1 = 0.00929 slug/ft^3\n",
+ "\n",
+ " Density of air at station 2 = 0.00692 slug/ft^3\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5 - Pg 345"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the mass rate of air flow\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "p0=19.7 #psia\n",
+ "R=53.3 #lb-ft/lb-R\n",
+ "T0=539.6 #R\n",
+ "g=32.2 #ft/s^2\n",
+ "pa=14.7 #psia\n",
+ "d=1 #in\n",
+ "k=1.4\n",
+ "#calculations\n",
+ "rho0=p0*144/(g*R*T0)\n",
+ "pr=pa/p0\n",
+ "G=math.pi/4 *(d/12.)*(d/12.) *math.pow((2*k/(k-1) *p0*144*rho0),(0.5)) *math.pow((pr),(1/k)) *math.pow((1-math.pow(pr,((k-1)/k))),0.5)\n",
+ "#results\n",
+ "print '%s %.5f %s' %(\"Mass rate of air flow =\",G,\"slug/sec\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Mass rate of air flow = 0.00978 slug/sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6 - Pg 346"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the mass rate of air flow\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "p0=64.7 #psia\n",
+ "R=53.3 #lb-ft/lb-R\n",
+ "T0=539.6 #R\n",
+ "g=32.2 #ft/s^2\n",
+ "pa=14.7 #psia\n",
+ "d=1. #in\n",
+ "k=1.4\n",
+ "#calculations\n",
+ "rho0=p0*144/(g*R*T0)\n",
+ "pr=pa/p0\n",
+ "G=math.pi/4 *(d/12)*d/12. *math.pow((k*p0*144*rho0),(0.5)) *math.pow((2/(k+1)),((k+1)/(2*(k-1))))\n",
+ "#results\n",
+ "print '%s %.5f %s' %(\"Mass rate of air flow =\",G,\"slug/sec\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Mass rate of air flow = 0.03616 slug/sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7a - Pg 347"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the weight of air flow through the nozzle\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "k=1.4\n",
+ "R=53.3 #lb-ft/lb R\n",
+ "pe=14.7 #psia\n",
+ "p0=114.7 #psia\n",
+ "T0=524.6 #R\n",
+ "g=32.2 #ft/s^2\n",
+ "d=0.5 #in\n",
+ "#calculations\n",
+ "pr=pe/p0\n",
+ "prcr=0.528\n",
+ "pr=prcr*p0\n",
+ "rho0= p0*144/(g*R*T0)\n",
+ "G=math.pi/4 *(d/12)*d/12. *math.pow((k*p0*144*rho0),(0.5)) *math.pow((2/(k+1)),((k+1)/(2*(k-1))))\n",
+ "Wt=G*g\n",
+ "#results\n",
+ "print '%s %.4f %s' %(\"weight of air flow through the nozzle =\",Wt,\"lb/s\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "weight of air flow through the nozzle = 0.5233 lb/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7b - Pg 348"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the exit Mach number, exit velocity and the exit area\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "k=1.4\n",
+ "R=53.3 #lb-ft/lb R\n",
+ "pe=14.7 #psia\n",
+ "p0=114.7 #psia\n",
+ "T0=524.6 #R\n",
+ "g=32.2 #ft/s^2\n",
+ "d=0.5 #in\n",
+ "Nm1=1.\n",
+ "#calculations\n",
+ "pr=pe/p0\n",
+ "Nme=math.sqrt(2/(k-1) *(math.pow(1./pr,(k-1)/k) -1))\n",
+ "Te=T0/(1+ (k-1)/2 *Nme*Nme)\n",
+ "Ve=Nme*math.sqrt(k*g*R*Te)\n",
+ "At=math.pi/4. *(d)*d\n",
+ "Ae=Nm1/Nme *math.pow(((1+ (k-1)/2 *Nme*Nme)/(1+ (k-1)/2 *Nm1*Nm1)),((k+1)/(2*(k-1)))) *At\n",
+ "#results\n",
+ "print '%s %.2f' %(\"Mach number exit = \",Nme)\n",
+ "print '%s %d %s' %(\"\\n Exit velocity =\",Ve,\"ft/s\")\n",
+ "print '%s %.3f %s' %(\"\\n Exit area =\",Ae,\" in^2\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Mach number exit = 2.00\n",
+ "\n",
+ " Exit velocity = 1672 ft/s\n",
+ "\n",
+ " Exit area = 0.331 in^2\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8a - Pg 349"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the exit mass flow rate, pressure, temperature, velocity and mach number\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "k=1.4\n",
+ "R=53.3 #lb-ft/lb R\n",
+ "p0=100. #psia\n",
+ "T0=534.6 #R\n",
+ "g=32.2 #ft/s^2\n",
+ "d=0.5 #in\n",
+ "Nm1=1.\n",
+ "A=2./144. #ft^2\n",
+ "#calculations\n",
+ "print '%s' %(\"Exit mach number is found using trial and error\")\n",
+ "Nme=2.44\n",
+ "rho0=p0*144/(g*R*T0)\n",
+ "G= A*math.sqrt(k*p0*144*rho0) *math.pow((2/(k+1)),((k+1)/(2*(k-1))))\n",
+ "pe=p0*math.pow((1/(1+(k-1)/2 *Nme*Nme)),(k/(k-1)))\n",
+ "Te=T0/(1+ (k-1)/2 *Nme*Nme)\n",
+ "Ve=Nme*(math.sqrt(k*g*R*Te))\n",
+ "#results\n",
+ "print '%s %.3f %s' %(\"\\n Exit mass flow rate =\",G,\"slug/s\")\n",
+ "print '%s %.2f %s' %(\"\\n Exit pressure =\",pe,\"psia\")\n",
+ "print '%s %.1f %s' %(\"\\n Exit temperature =\",Te,\" R\")\n",
+ "print '%s %d %s' %(\"\\n Exit velocity =\",Ve,\"ft/s\")\n",
+ "print '%s %.2f' %(\"\\n Exit mach number = \",Nme)\n",
+ "print '%s' %(\"The answers are a bit different from textbook due to rounding off error\")"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Exit mach number is found using trial and error\n",
+ "\n",
+ " Exit mass flow rate = 0.143 slug/s\n",
+ "\n",
+ " Exit pressure = 6.43 psia\n",
+ "\n",
+ " Exit temperature = 244.0 R\n",
+ "\n",
+ " Exit velocity = 1868 ft/s\n",
+ "\n",
+ " Exit mach number = 2.44\n",
+ "The answers are a bit different from textbook due to rounding off error\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8b - Pg 350"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the exit mass flow rate, pressure, temperature,velocity and mach number\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "k=1.4\n",
+ "R=53.3 #lb-ft/lb R\n",
+ "p0=100. #psia\n",
+ "T0=534.6 #R\n",
+ "g=32.2 #ft/s^2\n",
+ "d=0.5 #in\n",
+ "Nm1=1.\n",
+ "A=2./144. #ft^2\n",
+ "#calculations\n",
+ "print '%s' %(\"Exit mach number is found using trial and error\")\n",
+ "Nme=0.24\n",
+ "rho0=p0*144/(g*R*T0)\n",
+ "G= A*math.sqrt(k*p0*144*rho0) *math.pow((2/(k+1)),((k+1)/(2*(k-1))))\n",
+ "pe=p0*math.pow((1/(1+(k-1)/2 *Nme*Nme)),(k/(k-1)))\n",
+ "Te=T0/(1+ (k-1)/2 *Nme*Nme)\n",
+ "Ve=Nme*(math.sqrt(k*g*R*Te))\n",
+ "#results\n",
+ "print '%s %.3f %s' %(\"\\n Exit mass flow rate =\",G,\"slug/s\")\n",
+ "print '%s %.2f %s' %(\"\\n Exit pressure =\",pe,\"psia\")\n",
+ "print '%s %.1f %s' %(\"\\n Exit temperature =\",Te,\" R\")\n",
+ "print '%s %d %s' %(\"\\n Exit velocity =\",Ve,\"ft/s\")\n",
+ "print '%s %.2f' %(\"\\n Exit mach number = \",Nme)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Exit mach number is found using trial and error\n",
+ "\n",
+ " Exit mass flow rate = 0.143 slug/s\n",
+ "\n",
+ " Exit pressure = 96.07 psia\n",
+ "\n",
+ " Exit temperature = 528.5 R\n",
+ "\n",
+ " Exit velocity = 270 ft/s\n",
+ "\n",
+ " Exit mach number = 0.24\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9 - Pg 355"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the upstream Mach number, pressure, Temperature\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "k=1.4\n",
+ "R=53.3 #lb-ft/lb R\n",
+ "pu=6.43 #psia\n",
+ "Tu=244. #R\n",
+ "Nmu=2.44\n",
+ "#calculations\n",
+ "Nmd = math.sqrt(((k-1)*Nmu*Nmu +2)/(2*k*Nmu*Nmu - (k-1)))\n",
+ "pd=pu*(2*k*Nmu*Nmu - (k-1))/(k+1)\n",
+ "Td=Tu*(2*k*Nmu*Nmu - (k-1))/(k+1) *((k-1)*Nmu*Nmu +2)/((k+1)*Nmu*Nmu)\n",
+ "#results\n",
+ "print '%s %.3f' %(\"Mach number upstream = \",Nmd)\n",
+ "print '%s %.1f %s' %(\"\\n Pressure upstream =\",pd,\"psia\")\n",
+ "print '%s %.1f %s' %(\"\\n Temperature upstream =\",Td,\"R\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Mach number upstream = 0.519\n",
+ "\n",
+ " Pressure upstream = 43.6 psia\n",
+ "\n",
+ " Temperature upstream = 507.2 R\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 10 - Pg 359"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the pressure and temperature at section 1\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "k=1.4\n",
+ "R=53.3 #lb-ft/lb R\n",
+ "e=0.0005 #ft\n",
+ "mu=3.77e-7 #lb-sec/ft^2\n",
+ "pe=14.7 #psia\n",
+ "Te=524.6 #R\n",
+ "g=32.2 #ft/s^2\n",
+ "Vi=12.5 #ft/s\n",
+ "l=6. #in\n",
+ "b=8. #in\n",
+ "L=100. #ft\n",
+ "#calculations\n",
+ "rhoe=pe*144/(R*g*Te)\n",
+ "Ve=Vi/(g*rhoe*(l*b/144.))\n",
+ "Nme=Ve/(math.sqrt(k*g*R*Te))\n",
+ "Rd=l*b/(2*(l+b)) /12.\n",
+ "rr=2*R/e\n",
+ "Nr=Ve*4*Rd*rhoe/mu\n",
+ "f=0.019\n",
+ "f2=1/(2*k) *(1/Nme*Nme -1) - (k+1)/(4*k) *math.log((1+ (k-1)/2 *Nme*Nme)/(Nme*Nme *(1+(k-1)/2)))\n",
+ "ff=f*L/(8*Rd) +f2\n",
+ "Nm1=0.305\n",
+ "Tr2=(1+ (k-1)/2 *Nm1*Nm1)/(1+ (k-1/2))\n",
+ "Tre=(1+ (k-1)/2 *Nme*Nme)/(1+ (k-1/2))\n",
+ "pr2=Nm1*math.pow((1+ (k-1)/2 *Nm1*Nm1),(0.5)) /math.pow((1+(k-1)/2),0.5)\n",
+ "pre=Nme*math.pow((1+ (k-1)/2 *Nme*Nme),(0.5)) /math.pow((1+(k-1)/2),0.5)\n",
+ "p1=pe/pr2 *pre\n",
+ "T1=Te/Tr2 *Tre\n",
+ "#results\n",
+ "print '%s %.1f %s' %(\"Pressure at section 1 =\",p1,\"psia\")\n",
+ "print '%s %.1f %s' %(\"\\n Tempreature at section 1 =\",T1,\"R\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Pressure at section 1 = 21.5 psia\n",
+ "\n",
+ " Tempreature at section 1 = 535.1 R\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 11 - Pg 364"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the limiting pressure and distance in both adiabatic and non-adiabatic cases\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "k=1.4\n",
+ "R=53.3 #lb-ft/lb R\n",
+ "g=32.2 #ft/s^2\n",
+ "T1=534.6 #R\n",
+ "V1=400. #ft/s\n",
+ "p1=350. #psia\n",
+ "f=0.02\n",
+ "D=6./12. #ft\n",
+ "#calculations\n",
+ "Nm1=V1/math.sqrt(k*g*R*T1)\n",
+ "Nm2= 1. /math.sqrt(k)\n",
+ "p2=p1*(Nm1)/Nm2\n",
+ "fl= math.log(Nm1/Nm2) + 1./(2.*k*Nm1*Nm1) *(1- Nm1*Nm1/Nm2*Nm2)\n",
+ "L12=fl*2*D/f\n",
+ "ps=p1*Nm1*math.pow((1+ (k-1)/2 *Nm1*Nm1),0.5) /math.pow((1+(k-1)/2),0.5)\n",
+ "Nm2=1.\n",
+ "fl2= -(k+1)/(4*k) *math.log((1+ (k-1)/2 *Nm1*Nm1)/(Nm1*Nm1 *(1+ (k-1)/2.))) + 1/(2*k*Nm1*Nm1) *(1- Nm1*Nm1 /Nm2*Nm2)\n",
+ "L2=fl2*2*D/f\n",
+ "#results\n",
+ "print '%s %.1f %s' %(\"Limiting pressure =\",p2,\" psia\")\n",
+ "print '%s %.1f %s' %(\"\\n Distance =\",L12,\" ft\")\n",
+ "print '%s %.1f %s' %(\"\\n Limiting pressure in adiabatic case =\",ps,\" psia\")\n",
+ "print '%s %.1f %s' %(\"\\n Distance required =\",L2,\"ft\")\n",
+ "print '%s' %(\"the answer is a bit different due to rounding of error in textbook\")"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Limiting pressure = 146.2 psia\n",
+ "\n",
+ " Distance = 81.8 ft\n",
+ "\n",
+ " Limiting pressure in adiabatic case = 114.2 psia\n",
+ "\n",
+ " Distance required = 84.2 ft\n",
+ "the answer is a bit different due to rounding of error in textbook\n"
+ ]
+ }
+ ],
+ "prompt_number": 16
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file |