{ "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": [ "\n", "\n", "V1 = 0.3 # Initial volume in m**3\n", "\n", "V2 = 0.15 # Final volume in m**3\n", "\n", "P = 0.105 # Initial Pressure in MPa\n", "\n", "Q = -37.6 # Heat transferred in kJ\n", "\n", "W = P*(V2-V1)*1e6 # Work done\n", "\n", "U = Q*1e3-W # Internal energy change\n", "\n", "print \"\\n Example 4.1\"\n", "\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": [ "Qacb = 84 # Heat transfer along the path acb in kJ \n", "\n", "Wacb = 32 # Work done along the path acb in kJ\n", "\n", "Uba = Qacb-Wacb # Ub-Ua\n", "\n", "# Part (a)\n", "\n", "Wadb = 10.5 # Work done along the path adb in kJ\n", "\n", "Qadb = Uba+Wadb # Heat flow into the system along the path adb\n", "\n", "print \"\\n Example 4.2\"\n", "\n", "print \"\\n The heat flow into the system along the path adb is \",Qadb ,\" kJ\"\n", "\n", "\n", "\n", "\n", "\n", "# Part (b)\n", "\n", "Wb_a = -21 # work done along the path ba in kJ\n", "\n", "Uab = - Uba # Change in internal energy along the path ab in kJ\n", "\n", "Qb_a = Uab+Wb_a # Heat liberated along the path b-a\n", "\n", "print \"\\n The heat liberated along the path b-a is \",Qb_a,\" kJ\"\n", "\n", "\n", "\n", "# Part (c)\n", "\n", "Wdb = 0 # Constant volume\n", "\n", "Wad = 10.5 # work done along the path ad in kJ\n", "\n", "Wadb = Wdb-Wad # work done along the path adb in kJ\n", "\n", "Ud = 42\n", "\n", "Ua = 0\n", "\n", "Qad = Ud-Ua+Wad # Heat flow into the system along the path ad in kJ\n", "\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": 10, "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": [ "# Process a-b\n", "\n", "Qab = 0 # Heat transfer along the path ab in kJ/ min\n", "\n", "Wab = 2170 # Work transfer along the path ab in kJ/min\n", "\n", "Eab = Qab-Wab # Change in internal energy along the path ab in kJ/min\n", "\n", "# Process b-c\n", "\n", "Qbc = 21000 # Heat transfer along the path bc in kJ/ min\n", "\n", "Wbc = 0 # Work transfer along the path bc in kJ/min\n", "\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", "\n", "Ecd = -36600 # Change in internal energy along the path cd in kJ/min\n", "\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", "\n", "Qda = Q-Qab-Qbc-Qcd # Heat transfer along the path da in kJ/ min \n", "\n", "Eda = -Eab-Ebc-Ecd # Change in internal energy along the path da in kJ/min \n", "\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", "\n", "print\"The completed table is:\",M\n", " \n", "W = Qab+Qbc+Qcd+Qda\n", " \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": [ "# Part (a)\n", "\n", "m = 3 # mass of substance in kg\n", "\n", "V1 = 0.22 # Initial volume of system in m**3\n", "\n", "P1 = 500 # Initial pressure of system in kPa \n", "\n", "P2 = 100 # Final pressure of system in kPa \n", "\n", "V2 = V1*(P1/P2)**(1/1.2) # Final volume of system\n", "\n", "dU = 3.56*(P2*V2-P1*V1) # Change in internal energy of substance in kJ/kg\n", "\n", "n = 1.2 # polytropic index\n", "\n", "W = (P2*V2-P1*V1)/(1-n) # work done in process\n", "\n", "Q = dU+W # Heat addition in process\n", "\n", "\n", "\n", "print \"\\n Example 4.4\"\n", "\n", "print \"\\n Part A:\"\n", "\n", "print \"\\n For the quasi static process is: \\n \"\n", "\n", "print \"Q: \",Q ,\"kJ\"\n", "\n", "print \"\\n dU: \",dU ,\"kJ\"\n", "\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", "\n", "Qb = 30 # heat transfer in kJ \n", "\n", "Wb = Qb-dU # Work done in kJ\n", "\n", "print \"\\n Work transfer for the process is \",round(Wb,2) ,\"kJ.\" \n", "\n", "#The answers vary due to round off error\n", "\n", "# Part (c)\n", "\n", "print \"\\n\\n Part C:\"\n", "\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": 34, "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 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", "\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", " \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 }