diff options
author | root | 2014-07-14 15:31:28 +0530 |
---|---|---|
committer | root | 2014-07-14 15:31:28 +0530 |
commit | cea77a632f1b20598ba2a1be1b77e6587920c2a0 (patch) | |
tree | 0ac530caf18d10bd82bf11ffc1c96bfda13d0e39 /Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch2.ipynb | |
parent | 7b7e179ba5b3287d04539fc1826eba5d433eef6c (diff) | |
download | Python-Textbook-Companions-cea77a632f1b20598ba2a1be1b77e6587920c2a0.tar.gz Python-Textbook-Companions-cea77a632f1b20598ba2a1be1b77e6587920c2a0.tar.bz2 Python-Textbook-Companions-cea77a632f1b20598ba2a1be1b77e6587920c2a0.zip |
adding books
Diffstat (limited to 'Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch2.ipynb')
-rwxr-xr-x | Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch2.ipynb | 915 |
1 files changed, 915 insertions, 0 deletions
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch2.ipynb b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch2.ipynb new file mode 100755 index 00000000..72dc2069 --- /dev/null +++ b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch2.ipynb @@ -0,0 +1,915 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2 : Basic Concepts Of Thermodynamicsm" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.1 Page no : 41" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Variables\n", + "rho_Hg = 13596.; \t\t\t#kg/m**3\n", + "g = 9.806; \t\t\t#m/s**2\n", + "h = 0.76; \t\t\t#m\n", + "\n", + "# Calculations and Results\n", + "P = rho_Hg*g*h/1000; \t\t\t#kPa\n", + "\n", + "\n", + "h1 = 0.80; \t\t\t#m\n", + "P1 = h1/h*P;\n", + "print \"(i) Pressure of 80 cm of Hg %.3f kPa\"%P1\n", + "\n", + "\n", + "print (\"(ii) 30 cm Hg vacuum\")\n", + "H2 = 0.30; \t\t\t#cm Hg vacuum\n", + "h2 = h-H2; \t\t\t#cm of Hg absolute\n", + "\n", + "P2 = h2/h*P;\n", + "print \"Pressure due to 46 cm of Hg %.3f kPa\"%P2\n", + "\n", + "rho_H2O = 1000; \t\t\t#kg/m**3\n", + "h3 = 1.35; \t\t\t#m\n", + "P3 = rho_H2O*g*h3/1000;\n", + "print \"(iii) Pressure due to 1.35 m H2O gauge %.3f kPa\"%(P3)\n", + "\n", + "\n", + "P4 = 4.2*10**2;\n", + "print \"(iv) 4.2 bar %.3f kPa\"%(P4),\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(i) Pressure of 80 cm of Hg 106.658 kPa\n", + "(ii) 30 cm Hg vacuum\n", + "Pressure due to 46 cm of Hg 61.328 kPa\n", + "(iii) Pressure due to 1.35 m H2O gauge 13.238 kPa\n", + "(iv) 4.2 bar 420.000 kPa\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.2 page no : 42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "# Variables\n", + "d = 0.1; \t\t\t#m\n", + "F = 1000.; \t\t\t#N\n", + "\n", + "# Calculations\n", + "A = math.pi/4*d**2; \t\t\t#m**2\n", + "P = F/A/10**3;\n", + "\n", + "# Results\n", + "print \"Pressure on the piston = %.3f kN/m**2\"%(P),\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Pressure on the piston = 127.324 kN/m**2\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.3 page no : 42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Variables\n", + "SG = 0.9;\n", + "h = 1.2; \t\t\t#m\n", + "g = 9.81; \t\t\t#m/s**2\n", + "rho_w = 1000.; \t\t\t#kg/m**3\n", + "\n", + "# Calculations\n", + "rho = SG*rho_w; \t\t\t#kg/m**3\n", + "P = rho*g*h/10**3;\n", + "\n", + "# Results\n", + "print \"Gauge pressure P = %.3f kN/m**2\"%(P)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Gauge pressure P = 10.595 kN/m**2\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.4 page no : 43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Variables\n", + "Vacuum_recorded = 740.; \t\t\t#mm of Hg\n", + "Barometric_reading = 760.; \t\t\t#mm of Hg\n", + "\n", + "# Calculations\n", + "Absolute_pressure = (Barometric_reading-Vacuum_recorded)*133.4;\n", + "\n", + "# Results\n", + "print \"Absolute pressure in the condenser = %.3f Pa\"%(Absolute_pressure),\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Absolute pressure in the condenser = 2668.000 Pa\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.5 page no : 43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "# Variables\n", + "d = 0.5; \t\t\t#m\n", + "h = 0.75; \t\t\t#m\n", + "m = 4.; \t\t\t#kg\n", + "Manometer_reading = 620.; \t\t\t#mm of Hg above atmosphere\n", + "Barometer_reading = 760.; \t\t\t#mm of Hg\n", + "V = math.pi/4*d**2*h; \t\t\t#m**3\n", + "print (\"(i) Total pressure in the vessel\")\n", + "\n", + "# Calculations and Results\n", + "P = (Barometer_reading+Manometer_reading)*133.4/10**5; \t\t\t#bar\n", + "print \"P = %.3f bar\"%(P)\n", + "\n", + "print (\"(ii) Specific volume and density\")\n", + "SV = V/m; \n", + "print \"Specific volume = %.3f m**3/kg\"%(SV)\n", + "\n", + "D = m/V;\n", + "print \"Density = %.3f kg/m**3\"%(D),\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(i) Total pressure in the vessel\n", + "P = 1.841 bar\n", + "(ii) Specific volume and density\n", + "Specific volume = 0.037 m**3/kg\n", + "Density = 27.162 kg/m**3\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.6 page no : 43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Variables\n", + "h0 = .761; \t\t\t#m\n", + "h = .55; \t\t\t#m\n", + "g = 9.79; \t\t\t#m/s**2\n", + "rho = 13640.; \t\t\t#kg/m**3\n", + "\n", + "# Calculations\n", + "P = rho*g*(h0+h); \t\t\t#N/m**2\n", + "\n", + "# Results\n", + "print \"Gas pressure = %.3f bar\"%(P/10**5),\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Gas pressure = 1.751 bar\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.7 page no : 44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Variables\n", + "h_H2O = 34.; \t\t\t#mm of Hg\n", + "g = 9.81; \t\t\t#m/s**2\n", + "rho = 13600.; \t\t\t#kg/m**3\n", + "P_Hg = 97.5; \t\t\t#mm of Hg\n", + "P_atm = 760.; \t\t\t#mm of Hg\n", + "\n", + "# Calculations\n", + "P_H2O = h_H2O/13.6; \t\t\t#mm of Hg\n", + "Pabs = rho*g*(P_Hg+P_atm-P_H2O)/10**8; \t\t\t#bar\n", + "\n", + "# Results\n", + "print \"absolute pressure = %.3f bar\"%(Pabs)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "absolute pressure = 1.141 bar\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.8 page no : 44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Variables\n", + "SG = 0.8;\n", + "rho_H2O = 1000.; \t\t\t#kg/m**3\n", + "g = 9.81; \t\t\t#ms**2\n", + "h = 0.17; \t\t\t#m\n", + "Patm = 1.01325; \t\t\t#bar\n", + "\n", + "# Calculations\n", + "rho = SG*rho_H2O; \t\t\t#kg/m**3\n", + "P_liq = rho*g*h/10**5; \t\t\t#bar\n", + "P_gas = Patm - P_liq;\n", + "\n", + "# Results\n", + "print \"gas pressure = %.3f bar\"%(P_gas),\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "gas pressure = 1.000 bar\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.9 page no : 45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "# Variables\n", + "d = 0.2; \t\t\t#m\n", + "g = 9.81; \t\t\t#m/s**2\n", + "h = 0.117; \t\t\t#m\n", + "rho = 13600.; \t\t\t#kg/m**3\n", + "\n", + "# Calculations\n", + "p = rho*g*h;\n", + "m = (p*math.pi/4*d**2)/g;\n", + "\n", + "# Results\n", + "print \"mass = %.3f kg\"%(m),\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "mass = 49.989 kg\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.10 page no : 49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Variables\n", + "v = 800.; \t\t\t#m/s\n", + "g = 9.; \t\t\t#m/s**2\n", + "F = 3600.; \t\t\t#N\n", + "\n", + "# Calculations\n", + "m = F/g;\n", + "KE = 1./2*m*v**2./10**6;\n", + "\n", + "# Results\n", + "print \"Kinetic Energy = %.3f MJ\"%(KE),\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Kinetic Energy = 128.000 MJ\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.11 page no : 49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "from scipy.integrate import quad \n", + "\n", + "# Variables\n", + "m = 6.; \t\t\t#kg\n", + "T1 = 25.; \t\t\t#0C\n", + "T2 = 125.; \t\t\t#0C\n", + "\n", + "print (\"(i) Heat transferred\")\n", + "\n", + "# Calculations and Results\n", + "def f18(T): \n", + "\t return m*(0.4+0.004*T)\n", + "\n", + "Q = quad(f18,T1,T2)[0]\n", + "\n", + "print \"heat tranferred = %.3f kJ\"%(Q)\n", + "\n", + "print (\"(ii) Mean specific heat of the gas\")\n", + "c_n = Q/m/(T2-T1);\n", + "print \"Mean specific heat = %.3f kJ/kg.0C\"%(c_n),\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(i) Heat transferred\n", + "heat tranferred = 420.000 kJ\n", + "(ii) Mean specific heat of the gas\n", + "Mean specific heat = 0.700 kJ/kg.0C\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.12 page no : 50" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "from numpy import *\n", + "# Variables\n", + "Ice_point = 0.;\n", + "Steam_point = 100.;\n", + "\n", + "# Calculations\n", + "P = [[math.log(1.5),1],[math.log(7.5),1]];\n", + "Q = [0,100];\n", + "X = linalg.inv(P)*Q;\n", + "\n", + "a = X[0,1];\n", + "b = X[1,1];\n", + "p = 3.5;\n", + "t = a*math.log(p)+b;\n", + "\n", + "# Results\n", + "print (\"The value of temperature is given by %.3f\")%(t),(\"\u00b0C\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of temperature is given by 52.646 \u00b0C\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.13 page no : 50" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def func(t): \n", + "\t return 0.20*t-5*10**(-4)*t**2\n", + "# Variables # Calculations\n", + "t1 = 0; \t\t\t#0C\n", + "e1 = func(t1);\n", + "t2 = 100; \t\t\t#0C\n", + "e2 = func(t2);\n", + "t3 = 70; \t\t\t#0C\n", + "e3 = func(t3);\n", + "t = e3*(t2-t1)/e2-e1;\n", + "\n", + "# Results\n", + "print \"thermocouple will read\",t,\"\u00b0C\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "thermocouple will read 77.0 \u00b0C\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.15 page no : 51" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# Variables\n", + "p = 101.325; \t\t#kPa\n", + "V2 = 0.6; \t\t\t#m**3\n", + "V1 = 0; \t\t\t#m**3\n", + "\n", + "# Calculations\n", + "W = p*(V2-V1);\n", + "\n", + "# Results\n", + "print (\"work done by atmosphere = \"),(-W),\"kJ\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "work done by atmosphere = -60.795 kJ\n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.16 page no : 52" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from scipy import integrate\n", + "\n", + "# Variables\n", + "#p = 1.013*10**5; \t#N/m**2\n", + "p = lambda x: 1.013*10**5\n", + "V1 = 1.5; \t\t\t#m**3\n", + "V2 = 0; \t\t\t#m**3\n", + "\n", + "# Calculations\n", + "integ, err = integrate.quad(p,V1,V2)\n", + "\n", + "# Results\n", + "print (\"W = \"),(integ/10**3),\"kJ\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "W = -151.95 kJ\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.17 page no : 53" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "# Variables\n", + "T = 1.25; \t\t\t#N.m\n", + "N = 9500.;\n", + "p = 101.3; \t\t\t#kPa\n", + "d = 0.65; \t\t\t#m\n", + "L = 0.6; \t\t\t#m\n", + "\n", + "# Calculations\n", + "W1 = 2*math.pi*N*T/1000; \t#kJ\n", + "A = math.pi/4*d**2; #m**2\n", + "W2 = p*A*L; \t\t#kJ\n", + "Wnet = (-W1)+W2;\n", + "\n", + "# Results\n", + "print \"The net work transfer for the system = %.3f\"%(Wnet),\"kJ\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The net work transfer for the system = -54.444 kJ\n" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.18 page no : 53" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Variables\n", + "A = 45.*10**(-4); \t #m**2\n", + "P = 0.9*10**5; \t\t #N/m**2\n", + "Patm = 1.013*10**5; #N/m**2\n", + "L = 0.05; \t\t\t #m\n", + "\n", + "# Calculations\n", + "dV = 300.*10**(-6); \t\t\t#m**3\n", + "W = P*A*L-Patm*dV;\n", + "\n", + "# Results\n", + "print (\"net work done = \"),(W),\"J\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "net work done = -10.14 J\n" + ] + } + ], + "prompt_number": 22 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.19 page no : 54" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "from scipy.integrate import quad \n", + "\n", + "# Variables\n", + "p1 = 1.5; \t\t\t#bar\n", + "p2 = 7.5; \t\t\t#bar\n", + "V1 = 3/p1;\n", + "V2 = 3/p2;\n", + "\n", + "# Calculations\n", + "def f19( V): \n", + "\t return 3./V*10**2\n", + "\n", + "W = quad(f19, V1, V2)[0]\n", + "\n", + "# Results\n", + "print \"Work done = %.3f\"%(W),\"kJ\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Work done = -482.831 kJ\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.20 page no : 55" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "# Variables\n", + "W = 150; \t\t\t#kJ\n", + "V1 = 0.6; \t\t\t#m**3\n", + "\n", + "# Calculations and Results\n", + "V2 = (8-math.sqrt(64-4*2*2.58))/4; \t\t\t#m**3\n", + "print (\"Final volume = %.3f\")%V2,\"m**3\"\n", + "\n", + "p2 = 8-4*V2;\n", + "print \"Final pressure = %.2f\"%p2,\"bar\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Final volume = 0.354 m**3\n", + "Final pressure = 6.58 bar\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.21 page no : 56" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "from scipy.integrate import quad \n", + "\n", + "# Variables\n", + "p1 = 3.*10**5; \t\t\t#Pa\n", + "v1 = 0.18; \t\t\t#m**3/kg\n", + "p2 = 0.6*10**5; \t\t\t#Pa\n", + "\n", + "# Calculations\n", + "C = p1*v1**2;\n", + "v2 = math.sqrt(C/p2);\n", + "\n", + "def f17( v): \n", + " return C/v**2\n", + "\n", + "W = quad(f17, v1,v2)[0]\n", + "\n", + "# Results\n", + "print (\"Work done = %d\")%(W),(\"Nm/kg\")\n", + "\n", + "# Note : output would be differ as rounding error is there. v2 has rounding off error." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Work done = 29850 Nm/kg\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.22 page no : 57" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "from scipy.integrate import quad \n", + "\n", + "# Variables\n", + "m = 1.; \t\t\t#kg\n", + "p1 = 20.*10**5; \t#Pa\n", + "V1 = 0.05; \t\t\t#m**3\n", + "\n", + "# Calculations\n", + "V2 = 2*V1;\n", + "p2 = p1*(V1/V2)**2;\n", + "C = p1*V1**2;\n", + "V3 = V1;\n", + "\n", + "def f20( V): \n", + "\t return C/V**2\n", + "\n", + "W_12 = quad(f20, V1,V2)[0]\n", + "W_23 = p2*(V2-V3);\n", + "W_net = W_12-W_23;\n", + "\n", + "# Results\n", + "print (\"Net work done = \"),(W_net),(\"Nm\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Net work done = 25000.0 Nm\n" + ] + } + ], + "prompt_number": 26 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file |