{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 16:Acid-Base Equilibria and Solubility Equilibria"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:16.1,Page no:715"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "InitCH3COOH1=0.2                #Initial concentration of CH3COOH solution, M\n",
      "#Let 'x' be the equilibrium concentration of the [H+] and [CH3COO-] ions after dissociation of [CH3COOH], M\n",
      "Ka=1.8*10**-5                   #equilibrium constant of acid, M\n",
      "InitCH3COONa=0.3                #Initial concentration of CH3COONa solution and is equal to conc of Na+ and CH3COO- as it completely dissociates, M\n",
      "InitCH3COOH2=0.2                #Initial concentration of CH3COOH solution, M\n",
      "\n",
      "#Calculation\n",
      "#(a)\n",
      "import math\n",
      "x1=math.sqrt(Ka*InitCH3COOH1)   #from the definition of ionisation constant Ka=[H+]*[CH3COO-]/[CH3COOH]=x*x/(0.2-x), which reduces to x*x/0.2, as x<<0.2 (approximation)\n",
      "pH1=-math.log10(x1)             #since x is the conc. of [H+] ions\n",
      "\n",
      "#(b)\n",
      "#Let 'x' be the equilibrium concentration of the [H+] and hence conc of [CH3COO-] ions is '0.3 + x', M\n",
      "x2=Ka*InitCH3COOH2/InitCH3COONa           #from the definition of ionisation constant Ka=[H+]*[CH3COO-]/[CH3COOH]=x*(0.3+x)/(0.2-x), which reduces to x*0.3/0.2(approximation)\n",
      "pH2=-math.log10(x2)                       #since x is the conc. of [H+] ions\n",
      "\n",
      "#Result\n",
      "print\"(a) the pH of CH3COOH solution is \",round(pH1,2)\n",
      "print\"(b) the pH of CH3COOH and CH3COONa solution is :\",round(pH2,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) the pH of CH3COOH solution is  2.72\n",
        "(b) the pH of CH3COOH and CH3COONa solution is : 4.92\n"
       ]
      }
     ],
     "prompt_number": 92
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 16.3,Page no:719"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Ka=1.8*10**-5                     #ionisation constant of acid\n",
      "InitCH3COONa=1                    #Initial concentration of CH3COONa solution and is equal to conc of Na+ and CH3COO- as it completely dissociates, M\n",
      "InitCH3COOH=1 #Initial concentration of CH3COOH solution, M\n",
      "HCl=0.1 #moles of HCl added to 1L solution\n",
      "\n",
      "#Calculation\n",
      "import math\n",
      "#(a)\n",
      "x=Ka*InitCH3COOH/InitCH3COONa #from the definition of ionisation constant Ka=[H+]*[CH3COO-]/[CH3COOH]=x*(1+x)/(1-x), which reduces to x(approximation)\n",
      "pH=-math.log10(x) #since x is the conc. of [H+] ions\n",
      "#(b)\n",
      "CH3COO=InitCH3COONa-HCl #conc of CH3COO- ions, M\n",
      "CH3COOH=InitCH3COOH+HCl #conc of CH3COOH, M\n",
      "x2=Ka*CH3COOH/CH3COO #from the definition of ionisation constant Ka=[H+]*[CH3COO-]/[CH3COOH]=x*(0.9+x)/(1.1-x), which reduces to x*0.9/1.1(approximation)\n",
      "pH2=-math.log10(x2) #since x is the conc. of [H+] ions\n",
      "\n",
      "#Result\n",
      "print\"(a) the pH of CH3COOH and CH3COONa solution is :\",round(pH,2)\n",
      "print\"(b) the pH of solution after adding HCl is :\",round(pH2,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) the pH of CH3COOH and CH3COONa solution is : 4.74\n",
        "(b) the pH of solution after adding HCl is : 4.66\n"
       ]
      }
     ],
     "prompt_number": 93
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:16.5,Page no:728"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "InitCH3COOH=0.1 #Initial concentration of CH3COOH solution, M\n",
      "VCH3COOH=25 #volumeof CH3COOH, mL\n",
      "nCH3COOH=InitCH3COOH*VCH3COOH/1000 \n",
      "Ka=1.8*10**-5 #equilibrium constant of acid, M\n",
      "Kb=5.6*10**-10 #equilibrium constant of base, M\n",
      "N=0.1 #Initial concentration of NaOH solution, M\n",
      "V=10 #Initial volume of NaOH solution, mL\n",
      "\n",
      "\n",
      "#Calculation\n",
      "#(a)\n",
      "n=N*V/1000 #Initial moles of NaOH solution\n",
      "import math\n",
      "nCH3COOH_tit=nCH3COOH-n #moles of CH3COOH after titration\n",
      "nCH3COO=n #moles of CH3COO after titration\n",
      "H=nCH3COOH_tit*Ka/nCH3COO #conc of H+ ions, M\n",
      "pH=-math.log10(H) #since H is the conc. of [H+] ions\n",
      "\n",
      "#Result\n",
      "print\"(a) the pH of the solution is :\",round(pH,2)\n",
      "\n",
      "\n",
      "#Calculation\n",
      "#(b)\n",
      "V2=25.0 #Initial volume of NaOH solution, mL\n",
      "n2=N*V2/1000.0 #Initial moles of NaOH solution\n",
      "nCH3COOH_tit2=nCH3COOH-n2 #moles of CH3COOH after titration\n",
      "nCH3COO2=n2 #moles of CH3COO- ions after titration\n",
      "V_total=V2+VCH3COOH #total volume after titration\n",
      "CH3COO=nCH3COO2/V_total*1000 #conc of CH3COO- ions, M\n",
      "x=math.sqrt(Kb*CH3COO) #from the definition of ionisation constant Kb=[OH-]*[CH3COOH]/[CH3COO-]=x*x/(0.05-x), which reduces to x*x/0.05, as x<<0.05 (approximation)\n",
      "pOH=-math.log10(x) #since x is the conc. of [OH-] ions\n",
      "pH2=14.0-pOH \n",
      "\n",
      "#Result\n",
      "print\"(b) the pH of the solution is :\",round(pH2,2)\n",
      "\n",
      "#Calculation\n",
      "#(c)\n",
      "N=0.1 #Initial concentration of NaOH solution, M\n",
      "V=35 #Initial volume of NaOH solution, mL\n",
      "n=N*V/1000 #Initial moles of NaOH solution\n",
      "n_tit=n-nCH3COOH #moles of NaOH after titration\n",
      "nCH3COO=nCH3COOH #moles of CH3COO- ions after titration\n",
      "V_total=V+VCH3COOH #total volume\n",
      "OH=n_tit/V_total*1000 #conc of OH- ions, M\n",
      "pOH=-math.log10(OH) #since OH is the conc. of [OH-] ions\n",
      "pH=14-pOH \n",
      "\n",
      "#Result\n",
      "print\"(c) the pH of the solution is :\",round(pH,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) the pH of the solution is : 4.57\n",
        "(b) the pH of the solution is : 8.72\n",
        "(c) the pH of the solution is : 12.22\n"
       ]
      }
     ],
     "prompt_number": 94
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:16.6,Page no:730"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "InitNH3=0.1 #Initial concentration of NH3 solution, M\n",
      "VNH3=25 #volume of NH3, mL\n",
      "nNH3=InitNH3*VNH3/1000 \n",
      "Ka=5.6*10**-10 #equilibrium constant of acid, M\n",
      "N=0.1 #Initial concentration, M\n",
      "\n",
      "#Calculation\n",
      "import math\n",
      "V=VNH3/InitNH3*N #Initial volume, mL\n",
      "V_total=V+VNH3 #total volume of the mixture, mL\n",
      "n_NH4Cl=nNH3 #moles of NH4Cl\n",
      "NH4Cl=n_NH4Cl/V_total*1000 #conc of NH4+ ions formed, M\n",
      "x=math.sqrt(Ka*NH4Cl) #from the definition of ionisation constant Ka=[H+]*[NH3]/[NH4+]=x*x/(NH4+-x), which reduces to x*x/NH4+, as x<<NH4+ (approximation)\n",
      "pH=-math.log10(x) #since x is the conc. of [H+] ions\n",
      "\n",
      "#Result\n",
      "print\"The pH of the solution at equivalent point is :\",round(pH,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The pH of the solution at equivalent point is : 5.28\n"
       ]
      }
     ],
     "prompt_number": 95
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 16.8,Page no:738"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "solubility=0.67 #solubility of CaSO4, g/L\n",
      "\n",
      "#Calculation\n",
      "M=136.2 #mol mass of CaSO4, g\n",
      "s=solubility/M #concentration, M\n",
      "Ksp=s**2 #solubility product\n",
      "\n",
      "#Result\n",
      "print\"The Ksp of CaSO4 is :%.1e\"%Ksp"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Ksp of CaSO4 is :2.4e-05\n"
       ]
      }
     ],
     "prompt_number": 96
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:16.9,Page no:739"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Ksp=2.2*10**-20 #solubility product\n",
      "M=97.57 #mol mass of Cu(OH)2, g\n",
      "\n",
      "#Calculation\n",
      "s=(Ksp/4.0)**(1.0/3.0) #concentration, M\n",
      "solubility=s*M #solubility of Cu(OH)2, g/L\n",
      "\n",
      "#Result\n",
      "print\"The solubility of Cu(OH)2 is :%.2e\"%solubility,\"g/L\"\n",
      "\n",
      "#ALTERNATIVE METHOD:\n",
      "\n",
      "#Variable declaration\n",
      "Kspt=2.2*10**-20             #Ksp value from table 16.2\n",
      "M=97.75          #Molar mass of Cu(OH)2\n",
      "\n",
      "#Calculation\n",
      "from scipy.optimize import fsolve\n",
      "def f(s):\n",
      "    Cu2=s\n",
      "    OH_=2*s\n",
      "    return(Kspt-(Cu2*(OH_**2)))\n",
      "s=fsolve(f,1)\n",
      "solubility=round(s,8)*M\n",
      "\n",
      "#Result\n",
      "print \"Alternative method: Solubility of Cu(OH)2=%.1e\"%solubility,\"g/L\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The solubility of Cu(OH)2 is :1.72e-05 g/L\n",
        "Alternative method: Solubility of Cu(OH)2=1.8e-05"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " g/L\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:16.10,Page no:741"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Ksp=1.1*10**-10 #solubility product of BaSO4\n",
      "#for Ba2+ ion\n",
      "N=0.004 #normality, M\n",
      "V=200 #vol in mL\n",
      "n=N*V/1000 #moles\n",
      "#for K2SO4sol\n",
      "N1=0.008 #normality, M\n",
      "V1=600 #vol in mL\n",
      "\n",
      "#Calculation\n",
      "n1=N1*V1/1000 #moles\n",
      "Nnew=n*1000/(V+V1) #conc of Ba2+ ions in final sol\n",
      "N1new=n1*1000/(V+V1) #conc of SO4 2- ions in final sol\n",
      "Q=Nnew*N1new #as Q=[Ba2+][SO4 2-]\n",
      "\n",
      "#Result\n",
      "print\"Q=\",Q\n",
      "if(Q>Ksp): #determination of precipitation\n",
      "    print\"Q>Ksp, The solution is supersaturated and hence a precipitate will form\"\n",
      "else: \n",
      "    print\"Q<Ksp, The solution is not supersaturated and hence a precipitate will not form\"  "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Q= 6e-06\n",
        "Q>Ksp, The solution is supersaturated and hence a precipitate will form\n"
       ]
      }
     ],
     "prompt_number": 99
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:16.11,Page no:743"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Br=0.02 #conc of Ag+ ions, M\n",
      "Ksp1=7.7*10**-13 #solubility product of AgBr\n",
      "Ksp2=1.6*10**-10 #solubility product of AgCl\n",
      "Cl=0.02 #conc of Cl- ions, M\n",
      "\n",
      "#Calculation\n",
      "#for Br\n",
      "Ag1=Ksp1/Br #conc of Ag+ ions at saturated state, M\n",
      "#for Cl\n",
      "Ag2=Ksp2/Cl #conc of Ag+ ions at saturated state, M\n",
      "\n",
      "#Result\n",
      "print \"[Ag+]=\",Ag2,\"M\"\n",
      "print\"To precipitate Br- without precipitating Cl- the concentration of Ag must be greater than %.1e\"%Ag1,\"M but less than\",Ag2,\"M\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "[Ag+]= 8e-09 M\n",
        "To precipitate Br- without precipitating Cl- the concentration of Ag must be greater than 3.9e-11 M but less than 8e-09 M\n"
       ]
      }
     ],
     "prompt_number": 100
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:16.12,Page no: 745"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "N_AgNO3=6.5*10**-3 #normality of AgNO3, M\n",
      "AgCl=143.4 #mol mass of AgCl, g\n",
      "Ksp=1.6*10**-10 #solubility product of AgCl\n",
      "\n",
      "#Calculation\n",
      "Ag=N_AgNO3 #conc of Ag+ ions as 's' is negligible, M\n",
      "s=Ksp/Ag #as Ksp=[Ag+][Cl-], molar solubility of AgCl, M\n",
      "solubility=s*AgCl #solubility of AgCl in AgBr solution, g/L\n",
      "\n",
      "#Result\n",
      "print\"The solubility of AgCl in AgBr solution is :%.2e\"%solubility,\"g/L\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The solubility of AgCl in AgBr solution is :3.53e-06 g/L\n"
       ]
      }
     ],
     "prompt_number": 101
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:16.14,Page no:748"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "FeCl2=0.003 #normality of FeCl2, M\n",
      "Fe=FeCl2 #as Fe2+ is strong electrolyte, conc of Fe2+=conc of FeCl2, M\n",
      "Ksp=1.6*10**-14 #solubility product of FeCl2\n",
      "Kb=1.8*10**-5 #ionisation constant of base\n",
      "\n",
      "#Calculation\n",
      "import math\n",
      "OH=math.sqrt(Ksp/Fe) #as Ksp=[Fe2+][OH-]**2, conc of OH- ions, M\n",
      "x=(OH**2)/Kb+OH #as Kb=[NH4+][OH-]/[NH3]\n",
      "\n",
      "#Result\n",
      "print\"To initiate precipitation the conc of NH3 must be slightly greater than :%.1e\"%x,\"M\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "To initiate precipitation the conc of NH3 must be slightly greater than :2.6e-06 M\n"
       ]
      }
     ],
     "prompt_number": 102
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:16.15,Page no:750"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "CuSO4=0.2 #normality of CuSO4, M\n",
      "NH3=1.2 #initial conc of NH3, M\n",
      "VNH3=1 #volume of NH3, L\n",
      "Kf=5*10**13 #formation constant\n",
      "\n",
      "#Calculation\n",
      "CuNH34=CuSO4 #conc of Cu(NH3)4 2+, M\n",
      "NH3=NH3-4*CuNH34 #conc of NH3 after formation of complex, as 4 moles of NH3 react to form 1 mole complex, M\n",
      "x=CuNH34/(NH3**4*Kf) #as Kf=[Cu(SO4)3 2+]/[Cu2+][NH3]**4\n",
      "\n",
      "#Result\n",
      "print\"The conc of Cu2+ ions in equilibrium is :%.1e\"%x,\"M\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The conc of Cu2+ ions in equilibrium is :1.6e-13 M\n"
       ]
      }
     ],
     "prompt_number": 103
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:16.16,Page no:751"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "InitNH3=1 #initial conc of NH3, M\n",
      "Ksp=1.6*10**-10 #solubility product of AgCl\n",
      "Kf=1.5*10**7 #formation constant of complex\n",
      "\n",
      "#Calculation\n",
      "K=Ksp*Kf #overall equilibrium constant\n",
      "import math\n",
      "s=math.sqrt(K)/(1+2*InitNH3*math.sqrt(K)) #molar solubility of AgCl, M\n",
      "\n",
      "#Result\n",
      "print\"Amount of AgCl which can be dissolved in 1 L of 1 M NH3 sol in equilibrium is :\",round(s,3),\"M\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Amount of AgCl which can be dissolved in 1 L of 1 M NH3 sol in equilibrium is : 0.045 M\n"
       ]
      }
     ],
     "prompt_number": 91
    }
   ],
   "metadata": {}
  }
 ]
}