{
 "metadata": {
  "name": "",
  "signature": "sha256:973d427aa265e6008d444ff4e5a0026589bdadc695d5f549c16acb669fdf56e2"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 1. Fundamental Concepts of Thermodynamics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 1.1, Page Number 7"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "Pi = 3.21e5             #Recommended tyre pressure, Pa\n",
      "Ti = -5.00              #Initial Tyre temperature, \u00b0C\n",
      "Tf = 28.00              #Final Tyre temperature, \u00b0C\n",
      "\n",
      "#Calculations\n",
      "Ti = 273.16 + Ti\n",
      "Tf = 273.16 + Tf\n",
      "pf = Pi*Tf/Ti           #Final tyre pressure, Pa\n",
      "\n",
      "#Results\n",
      "print 'Final Tyre pressure is %6.2e Pa'%pf"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Final Tyre pressure is 3.61e+05 Pa\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.2, Page Number 8"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "phe = 1.5          #Pressure in Helium chamber, bar\n",
      "vhe = 2.0          #Volume of Helium chamber, L\n",
      "pne = 2.5          #Pressure in Neon chamber, bar\n",
      "vne = 3.0          #Volume of Neon chamber, L\n",
      "pxe = 1.0          #Pressure in Xenon chamber, bar\n",
      "vxe = 1.0          #Volume of Xenon chamber, L\n",
      "R = 8.314e-2       #Ideal Gas Constant, L.bar/(mol.K)\n",
      "T = 298            #Temperature of Gas, K\n",
      "#Calculations\n",
      "\n",
      "nhe = phe*vhe/(R*T)            #Number of moles of Helium, mol\n",
      "nne = pne*vne/(R*T)            #Number of moles of Neon, mol\n",
      "nxe = pxe*vxe/(R*T)            #Number of moles of Xenon, mol\n",
      "n = nhe + nne + nxe            #Total number of moles, mol\n",
      "V = vhe + vne + vxe            #Total volume of system, L\n",
      "xhe = nhe/n\n",
      "xne = nne/n\n",
      "xxe = nxe/n\n",
      "P = n*R*T/(V)\n",
      "phe = P*xhe              #Partial pressure of Helium, bar\n",
      "pne = P*xne              #Partial pressure of Neon, bar\n",
      "pxe = P*xxe              #Partial pressure of Xenon, bar\n",
      "\n",
      "#Results\n",
      "print 'Moles of He=%4.3f, Ne=%4.3f and, Xe=%4.3f in mol'%(nhe,nne,nxe) \n",
      "print 'Mole fraction of xHe=%4.3f, xNe=%4.3f and, xXe=%4.3f'%(xhe,xne,xxe)\n",
      "print 'Final pressure is %4.3f bar'%P\n",
      "print 'Partial pressure of pHe=%4.3f, pNe=%4.3f and, pXe=%4.3f in bar'%(phe,pne,pxe)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Moles of He=0.121, Ne=0.303 and, Xe=0.040 in mol\n",
        "Mole fraction of xHe=0.261, xNe=0.652 and, xXe=0.087\n",
        "Final pressure is 1.917 bar\n",
        "Partial pressure of pHe=0.500, pNe=1.250 and, pXe=0.167 in bar\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.4, Page Number 10"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration\n",
      "T = 300.0               #Nitrogen temperature, K\n",
      "v1 = 250.00             #Molar volume, L\n",
      "v2 = 0.1                #Molar volume, L\n",
      "a = 1.37                #Van der Waals parameter a, bar.dm6/mol2 \n",
      "b = 0.0387              #Van der Waals parameter b, dm3/mol\n",
      "R = 8.314e-2            #Ideal Gas Constant, L.bar/(mol.K)\n",
      "n = 1.\n",
      "#Calculations\n",
      "\n",
      "p1 = n*R*T/v1           \n",
      "p2 = n*R*T/v2\n",
      "pv1 = n*R*T/(v1-n*b)- n**2*a/v1**2\n",
      "pv2 = n*R*T/(v2-n*b)- n**2*a/v2**2\n",
      "\n",
      "#Results\n",
      "print 'Pressure from ideal gas law = %4.2e bar nad from Van der Waals equation = %4.2e bar '%(p1, pv1)\n",
      "print 'Pressure from ideal gas law = %4.1f bar nad from Van der Waals equation = %4.1f bar '%(p2, pv2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure from ideal gas law = 9.98e-02 bar nad from Van der Waals equation = 9.98e-02 bar \n",
        "Pressure from ideal gas law = 249.4 bar nad from Van der Waals equation = 269.9 bar \n"
       ]
      }
     ],
     "prompt_number": 1
    }
   ],
   "metadata": {}
  }
 ]
}