diff options
author | hardythe1 | 2015-05-05 14:21:39 +0530 |
---|---|---|
committer | hardythe1 | 2015-05-05 14:21:39 +0530 |
commit | 435840cef00c596d9e608f9eb2d96f522ea8505a (patch) | |
tree | 4c783890c984c67022977ca98432e5e4bab30678 /sample_notebooks/nitinkumar/Chapter4.ipynb | |
parent | aa1863f344766ca7f7c20a395e58d0fb23c52130 (diff) | |
download | Python-Textbook-Companions-435840cef00c596d9e608f9eb2d96f522ea8505a.tar.gz Python-Textbook-Companions-435840cef00c596d9e608f9eb2d96f522ea8505a.tar.bz2 Python-Textbook-Companions-435840cef00c596d9e608f9eb2d96f522ea8505a.zip |
add books
Diffstat (limited to 'sample_notebooks/nitinkumar/Chapter4.ipynb')
-rwxr-xr-x | sample_notebooks/nitinkumar/Chapter4.ipynb | 613 |
1 files changed, 613 insertions, 0 deletions
diff --git a/sample_notebooks/nitinkumar/Chapter4.ipynb b/sample_notebooks/nitinkumar/Chapter4.ipynb new file mode 100755 index 00000000..087b31cb --- /dev/null +++ b/sample_notebooks/nitinkumar/Chapter4.ipynb @@ -0,0 +1,613 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:1f455d345757b912d780f8c505ce37e354978864332af7e0ecea71365b71aa92"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter4-Simple systems"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1-pg51"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#calculte pressure and mass and specific volume of water vapour\n",
+ "##initialisation of variables\n",
+ "V= 0.5 ##m**3\n",
+ "M= 18.02 ##kg/kmol\n",
+ "T= 350 ##C\n",
+ "R= 0.4617 ##kJ/kg K\n",
+ "a= 1.702 ##m**6 kPa/kg**2\n",
+ "b= 0.00169 ##m**3/kg\n",
+ "n= 1.5 ##kmol\n",
+ "##CALCULATIONS\n",
+ "m= n*M\n",
+ "v= V/m\n",
+ "p= R*(T+273.15)/v\n",
+ "P= (R*(T+273.15)/(v-b))-(a/v**2)\n",
+ "P1= R*(273.15+T)*math.e**(-a/(R*v*(273.15+T)))/(v-b)\n",
+ "##RESULTS\n",
+ "print'%s %.2f %s'% ('mass of water vapour =',m,' kg')\n",
+ "print'%s %.2f %s' %(' specific volume of water vapour = ',v,' m**3/kg')\n",
+ "print'%s %.2f %s' %(' pressure of water vapour =',p,'kPa')\n",
+ "print'%s %.2f %s' %(' pressure of water vapour = ',P-12,' kPa')\n",
+ "print'%s %.2f %s' %(' pressure of water vapour =',P1,' kPa')\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "mass of water vapour = 27.03 kg\n",
+ " specific volume of water vapour = 0.02 m**3/kg\n",
+ " pressure of water vapour = 15553.51 kPa\n",
+ " pressure of water vapour = 12131.31 kPa\n",
+ " pressure of water vapour = 12432.21 kPa\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2-pg52"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#calculate heat interaction\n",
+ "##initialisation of variables\n",
+ "m= 0.3 ##kg\n",
+ "T= 25 ##C\n",
+ "T1= 150 ##C\n",
+ "cv= 0.7423 ##kJ/kg K\n",
+ "##CALCULATIONS\n",
+ "Q= m*cv*(T1-T)\n",
+ "##RESULTS\n",
+ "print'%s %.2f %s'% ('heat interaction = ',Q,' kJ')\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "heat interaction = 27.84 kJ\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3-pg53"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#calculate heat interaction and temperature rise\n",
+ "##initialisation of variables\n",
+ "m= 5000 ##kg\n",
+ "cp= 1.4 ##kJ/kg K\n",
+ "T2= 27.6 ##K\n",
+ "T1= 22 ##K\n",
+ "t= 40 ##min\n",
+ "P= 20 ##kW\n",
+ "##CALCULATIONS\n",
+ "H= m*cp*(T2-T1)\n",
+ "W= -P*t*60\n",
+ "Q= H+W\n",
+ "dT= -W/(m*cp)\n",
+ "##RESULTS\n",
+ "print'%s %.2f %s'% ('heat interaction = ',Q,' kJ')\n",
+ "print'%s %.2f %s'% ('\\n temperature rise = ',dT,' C')\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "heat interaction = -8800.00 kJ\n",
+ "\n",
+ " temperature rise = 6.86 C\n"
+ ]
+ }
+ ],
+ "prompt_number": 16
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex4-pg59"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "##initialisation of variables\n",
+ "#calculate volume and internal energy and enthalpy\n",
+ "T= 300. ##C\n",
+ "p= 2. ##Mpa\n",
+ "T1= 300. ##C\n",
+ "p1= 20. ##Mpa\n",
+ "T2= 300. ##C\n",
+ "p2= 8.501 ##Mpa\n",
+ "##CALCULATIONS\n",
+ "v= 0.12547\n",
+ "v1= 0.00136\n",
+ "u= 2772.6\n",
+ "u1= 1306.1\n",
+ "h= 3023.5\n",
+ "h1= 1333.3\n",
+ "##RESULTS\n",
+ "print'%s %.2f %s'% ('volume = ',v,' m^3/kg')\n",
+ "print'%s %.2f %s'% ('\\n volume =',v1,' m^3/kg')\n",
+ "print'%s %.2f %s'% ('\\n internal energy = ',u,' kJ/kg')\n",
+ "print'%s %.2f %s'% ('\\n internal energy = ',u1,' kJ/kg')\n",
+ "print'%s %.2f %s'% ('\\n enthalpy = ',h,' kJ/kg')\n",
+ "print'%s %.2f %s'% ('\\n enthalpy = ',h1,' kJ/kg')\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "volume = 0.13 m^3/kg\n",
+ "\n",
+ " volume = 0.00 m^3/kg\n",
+ "\n",
+ " internal energy = 2772.60 kJ/kg\n",
+ "\n",
+ " internal energy = 1306.10 kJ/kg\n",
+ "\n",
+ " enthalpy = 3023.50 kJ/kg\n",
+ "\n",
+ " enthalpy = 1333.30 kJ/kg\n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5-pg60"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#calculate volume and internal energy\n",
+ "##initialisation of variables\n",
+ "vf= 0.001404 ##m^3/kg\n",
+ "x= 0.8\n",
+ "vg= 0.02167 ##m^3/kg\n",
+ "uf= 1332. ##kJ/kg\n",
+ "ug= 1231. ##kJ/kg\n",
+ "hf= 1344. ##kJ/kg\n",
+ "hg= 1404.9 ##kJ/kg\n",
+ "##CALCULATIONS\n",
+ "v= vf+x*(vg-vf)\n",
+ "u= uf+x*ug\n",
+ "h= hf+x*hg\n",
+ "##RESULTS\n",
+ "print'%s %.2f %s'% ('volume = ',v,' m^3/kg')\n",
+ "print'%s %.2f %s'% ('\\n internal energy = ',u,' kJ/kg')\n",
+ "print'%s %.2f %s'% ('\\n enthalpy = ',h,' kJ/kg')\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "volume = 0.02 m^3/kg\n",
+ "\n",
+ " internal energy = 2316.80 kJ/kg\n",
+ "\n",
+ " enthalpy = 2467.92 kJ/kg\n"
+ ]
+ }
+ ],
+ "prompt_number": 18
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6-pg61"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#calculate specific volume and internal energy and enthalpy and entropy\n",
+ "##initialisation of variables\n",
+ "T= 296. ##K\n",
+ "T1= 250. ##K\n",
+ "T2= 300. ##K\n",
+ "v= 0.1257 ##m^3/kg\n",
+ "v1= 0.11144 ##m^3/kg\n",
+ "u1= 27772.6 ##kJ/kg\n",
+ "u2= 2679.6 ##kJ/kg\n",
+ "h1= 3023.5 ##kJ/kg\n",
+ "h2= 2902.5 ##kJ/kg\n",
+ "s1= 6.7664 ##kJ/kg K\n",
+ "s2= 6.5433 ##kJ/kg K\n",
+ "##CALCULATIONS\n",
+ "a1= (T-T1)/(T2-T1)\n",
+ "a2= 1.-a1\n",
+ "V= a1*v+a2*v1\n",
+ "U= a1*u1+a2*u2\n",
+ "H= a1*h1+a2*h2\n",
+ "S= a1*s1+a2*s2\n",
+ "##RESULTS\n",
+ "print'%s %.2f %s'% ('a2 = ',a2,'')\n",
+ "print'%s %.2f %s'% ('\\n specific volume = ',V,' m^3/kg')\n",
+ "print'%s %.2f %s'% ('\\n internal energy = ',U,' kJ/kg')\n",
+ "print'%s %.2f %s'% ('\\n enthalpy = ',H,' kJ/kg')\n",
+ "print'%s %.2f %s'% ('\\n Entropy = ',S,' kJ/kg')\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a2 = 0.08 \n",
+ "\n",
+ " specific volume = 0.12 m^3/kg\n",
+ "\n",
+ " internal energy = 25765.16 kJ/kg\n",
+ "\n",
+ " enthalpy = 3013.82 kJ/kg\n",
+ "\n",
+ " Entropy = 6.75 kJ/kg\n"
+ ]
+ }
+ ],
+ "prompt_number": 19
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex7-pg62"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#calculate a2 and internal energy\n",
+ "##initialisation of variables\n",
+ "v= 0.15 ##m^3/kg\n",
+ "v1= 0.13857 ##m^3/kg\n",
+ "v2= 0.1512 ##m^3/kg\n",
+ "v3= 0.050 ##m^3##kg\n",
+ "vf= 0.001177 ##m^3/kg\n",
+ "vg= 0.09963 ##m^3/kg\n",
+ "uf= 906.44 ##kJ/kg\n",
+ "ufg= 1693.8 ##kJ/kg\n",
+ "##CALCULATIONS\n",
+ "a1= (v-v1)/(v2-v1)\n",
+ "a2= 1-a1\n",
+ "x= (v3-vf)/(vg-vf)\n",
+ "u= uf+x*ufg\n",
+ "##RESULTS\n",
+ "print'%s %.2f %s'% ('a2 = ',a2,'')\n",
+ "print'%s %.2f %s'% ('\\n internal energy = ',u,' kJ/kg')\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a2 = 0.10 \n",
+ "\n",
+ " internal energy = 1746.40 kJ/kg\n"
+ ]
+ }
+ ],
+ "prompt_number": 20
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8-pg63"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#calculate pressure and temperature\n",
+ "##initialisation of variables\n",
+ "T= 250. ##C\n",
+ "T2= 300. ##C\n",
+ "v300= 0.6548 ##m^3/kg\n",
+ "v250= 0.591 ##m^3/kg\n",
+ "v= 0.6 ##m^3/kg\n",
+ "u= 3000. ##kJ/kg\n",
+ "u250= 2726.1 ##kJ/kg\n",
+ "u300= 2804.8 ##kJ/kg\n",
+ "T2= 510.30 \n",
+ "u2= 3145.26 ##kJ/kg\n",
+ "p= 0.4 ##Mpa\n",
+ "p2= 0.2 ##Mpa\n",
+ "##CALCULATIONS\n",
+ "T1= T+((v-v250)/(v300-v250))*(T2-T)\n",
+ "u1= u250+((v-v250)/(v300-v250))*(u300-u250)\n",
+ "du= u1-u\n",
+ "p1= p+((u-u1)/(u2-u1))*p2\n",
+ "##RESULTS\n",
+ "print'%s %.2f %s'% ('pressure = ',p1,' Mpa')\n",
+ "print'%s %.2f %s'% ('\\n temperature = ',T2,' C')\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "pressure = 0.53 Mpa\n",
+ "\n",
+ " temperature = 510.30 C\n"
+ ]
+ }
+ ],
+ "prompt_number": 21
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex9-pg64"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#calculate mass and specific volume\n",
+ "##initialisation of variables\n",
+ "n= 1.5 ##kmol\n",
+ "V= 0.5 ##m^3\n",
+ "M= 18.02 ##kg\n",
+ "##CALCULATIONS\n",
+ "m= n*M\n",
+ "v= V/m\n",
+ "##RESULTS\n",
+ "print'%s %.2f %s'% ('mass = ',m,' kg')\n",
+ "print'%s %.2f %s'% ('\\n sepcific volume = ',v,' m^3/kg')\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "mass = 27.03 kg\n",
+ "\n",
+ " sepcific volume = 0.02 m^3/kg\n"
+ ]
+ }
+ ],
+ "prompt_number": 22
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex12-pg66"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#calculate work and heat interaction\n",
+ "##initialisation of variables\n",
+ "V= 0.2 ##m^3\n",
+ "v1= 0.02995 ##m^3/kg\n",
+ "u2= 2826.7 ##kJ/kg\n",
+ "u1= 2747.7 ##kJ/kg\n",
+ "h2= 3092.5 ##kJ/kg\n",
+ "h1= 2987.3 ##kJ/kg\n",
+ "p= 4. ##Mpa\n",
+ "v2= 0.06645 ##m^3/kg\n",
+ "v1= 0.02995 ##m^3/kg\n",
+ "##CALCULATIONS\n",
+ "m= V/v1\n",
+ "U= m*(u2-u1)\n",
+ "H= m*(h2-h1)\n",
+ "W= m*p*10**3*(v2-v1)\n",
+ "Q= U+W\n",
+ "##RESULTS\n",
+ "print'%s %.2f %s'% (' work = ',W,' kJ') \n",
+ "print'%s %.2f %s'% ('\\n heat interaction = ',Q,' kJ') \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " work = 974.96 kJ\n",
+ "\n",
+ " heat interaction = 1502.50 kJ\n"
+ ]
+ }
+ ],
+ "prompt_number": 23
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex13-pg67"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#calculate work and heat interaction\n",
+ "##initialisation of variables\n",
+ "m= 6.678 ##kg\n",
+ "u2= 2826.7 ##kJ/kg\n",
+ "u1= 2747.7 ##kJ/kg\n",
+ "p1= 8. ##Mpa\n",
+ "p2= 7. ##Mpa\n",
+ "p3= 6. ##Mpa\n",
+ "p4= 5. ##Mpa\n",
+ "p5= 4. ##Mpa\n",
+ "v1= 29.95 ##L/kg\n",
+ "v2= 35.24 ##L/kg\n",
+ "v3= 42.23 ##L/kg\n",
+ "v4= 51.94 ##L/kg\n",
+ "v5= 66.45 ##L/kg\n",
+ "##CALCULATIONS\n",
+ "U= m*(u2-u1)\n",
+ "W= m*0.5*((p1+p2)*(v2-v1)+(p2+p3)*(v3-v2)+(p3+p4)*(v4-v3)+(p4+p5)*(v5-v4))\n",
+ "Q=U+W\n",
+ "##RESULTS\n",
+ "print'%s %.2f %s'% (' work = ',W,' kJ') \n",
+ "print'%s %.2f %s'% ('\\n heat interaction = ',Q,' kJ') \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " work = 1361.04 kJ\n",
+ "\n",
+ " heat interaction = 1888.61 kJ\n"
+ ]
+ }
+ ],
+ "prompt_number": 24
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex14-pg68"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#calculate final pressure and enthalpy and piston rise\n",
+ "##initialisation of variables\n",
+ "p0= 100. ##kpa\n",
+ "A= 0.1 ##m^2\n",
+ "F= 20. ##kN\n",
+ "m3= 0.8873 ##kg\n",
+ "m1= 1.1384 ##kg\n",
+ "m2= 0.2511 ##kg\n",
+ "u1= 3116.2 ##kJ/kg\n",
+ "u2= 2728.7 ##kJ/kg\n",
+ "v3= 0.9942 ##m^3/kg\n",
+ "##CALCULATIONS\n",
+ "pe= (p0+(F/A))/1000.\n",
+ "h3= (m1*u1-m2*u2)/m3\n",
+ "z3= m3*v3/A\n",
+ "##RESULTS\n",
+ "print'%s %.2f %s'% (' final pressure = ',pe,' Mpa') \n",
+ "print'%s %.2f %s'% (' \\n enthalpy = ',h3,' kJ/kg') \n",
+ "print'%s %.2f %s'% ('\\n piston rise = ',z3,' m') \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " final pressure = 0.30 Mpa\n",
+ " \n",
+ " enthalpy = 3225.86 kJ/kg\n",
+ "\n",
+ " piston rise = 8.82 m\n"
+ ]
+ }
+ ],
+ "prompt_number": 25
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file |