{ "metadata": { "name": "", "signature": "sha256:76568d79b614fc85568c92855047632dbe19f5ec7540dbd287268967c3318f2b" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter 2 : Review of basic concepts" ] }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 2.1 Page No : 29" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "import math\n", "\n", "# Variables\n", "R = 8.314;\t\t\t #universal gas constant in J/molK\n", "t1 = 300.;\t\t\t #initial temperature of gas in K\n", "p1 = 0.1;\t\t\t #initial pressure of the gas in MPa\n", "p2 = 0.5;\t\t\t #pressure of gas after heating in MPa\n", "p3 = 0.1;\t\t\t #pressure of gas after expansion in MPa\n", "n = 1.; \t\t\t #number of moles of gas in mole\n", "\n", "# Calculations\n", "w1 = 0*n; \t\t\t # Calculations of work done by the gas during heating in kJ (since dv = 0)\n", "t2 = t1*(p2/p1);\t\t\t # Calculations of temperature of gas after heating in K\n", "t3 = t2;\t\t \t # Calculations of temperature of gas after expansion in K (constant temperature expansion)\n", "volume2 = p2/p3;\t\t\t # Calculations of ratio of volume of gas after expansion to the volume of gas after heating (no unit)\n", "w2 = (R*t2*math.log(volume2)*n)/1000\n", "volume3 = t3/t1;\t\t\n", "w3 = (R*t1*(1-volume3)*n)/1000\n", "work_net = w1+w2+w3;\t\t\t # Calculations of net work done by the gas for the process in kJ\n", "\n", "# Results\n", "print ' Work done during heating process:Work from 1-2 = %d kJ '%(w1);\n", "print ' Work done during constant temperature expansion: Work from 2-3 = %.3f kJ '%(w2);\n", "print ' Work done during constant pressure compression: Work from 3-1 = %.3f kJ '%(w3);\n", "print ' Net work done by the gas during the process = %.3f kJ '%(work_net);\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " Work done during heating process:Work from 1-2 = 0 kJ \n", " Work done during constant temperature expansion: Work from 2-3 = 20.071 kJ \n", " Work done during constant pressure compression: Work from 3-1 = -9.977 kJ \n", " Net work done by the gas during the process = 10.095 kJ \n" ] } ], "prompt_number": 3 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 2.2 Page No : 30" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "v1 = 0.1;\t\t\t #volume of gas initially present in the cylinder in m**3\n", "p1 = 0.1;\t\t\t #initial pressure of gas in MPa\n", "p_atm = 0.1;\t\t #atmospheric pressure acting on the piston in MPa\n", "v2 = 0.3;\t\t\t #volume of gas after heating in m**3\n", "p2 = 0.6;\t\t\t #pressure of gas after heating in MPa\n", "\n", "# Calculations\n", "work = ((p1+p2)*(v2-v1)*10**6)/(2*1000);\t\t\t # Calculations of work done by the gas in kJ \n", "\n", "# Results\n", "print ' The work done by the gas = %d kJ'%(work);\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The work done by the gas = 70 kJ\n" ] } ], "prompt_number": 4 } ], "metadata": {} } ] }