{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter15 Ionic Equilibria"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 15.1,Page no.62"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "solubility product = 2048.0 * 10**-15\n",
      "solubility= 2048.0 * 10**6\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "c=8*10**-5 # molar\n",
    "n=2.0\n",
    "#CALCULATIONS\n",
    "Ksp=c**3*n**2\n",
    "#RESULTS\n",
    "Ksp=Ksp*10**15\n",
    "x=Ksp\n",
    "print 'solubility product =',Ksp,'* 10**-15'\n",
    "print 'solubility=',x,'* 10**6'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 15.2,Page no.62"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "mean ionic activity cooeficient = 1.0\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "Ksp=2*10**-12 \n",
    "M=8.84*10** -5 # molar \n",
    "n=2.0\n",
    "#CALCULATIONS \n",
    "r=(Ksp/(n**2*M**3))**(1/3) \n",
    "#RESULTS \n",
    "print 'mean ionic activity cooeficient =',r"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 15.3,Page no.63"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "mean ionic activity coeficient = 0.791\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "from math import sqrt\n",
    "n=2.0 \n",
    "C=0.01 #M\n",
    "#CALCULATIONS \n",
    "r=10**(-0.509*n*sqrt(C)) \n",
    "r=round(r,3)\n",
    "#RESULTS \n",
    "print 'mean ionic activity coeficient =',r"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 15.4,Page no.63"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "degree of ionisation = 0.01 * 10**-5\n",
      "ion product of water = 0.0001 * 10**-10\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "M=18 #gms\n",
    "k=5.5*10** -8 #ohmˆ−1 cmˆ−1\n",
    "lc=349.8 #cmˆ2 equivˆ−1 ohmˆ−1\n",
    "la=198 #cmˆ2 equivˆ−1 ohmˆ−1\n",
    "#CALCULATIONS\n",
    "A=M*k\n",
    "A0= lc+la \n",
    "a=A/A0\n",
    "a1= 1000*a/M \n",
    "Kw=a1*a1\n",
    "#RESULTS\n",
    "a1=a1* 10**5\n",
    "a1=round(a1,2)\n",
    "Kw=Kw* 10**10\n",
    "Kw=round(Kw,4)\n",
    "print 'degree of ionisation =',a1,'* 10**-5'\n",
    "print 'ion product of water =',Kw,'* 10**-10'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 15.5,Page no.64"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "pKa = 3.752\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "Ka=1.772*10** -4 \n",
    "#CALCULATIONS \n",
    "pK=-math.log10(Ka) \n",
    "#RESULTS\n",
    "pK=round(pK,3)\n",
    "print 'pKa =',pK"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 15.6,Page no.64"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ionisation constant = 0.00002212\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "K=1.75*10** -5 \n",
    "c=0.01 #M \n",
    "#CALCULATIONS \n",
    "r=10**( -0.509*sqrt(c)) \n",
    "Ka=K/r**2 \n",
    "#RESULTS \n",
    "print 'ionisation constant =',format(Ka, '.8f')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 15.7,Page no.64"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "pH = 2.878\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "from math import sqrt\n",
    "ka=1.75*10** -5 \n",
    "ca=0.1 #mole lit \n",
    "#CALCULATIONS\n",
    "pH=-math.log10(sqrt(ka*ca)) \n",
    "#RESULTS \n",
    "pH=round(pH,3)\n",
    "print 'pH =',pH"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 15.8,Page no.65"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "pH = 8.785\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "kw=10**-14\n",
    "ka=2.69*10** -5\n",
    "c=0.1 #N\n",
    "#CALCULATIONS\n",
    "pH=-math.log10(sqrt(kw*ka/c))\n",
    "#RESULTS\n",
    "pH=round(pH,3)\n",
    "print 'pH =',pH"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 15.9,Page no.65"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "pH= 5.093\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "pH=4.57\n",
    "M=0.03 #mole litre ˆ−1\n",
    "M1=0.1 #mole litre ˆ−1\n",
    "#CALCULATIONS\n",
    "pH1=pH+math.log10(M1/M)\n",
    "#RESULTS\n",
    "pH1=round(pH1,3)\n",
    "print 'pH=',pH1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 15.10,Page no.65"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "pH= 8.567\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "pH=9.26\n",
    "M=0.02 #N\n",
    "M1=0.01 #/N\n",
    "#CALCULATIONS\n",
    "pH1=pH+math.log(M1/M)\n",
    "#RESULTS\n",
    "pH1=round(pH1,3)\n",
    "print 'pH=',pH1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 15.11,Page no.66"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "pH = 7.11\n",
      "dpH = 0.03\n",
      "dpH = 4.0\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#initialisation of variables\n",
    "pKa=6.84\n",
    "n=0.04 #mole\n",
    "n1=0.02 #mole\n",
    "n2=0.001 #mole\n",
    "pH3=7.0\n",
    "#CALCULATIONS\n",
    "pH=pKa+math.log10(n/n1) \n",
    "pH1=pKa+math.log10((n-n2)/(n1+n2)) \n",
    "dpH=pH-pH1 \n",
    "pH2=-math.log10(n2)\n",
    "dpH1=pH3-pH2\n",
    "#RESULTS\n",
    "pH1=round(pH1,2)\n",
    "dpH=round(dpH,2)\n",
    "print 'pH =',pH1\n",
    "print 'dpH =',dpH\n",
    "print 'dpH =',dpH1"
   ]
  }
 ],
 "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
}
