{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chapter 04:First Law of Thermodynamics" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Ex4.1:pg-72" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " Example 4.1\n", "\n", " The internal energy of the gas decrease by 21.85 kJ in the process.\n" ] } ], "source": [ "import math\n", "V1 = 0.3 # Initial volume in m**3\n", "V2 = 0.15 # Final volume in m**3\n", "P = 0.105 # Initial Pressure in MPa\n", "Q = -37.6 # Heat transferred in kJ\n", "W = P*(V2-V1)*1e6 # Work done\n", "U = Q*1e3-W # Internal energy change\n", "print \"\\n Example 4.1\"\n", "print \"\\n The internal energy of the gas decrease by \",abs(U)/1e3,\" kJ in the process.\"\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Ex4.2:pg-73" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " Example 4.2\n", "\n", " The heat flow into the system along the path adb is 62.5 kJ\n", "\n", " The heat liberated along the path b-a is -73 kJ\n", "\n", " The heat absorbed in the path ad and db are 52.5 kJ nd 10.0 kJ respectively.\n" ] } ], "source": [ "import math\n", "Qacb = 84 # Heat transfer along the path acb in kJ \n", "Wacb = 32 # Work done along the path acb in kJ\n", "Uba = Qacb-Wacb # Ub-Ua\n", "# Part (a)\n", "Wadb = 10.5 # Work done along the path adb in kJ\n", "Qadb = Uba+Wadb # Heat flow into the system along the path adb\n", "print \"\\n Example 4.2\"\n", "print \"\\n The heat flow into the system along the path adb is \",Qadb ,\" kJ\"\n", "# Part (b)\n", "Wb_a = -21 # work done along the path ba in kJ\n", "Uab = - Uba # Change in internal energy along the path ab in kJ\n", "Qb_a = Uab+Wb_a # Heat liberated along the path b-a\n", "print \"\\n The heat liberated along the path b-a is \",Qb_a,\" kJ\"\n", "\n", "\n", "\n", "# Part (c)\n", "Wdb = 0 # Constant volume\n", "Wad = 10.5 # work done along the path ad in kJ\n", "Wadb = Wdb-Wad # work done along the path adb in kJ\n", "Ud = 42\n", "Ua = 0\n", "Qad = Ud-Ua+Wad # Heat flow into the system along the path ad in kJ\n", "Qdb = Qadb-Qad #Heat flow into the system along the path db in kJ\n", "\n", "print \"\\n The heat absorbed in the path ad and db are \",Qad ,\" kJ nd \",Qdb ,\" kJ respectively.\"\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Ex4.3:pg-73" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " Example 4.3\n", "The completed table is: [[0, 2170, -2170], [21000, 0, 21000], [-2100, 34500, -36600], [-35900, -53670, 17770]]\n", "\n", " Net rate of work output is -284 kW\n" ] } ], "source": [ "import math\n", "# Process a-b\n", "Qab = 0 # Heat transfer along the path ab in kJ/ min\n", "Wab = 2170 # Work transfer along the path ab in kJ/min\n", "Eab = Qab-Wab # Change in internal energy along the path ab in kJ/min\n", "# Process b-c\n", "\n", "Qbc = 21000 # Heat transfer along the path bc in kJ/ min\n", "Wbc = 0 # Work transfer along the path bc in kJ/min\n", "Ebc = Qbc-Wbc # Change in internal energy along the path bc in kJ/min\n", "\n", "# Process c-d\n", "\n", "Qcd = -2100 # Heat transfer along the path cd in kJ/ min\n", "Ecd = -36600 # Change in internal energy along the path cd in kJ/min\n", "Wcd = Qcd-Ecd # Work transfer along the path cd in kJ/min\n", "\n", "# Process d-a\n", "\n", "Q = -17000 # Total heat transfer in kJ/min\n", "Qda = Q-Qab-Qbc-Qcd # Heat transfer along the path da in kJ/ min \n", "Eda = -Eab-Ebc-Ecd # Change in internal energy along the path da in kJ/min \n", "Wda = Qda-Eda # Work transfer along the path da in kJ/min\n", "\n", "print \"\\n Example 4.3\"\n", "\n", "\n", "\n", "M = [[Qab, Wab, Eab] , [Qbc, Wbc, Ebc], [Qcd, Wcd, Ecd], [Qda, Wda, Eda]]\n", "print\"The completed table is:\",M \n", "W = Qab+Qbc+Qcd+Qda \n", "print \"\\n Net rate of work output is \",W/60 ,\" kW\"\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Ex4.4:pg-75" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " Example 4.4\n", "\n", " Part A:\n", "\n", " For the quasi static process is: \n", " \n", "Q: 37.2676405731 kJ\n", "\n", " dU: -92.1338891945 kJ\n", "\n", " W: 129.4 kJ \n", "\n", " Part B:\n", "\n", " Work transfer for the process is 122.13 kJ.\n", "\n", "\n", " Part C:\n", "\n", " Wb is not equal to integral(p*dv) since the process is not quasi static.\n" ] } ], "source": [ "import math\n", "# Part (a)\n", "\n", "m = 3 # mass of substance in kg\n", "V1 = 0.22 # Initial volume of system in m**3\n", "P1 = 500 # Initial pressure of system in kPa\n", "P2 = 100 # Final pressure of system in kPa \n", "V2 = V1*(P1/P2)**(1/1.2) # Final volume of system\n", "dU = 3.56*(P2*V2-P1*V1) # Change in internal energy of substance in kJ/kg\n", "n = 1.2 # polytropic index\n", "W = (P2*V2-P1*V1)/(1-n) # work done in process\n", "Q = dU+W # Heat addition in process\n", "\n", "print \"\\n Example 4.4\"\n", "print \"\\n Part A:\"\n", "print \"\\n For the quasi static process is: \\n \"\n", "print \"Q: \",Q ,\"kJ\"\n", "print \"\\n dU: \",dU ,\"kJ\"\n", "print \"\\n W: \",round(W,2) ,\"kJ\",\n", "\n", "#The provided in the textbook is wrong\n", "\n", "# Part (b)\n", "\n", "print \"\\n\\n Part B:\"\n", "Qb = 30 # heat transfer in kJ\n", "Wb = Qb-dU # Work done in kJ\n", "print \"\\n Work transfer for the process is \",round(Wb,2) ,\"kJ.\" \n", "#The answers vary due to round off error\n", "# Part (c)\n", "\n", "print \"\\n\\n Part C:\"\n", "print \"\\n Wb is not equal to integral(p*dv) since the process is not quasi static.\"\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Ex4.5:pg-76" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " Example 4.5\n", "\n", " The work done by the system is 8.55 kJ\n", "\n", " The heat flow into the system is 68.085 kJ\n" ] } ], "source": [ "import math\n", "import numpy as np\n", "from scipy.integrate import quad\n", "V1 = 0.03 # initial volume in m**3\n", "\n", "P1 = 170.0 # Initial pressure in kPa\n", "\n", "P2 = 400.0 # Final pressure in kPa\n", "\n", "V2 = 0.06 # Final volume in m**3\n", "\n", "U = 3.15*(P2*V2-P1*V1) # internal energy in kJ\n", "\n", "b = np.matrix([P1, P2])\n", "\n", "B=b.transpose()\n", "\n", "A = np.matrix([[1,V1],[1,V2]]) \n", "\n", "x = A.getI()*B \n", "\n", "a = x[0] ; b = x[1] \n", "\n", "def pressure(V): \n", " P = a+b*V\n", " return P\n", "\n", " endfunction \n", "\n", "W, err = quad(pressure, V1, V2)\n", " \n", "#W = integrate(pressure,V1,V2) \n", " \n", "Q = U+W # heat flow into the system in kJ\n", " \n", "print \"\\n Example 4.5\"\n", " \n", "print \"\\n The work done by the system is \",W ,\" kJ\"\n", " \n", "print \"\\n The heat flow into the system is \",Q ,\" kJ\"\n", " \n", " " ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.11" } }, "nbformat": 4, "nbformat_minor": 0 }