{ "metadata": { "name": "", "signature": "sha256:79d03e9c97c3d8ac9e7b819d4383e36696e6a2ea64bb801edb77a95675cdc73c" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter 02: Heat, Work, Internal Energy, Enthalpy, and The First Law of Thermodynamics" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example Problem 2.1, Page 18" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "#Variable Declaration Part a\n", "vi = 20.0 #Initial volume of ideal gas, L\n", "vf = 85.0 #final volume of ideal gas, L\n", "Pext = 2.5 #External Pressure against which work is done, bar\n", "\n", "#Calculations\n", "w = -Pext*1e5*(vf-vi)*1e-3\n", "\n", "#Results\n", "print 'Part a: Work done in expansion is %6.1f kJ'%(w/1000)\n", "\n", "#Variable Declaration Part b\n", "ri = 1.00 #Initial diameter of bubble, cm\n", "rf = 3.25 #final diameter of bubble, cm\n", "sigm = 71.99 #Surface tension, N/m\n", "\n", "from math import pi\n", "#Calculations\n", "w = -2*sigm*4*pi*(rf**2-ri**2)*1e-4\n", "\n", "#Results\n", "print 'Part b: Work done in expansion of bubble is %4.2f J'%w\n", "\n", "#Variable Declaration Part c\n", "i = 3.20 #Current through heating coil, A \n", "v = 14.5 #fVoltage applied across coil, volts\n", "t = 30.0 #time for which current is applied,s\n", "\n", "from math import pi\n", "#Calculations\n", "w = v*i*t\n", "\n", "#Results\n", "print 'Part c: Work done in paasing the cuurent through coil is %4.2f kJ'%(w/1000)\n", "\n", "#Variable Declaration Part d\n", "k = 100.0 #Constant in F = -kx, N/cm \n", "dl = -0.15 #stretch , cm\n", "\n", "from math import pi\n", "#Calculations\n", "w = -k*(dl**2-0)/2\n", "\n", "#Results\n", "print 'Part d: Work done stretching th fiber is %4.2f J'%w" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Part a: Work done in expansion is -16.2 kJ\n", "Part b: Work done in expansion of bubble is -1.73 J\n", "Part c: Work done in paasing the cuurent through coil is 1.39 kJ\n", "Part c: Work done stretching th fiber is -1.12 J\n" ] } ], "prompt_number": 15 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example Problem 2.2, Page Number 20" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Variable Declaration \n", "m = 100.0 #Mass of water, g \n", "T = 100.0 #Temperature of water, \u00b0C\n", "Pext = 1.0 #External Pressure on assembly, bar\n", "x = 10.0 #percent of water vaporised at 1 bar,-\n", "i = 2.00 #current through heating coil, A\n", "v = 12.0 #Voltage applied, v\n", "t = 1.0e3 #time for which current applied, s \n", "rhol = 997 #Density of liquid, kg/m3\n", "rhog = 0.59 #Density of vapor, kg/m3\n", "\n", "#Calculations\n", "q = i*v*t\n", "vi = m/(rhol*100)*1e-3\n", "vf = m*(100-x)*1e-3/(rhol*100) + m*x*1e-3/(rhog*100)\n", "w = -Pext*(vf-vi)*1e5\n", "#Results\n", "print 'Heat added to the water %4.2f kJ'%(q/1000)\n", "print 'Work done in vaporizing liquid is %4.2f J'%w" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Heat added to the water 24.00 kJ\n", "Work done in vaporizing liquid is -1703.84 J\n" ] } ], "prompt_number": 23 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example Problem 2.3, Page Number 22" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Variable Declaration Part d\n", "m = 1.5 #mass of water in surrounding, kg \n", "dT = 14.2 #Change in temperature of water, \u00b0C or K\n", "cp = 4.18 #Specific heat of water at constant pressure, J/(g.K)\n", "\n", "#Calculations\n", "qp = m*cp*dT\n", "\n", "#Results\n", "print 'Heat removed by water at constant pressure %4.2f kJ'%qp" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Heat removed by water at constant pressure 89.03 kJ\n" ] } ], "prompt_number": 26 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example Problem 2.4, Page Number 28" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from math import log\n", "#Variable declaration\n", "n = 2.0 #moles of ideal gas\n", "R = 8.314 #Ideal gas constant, bar.L/(mol.K)\n", "#For reverssible Isothermal expansion \n", "Pi1 = 25.0 #Initial Pressure of ideal gas, bar\n", "Vi1 = 4.50 #Initial volume of ideal gas, L\n", "Pf1 = 4.50 #Fianl Pressure of ideal gas, bar\n", "Pext = 4.50 #External pressure, bar \n", "Pint = 11.0 #Intermediate pressure, bar\n", "\n", "#Calcualtions reverssible Isothermal expansion \n", "T1 = Pi1*Vi1/(n*R)\n", "Vf1 = n*R*T1/Pf1\n", "w = -n*R*T1*log(Vf1/Vi1)\n", "\n", "#Results\n", "print 'For reverssible Isothermal expansion'\n", "print 'Work done = %4.2e J'%w\n", "\n", "#Calcualtions Single step irreverssible expansion \n", "\n", "w = -Pext*1e5*(Vf1-Vi1)*1e-3\n", "\n", "#Results\n", "print 'For Single step reverssible expansion'\n", "print 'Work done = %4.2e J'%w\n", "\n", "#Calcualtions Two step irreverssible expansion \n", "Vint = n*R*T1/(Pint)\n", "w = -Pint*1e5*(Vint-Vi1)*1e-3 - Pf1*1e5*(Vf1-Vint)*1e-3\n", "\n", "#Results\n", "print 'For Two step reverssible expansion'\n", "print 'Work done = %4.2e J'%w\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "For reverssible Isothermal expansion\n", "Work done = -1.93e+02 J\n", "For Single step reverssible expansion\n", "Work done = -9.22e+03 J\n", "For Twi step reverssible expansion\n", "Work done = -1.29e+04 J\n" ] } ], "prompt_number": 6 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example Problem 2.5, Page Number 32" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from math import log\n", "\n", "#Variable declaration\n", "n = 2.5 #moles of ideal gas\n", "R = 0.08314 #Ideal gas constant, bar.L/(mol.K)\n", "cvm = 20.79 #Heat Capacity at constant volume, J/(mol.K)\n", "\n", "p1 = 16.6 #Pressure at point 1, bar\n", "v1 = 1.00 #Volume at point 1, L\n", "p2 = 16.6 #Pressure at point 2, bar\n", "v2 = 25.0 #Volume at point 2, L \n", "v3 = 25.0 #Volume at point 3, L\n", "\n", "#Calculations\n", "T1 = p1*v1/(n*R)\n", "T2 = p2*v2/(n*R)\n", "T3 = T1 #from problem statement\n", " #for path 1-2\n", "DU12 = n*cvm*(T2-T1)\n", "w12 = -p1*1e5*(v2-v1)*1e-3\n", "q12 = DU12 - w12\n", "DH12 = DU12 + n*R*(T2-T1)*1e2\n", "\n", " #for path 2-3\n", "w23 = 0.0\n", "DU23 = q23 = n*cvm*(T3-T2)\n", "DH23 = -DH12\n", "\n", "\n", " #for path 3-1\n", "DU31 = 0.0 #Isothemal process\n", "DH31 = 0.0\n", "w31 = -n*R*1e2*T1*log(v1/v3)\n", "q31 = -w31\n", "\n", "DU = DU12+DU23+DU31\n", "w = w12+w23+w31\n", "q = q12+q23+q31\n", "DH = DH12+DH23+DH31\n", "\n", "#Results\n", "print 'For Path q w DU DH '\n", "print '1-2 %7.2f %7.2f %7.2f %7.2f'%(q12,w12,DU12,DH12)\n", "print '2-3 %7.2f %7.2f %7.2f %7.2f'%(q23,w23,DU23,DH23)\n", "print '3-1 %7.2f %7.2f %7.2f %7.2f'%(q31,w31,DU31,DH31)\n", "print 'Overall %7.2f %7.2f %7.2f %7.2f'%(q,w,DU,DH)\n", "print 'all values are in J'" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "For Path q w DU DH \n", "1-2 139463.96 -39840.00 99623.96 139463.96\n", "2-3 -99623.96 0.00 -99623.96 -139463.96\n", "3-1 -5343.33 5343.33 0.00 0.00\n", "Overall 34496.67 -34496.67 0.00 0.00\n", "all values are in J\n" ] } ], "prompt_number": 47 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example Problem 2.6, Page Number 34" ] }, { "cell_type": "code", "collapsed": false, "input": [ "n = 2.5 #moles of ideal gas\n", "R = 8.314 #Ideal gas constant, J/(mol.K)\n", "cvm = 12.47 #Heat Capacity at constant volume, J/(mol.K)\n", "\n", "pext = 1.00 #External Pressure, bar\n", "Ti = 325. #Initial Temeprature, K\n", "pi = 2.50 #Initial Pressure, bar\n", "pf = 1.25 #Final pressure, bar \n", "\n", "#Calculations Adiabatic process q = 0; DU = w\n", "q = 0.0 \n", "Tf = Ti*(cvm + R*pext/pi)/(cvm + R*pext/pf )\n", "DU = w = n*cvm*(Tf-Ti)\n", "DH = DU + n*R*(Tf-Ti)\n", "\n", "#Results\n", "print 'The final temperature at end of adiabatic procees is %4.1f K'%Tf\n", "print 'The enthalpy change of adiabatic procees is %4.1f J'%DH\n", "print 'The Internal energy change of adiabatic procees is %4.1f J'%DU\n", "print 'The work done in expansion of adiabatic procees is %4.1f J'%w\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The final temperature at end of adiabatic procees is 268.5 K\n", "The enthalpy change of adiabatic procees is -2937.0 J\n", "The Internal energy change of adiabatic procees is -1762.2 J\n", "The work done in expansion of adiabatic procees is -1762.2 J\n" ] } ], "prompt_number": 51 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example Problem 2.7, Page Number 35" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Variable Declaration Part d\n", "h1 = 1000.0 #initial Altitude of cloud, m \n", "hf = 3500.0 #Final Altitude of cloud, m \n", "p1 = 0.802 #Pressure at h1, atm \n", "pf = 0.602 #Pressure at hf, atm\n", "T1 = 288.0 #Initial temperature of cloud, K\n", "cp = 28.86 #Specific heat of air, J/mol.K\n", "R = 8.314 #Gas constant, J/mol.K\n", "\n", "from math import log, exp\n", "\n", "#Calculations\n", "Tf = exp(-(cp/(cp-R)-1)/(cp/(cp-R))*log(p1/pf))*T1\n", "#Results\n", "print 'Final temperature of cloud %4.1f K'%Tf\n", "if Tf < 273:\n", " print 'You can expect cloud'\n", "else:\n", " print 'You can not expect cloud'\n", " " ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Final temperature of cloud 265.2 K\n", "You can expect cloud\n" ] } ], "prompt_number": 34 } ], "metadata": {} } ] }