{
 "metadata": {
  "name": "",
  "signature": "sha256:d798b16416897dedbfd57aff5c233c1f7e9c52a7f0081b45c972d6ab47468c7c"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 15 - Thermodynamics of chemical reactions"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1 - Pg 318"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the amount of dissociation\n",
      "#Initalization of variables\n",
      "import math\n",
      "import numpy\n",
      "kp=math.pow(10,(1.45))\n",
      "#calculations\n",
      "s=[1-kp*kp , 0, -3, 2]\n",
      "vec=numpy.roots(s)\n",
      "X=numpy.real(vec[2])\n",
      "xper=X*100\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Amount of dissociaton =\",xper,\"percent\")\n",
      "print '%s %.3f %s %.3f %s %.3f %s' %(\"\\n Of each original mole of CO2, there will be\",X,\"mole of CO \",X/2.,\" mol of Oxygen and\",(1-X),\"mol of CO2\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Amount of dissociaton = 12.7 percent\n",
        "\n",
        " Of each original mole of CO2, there will be 0.127 mole of CO  0.063  mol of Oxygen and 0.873 mol of CO2\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2 - Pg 319"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the max. temperature reached\n",
      "#Initalization of variables\n",
      "U=121200. #Btu/mol\n",
      "Uco2=51635. #Btu/mol\n",
      "Un2=27589. #Btu/mol\n",
      "Uco22=57875. #Btu/mol\n",
      "Un22=21036. #Btu/mol\n",
      "T1=5000. #R\n",
      "T2=5500. #R\n",
      "#calculations\n",
      "Ut1=Uco2+1.88*Un2\n",
      "Ut2=Uco22 + 1.88*Un22\n",
      "print '%s' %(\"By extrapolation,\")\n",
      "Tx=5710 #R\n",
      "#results\n",
      "print '%s %d %s' %(\"Max. Temperature reached =\",Tx,\"R\")\n",
      "print '%s' %(\"The calculation for Ut2 is wrong in textbook. Please use a calculator.\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "By extrapolation,\n",
        "Max. Temperature reached = 5710 R\n",
        "The calculation for Ut2 is wrong in textbook. Please use a calculator.\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3 - Pg 319"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the max. obtainable temperature\n",
      "#Initalization of variables\n",
      "print '%s' %(\"By trial and error,\")\n",
      "import math\n",
      "X=0.201\n",
      "X1=0.2\n",
      "R=59.3 #universal gas constant\n",
      "T=5000 #R\n",
      "U=121200 #Btu/mol\n",
      "Uco2=51635. #Btu/mol\n",
      "Un2=27907. #Btu/mol\n",
      "U3=29616. #Btu/mol\n",
      "U4=27589. #Btu/mol\n",
      "#calculations\n",
      "kp1=R*(1-X1)/math.pow(X1,1.5) /math.pow(T,0.5)\n",
      "kp2=R*(1-X)/math.pow(X,1.5) /math.pow(T,0.5)\n",
      "q=(1-X)*Uco2 + X*Un2+ X/2 *U3 +1.88*U4 + X*U\n",
      "print '%s' %(\"Interpolating between T=4500 R and T=5000 R, we get\")\n",
      "T2=4907 #R\n",
      "#results\n",
      "print '%s %d %s' %(\"Max. obtainable temperature =\",T2,\" R\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "By trial and error,\n",
        "Interpolating between T=4500 R and T=5000 R, we get\n",
        "Max. obtainable temperature = 4907  R\n"
       ]
      }
     ],
     "prompt_number": 3
    }
   ],
   "metadata": {}
  }
 ]
}