{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter9 Chemical Equilibria"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.1, Page no.35"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Kc= 0.5002 lˆ2 moleˆ−2\n",
      "Kx= 0.0164 e\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "T=400        #in Celsius\n",
    "R=0.08205    #in l−atm moleˆ−1 degˆ−1\n",
    "Kp=1.64*10**-4\n",
    "n=2.0\n",
    "P=10         #in atm\n",
    "#CALCULATIONS\n",
    "Kc=Kp*(R*(273.1+T))**n\n",
    "Kx=Kp*P**n\n",
    "#RESULTS\n",
    "Kc=round(Kc,4)\n",
    "print 'Kc=',Kc,'lˆ2 moleˆ−2'\n",
    "print 'Kx=',Kx,'e'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.2, Page no.35"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "degree of dissociation= 0.1846\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "R=0.08205     #in l−atm moleˆ−1 degˆ−1\n",
    "T=25          #in Celsius\n",
    "g=1.588       #in gms\n",
    "P=1           #in atm\n",
    "V=0.5         #litres\n",
    "M1=92.02      #g moleˆ−1 \n",
    "#CALCULATIONS\n",
    "M2=R*(273.1+T)*g/(P*V)\n",
    "a=(M1-M2)/M2 \n",
    "#RESULTS\n",
    "a=round(a,4)\n",
    "print 'degree of dissociation=',a"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.3, Page no.36"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Kp= 0.14\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "P=1        #atm\n",
    "a=18.46    #in percentage\n",
    "P1=0.5     #atm\n",
    "#CALCULATIONS\n",
    "Kp=P*4*(a/100)**2/(1-(a/100)**2)\n",
    "#RESULTS\n",
    "Kp=round(Kp,2)\n",
    "print 'Kp=',Kp"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.4, Page no.36"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Kp= 1.83\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "M1=208.3     #gms\n",
    "g=2.69       #gms\n",
    "R=0.08205    #l−atm moleˆ−1 degˆ−1\n",
    "T=250        #Celsius\n",
    "P=1          #atm\n",
    "V=1          #lit\n",
    "#CALCULATIONS\n",
    "M2=g*R*(273.1+T)/(P*V)\n",
    "a=(M1-M2)/M2\n",
    "Kp=a**2*P/(1-a**2)\n",
    "#RESULTS\n",
    "Kp=round(Kp,3)\n",
    "print 'Kp=',Kp"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.5, Page no.37"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "degree of dissociation= 0.574\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "x=0.0574           #mole\n",
    "n=0.1              #mole\n",
    "#CALCULATIONS\n",
    "a=x/n\n",
    "#RESULTS\n",
    "print 'degree of dissociation=',a"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.6, Page no.37"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x= 0.341 mole\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "R=0.08205       #l−atm moleˆ−1 degˆ−1\n",
    "T=250           #Celsius\n",
    "n=0.1           #mole\n",
    "Kp=1.78\n",
    "#CALCULATIONS\n",
    "x=n+(n**2*R*(273.1+T)/Kp)\n",
    "#RESULTS\n",
    "x=round(x,3)\n",
    "print 'x=',x,'mole'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.7, Page no.38"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "P= 3.668 atm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from math import sqrt\n",
    "#initialisation of variables\n",
    "Ppcl5=1    #atm\n",
    "Kp=1.78 \n",
    "#CALCULATIONS\n",
    "Ppcl2=sqrt(Kp)\n",
    "P=2*Ppcl2+Ppcl5\n",
    "#RESULTS\n",
    "P=round(P,3)\n",
    "print 'P=',P,'atm'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.8, Page no.38"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Kp= 42.72 atm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "Kp=1.78\n",
    "a=0.2\n",
    "#CALCULATIONS\n",
    "P=Kp*(1-a**2)/a**2\n",
    "#RESULTS\n",
    "print 'Kp=',P,'atm'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.10, Page no.38"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "K= 4.001\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "n=0.6667       #mole\n",
    "#CALCULATIONS\n",
    "K=n**2/((1-n)**2)\n",
    "#RESULTS\n",
    "K=round(K,3)\n",
    "print 'K=',K"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.11, Page no.39"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dG= 1160.57 cal\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "pN2O4=0.141          #atm\n",
    "pNO2=1               #atm\n",
    "R=1.987              #cal moleˆ−1 degˆ−1\n",
    "T=25                 #Celsius\n",
    "#CALCULATIONS\n",
    "dG=-R*2.303*(273.1+T)*math.log10(pN2O4/pNO2**2)\n",
    "#RESULTS\n",
    "dG=round(dG,3)\n",
    "print 'dG=',dG,'cal'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.12, Page no.40"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dG= -1160.57 cal\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "pN2O4=1 #atm \n",
    "pNO2=0.141 #atm \n",
    "R=1.987 #cal moleˆ−1 degˆ−1 \n",
    "T=25    #C \n",
    "#CALCULATIONS \n",
    "dG=-R*2.303*(273.1+T)*math.log10(pN2O4/pNO2) \n",
    "#RESULTS \n",
    "dG=round(dG,3)\n",
    "print 'dG=',dG,'cal'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.13, Page no.40"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dG= -3526.964 cal\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "Kc=2.7*10**2 \n",
    "R= 1.987  #cal moleˆ−1 degˆ−1 \n",
    "T= 43.9   #c \n",
    "#CALCULATIONS \n",
    "dG=-R*(273.1+T)*2.303*math.log10(Kc) \n",
    "#RESULTS\n",
    "dG=round(dG,3)\n",
    "print 'dG=',dG,'cal'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.14, Page no.40"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Kp= 6.30787913713e-05 e\n",
      "ANSWER IN THE TEXTBOOK IS WRONG\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "dH=-17.889    # cal degˆ−1 \n",
    "T=25          #C \n",
    "dS=-19.28     # cal degˆ−1 \n",
    "R=1.987       # cal moleˆ−1 degˆ−1 \n",
    "#CALCULATIONS \n",
    "dG=dH-dS*(273.1+T) \n",
    "Kp=10**(dG/(-R*(273.1+T)*2.303)) \n",
    "#RESULTS \n",
    "print 'Kp=',Kp,'e'\n",
    "print 'ANSWER IN THE TEXTBOOK IS WRONG'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.15, Page no.40"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Kp= 1.01157190896 e\n",
      "ANSWER IN THE TEXTBOOK IS WRONG\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "HCO2=-94.2598 # kcal\n",
    "HH2=0 # kcal\n",
    "HCO=-32.8079 # kcal\n",
    "HH2O=-54.6357 # kcal\n",
    "R=1.987 # cal degˆ−1 moleˆ−1\n",
    "T=25    #C\n",
    "#CALCULATIONS \n",
    "Kp=10**(-(HCO2 -HCO -HH2O)/(R*2.303*(273.1+T)))\n",
    "#RESULTS \n",
    "print 'Kp=',Kp,'e' \n",
    "print 'ANSWER IN THE TEXTBOOK IS WRONG'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.16, Page no.41"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dG= -202.666 cal\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "G0=1161.0 # cal\n",
    "R=1.987 # cal moleˆ−1 degˆ−1\n",
    "T=25.0 #C\n",
    "P=1.0 #atm\n",
    "P1=10.0 #atm\n",
    "#CALCULATIONS\n",
    "dG=G0+R*(273.0+T)*2.303*math.log10(P**2/P1) \n",
    "#RESULTS \n",
    "dG=round(dG,3)\n",
    "print 'dG=',dG,'cal'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.17, Page no.41"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "enthalpy change= 43273.17 cal\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "K2500=3.6*10**-3\n",
    "K2000=4.08*10** -4 \n",
    "R=1.987 # cal moleˆ−1 Kˆ−1\n",
    "T1=2500 #K\n",
    "T2=2000 #K\n",
    "#CALCULATIONS\n",
    "dH=math.log10(K2500/K2000)*2.303*R*T1*T2/(T1-T2) \n",
    "#RESULTS \n",
    "dH=round(dH,3)\n",
    "print 'enthalpy change=',dH,'cal'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.18, Page no.42"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "K800= 3.596\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "dH=-10200    #cal\n",
    "R=1.987     # cal degˆ−1 moleˆ−1\n",
    "T1=690      #K\n",
    "T2=800      #K\n",
    "KT1=10\n",
    "#CALCULATIONS\n",
    "KT2=KT1*10**(dH*(T2-T1)/(2.303*R*T1*T2)) \n",
    "#RESULTS \n",
    "KT2=round(KT2,3)\n",
    "print 'K800=',KT2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.19, Page no.42"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Kp= 1.953\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "T=1000.0 #K \n",
    "R=1.987 # cal moleˆ−1 Kˆ−1 \n",
    "G=-1330.0 # cal moleˆ−1 \n",
    "#CALCULATIONS \n",
    "Kp=10.0**(G/(-R*T*2.303)) \n",
    "#RESULTS\n",
    "Kp=round(Kp,3)\n",
    "print 'Kp=',Kp"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.20, Page no.43"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "percent dissaciated= 97.304 percent\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "from math import sqrt\n",
    "Kp=1.78 \n",
    "P=0.1 #atm \n",
    "#CALCULATIONS \n",
    "a=sqrt(Kp/(Kp+P))*100 \n",
    "#RESULTS \n",
    "a=round(a,3)\n",
    "print 'percent dissaciated=',a,'percent'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.21, Page no.43"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "equilibrium constant= 0.00000072\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "R=1.987 # cal moleˆ−1 Kˆ−1 \n",
    "T=2000 #K \n",
    "dH= 117172 # cal moleˆ−1 \n",
    "H=-43 # cal moleˆ−1 \n",
    "n=2 \n",
    "H1=-56.12 # cal moleˆ−1 \n",
    "#CALCULATIONS 1\n",
    "K=10**( -(1/(2.303*R))*((dH/T)+n*H-H1))\n",
    "#RESULTS\n",
    "print 'equilibrium constant=',format(K, '.8f')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.22, Page no.43"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ANSWER IN TEXTBOOK IS WRONG\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "T=25.0 #C \n",
    "R=1.987 # cal moleˆ−1 Kˆ−1 \n",
    "n=2.0 \n",
    "dH=-21.840 # cal moleˆ−1 \n",
    "HHCl=-37.73 # cal moleˆ−1 \n",
    "HH2=-24.44 # cal moleˆ−1 \n",
    "HCl=-45.95 # cal moleˆ−1 1\n",
    "#CALCULATIONS\n",
    "K=10**(( -1/(2.303*R))*((dH*n/(273.15+T))+n*HHCl -HH2 - HCl))\n",
    "print 'ANSWER IN TEXTBOOK IS WRONG'"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [Root]",
   "language": "python",
   "name": "Python [Root]"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
