{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 1:Water"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:1,Page no:1.7"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "W1=219.0 #amount of Mg(HCO3)2 in water in ppm#\n",
      "W2=36.0 #amount of Mg2+ in water in ppm#\n",
      "W3=18.3 #amount of (HCO3)- in water in ppm#\n",
      "W4=1.5 #amount of H+_in water in ppm#\n",
      "M1=100/146.0 #multiplication factor of Mg(HCO3)2#\n",
      "M2=100/24.0 #multiplication factor of Mg(HCO3)2#\n",
      "M3=100/122.0 #multiplication factor of Mg(HCO3)2#\n",
      "M4=100/2.0 #multiplication factor of Mg(HCO3)2#\n",
      "\n",
      "#Calculation\n",
      "P1=W1*M1 #in terms of CaCO3#\n",
      "P2=W2*M2 #in terms of CaCO3#\n",
      "P3=W3*M3 #in terms of CaCO3#\n",
      "P4=W4*M4 #in terms of CaCO3#\n",
      "L=0.74*((2*P1)+P2+P3+P4) \n",
      "\n",
      "R=1.0 #water supply rate in m**3/s#\n",
      "D=R*60.0*60.0*24.0*L \n",
      "K=D*1000.0 #in lit/day#\n",
      "T=K/10.0**9 #in tonnes#\n",
      "S=1.06*(P2+P4-P3) \n",
      "D2=R*60*60*24*S \n",
      "A=D2*1000 #in lit/day#\n",
      "B=A/10.0**9 #in tonnes#\n",
      "J1=90/100.0 #purity of lime#\n",
      "J2=95/100.0 #purity of soda#\n",
      "C1=500.0 #cost of one tonne lime#\n",
      "C2=7000.0 #cost of one tonne soda#\n",
      "CL=round(T,1)*C1/J1 \n",
      "print\"\\ncost of lime is\",CL,\"Rs\"\n",
      "CS=round(B,1)*C2/J2 \n",
      "print\"\\ncost of soda is \",CS,\"Rs\"\n",
      "C=CL+CS \n",
      "\n",
      "#Result\n",
      "print\"\\ntotal cost is \",round(C) ,\"Rs\"\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "cost of lime is 19166.6666667 Rs\n",
        "\n",
        "cost of soda is  141473.684211 Rs\n",
        "\n",
        "total cost is  160640.0 Rs\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:15,Page no:1.25"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "W1=40.0 #amount of Ca2+ in water in mg/l#\n",
      "W2=24.0 #amount of Mg2+ in water in mg/l#\n",
      "W3=8.05 #amount of Na+ in water in mg/l#\n",
      "W4=183.0 #amount of (HCO3)- in water in mg/l#\n",
      "W5=55.68 #amount of (SO4)2- in water in mg/l#\n",
      "W6=6.74 #amount of Cl- in water in mg/l#\n",
      "M1=100/40.0 #multiplication factor of Ca2+#\n",
      "M2=100/24.0 #multiplication factor of Mg2+#\n",
      "M3=100/(23.0*2) #multiplication factor of Na+#\n",
      "M4=100/(61.0*2) #multiplication factor of (HCO3)-#\n",
      "M5=100/96.0 #multiplication factor of (SO4)2-#\n",
      "M6=100/(35.5*2) #multiplication factor of Cl-#\n",
      "\n",
      "#Calculation\n",
      "P1=W1*M1 #in terms of CaCO3#\n",
      "P2=W2*M2 #in terms of CaCO3#\n",
      "P3=W3*M3 #in terms of CaCO3#\n",
      "P4=W4*M4 #in terms of CaCO3#\n",
      "P5=W5*M5 #in terms of CaCO3#\n",
      "P6=W6*M6 #in terms of CaCO3#\n",
      "\n",
      "\n",
      "#Result\n",
      "print\"\\nCalcium alkalinity =\",P1,\"ppm\" \n",
      "print\"\\nMagnesium alkalinity =\",P4-P1,\"ppm\"\n",
      "print\"\\n  total alkalinity = \",P1+P4-P1,\"ppm\"\n",
      "print\"\\n  total hardness = \",P1+P2,\"ppm\"\n",
      "print\"\\nCa temporary hardness = \",P1,\"ppm\"\n",
      "print\"\\nMg temporary hardness = \",P4-P1,\"ppm\"\n",
      "print\"\\nMg permanant hardness = \",P2-(P4-P1),\"ppm\"\n",
      "print\"\\nSalts are:\"\n",
      "print\"\\nCa(HCO3)2 salt = \",P1,\"ppm\"\n",
      "print\"\\nMg(HCO3)2 salt = \",P4-P1,\"ppm\"\n",
      "print\"\\nMgSO4 salt = \",P2-(P4-P1),\"ppm\"\n",
      "print\"\\nNaCl salt = \",P6,\"ppm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Calcium alkalinity = 100.0 ppm\n",
        "\n",
        "Magnesium alkalinity = 50.0 ppm\n",
        "\n",
        "  total alkalinity =  150.0 ppm\n",
        "\n",
        "  total hardness =  200.0 ppm\n",
        "\n",
        "Ca temporary hardness =  100.0 ppm\n",
        "\n",
        "Mg temporary hardness =  50.0 ppm\n",
        "\n",
        "Mg permanant hardness =  50.0 ppm\n",
        "\n",
        "Salts are:\n",
        "\n",
        "Ca(HCO3)2 salt =  100.0 ppm\n",
        "\n",
        "Mg(HCO3)2 salt =  50.0 ppm\n",
        "\n",
        "MgSO4 salt =  50.0 ppm\n",
        "\n",
        "NaCl salt =  9.49295774648 ppm\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:19,Page no:1.39"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "P=4.7 #required HCl in ml using HpH indicator #\n",
      "H=10.5 #required HCl im ml using MeOH indicator#\n",
      "M=P+H \n",
      "N=0.02 #normality of HCl#\n",
      "\n",
      "print\"\\nSince P<0.5*M sample contain (CO3)2- and (HCO3)- alkalinity\"\n",
      "C=50 #equivalent of CaCO3 in mg for 1ml 1N HCl#\n",
      "\n",
      "#Calculation\n",
      "A=C*(2*P)*N #amount of (CO3)2- alkalinity in mg in 100 ml of water#\n",
      "B=A*1000/100 \n",
      "D=C*(M-2*P)*N #the amount of (HCO3)- alkalinity in mg in 100 ml of water#\n",
      "E=D*1000/100 \n",
      "T=B+E \n",
      "\n",
      "#Result\n",
      "print\"\\nTotal alkalinity is \",T,\"mg/l or ppm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Since P<0.5*M sample contain (CO3)2- and (HCO3)- alkalinity\n",
        "\n",
        "Total alkalinity is  152.0 mg/l or ppm\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:25,Page no:1.56"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "W1=160.0 #amount of Ca2+ in ppm#\n",
      "W2=88.0 #amount of Mg2+ in ppm#\n",
      "W3=72.0 #amount of CO2 in ppm#\n",
      "W4=488.0 #amount of (HCO3)- in ppm#\n",
      "W5=139.0 #amount of (FeSO4).7H2O in ppm#\n",
      "M1=100/40.0 #multiplication factor of Ca2+#\n",
      "M2=100/24.0 #multiplication factor of Mg2+#\n",
      "M3=100/44.0 #multiplication factor of CO2#\n",
      "M4=100/(61.0*2.0) #multiplication factor of (HCO3)-#\n",
      "M5=100/278.0 #multiplication factor of (FeSO4).7H2O#\n",
      "\n",
      "P1=400 #in terms of CaCO3#\n",
      "P2=300 #in terms of CaCO3#\n",
      "P3=200 #in terms of CaCO3#\n",
      "P4=400 #in terms of CaCO3#\n",
      "P5=50 #in terms of CaCO3#\n",
      "V=100000.0 #volume of water in litres#\n",
      "\n",
      "\n",
      "#Calculation\n",
      "L=0.74*(P2+P3+P4+P5)*V #lime required in mg#\n",
      "L=L/10.0**6 \n",
      "S=1.06*(P1+P2+P5-P4)*V #soda required in mg#\n",
      "S=S/10.0**6 \n",
      "\n",
      "#Result\n",
      "print\"Lime required is \",L,\"kg\"\n",
      "print\"\\nSoda required is \",S,\"kg\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Lime required is  70.3 kg\n",
        "\n",
        "Soda required is  37.1 kg\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    ],
   "metadata": {}
  }
 ]
}