{
 "metadata": {
  "name": "",
  "signature": "sha256:be81f2921bd837b769765ce2f11df805d4272c8fa82950148df6411036b4a56d"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter5 -The ideal gas"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example1-pg 85"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate specific volumes at given pressure\n",
      "##initialisation of variables\n",
      "R= 8.314 ##J/mol K\n",
      "M= 18.016 ##gms\n",
      "T= 400. ##C\n",
      "p= 0.01 ##Mpa\n",
      "p1= 0.1 ##Mpa\n",
      "p2= 20. ##Mpa\n",
      "##CALCULATIONS\n",
      "v= R*(273.156+T)/(M*p*1000)\n",
      "v1= R*(273.156+T)/(M*p1*1000)\n",
      "v2= R*(273.156+T)/(M*p2*1000)\n",
      "##RESULTS\n",
      "print'%s %.3f %s'%(' specific voulme =',v,'m^3/kg')\n",
      "print'%s %.3f %s'%('specific voulme = ', v1,'m^3/kg')\n",
      "print'%s %.3f %s'%('specific voulme = ',v2,'m^3/kg')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " specific voulme = 31.065 m^3/kg\n",
        "specific voulme =  3.106 m^3/kg\n",
        "specific voulme =  0.016 m^3/kg\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3-pg87"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "##initialisation of variables\n",
      "R=8.314\n",
      "V= 20 ##L\n",
      "m= 0.050 ##gms\n",
      "M= 29 ##gms\n",
      "T1= 20 ##C\n",
      "T2= 150 ##C\n",
      "k= 1.4\n",
      "V1= 0.05 ##m**3\n",
      "##CALCULATIONS\n",
      "p1= m*R*(273.15+T1)/(M*(V/10))\n",
      "p2= m*R*(273.15+T2)/(M*(V/10))\n",
      "dU= p1*V1*(((273.15+T2)/(273.15+T1))-1)*100/(k-1)\n",
      "dH= k*dU\n",
      "##RESULTS\n",
      "print'%s %.2f %s'% (' intial pressure =',p1,' kPa')\n",
      "print'%s %.2f %s'% ('  final pressure = ',p2,' kPa')\n",
      "print'%s %.2f %s'% ('  internal energy = ',dU,' kJ')\n",
      "print'%s %.2f %s'% ('  enthalpy = ',dH,' kJ')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " intial pressure = 2.10  kPa\n",
        "  final pressure =  3.03  kPa\n",
        "  internal energy =  11.65  kJ\n",
        "  enthalpy =  16.31  kJ\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex4-pg91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "##initialisation of variables\n",
      "T1= 200 ##K\n",
      "p= 600 ##kPa\n",
      "p1= 50 ##kPa\n",
      "n= 1.8\n",
      "M= 4. ##gms\n",
      "k= 5/3.\n",
      "m= 0.007 ##gms\n",
      "R= 8.314 ##J/mol K\n",
      "##CALCULATIONS\n",
      "T2= T1*(p/p1)**((n-1)/n)\n",
      "W= m*R*(T1-T2)/((n-1)*M)\n",
      "Q= ((n-k)*m*R*(T2-T1))/((n-1)*(k-1)*M)\n",
      "##RESULTS\n",
      "print'%s %.2f %s'% (' final temperature = ',T2,' K')\n",
      "print'%s %.2f %s'% ('  work = ',W,' kJ')\n",
      "print'%s %.2f %s'% ('  energy = ',Q,' kJ')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " final temperature =  603.48  K\n",
        "  work =  -7.34  kJ\n",
        "  energy =  1.47  kJ\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 5-pg92 "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate final temperature and pressure and work ,energy\n",
      "##initialisation of variables\n",
      "p1= 300.##kPa\n",
      "V1= 0.03 ##m^3\n",
      "V2= 0.08 ##m^3\n",
      "T1= 27. ##C\n",
      "##CALCULATIONS1\n",
      "T2= T1+273\n",
      "p2= p1*(V1/V2)*(T2/(T1+273))\n",
      "W= 0\n",
      "Q= 0\n",
      "##RESULTS\n",
      "print'%s %.2f %s'%('final temperature =',T2,'K')\n",
      "print'%s %.1f %s'%('final pressure =',p2,'kPa')\n",
      "print'%s %.f %s'%('work = ',W,'kJ')\n",
      "print'%s %.f %s'%('energy =',Q,'kJ')\n",
      " \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "final temperature = 300.00 K\n",
        "final pressure = 112.5 kPa\n",
        "work =  0 kJ\n",
        "energy = 0 kJ\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example6 -pg93\n",
      "\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate mass of nitrogen and final temperature and piston rise\n",
      "##initialisation of variables\n",
      "p1= 2. ##Mpa\n",
      "V1= 0.2 ##m^3\n",
      "R= 8.314 ##J/mol K\n",
      "T1= 500. ##C\n",
      "M= 28. ##gms\n",
      "p2= 0.3 ##Mpa\n",
      "T2= 250 ##C\n",
      "k= 1.4\n",
      "A= 0.1 ##m^2\n",
      "##CALCULATIONS\n",
      "m1= p1*10*10*10*V1*M/(R*(273.15+T1))\n",
      "m2= p2*10*10*10*V1*M/(R*(273.15+T2))\n",
      "m3= -(m2-m1)\n",
      "T3= (m1*(273.15+T1)-m2*(273.15+T2))/(k*m3)\n",
      "z3= m3*R*T3/(p2*10*10*10*A*M)\n",
      "##RESULTS\n",
      "print'%s %.4f %s'%(' mass of nitrogen =',m3,'kg')\n",
      "print'%s %.1f %s'%('final temperature =',T3,'K')\n",
      "print'%s %.2f %s'%('piston rise =',z3,'m')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " mass of nitrogen = 1.3561 kg\n",
        "final temperature = 603.1 K\n",
        "piston rise = 8.10 m\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex7-pg94"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "##initialisation of variables\n",
      "m= 0.3 ##kg\n",
      "R= 8.314 ##J/mol K\n",
      "M= 28 ##gms\n",
      "T1= 500. ##C\n",
      "p1= 500. ##kPa\n",
      "k= 1.4\n",
      "V3= 0.3 ##m**2\n",
      "##CALCULATIONS\n",
      "V1= m*R*(273.15+T1)/(M*p1)\n",
      "T3= k*(273.15+T1)\n",
      "p3= m*R*T3*100/(M*V)\n",
      "##RESULTS\n",
      "print'%s %.2f %s'% (' final pressure =',p3,' kPa')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " final pressure = 482.10  kPa\n"
       ]
      }
     ],
     "prompt_number": 6
    }
   ],
   "metadata": {}
  }
 ]
}