{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 14:Chemical Equilibrium"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:14.2,Page no:622"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "NO=0.0542 #equilibrium conc of NO, M\n",
      "O2=0.127 #equilibrium conc of O2, M\n",
      "NO2=15.5 #equilibrium conc of NO2, M\n",
      "\n",
      "#Calculation\n",
      "Kc=NO2**2/(O2*NO**2) #equilibrium constant for given reaction\n",
      "\n",
      "#Result\n",
      "print\"The value of the equilibrium constant of the reaction is %.2e\"%Kc\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of the equilibrium constant of the reaction is 6.44e+05\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:14.3,Page no:623"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "PCl3=0.463 #equilibrium pressure of PCl3, atm\n",
      "PCl5=0.875 #equilibrium pressure of PCl5, atm\n",
      "Kp=1.05 #equilibrium constant of the reaction\n",
      "\n",
      "#Calculation\n",
      "Cl2=Kp*PCl5/PCl3 #equilibrium pressure of Cl2 in atm, formula from the definition of equilibrium constant\n",
      "\n",
      "#Result\n",
      "print\"The value of the equilibrium pressure of the Cl2 gas is :\",round(Cl2,2),\"atm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of the equilibrium pressure of the Cl2 gas is : 1.98 atm\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:14.4,Page no:623"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Kc=10.5 \n",
      "delta_n=1-3 \n",
      "T=273+220 \n",
      "\n",
      "#Calculation\n",
      "Kp=Kc*(0.0821*T)**delta_n \n",
      "\n",
      "#Result\n",
      "print\"The value of the equilibrium constant of the reaction is :%.2e\"%Kp"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of the equilibrium constant of the reaction is :6.41e-03\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:14.6,Page no:626"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "CO2=0.236 #pressure of CO2 gas, atm\n",
      "T=273+800 \n",
      "\n",
      "#Calculation\n",
      "#(a)\n",
      "Kp=CO2 \n",
      "#(b)\n",
      "delta_n=1 \n",
      "Kc=Kp*(0.0821*T)**-delta_n \n",
      "\n",
      "#Result\n",
      "print\"(a) the value of Kp of the reaction is :\",Kp\n",
      "print\"(b) the value of Kc of the reaction is %.2e\"%Kc"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) the value of Kp of the reaction is : 0.236\n",
        "(b) the value of Kc of the reaction is 2.68e-03\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:14.8,Page no:633"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Kc=1.2 #equilibrium constant for the reaction\n",
      "N2=.249/3.5 #conc of N2, M\n",
      "H2=(3.21*10**-2)/3.5 #conc of H2, M\n",
      "NH3=(6.42*10**-4)/3.5 #conc of NH3, M\n",
      "\n",
      "#Calculation\n",
      "Qc=NH3**2/(N2*H2**3) #reaction quotient initial\n",
      "print\"Qc=\",round(Qc,3),\"(approx)\"\n",
      "\n",
      "#Result\n",
      "if(Qc==Kc):\n",
      "    d=\"the system is in equilibrium\" \n",
      "elif(Qc<Kc):\n",
      "    d=\"the system is not in equilibrium and the reaction will move from left to right\" \n",
      "else:\n",
      "    d=\"the system is not in equilibrium and the reaction will move from right to left\" \n",
      "print d"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Qc= 0.613 (approx)\n",
        "the system is not in equilibrium and the reaction will move from left to right\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:14.9,Page no:635"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Kc=54.3 \n",
      "H2i=0.5 #initial moles of H2\n",
      "I2i=0.5 #initial moles of I2\n",
      "\n",
      "#Calculation\n",
      "#Let us assume that x moles have reacted, so, HI=2x, H2=0.5-x, I2=0.5-x, when we substitute in Kc=(HI)**2/(H2)*(I2) we get 54.3=(2x)**2/((0.5-x)*(0.5-x)) taking root we get 7.37=2*x/0.5-x\n",
      "x=0.393 #from the above equation\n",
      "H2=0.5-x \n",
      "I2=0.5-x \n",
      "HI=2*x \n",
      "\n",
      "#Result\n",
      "print\"The equilibrium concentration of H2 is :\",H2,\"M\" \n",
      "print\"The equilibrium concentration of I2 is :\",I2,\"M\"\n",
      "print\"The equilibrium concentration of HI is :\",HI,\"M\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The equilibrium concentration of H2 is : 0.107 M\n",
        "The equilibrium concentration of I2 is : 0.107 M\n",
        "The equilibrium concentration of HI is : 0.786 M\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:14.10,Page no:636"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Variable declaration\n",
      "Kc=54.3 \n",
      "HIo=0.0224 \n",
      "H2o=0.00623 \n",
      "I2o=0.00414 \n",
      "#let us assume that x moles have reacted, so, HI=HIo+2x, H2=0.00623-x, I2=0.00414-x, when we substitute in Kc=(HI)**2/(H2)*(I2) we get 54.3=(2x+0.0224)**2/((0.00623-x)*(0.00414-x)) simplifying we get 50.3x**2-0.654x+8.98*10**-4=0\n",
      "a=50.3 \n",
      "b=-0.654 \n",
      "c=8.98*10**-4 \n",
      "\n",
      "#Calculation\n",
      "x1=(-b+math.sqrt(b**2-4*a*c))/(2*a) \n",
      "x2=(-b-math.sqrt(b**2-4*a*c))/(2*a) \n",
      "if(x1>I2o):\n",
      "    x=x2 \n",
      "else:\n",
      "    x=x1 \n",
      "H2=0.00623-x \n",
      "I2=0.00414-x \n",
      "HI=2*x+0.0224 \n",
      "\n",
      "#Result\n",
      "print\"The equilibrium concentration of H2 is :\",round(H2,5),\"M\"\n",
      "print\"The equilibrium concentration of I2 is :\",round(I2,5),\"M\"\n",
      "print\"The equilibrium concentration of HI is :\",round(HI,4),\"M\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The equilibrium concentration of H2 is : 0.00467 M\n",
        "The equilibrium concentration of I2 is : 0.00258 M\n",
        "The equilibrium concentration of HI is : 0.0255 M\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:14.11,Page no:639"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Kc=2.37*10**-3 #equilibrium constant for the reaction\n",
      "N2=0.683 #conc of N2, M\n",
      "H2=8.8 #conc of H2, M\n",
      "NH3=3.65 #conc of NH3, M\n",
      "\n",
      "#Calculation\n",
      "Qc=NH3**2/(N2*H2**3) #reaction quotient initial\n",
      "print\"Qc=%.2e\"%Qc\n",
      "\n",
      "#Result\n",
      "if(Qc==Kc):\n",
      "    d=\"the system is in equilibrium\" \n",
      "elif(Qc<Kc):\n",
      "    d=\"the system is not in equilibrium and the reaction will move from left to right\" \n",
      "else:\n",
      "    d=\"the system is not in equilibrium and the reaction will move from right to left\" \n",
      "print d\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Qc=2.86e-02\n",
        "the system is not in equilibrium and the reaction will move from right to left\n"
       ]
      }
     ],
     "prompt_number": 3
    }
   ],
   "metadata": {}
  }
 ]
}