{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 5 : Energy Balances"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.1   Page 186"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Increase in internal energy between the storage tank and the bottom of the well =  31.237  kW.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis pumping of 1 l/s of water\n",
    "Hadd = 52.                      # kW\n",
    "Hlost = 21.                     # kW\n",
    "\n",
    "# Calculation \n",
    "fi = Hadd - Hlost               # kW\n",
    "p1 = 101325.                    # Pa\n",
    "p2 = p1\n",
    "Z1 = -50                        # m\n",
    "Z2 = 10                         # m\n",
    "g = 9.80665                     # m/s sq\n",
    "gc = 1                          # kg.m/(N.s sq)\n",
    "row = 1                         #   kg/l\n",
    "W = 1.5*.55                     # kW\n",
    "# energy balance b/w A and B\n",
    "# dE = E2-E1 = W + Q + (Z1-Z2)*(g/gc)*qm\n",
    "dE = 31.237                     # kW\n",
    "\n",
    "# Result\n",
    "print \"Increase in internal energy between the storage tank and the bottom of the well = \",dE,\" kW.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.2  Page 197"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat added =  9243.82741713  kJ/kmol methane.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# using table 5.1\n",
    "# basis 1 kmol of methane\n",
    "T1 = 303.15             # K\n",
    "T2 = 523.15             # K\n",
    "\n",
    "# Calculation \n",
    "# using eq 5.17\n",
    "H = 19.2494*(T2-T1) + 52.1135*10**-3*(T2**2-T1**2)/2 + \\\n",
    "11.973*10**-6*(T2**3-T1**3)/3 - 11.3173*(T2**4-T1**4)*10**-9/4      # kJ\n",
    "\n",
    "# Result\n",
    "print \" Heat added = \",H,\" kJ/kmol methane.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 5.3   Page 198"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat added =  9430.3  kJ/kmol of methane.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 1 kmol methane at 25 bar\n",
    "Pc = 46.04              # bar\n",
    "Tc = 190.5              # K\n",
    "Pr = 25/Pc\n",
    "\n",
    "# Calculation \n",
    "# H-Ho = intgr(from303.15 to 523.15){CmpR dT}\n",
    "# solving it by simpson's rule\n",
    "HE = 255.2              # kJ/kmol\n",
    "H = 9175.1 + HE\n",
    "\n",
    "# Result\n",
    "print \" Heat added = \",H,\" kJ/kmol of methane.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 5.4   Page 206"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat required to be added to toulene =  26.1324337975  kW.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# using table 5.3\n",
    "# .25 kg/s toulene heated from 290.15K to 350.15K\n",
    "qm = .25/92             # kmol/s\n",
    "\n",
    "# Calculation \n",
    "# reference 7\n",
    "fi = 2.717*10**-3*(1.8083*(350.15-290.15) + 812.223*10**-3*(350.15**2-290.15**2)/2 \\\n",
    " - 1512.67*10**-6*(350.15**3-290.15**3)/3 + 1630.01*10**-9*(350.15**4-290.15**4)/4)\n",
    " \n",
    "# Result\n",
    "print \" Heat required to be added to toulene = \",fi,\" kW.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 5.5   Page 206"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat required to be added =  290.8 kJ.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 1kg of 20% NaOH sol\n",
    "# referring to fig 5.4\n",
    "C11 = 3.56                      # kJ/kg.K   at 280.15K\n",
    "C12 = 3.71                      # kJ/kg.K   at 360.15K\n",
    "\n",
    "# Calculation \n",
    "C1m = (C11+C12)/2\n",
    "H = 1*C1m*(360.15-280.15)       # kJ\n",
    "\n",
    "# Result\n",
    "print \" Heat required to be added = \",H,\"kJ.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.6   Page 207"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat to be supplied =  360.066666667  kW  Percent error =  8.27133892074 .\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 1kg Diphyl A-30\n",
    "Q = .7511*(553.15-313.15) + 1.465*10**-3*(553.15**2-313.15**2)/2    # kJ/kg\n",
    "fi = Q*4000                                 # kJ/h    for mass flowrate 4000 kg/h\n",
    "\n",
    "# Calculation \n",
    "Clm = (1.1807+1.5198)/2\n",
    "fi1 = Clm*(553.15-313.15)*4000/3600.        # kJ/h\n",
    "err = (fi1-Q)*100/Q\n",
    "\n",
    "# Result\n",
    "print \" Heat to be supplied = \",fi1,\" kW  Percent error = \",err,\".\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.7  Page 208"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat content of 1 kmol of gas mixture at 298K =  15016.6500785  kJ/kmol.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "T1 = 298.15                 # K\n",
    "T2 = 775.15                 #K\n",
    "\n",
    "# Calculation \n",
    "# using eq 5.17\n",
    "Q = 28.839*(T2-T1)+2.0395*10**-3*(T2**2-T1**2)/2 + \\\n",
    "6.9907*10**-6*(T2**3-T1**3)/3 - 3.2304*10**-9*(T2**4-T1**4)/4       # kJ/kmol\n",
    "\n",
    "# Result\n",
    "print \" Heat content of 1 kmol of gas mixture at 298K = \",Q,\" kJ/kmol.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.8   Page 210"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat removal rate of subcooling zone of the condenser =  1905578.44431  kJ/h.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 8000 kg/h mixture is to be cooled\n",
    "qn1m = .118*8000                    # kg/h\n",
    "qn1 = qn1m/93.1242                  # kmol/h\n",
    "qn2m = 8000-qn1m                    # kg/h\n",
    "qn2 = qn2m/18                       # kmol/h\n",
    "T1 = 373.15                         #K\n",
    "T2 = 313.15                         #K\n",
    "\n",
    "# Calculation \n",
    "fi = qn1*(206.27*(T1-T2)-211.5065*10**-3*(T1**2-T2**2)/2+564.2902*10**-6*(T1**3-T2**3)/3) \\\n",
    " + qn2*(50.845*(T1-T2)+213.08*10**-3*(T1**2-T2**2)/2-631.398*10**-6*(T1**3-T2**3)/3 \\\n",
    " +648.746*10**-9*(T1**4-T2**4)/4)   # kJ/h\n",
    " \n",
    "# Result \n",
    "print \" Heat removal rate of subcooling zone of the condenser = \",fi,\" kJ/h.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.9   Page 220"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " a   V.P. of n-hexane at 305.15K =  0.270921991993  bar.    \n",
      "b   V.P. of water at 395.15K =  1.96343968214  bar.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# (a)\n",
    "T = 305.15                                      #K\n",
    "\n",
    "# Calculation \n",
    "Pv1 = 10**(4.0026-(1171.530/(305.15-48.784)))   # bar\n",
    "# (b)\n",
    "T = 395.15 \n",
    "Pv2 = 10**(3.559-(643.748/(395.15-198.043)))     # bar\n",
    "\n",
    "# Result\n",
    "print \" a   V.P. of n-hexane at 305.15K = \",Pv1,\\\n",
    "\" bar.    \\nb   V.P. of water at 395.15K = \",Pv2,\" bar.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.10   Page 225"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " a   Latent heat of vaporization at Tb using Riedel eq is  36944.6599382  kJ/kmol.    \n",
      "b   Latent heat of vaporizaation at 298.15 K using Watson eq is  42928.2871556  kJ/kmol.\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# solution \n",
    "\n",
    "# Variables \n",
    "# (a)\n",
    "Pc = 3732.              # kPa\n",
    "Tc = 630.3              # K\n",
    "Tb = 417.6              # K\n",
    "TBr = Tb/Tc\n",
    "\n",
    "# Calculation \n",
    "lambdav = 8.314472*417.6*(1.092*(math.log(3732)-5.6182)/(.930-.6625))\n",
    "# (b)\n",
    "T1 = 298.15  #K\n",
    "lambdav1 = 36240*((630.3-298.15)/(630.3-417.6))**.38\n",
    "\n",
    "# Result\n",
    "print \" a   Latent heat of vaporization at Tb using Riedel eq is \",lambdav,\\\n",
    "\" kJ/kmol.    \\nb   Latent heat of vaporizaation at 298.15 K using Watson eq is \",\\\n",
    "lambdav1,\" kJ/kmol.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.11   Page 225"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " a   \n",
      "Latent heat of vaporization at Tb using  Riedel eq is  40200.030668  kJ/kmol  \n",
      "NIST eq is  38564.1849773  kJ/kmol    \n",
      "b   Latent heat of vaporization at 298.15 K using  Watson eq is  42946.0066334  kJ/kmol  \n",
      "NIST eq is  42479.9527916  kJ/kmol\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# solution \n",
    "\n",
    "# Variables \n",
    "# (a)\n",
    "Pc = 61.37                  # bar\n",
    "Tc = 514.                   #K\n",
    "Tb = 351.4\n",
    "P = 1                       # atm\n",
    "TBr = Tb/Tc\n",
    "\n",
    "# Calculation \n",
    "# Riedel eq\n",
    "lambdav1 = 8.314472*Tb*1.092*(math.log(6137)-5.6182)/(.930-TBr)\n",
    "\n",
    "# NIST eq\n",
    "lambdav2 = 50430*math.exp(-(-.4475*TBr))*(1-TBr)**.4989\n",
    "\n",
    "# (b)\n",
    "T1 = 298.15\n",
    "TBr1 = T1/Tc\n",
    "\n",
    "# Watson eq\n",
    "lambdav21 = 38563*((514-298.15)/(514-351.4))**.38\n",
    "\n",
    "# NIST eq\n",
    "lambdav22 = 50430*math.exp(-(-.4475*TBr1))*(1-TBr1)**.4969\n",
    "\n",
    "# Result\n",
    "print \" a   \\nLatent heat of vaporization at Tb using  Riedel eq is \",lambdav1,\\\n",
    "\" kJ/kmol  \\nNIST eq is \",lambdav2,\\\n",
    "\" kJ/kmol    \\nb   Latent heat of vaporization at 298.15 K using  Watson eq is \",lambdav21,\\\n",
    "\" kJ/kmol  \\nNIST eq is \",lambdav22,\" kJ/kmol\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.12  Page 227"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Saturation Pressure of steam at 565.15K is  76.6507315525  bar.\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "# solution \n",
    "# Variables \n",
    "# using Appendix IV.2\n",
    "Ps1 = 75.\n",
    "Ps2 = 80.\n",
    "T1 = 563.65\n",
    "T2 = 568.12\n",
    "T = 565.15 \n",
    "\n",
    "# Calculation \n",
    "Ps = 75*math.exp((T2*(T-T1)*math.log(80./75)/(T*(T2-T1))))\n",
    "\n",
    "# Result\n",
    "print \" Saturation Pressure of steam at 565.15K is \",Ps,\" bar.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.13   Page 236"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Bubble point =  321.6  K and  Dew point =  329.9  K.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis  1 kmol equimolar mix\n",
    "npent = .5                  # kmol\n",
    "nhex = .5                   # kmol\n",
    "P = 101.325                 # kPa\n",
    "x1 = .5\n",
    "x2 = x1\n",
    "Ts1 = 309.2                 # K\n",
    "Ts2 = 341.9                 # K\n",
    "\n",
    "# Calculation \n",
    "T1 = (Ts1+Ts2)/2.\n",
    "\n",
    "# using these data, we get table 5.10 and 5.11\n",
    "Tbb = 321.6                 # K\n",
    "Tdp = 329.9                 # K\n",
    "\n",
    "# Result\n",
    "print \" Bubble point = \",Tbb,\\\n",
    "\" K and  Dew point = \",Tdp,\" K.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.14   Page 237"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " The quantity of flash steam produced =  133.756324936  kg/h.\n"
     ]
    }
   ],
   "source": [
    "from numpy import poly1d,roots\n",
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 1000 kg/h of condensate at the saturation temperature corresponding to 8 bar a\n",
    "# using Appendix IV.2\n",
    "H = 720.94                  # kJ/kg\n",
    "Hm = 419.06                 # kJ/kg\n",
    "\n",
    "# Calculation \n",
    "x = poly1d(0,'x')\n",
    "condensate = 1000-x\n",
    "Hcondensate1 = 1000*H\n",
    "Hcondensate2 = condensate*419.06\n",
    "Ht = x*2676.\n",
    "p = Hcondensate2+Ht-Hcondensate1\n",
    "\n",
    "# Result\n",
    "print \" The quantity of flash steam produced = \",roots(p)[0],\" kg/h.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.15   Page 238"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Flow of vapor from he chiller =  6.50500625782  kg/s.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "from numpy import poly1d, roots\n",
    "\n",
    "# Variables \n",
    "qv1 = 50.                           # l/s\n",
    "qm = qv1*1.08                       # kg/s\n",
    "fi = qm*3.08*(263.15-258.15)        # kW\n",
    "lv = 384.19-168.7                   # kJ/kg\n",
    "\n",
    "# Calculation \n",
    "qm2 = fi/lv\n",
    "H = 256.35                          # kJ/kg\n",
    "x = poly1d(0,'x')\n",
    "p = H*(qm2+x) - 168.7*qm2-x*384.19\n",
    "a = qm2+roots(p)[0]\n",
    "\n",
    "# Result\n",
    "print \" Flow of vapor from he chiller = \",a,\" kg/s.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.16    Page 238"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " a   Recycle ratio =  0.149514564975  kg Cl2/kg fresh feed    \n",
      "b   Cooling water required at  interface =  0.0230689309258  kg/s  after cooler =  0.152400566068  kg/s    \n",
      "c   Refrigiration load of chiller =  35.1468085758  kW.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis liquifaction capacity = 0.116 kg/s\n",
    "p1 = 101.                   # kPa\n",
    "Ts1 = 239.15\n",
    "lv1 = 288.13                # kJ/kg\n",
    "p2 = 530.                   # kPa\n",
    "Ts2 = 290.75                # K\n",
    "lv2 = 252.93                # kJ/kg\n",
    "\n",
    "# Calculation \n",
    "# referring to table 5.3 and using eq 5.21\n",
    "H1 = -39.246*(Ts2-Ts1)+1401.223*10**-3*(Ts2**2-Ts1**2)/2-6047.226* \\\n",
    "10**-6*(Ts2**3-Ts1**3)/3+8591.4*10**-9*(Ts2**4-Ts1**4)/4        # kJ/kmol\n",
    "T3 = 313.15\n",
    "H2 = (28.5463*(T3-Ts1)+23.8795*10**-3*(T3**2-Ts1**2)/2-21.3631* \\\n",
    "10**-6*(T3**3-Ts1**3)/3+6.4726*10**-9*(T3**4-Ts1**4)/4)/70.903  # kJ/kg\n",
    "fi2 = .116*H2\n",
    "Cl2evp = fi2/lv1            # kg/s\n",
    "Cl2recy = Cl2evp/(1-.185)\n",
    "R = Cl2recy/.116            # kg/kg fresh feed\n",
    "\n",
    "# T4/T1 = (p2/p1)**[(gamma-1)/gamma]\n",
    "gm = 1.355\n",
    "p22 = 326.3\n",
    "p21 = 101.\n",
    "T4 = Ts1*(p2/p1)**((gm-1)/gm)\n",
    "T5 = 313.15\n",
    "fi3 = 1.88*10**-3*(343.1+91.6-26.2+2.5)         # kW\n",
    "Fwater1 = fi3/(8*4.1868)                        # kg/s\n",
    "\n",
    "# similarly\n",
    "T6 = 379.9\n",
    "fi4 = 1.88*10**-3*(28.5463*(T6-T5)+23.8795*10**-3*(T6**2-T5**2)/2-21.3631 \\\n",
    "*10**-6*(T6**3-T5**3)/3+6.4726*10**-9*(T6**4-T5**4)/4)  # kW\n",
    "Fwater2 = fi4/(8*4.1868)                        # kg/s\n",
    "Wreq = Fwater1+Fwater2\n",
    "fi5 = 1.88*10**-3*(28.5463*(T5-Ts2)+23.8795*10**-3* \\\n",
    "(T5**2-Ts2**2)/2-21.3631*10**-6*(T5**3-Ts2**3)/3+6.4726 \\\n",
    "*10**-9*(T5**4-Ts2**4)/4) +.1333*252.93         # kW\n",
    "\n",
    "# Result\n",
    "print \" a   Recycle ratio = \",R,\" kg Cl2/kg fresh feed    \\nb   Cooling water required at  interface = \"\\\n",
    ",Fwater1,\" kg/s  after cooler = \",Wreq,\" kg/s    \\nc   Refrigiration load of chiller = \",fi5,\" kW.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.17   Page 242"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Quantity of eutectic mixture condensed =  39.7117062542  kg per 100 kg of tin melted at its melting point.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 100 kg of tin\n",
    "T1 = 303.15\n",
    "T2 = 505.15\n",
    "n = 100/118.7                   # kmol\n",
    "\n",
    "# Calculation \n",
    "# Q1 = n*[intgr from T1 to T2 (Cms dT)]\n",
    "Q1 = 4973.3                     # kJ\n",
    "lf = 7201.\n",
    "Q2 = n*lf                       # kJ\n",
    "Q = Q1+Q2\n",
    "lv = 278.                       # kJ/kg\n",
    "vp = Q/lv                       # kg\n",
    "\n",
    "# Result\n",
    "print \" Quantity of eutectic mixture condensed = \",vp,\\\n",
    "\" kg per 100 kg of tin melted at its melting point.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.18    Page 243"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " total time required =  42.2249688079  hrs.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "Ts1 = (438.2+436)/2.\n",
    "Ta = 300.\n",
    "\n",
    "# Calculation \n",
    "fi1 = .045*(Ts1-Ta)*3600.\n",
    "theta1 = 307293/fi1                 #h\n",
    "Ts2 = (436+434)/2.\n",
    "fi2 = .045*(Ts2-Ta)*3600.\n",
    "theta2 = 302415./fi2\n",
    "Ts3 = (434+432.1)/2\n",
    "fi3 = .045*(Ts3-Ta)*3600.\n",
    "theta3 = 313859/fi3\n",
    "theta = theta1+theta2+theta3\n",
    "\n",
    "# Result\n",
    "print \" total time required = \",theta,\" hrs.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.19   Page 245"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a   Yield of dry ice =  89.8658011815  kg.    \n",
      "b   Percent liquifaction =  71.2505768343 .    \n",
      "c   Temp of vented gas =  262.15  K.\n"
     ]
    }
   ],
   "source": [
    "from numpy import poly1d, roots\n",
    "\n",
    "# solution \n",
    "\n",
    "# Variables \n",
    "H1 = 482.9                      # kJ/kg\n",
    "H2 = 273.4\n",
    "fi1 = 100*(H1-H2)               # kJ/h\n",
    "T1 = 313.15\n",
    "T2 = 403.15\n",
    "\n",
    "# Calculation \n",
    "fi11 = 21.3655*(T2-T1)+64.2841*10**-3*(T2**2-T1**2)/2-41.0506*10**-6 \\\n",
    "*(T2**3-T1**3)/3+9.7999*10**-9*(T2**4-T1**4)/4          # kJ/h\n",
    "\n",
    "# at 20 MPa\n",
    "h1 = 211.1\n",
    "Ts = 277.6\n",
    "H11 = 427.8\n",
    "x = poly1d(0,'x')\n",
    "p = x*h1+(100-x)*H11-100*H2\n",
    "a = roots(p)[0]\n",
    "fi2 = (100-a)*(H11-h1)          # kJ/h\n",
    "h2 = -148.39\n",
    "H3 = 422.61\n",
    "y = poly1d(0,'y')\n",
    "p1 = 100*176.18-(100-y)*H3+h2*y\n",
    "b = roots(p1)[0]\n",
    "fi3 = 100*(h1-176.8)\n",
    "H = fi3+24021 \n",
    "H4 = H/(100-43.16)\n",
    "# from ref 23\n",
    "T = 262.15\n",
    "\n",
    "# Result\n",
    "print \"a   Yield of dry ice = \",b,\\\n",
    "\" kg.    \\nb   Percent liquifaction = \",a,\\\n",
    "\".    \\nc   Temp of vented gas = \",T,\" K.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.20   Page 247"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Amount of steam produced =  353.569213147  kg/h.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 200 kg/h of Sulphur firing\n",
    "F = 200./32                     # kmol/h\n",
    "O2req = 6.25*1.1\n",
    "airin = O2req/.21\n",
    "\n",
    "# Calculation \n",
    "N2in = airin-O2req\n",
    "T1 = 1144.15\n",
    "T2 = 463.15\n",
    "fi = 788852.2                   # kJ/h\n",
    "H = 15*4.1868+1945.2\n",
    "qm = fi*.9/2008                 # kg/h\n",
    "\n",
    "# Result\n",
    "print \" Amount of steam produced = \",qm,\" kg/h.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.21   Page 248"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " a   H =  4370.454066  kJ/kmol    b   H =  33019.341801  kJ/kmol\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# enthalpy at Tbb\n",
    "Tbb = 321.6\n",
    "T1 = 298.15\n",
    "\n",
    "# Calculation \n",
    "H1 = 65.4961*(Tbb-T1)+628.628*10**-3*(Tbb**2-T1**2)/2-1898.8*10**-6*(Tbb**3-T1**3)/3 \\\n",
    "+3186.51*10**-9*(Tbb**4-T1**4)/4                                # kJ/kmol\n",
    "H2 = 31.421*(Tbb-T1)+976.058*10**-3*(Tbb**2-T1**2)/2-2353.68* \\\n",
    "10**-6*(Tbb**3-T1**3)/3+3092.73*10**-9*(Tbb**4-T1**4)/4         # kJ/kmol\n",
    "Hsol = (H1+H2)/2                                                # kJ/kmol\n",
    "\n",
    "# enthalpy at Tdp\n",
    "lv1 = 25790*((469.7-329.9)/(469.7-309.2))**.38\n",
    "lv2 = 28850*((507.6-329.9)/(507.6-341.9))**.38\n",
    "Tdp = 329.9\n",
    "H21ig = 65.4961*(Tdp-T1)+628.628*10**-3*(Tdp**2-T1**2)/2-1898.8*10**-6* \\\n",
    "(Tdp**3-T1**3)/3+3186.51*10**-9*(Tdp**4-T1**4)/4 + lv1          # kJ/kmol\n",
    "H22ig = 31.421*(Tdp-T1)+976.058*10**-3*(Tdp**2-T1**2)/2-2353.68* \\\n",
    "10**-6*(Tdp**3-T1**3)/3+3092.73*10**-9*(Tdp**4-T1**4)/4 +lv2    # kJ/kmol\n",
    "Hmixig = (H21ig+H22ig)/2\n",
    "\n",
    "# Result\n",
    "print \" a   H = \",Hsol,\" kJ/kmol    b   H = \",Hmixig,\" kJ/kmol\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.22   Page 252"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enthalpy of vapor-liquid mixture after flashing =  23529.2  kJ/mol.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "H1 = 23549.                 #kJ/kmol\n",
    "H2 = 16325.\n",
    "H3 = 28332.\n",
    "\n",
    "# Calculation \n",
    "H4 = .4*H2+.6*H3\n",
    "\n",
    "# Result\n",
    "print \"Enthalpy of vapor-liquid mixture after flashing = \",H4,\" kJ/mol.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.23   Page 253"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Purity of product H2 stream =  91.5733341399  percent.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables\n",
    "# basis feed gas = 12000 Nm**3 = 535.4 kmol/h\n",
    "T1 = 147.65                         # K\n",
    "n1 = 535.4*.3156                    # kmol/h  HP tail gas stream\n",
    "T = 118.5                           # K\n",
    "\n",
    "# Calculation \n",
    "n2 = (535.4-n1)*.0602               # kmol/h    LP tail stream\n",
    "n3 = 535.4-n2-n1                    # kmol/h  product H2 stream\n",
    "p = 315.35*100/n3\n",
    "\n",
    "# Result\n",
    "print \" Purity of product H2 stream = \",p,\" percent.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.24    Page 256"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " a   Refrigiration requirement =  170787.7  kJ/h    b   Refrigiration requirement based on real enthalpies =  61756.688  kJ/h.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# fi1 = integr (from 304.15 to 313.15) {11831.6+24997.4*10T**-3-5979.8*10**-6T**2-31.7*10**-9T3}dt\n",
    "fi1 = 170787.7 # kJ/h\n",
    "\n",
    "# Calculation \n",
    "fi2 = 535.4*12086 - (344.36*8743.2+168.97*18036+22.07*15892)          # kJ/h\n",
    "\n",
    "# Result\n",
    "print \" a   Refrigiration requirement = \",fi1,\\\n",
    "\" kJ/h    b   Refrigiration requirement based on real enthalpies = \",fi2,\" kJ/h.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.25   Page 257"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Liquid product stream =  89.669  kmol/h  Vapor product stream =  50.331  kmol/h\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 100 kmol/h of benzene feed rate\n",
    "Cl2 = .4*100\n",
    "HClp = 40.\n",
    "Benzenecon = 37.\n",
    "MCBp = 100*.37*.9189\n",
    "\n",
    "# Calculation \n",
    "DCBp = Benzenecon-MCBp\n",
    "unreactBenzene = 100-Benzenecon\n",
    "Nt = HClp + MCBp + DCBp + unreactBenzene\n",
    "# using eq      xi = Ni/(L(1-K1)+NtKi)  and sigma xi = 1\n",
    "L = 89.669                  # kmol/h\n",
    "V = Nt - L\n",
    "\n",
    "# Result\n",
    "print \" Liquid product stream = \",L,\" kmol/h  Vapor product stream = \",V,\" kmol/h\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.26   Page 260"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat of formation of Ethylene is  52.44  kJ/mol.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# 2C + 2O2 = 2CO2                  A\n",
    "# 2H2 + O2 = 2H2O                  B\n",
    "# C2H4 + 3O2 = 2CO2 + 2H2O         C\n",
    "# A+B-C  gives\n",
    "# 2C(g) + 2H2 = C2H4(g)            D\n",
    "\n",
    "# Calculation \n",
    "H = -2*393.51-2*241.82+1323.1           # kJ/mol\n",
    "\n",
    "# Result\n",
    "print \" Heat of formation of Ethylene is \",H,\" kJ/mol.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.27   Page 260"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat of combustion of ethyl mercaptan =  -2172.891  kJ/mol.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Calculation \n",
    "\n",
    "Hc = 2*(-393.51)-887.811+2*(-285.83)-(-73.6+0)              #kJ/mol\n",
    "\n",
    "# Result\n",
    "print \" Heat of combustion of ethyl mercaptan = \",Hc,\" kJ/mol.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.28   Page 261"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Heat of formation of liquid di ethyl ether =  -279.292123302  kJ/mol.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "# Variables \n",
    "lv1 = 26694.                # kj/kmol\n",
    "Tc = 466.74\n",
    "\n",
    "# Calculation \n",
    "lv2 = lv1*((Tc-298.15)/(Tc-307.7))**.38/1000                # kJ/mol\n",
    "Hf = -252.                  # kJ/mol\n",
    "Hf1 = Hf-lv2                # kJ/kmol\n",
    "\n",
    "# Result\n",
    "print \"Heat of formation of liquid di ethyl ether = \",Hf1,\" kJ/mol.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.29   Page 261"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat of formation of motor spirit =  -2085.0  kJ/kg.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 1 kg motor spirit\n",
    "G = 141.5/(131.5+64)\n",
    "\n",
    "# Calculation \n",
    "# r = C/H\n",
    "r = (74.+15*G)/(26-15*G)\n",
    "C = r/6.605                     # C content of motor spirit\n",
    "H2 = 1-C\n",
    "O2req = C+H2\n",
    "Hf = 44050-27829-18306.         # kJ/kg\n",
    "\n",
    "# Result\n",
    "print \" Heat of formation of motor spirit = \",Hf,\" kJ/kg.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.30   Page 267"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Mean heat capacity between 600K and 298.15 K is  173.433824747  kJ/kmol K.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "# Variables \n",
    "# basis 1 kmol of styrene\n",
    "dH = 241749-189398.                     # kJ/mol\n",
    "\n",
    "# Calculation \n",
    "Cmpn = dH/(600-298.15)                  # kJ/kmol K\n",
    "\n",
    "# Result\n",
    "print \" Mean heat capacity between 600K and 298.15 K is \",Cmpn,\" kJ/kmol K.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.31   Page 269"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat of reaction =  1432.17  kJ/mol SiO2.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Calculation \n",
    "# basis 1 mol of SiO2 reacted\n",
    "Hf = (-2879+3*(-296.81)+3*0/2)-(3*(-1432.7)+1*(-903.5))  # kJ/mol SiO2\n",
    "\n",
    "# Result\n",
    "print \" Heat of reaction = \",Hf,\" kJ/mol SiO2.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.32   Page 269"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " heat of reaction =  3456.15219753  kJ/100 kg solution.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 100 kg of 2% ammonia solution\n",
    "NH3 = 2.                # kg\n",
    "H2O = 98.               # kg\n",
    "\n",
    "# Calculation \n",
    "Hr = -361.2-(-45.94-285.83)             # kJ/mol NH3 dissolved\n",
    "Hd = -(Hr*2*1000/17.0305)               # kJ/100 kg sol.\n",
    "\n",
    "# Result\n",
    "print \" heat of reaction = \",Hd,\" kJ/100 kg solution.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.33   Page 272"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat of reaction at 775K is  93855.2952943  kJ/kmol.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 1 kmol of SO2 reacted\n",
    "a = 22.036-24.771-.5*(26.026)\n",
    "b = (121.624-62.948-.5*11.755)\n",
    "c = (-91.876+44.258-.5*(-2.343))\n",
    "d = (24.369-11.122-.5*(-.562))\n",
    "Hr = -395720+296810.                # kJ/kmol\n",
    "\n",
    "# Calculation \n",
    "Hro = Hr-a*298.15-b*10**-3*298.15**2/2-c*10**-6*298.15**3/3-d*10**-9*298.15**4/4.\n",
    "T = 778.15\n",
    "Hrt = -Hro-15.748*T+26.4*10**-3*T**2-15.48*10**-6*T**3+3.382*10**-9*T**4\n",
    "\n",
    "# Result\n",
    "print \" Heat of reaction at 775K is \",Hrt,\" kJ/kmol.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.34   Page 272"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat of reaction at 373 K is  -6441.65717017  kJ/kmol reactant.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Calculation\n",
    "Hr = -480-285.83+277.2+484.2                            # kJ/mol\n",
    "Hrt1 = Hr*1000 + (146.89+75.76-119.55-129.70)*75        # kJ/kmol \n",
    "a = 4.2905+50.845-100.92-155.48\n",
    "b = 934.378+213.08+111.8386+326.5951\n",
    "c = -2640-631.398-498.54-744.199\n",
    "d = 3342.58+648.746\n",
    "Hro = Hr*1000+a*(-298.15)+b*10**-3*(-298.15**2)/2+ \\\n",
    "c*10**-6*(-298.15**3)/3+d*10**-9*(-298.15**4)/4\n",
    "T = 373.15\n",
    "Hrt = Hro+a*T+792.949*10**-3*T**2-1504.712*10**-6*T**3+997.832*10**-9*T**4\n",
    "\n",
    "# Result\n",
    "print \" Heat of reaction at 373 K is \",Hrt,\" kJ/kmol reactant.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.35   Page 273"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Net enthalpy change =  -178.010235047  kW.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "T2 = 800.\n",
    "T1 = 298.15\n",
    "\n",
    "# Calculation \n",
    "fi1 = 3614.577*(T2-T1)+305.561*10**-3*(T2**2-T2**2)/2+836.881*10**-6*(T2**3-T1**3)/3-393.707*10**-9*(T2**4-T1**4)/4  # kW\n",
    "T3 = 875.\n",
    "fi2 = 3480.737*(T3-T1)+754.347*10**-3*(T3**2-T2**2)/2+442.159*10**-6*(T3**3-T1**3)/3-278.735*10**-9*(T3**4-T1**4)/4  # kW\n",
    "Hr = -98910.                            # kJ/kmol SO2 reacted     by eg 5.33\n",
    "fi3 = (8.8511-.351)*Hr/3600.            # kW\n",
    "dH = fi2/3600+fi3-fi1/3600.\n",
    "\n",
    "# Result\n",
    "print \" Net enthalpy change = \",dH,\" kW.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.36   Page 275"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat of reaction =  -605.80005705  kJ/kmol total reactants.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 100 kmol outgoing gas mixture from scrubber\n",
    "moistin = 3127.7*.015/18                        # kmol\n",
    "waterin = 40.2+moistin                          # kmol\n",
    "\n",
    "\n",
    "# Calculation \n",
    "# using tables 5.29 and 5.30\n",
    "Hr = -27002658-(-26853359.)\n",
    "Hr1 = Hr/246.4493                               # kJ/kmol total reactants\n",
    "\n",
    "# Result\n",
    "print \" Heat of reaction = \",Hr1,\" kJ/kmol total reactants.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.37   Page 276"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Downtherm circulation rate =  57837.7819041  kg/h.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "fi3 = 15505407.                     # kJ/h\n",
    "lv = 296.2                          # from table 5.6\n",
    "Ht = 17131551.                      # kJ/h\n",
    "\n",
    "# Calculation \n",
    "r = Ht/lv                           # kg/h\n",
    "\n",
    "# Result\n",
    "print \" Downtherm circulation rate = \",r,\" kg/h.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.38   Page 279"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Compositions of gas streams :   \n",
      "Component        Stream 3    Stream 5    Stream 4      Stream 6 \n",
      " Cl2            10.802       10.802\n",
      "  HCl           0.198       0.198\n",
      " C2H4           1       1\n",
      " EDC            3.6264582115        0.2355      3.3947         98.5665\n",
      " TEC            0.00246937055797         Nil        0.00246937055797        0.198\n",
      " Heavy duty of Overhead condenser =  157524.3947  kJ/h.   \n",
      " Heavy duty of external cooler =  21095870.3588  kJ/h.\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# solution \n",
    "\n",
    "# Variables \n",
    "F = 100.                        # kmol/h    feed rate of ethylene\n",
    "Econ = .99*F\n",
    "\n",
    "\n",
    "# Calculation and Result\n",
    "Econ1 = Econ*.998\n",
    "Econ2 = Econ-Econ1\n",
    "Cl2con = Econ1+2*Econ2\n",
    "Cl2in = F*1.1\n",
    "Cl2s3 = Cl2in-Cl2con\n",
    "HCls3 = Econ2\n",
    "TCEp = Econ2\n",
    "EDCp = Econ1\n",
    "nC2H4 = 1\n",
    "T = 328.15\n",
    "pv1 = math.exp(4.58518-1521.789/(T-24.67))               # bar\n",
    "pv2 = math.exp(4.06974-1310.297/(T-64.41))               # bar\n",
    "xEDC = Econ1/(Econ1+Econ2)\n",
    "xTEC = 1-xEDC\n",
    "pEDC = 37.2*xEDC\n",
    "pTEC = 12.64*xTEC\n",
    "pCl2HClC2H4 = 1.6*100-pEDC-pTEC\n",
    "yEDC = pEDC/160\n",
    "yTEC = pTEC/160\n",
    "nt = (Cl2s3+Econ2+1)*160/pCl2HClC2H4\n",
    "nEDC = yEDC*nt\n",
    "nTEC = yTEC*nt\n",
    "print \" Compositions of gas streams :   \"\n",
    "print \"Component        Stream 3    Stream 5    Stream 4      Stream 6 \"\n",
    "print \" Cl2           \",Cl2s3,\"     \",Cl2s3\n",
    "print \"  HCl          \",HCls3,\"     \",HCls3\n",
    "print \" C2H4          \",nC2H4,\"     \",nC2H4\n",
    "print \" EDC           \",nEDC,\"       0.2355      3.3947         98.5665\"\n",
    "print \" TEC           \",nTEC,\"        Nil       \",nTEC,\"      \",TCEp\n",
    "fi1 = (10.802*33.9+.198*29.1+1*43.6+3.6302*17.4+.0025*85.3)*(328.15-273.15)\n",
    "fi2 = 35.053*1000*3.3947+39.58*1000*.0025\n",
    "fi3 = (3.3947*129.4+.0025*144.4)*55/2\n",
    "fi = fi1+ fi2+ fi3                                      # kJ/h\n",
    "print \" Heavy duty of Overhead condenser = \",fi,\" kJ/h.   \"\n",
    "fi5 = (100*43.6+110*33.9)*(328.15-273.15)\n",
    "fi6 = 3.6302*1000*33.6+.0025*1000*38.166\n",
    "fi7 = (98.5665*129.4+.1988*144.4)*(328.15-273.15)\n",
    "fi8 = 216845.5*98.802+392394.5*.198\n",
    "ficol = fi5+fi8-fi1-fi6-fi7\n",
    "print \" Heavy duty of external cooler = \",ficol,\" kJ/h.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.39   Page 284"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Temperature of the gas mixture leaving the reactor =  657.41  K.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "To = 298.15\n",
    "T1 = 483.15\n",
    "\n",
    "# Calculation \n",
    "# fi1 = intgr(from To to T1){12199.5+2241.4*10**-3*T+1557.7*10**-6*T**2-671.3*10**-9*T**3}dT\n",
    "fi1 = 2455874.6                 # kJ/h\n",
    "dHr = 2*(-45.94)                # kJ/mol N2 reacted\n",
    "fi2 = 91.88*1000*23.168\n",
    "fi3 = fi1+fi2\n",
    "# fi3 = intgr(from To to T2){10713.9+3841*10**-3*T+1278.8*10**-6*T**2-752.6*10**-9*T**3}dT \n",
    "# solving it\n",
    "T2 = 657.41                     # K\n",
    "\n",
    "# Result\n",
    "print \"Temperature of the gas mixture leaving the reactor = \",T2,\" K.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.40  Page 292"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " a)   Composition of dry product gas stream : \n",
      " Component       Dry product gas stream,kmol\n",
      " HCl                  0.8\n",
      "  O2                  0.55\n",
      " Cl2                  1.6\n",
      " H2O                  1.6\n",
      "  N2                  5.07857142857\n",
      "b)   \n",
      " Adiabatic reaction temperature of product gas stream =  599.5  K.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 4 kmol of HCl gas\n",
    "O2req = 1.                  # kmol\n",
    "O2spply = 1.35*1\n",
    "\n",
    "# Calculation \n",
    "N2 = 1.35*79/21.\n",
    "air = O2spply+N2\n",
    "HClbrnt = .8*4\n",
    "HCl = 4-HClbrnt\n",
    "O2 = O2spply-.8\n",
    "Cl2 = .8*2\n",
    "H2O = .8*2\n",
    "\n",
    "# Result\n",
    "print \" a)   Composition of dry product gas stream : \"\n",
    "print \" Component       Dry product gas stream,kmol\"\n",
    "print \" HCl                 \",HCl\n",
    "print \"  O2                 \",O2\n",
    "print \" Cl2                 \",Cl2\n",
    "print \" H2O                 \",H2O\n",
    "print \"  N2                 \",N2\n",
    "print \"b)   \"\n",
    "H2 = 114.4*1000*.8\n",
    "# H2 = intgr(from 298.15 to T){286.554+12.596*10**-3*T+63.246*10**-6*T**2-25.933*10**-9*T**3}dT\n",
    "# solving it\n",
    "T = 599.5                   # K\n",
    "print \" Adiabatic reaction temperature of product gas stream = \",T,\" K.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.41   Page 294"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Adiabatic reaction T at the outlet of the reactor is  798.79  K.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# 1 kmol of EB vapors entering the reactor at 811.15 K\n",
    "# (from 811.15 to T1)intgr{-36.72+671.12*10**-3*T-422.02*10**-6*T**2+101.15*10**-9*T**3}dT = (from T1 to 978.15)intgr{487.38+1.19*10**-3*T+198.16*10**-6*T**2-68.21*10**-9*T**3}dT\n",
    "# we get\n",
    "T1 = 929.72                     # K\n",
    "To = 298.15\n",
    "H1 = 493405.                    # kJ\n",
    "EBr = .35\n",
    "\n",
    "# Calculation \n",
    "Styrenep = EBr*.9\n",
    "Benzeneb = EBr*.03\n",
    "Ethyleneb = Benzeneb\n",
    "Cb = EBr*.01\n",
    "Toulened = EBr*.06\n",
    "Hr1 = 147.36-29.92              # kJ/mol EB\n",
    "Hr2 = 82.93+52.5-29.92\n",
    "Hr3 = -29.92\n",
    "Hr4 = 50.17-74.52-147.36        # kJ/mol styrene\n",
    "dHr = 1000*(Hr1*(Styrenep+Toulened)+Hr2*Benzeneb+Hr3*Cb+Hr4*Toulened)\n",
    "H2 = H1-dHr\n",
    "\n",
    "# H2 = (from To t0 T2)intgr{Comp2dT\n",
    "# we get\n",
    "\n",
    "T2 = 798.79                     # K\n",
    "\n",
    "# Result\n",
    "print \" Adiabatic reaction T at the outlet of the reactor is \",T2,\" K.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.42   Page 297"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat of crystallization of 1 kg crystal is  219.681597979  kJ.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "Hsol = 62.86                    # kJ/mol solute\n",
    "Mcrystal = 286.1414\n",
    "\n",
    "# Calculation \n",
    "Hcry = Hsol*1000/Mcrystal       # kJ/kg solute\n",
    "\n",
    "# Result\n",
    "print \" Heat of crystallization of 1 kg crystal is \",Hcry,\" kJ.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.43    Page 297"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat of crystallization =  -81.98  kJ/mol.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "Hf = -285.82                        # kJ/mol    of H2O\n",
    "\n",
    "# Calculation \n",
    "Hcryst = -4327.26-(-1387.08+10*Hf)\n",
    "\n",
    "# Result\n",
    "print \" Heat of crystallization = \",Hcryst,\" kJ/mol.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.44   Page 297"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat of solution of Boric acid =  22.01  kJ/mol.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "Hfs = -1094.33\n",
    "Hfao = -1072.32\n",
    "\n",
    "# Calculation \n",
    "Hsol = Hfao-Hfs\n",
    "\n",
    "# Result\n",
    "print \" Heat of solution of Boric acid = \",Hsol,\" kJ/mol.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.45   Page 297"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " a   Hdissolulition =  -71.104  kJ/mol ZnSO4.    b   Hsolution =  23.036  kJ/kmol.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# (a)\n",
    "Hf = -982.8\n",
    "Hfcryst = -1053.904\n",
    "\n",
    "# Calculation \n",
    "Hdis = Hfcryst-Hf\n",
    "# (b)\n",
    "Hfcr = -3077.75\n",
    "Hsol = Hfcryst+7*(-285.83)-(-3077.75)\n",
    "\n",
    "# Result\n",
    "print \" a   Hdissolulition = \",Hdis,\" kJ/mol ZnSO4.    b   Hsolution = \",Hsol,\" kJ/kmol.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.46   Page 300"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " T =  329.5  K.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# using chart 5.16 we get\n",
    "T = 329.5                       # K\n",
    "\n",
    "# Result\n",
    "print \" T = \",T,\" K.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.47   Page 300"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Final sol T =  336.930679731  K.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 100(m1) kg 46% sol\n",
    "NaOH = 46.                  # kg\n",
    "H2O = 54.                   # kg\n",
    "\n",
    "# Calculation \n",
    "m2 = NaOH/.25\n",
    "NaOHo = 25.                 # kg\n",
    "H2Oo = 75.                  # kg\n",
    "Hf1 = -453.138              # kJ/mol\n",
    "Hf2 = -467.678              # kJ/mol\n",
    "Hs = Hf2-Hf1\n",
    "Hg = -Hs*1000*1.501\n",
    "\n",
    "# using Appendix IV.1\n",
    "Hw1 = 146.65\n",
    "Hw2 = 104.9\n",
    "Hadd = 84*(Hw1-Hw2)\n",
    "H = Hg+Hadd\n",
    "C1 = 3.55\n",
    "T2 = 298.15+H/(184*C1)      # K\n",
    "\n",
    "# Result\n",
    "print \" Final sol T = \",T2,\" K.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.48    Page 301"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Heat effect of the sol =  10388.7187316  kJ.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 100 kg of sol with 32% N\n",
    "MNH4NO3 = 80.0434\n",
    "MNH2CONO2 = 60.0553\n",
    "MN2 = 28.0134\n",
    "\n",
    "# Calculation \n",
    "na = 32/(60.9516)\n",
    "Ureadis = 1.1758*na*MNH2CONO2                   # kg\n",
    "water = 100-(na*MNH4NO3+Ureadis)\n",
    "ndis = 525.\n",
    "m = ndis/water\n",
    "HE1 = 40.3044-2.5962*m+.1582*m**2-3.4782*10**-3*m**3\n",
    "HE = HE1*ndis\n",
    "\n",
    "# Result\n",
    "print \"Heat effect of the sol = \",HE,\" kJ.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 5.49   Page 302"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Integral heat of sol of n-amyl alcohol =  19.3203381059  kJ/kg n-amyl alcohol and of benzene =  24.2857917277  kJ/kg benzene.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "Hmix = 896.\n",
    "M1 = 88.                          # molar mass of n-amyl alcohol\n",
    "M2 = 78.                          # molar mass of benzene\n",
    "\n",
    "# Calculation \n",
    "B = .473*M2\n",
    "A = .527*M1\n",
    "Ha = Hmix/A\n",
    "Hb = Hmix/B\n",
    "\n",
    "# Result\n",
    "print \" Integral heat of sol of n-amyl alcohol = \",Ha,\\\n",
    "\" kJ/kg n-amyl alcohol and of benzene = \",Hb,\" kJ/kg benzene.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 5.50   Page 302"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a   Resultant T of 77 percent sol =  379.5  K.    \n",
      "b   Heat to be removed to cool it to 298.15 K =  -167.5  kJ/kg sol    \n",
      "c   By mean heat capacity method :  166.7675  kJ/kg sol    \n",
      "d   Quantity of 15 percent acid to be mixed =  25.8064516129  kg.    \n",
      "e   from fig :  25.3  kg.\n"
     ]
    }
   ],
   "source": [
    "from numpy import poly1d, roots\n",
    "# solution \n",
    "\n",
    "# Variables \n",
    "# from fig 5.18\n",
    "Ta = 379.5                              # K\n",
    "dH = -274-(-106.5)                      # kJ/kg sol\n",
    "Cm = 2.05                               # kJ/kg K\n",
    "dHc = Cm*(Ta-298.15)\n",
    "\n",
    "# Calculation \n",
    "# basis 100 kg of 93 % acid\n",
    "# acid balance \n",
    "x = poly1d(0,'x')\n",
    "p = .93*100+x*.15-(100+x)*.77\n",
    "y = roots(p)[0]\n",
    "\n",
    "#from fig\n",
    "y1 = 25.3\n",
    "\n",
    "# Result\n",
    "print \"a   Resultant T of 77 percent sol = \",Ta, \\\n",
    "\" K.    \\nb   Heat to be removed to cool it to 298.15 K = \",dH,\\\n",
    "\" kJ/kg sol    \\nc   By mean heat capacity method : \",dHc,\\\n",
    "\" kJ/kg sol    \\nd   Quantity of 15 percent acid to be mixed = \",y,\\\n",
    "\" kg.    \\ne   from fig : \",y1,\" kg.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 5.51   Page 304"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Temp of sol =  363.832345186  K.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 100 kg of 93% acid and 25.8 kg of 15% acid\n",
    "Hfp = -814.\n",
    "Hf1 = -830.\n",
    "HE1 = Hf1-Hfp\n",
    "Hf2 = -886.2\n",
    "HE2 = Hf2-Hfp\n",
    "Hf3 = -851.\n",
    "HE3 = Hf3-Hfp\n",
    "\n",
    "# Calculation \n",
    "Hsol = .9876*1000*(-37)-(.9482*1000*(-16)+.0394*1000*(-72.2))\n",
    "Hev = 100*(30-25)*1.6\n",
    "Hcon = 25.8*25*3.7\n",
    "netHev = -Hsol-Hcon+Hev\n",
    "T = 298.15+netHev/(125.8*2.05)\n",
    "\n",
    "# Result\n",
    "print \" Temp of sol = \",T,\" K.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.52   Page 306"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat of mixing =  -74878.72  kJ.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 1000 kg of mixed acid\n",
    "C11 = 2.45\n",
    "\n",
    "# Calculation \n",
    "H1 = -296.7+C11*(308.15-273.15)\n",
    "C12 = 2.2\n",
    "H2 = -87.8+C12*(308.15-273.15)\n",
    "C13 = 1.45\n",
    "H3 = -35.5+C13*(308.15-273.15)\n",
    "C14 = 1.8\n",
    "H4 = -148.9+C14*(308.15-273.15)\n",
    "Hmix = 1000*H4-(76.3*H1+345.9*H2+577.7*H3)\n",
    "\n",
    "# Result\n",
    "print \" Heat of mixing = \",Hmix,\" kJ.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.53   Page 308"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Total heat exchanged =  -796777.546799  kJ/h.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "F = 1135.\n",
    "Benzenef = 400*.993\n",
    "\n",
    "# Calculation \n",
    "HNO3con = Benzenef*63/78.\n",
    "H1 = -186.5\n",
    "C11 = 1.88\n",
    "H11 = H1+C11*(298.15-273.15)\n",
    "H2 = -288.9\n",
    "C12 = 1.96\n",
    "H22 = H2+C12*(298.15-273.15)\n",
    "H3 = 0\n",
    "C13 = 1.98\n",
    "H33 = C13*(298.15-273.15)\n",
    "Hr = -285.83+12.5-(-174.1+49.08)\n",
    "Benzener = Benzenef/78.1118\n",
    "fi = 903.84*H22+HNO3con*H33-F*H11+Benzener*Hr*1000              # kJ/h\n",
    "\n",
    "# Result\n",
    "print \" Total heat exchanged = \",fi,\" kJ/h.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.54   Page 311"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Temp of resultant sol =  373.525565624  K.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# from ref 24\n",
    "H = 1600.83\n",
    "To = 273.15\n",
    "h = 200.\n",
    "Hf1 = -79.3                 # table 5.59\n",
    "Hf2 = -46.11\n",
    "Hsol = Hf1-Hf2\n",
    "\n",
    "# Calculation \n",
    "Hg = Hsol*1000*140./17.0305\n",
    "Raq = 140/.15               # kg/h\n",
    "dT = Hg/(4.145*Raq)\n",
    "T = -dT+303.\n",
    "\n",
    "# Result\n",
    "print \" Temp of resultant sol = \",T,\" K.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.55   Page 311"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat generated for making 2 percent solution =  -3996.35947271  kJ/100 kg sol.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "Hf1 = -80.14\n",
    "Hf2 = -46.11\n",
    "\n",
    "# Calculation \n",
    "Hsol = Hf1-Hf2\n",
    "Hg = Hsol*1000.*2/17.0305\n",
    "\n",
    "# Result\n",
    "print \" Heat generated for making 2 percent solution = \",Hg,\" kJ/100 kg sol.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.56   Page 312"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat removal in the cooler =  9372691.2781  kJ/h.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "fi3 = 15505407.\n",
    "fi4 = 11395056.\n",
    "fi5 = fi3-fi4  # kJ/h\n",
    "\n",
    "# Calculation \n",
    "fi6 = 111.375*62.75*1000\n",
    "fi7 = 1063379.\n",
    "fi8 = 5532.15*4.1868*(303.15-298.15)\n",
    "fi9 = 9030.4*3.45*(323.15-298.15)\n",
    "fi = fi5+fi6+fi8-fi7-fi9\n",
    "\n",
    "# Result\n",
    "print \" Heat removal in the cooler = \",fi,\" kJ/h.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.57    Page 314"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAEACAYAAAC6d6FnAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8VPW9//HXENYgizRIA8HLYlRERUQWK8KwishmXTAI\nKMVbLFWoC6Jor3FD6xURrdAq1QoKAuqlIAgWYQpu0PoLAQp6CeKSgCICgsgFQub3x+cMM8bAzGSZ\nM8v7+XicR2a+c2bmwwHOJ98dREREREREREREREREREREREREREQkiaUBecBi5/k853kesN35CdAC\nOBTy2vSQz+gAbAS2AtOqPGIREakUtwOvAIvKeO0J4D7ncQvsJl+WdUAn5/FSoF8lxiciIlUgC1gB\n9CBYAwjwAF8ArZ3nLSg7AWQCW0KeXwf8qVKjFBGRqFSL4JypwASgpIzXLgW+BraFlLXEmn98QFen\nrBlQGHJOkVMmIiIuqR7m9QHALuyG7i3j9RxgTsjzHUBzYC9wIbAQaFvhKEVEpNKFSwC/AAYB/YHa\nQH1gFjDSee+V2I0+4IhzAPw/rGaQjf3GnxVyXpZT9hOtW7f2b9u2rayXRESkbNuAM6ryC7rz4z6A\nfsCqUudkYCOGAFphzT4Nnedrgc5Yv8HJOoH94vfff//9bocQN3QtgnQtgnQtggB/eW7q4WoAP7k5\nhzweCswt9Xo34EHgKNZnMAbY57w2FvgrUAdLAMui/G4REalE0SSAfzhHwKgyznnDOcryEXBeFN8n\nIiJVKJJRQOICr9frdghxQ9ciSNciSNei4jxuB1AGp0lLREQi4fF4oBz3c9UARERSlBKAiEiKUgIQ\nEUlRSgAiIikq2nkAUsmKi2HPnuCxb58d330HBw7AwYPw/ffwww/wf/8Hhw/bz+JiOHbMDr8fqlUL\nHjVrQq1adqSnwymnBI9GjYJH48bQpAnUrw+eeBwOICJVKh7/2yf8KKCSEvjmG9ixI3h89VXw2LXL\njm++gf37oWFD+NnP7KbcsCE0aGBHvXp2065b147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J8ArN/gw1gFF2ORXIuLgQbO436k9rUInLcSeBO4KlbBxVgk16Ih\n8G9sng7YTTAZRXItcoFHnccZwLdA9diEF1OXYjf1EyWAqO+bbqwF1An7C/0MOAq8Cgwudc4g4CXn\n8VrsH3uTGMUXS5Fciw+A75zHawn+h082kVwLsEEHrwHfxCyy2IvkWgzD+t8C82vCTcZMVJFci51A\nfedxfSwBFMcovlhaA+w9yetR3zfdSADNsKGlAYX8dFJYWeck440vkmsRajTBDJ9sIv13MRhbVgRs\n+FsyiuRaZAONsKHW/wJGxCa0mIvkWjwPtMXmIeVjS9ekoqjvm25UkyL9T1t64lky/meP5s/UA/gV\ncEkVxeK2SK7FU8Ddzrke4nM/i8oQybWogc2x6QWkYzXFD7H232QSybWYhDUNeYHWwN+xtcoOnOQ9\nySqq+6asQNZwAAABHElEQVQbCaCI4OqhOI8Lw5yT5ZQlm0iuBVjH7/NYH8DJqoCJLJJr0QFrAgBr\n670caxZYRHKJ5Fp8iTX7HHKO1dhNL9kSQCTX4hfY0jQA27CJq2dhNaNUkhD3zerYX1ILoCbhO4G7\nkLwdn5Fci9OxNtAuMY0s9iK5FqFeJHlHAUVyLc4GVmCdpOlYx+A5sQsxZiK5Fk8SXJG4CZYgGsUo\nvlhrQWSdwHF937wc+AS7sd3jlI1xjoA/Oq/nY1XdZBXuWszEOrUCeyysK/0BSSSSfxcByZwAILJr\ncSc2EmgjMC6m0cVWuGuRga1SkI9di2GxDjBG5mL9HEewGuCvSN37poiIiIiIiIiIiIiIiIiIiIiI\niIiIiIiIiIhIavj/31aygaPb0jQAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f32273f21d0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                     Enthalpy, kJ/kmol mix \n",
      "  x1         HE             H\n",
      "  0          0             4721.5\n",
      "  0.1        37.372608         4723.522608\n",
      "  0.2        78.615936         4729.415936\n",
      "  0.3        111.825504         4727.275504\n",
      "  0.4        131.236032         4711.336032\n",
      "  0.5        135.6         4680.35\n",
      "  0.6        126.566208         4635.966208\n",
      "  0.7        107.058336         4581.108336\n",
      "  0.8        79.653504         4518.353504\n",
      "  0.9        44.960832         4448.310832\n",
      "  1.0        0.0        4368.0\n"
     ]
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "# solution \n",
    "from numpy import linspace\n",
    "from matplotlib.pyplot import plot, show\n",
    "\n",
    "# Variables \n",
    "To = 273.15\n",
    "T1 = 308.15\n",
    "H1 = 124.8*(T1-To)                  # kJ/kmol\n",
    "H2 = 134.9*(T1-To)                  # kJ/kmol\n",
    "\n",
    "# Calculation \n",
    "HE1 = .1*.9*(542.4+55.4*(.9-.1)-132.8*(.9-.1)**2-168.9*(.9-.1)**3)  # kJ/kmol of mix\n",
    "Ha = HE1+H1*.1+H2*.9\n",
    "HE2 = .2*.8*(542.4+55.4*(.8-.2)-132.8*(.8-.2)**2-168.9*(.8-.2)**3)  # kJ/kmol of mix\n",
    "Hb = HE2+H1*.2+H2*.8\n",
    "HE3 = .3*.7*(542.4+55.4*(.7-.3)-132.8*(.7-.3)**2-168.9*(.7-.3)**3)  # kJ/kmol of mix\n",
    "Hc = HE3+H1*.3+H2*.7\n",
    "HE4 = .4*.6*(542.4+55.4*(.6-.4)-132.8*(.6-.4)**2-168.9*(.6-.4)**3)  # kJ/kmol of mix\n",
    "Hd = HE4+H1*.4+H2*.6\n",
    "HE5 = .5*.5*(542.4+55.4*(.5-.5)-132.8*(.5-.5)**2-168.9*(.5-.5)**3)  # kJ/kmol of mix\n",
    "He = HE5+H1*.5+H2*.5\n",
    "HE6 = .6*.4*(542.4+55.4*(.4-.6)-132.8*(.4-.6)**2-168.9*(.4-.6)**3)  # kJ/kmol of mix\n",
    "Hf = HE6+H1*.6+H2*.4\n",
    "HE7 = .7*.3*(542.4+55.4*(.3-.7)-132.8*(.3-.7)**2-168.9*(.3-.7)**3)  # kJ/kmol of mix\n",
    "Hg = HE7+H1*.7+H2*.3\n",
    "HE8 = .8*.2*(542.4+55.4*(.2-.8)-132.8*(.2-.8)**2-168.9*(.2-.8)**3)  # kJ/kmol of mix\n",
    "Hh = HE8+H1*.8+H2*.2\n",
    "HE9 = .9*.1*(542.4+55.4*(.1-.9)-132.8*(.1-.9)**2-168.9*(.1-.9)**3)  # kJ/kmol of mix\n",
    "Hi = HE9+H1*.9+H2*.1\n",
    "HE10 = .0*1.*(542.4+55.4*(.0-1.)-132.8*(.0-1.)**2-168.9*(.0-1.)**3)  # kJ/kmol of mix\n",
    "Hj = HE10+H1+H2*0\n",
    "x = linspace(0,1,100)\n",
    "y = linspace(4300,5000,100)\n",
    "y = 4721.5-57.4*x+1137.7*x**2-3993.6*x**3+3909.2*x**4-1351.2*x**5\n",
    "\n",
    "# Result\n",
    "plot(x,y)\n",
    "show()\n",
    "#title(\"H vs x1\")\n",
    "#xlabel(\"x1\")\n",
    "#ylabel(\"H (kJ/kg sol.)\")\n",
    "print \"                     Enthalpy, kJ/kmol mix \"\n",
    "print \"  x1         HE             H\"\n",
    "print \"  0          0            \",H2\n",
    "print \"  0.1       \",HE1,\"       \",Ha\n",
    "print \"  0.2       \",HE2,\"       \",Hb\n",
    "print \"  0.3       \",HE3,\"       \",Hc\n",
    "print \"  0.4       \",HE4,\"       \",Hd\n",
    "print \"  0.5       \",HE5,\"       \",He\n",
    "print \"  0.6       \",HE6,\"       \",Hf\n",
    "print \"  0.7       \",HE7,\"       \",Hg\n",
    "print \"  0.8       \",HE8,\"       \",Hh\n",
    "print \"  0.9       \",HE9,\"       \",Hi\n",
    "print \"  1.0       \",HE10,\"      \",Hj\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.59   Page 318"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " H1 at x1=0.3 is  300.0  kJ/kg sol  \n",
      "H2 at x1=0.3 is  30.0  kJ/kg sol  \n",
      "H1 at x1=0.6 is  63.0  kJ/kg sol  \n",
      "H2 at x1=0.6 is  214.0  kJ/kg sol.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "# Variables \n",
    "\n",
    "# from graph drawn in 5.57 we can see\n",
    "H1E1 = 300.\n",
    "H1E2 = 63.\n",
    "H2E1 = 30.\n",
    "H2E2 = 214.\n",
    "\n",
    "# Result\n",
    "print \" H1 at x1=0.3 is \",H1E1,\" kJ/kg sol  \\nH2 at x1=0.3 is \",H2E1,\\\n",
    "\" kJ/kg sol  \\nH1 at x1=0.6 is \",H1E2,\" kJ/kg sol  \\nH2 at x1=0.6 is \",H2E2,\" kJ/kg sol.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.60   Page 320"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat of dilution =  -57267.8712082  kJ/kg original solution   \n",
      "Final T of resultant solution =  331.612662617  K.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "# Variables \n",
    "# basis 100 kg 96.1% H2SO4\n",
    "# from table 5.64\n",
    "m1SO3 = 78.4                        # kg\n",
    "m1H2O = 21.6\n",
    "n1SO3 = m1SO3/80.063\n",
    "n1H2O = m1H2O/18.015\n",
    "\n",
    "# Calculation \n",
    "# resultant sol has 23.2% H2SO4\n",
    "m2SO3 = 19.\n",
    "m2H2O = 81.\n",
    "Mrsol = m1SO3*100./m2SO3\n",
    "Mw = Mrsol-100.\n",
    "w = Mrsol-m1SO3/18.015              # kmol\n",
    "HEosol = n1SO3*(-56940.)+n1H2O*(-32657.)           # kJ\n",
    "HErsol = n1SO3*(-156168.)+w-(-335.)\n",
    "HE = HErsol-HEosol                  # kJ/kg original acid\n",
    "C = 3.43                            # kJ/kg K\n",
    "dT = -HE/(Mrsol*C)\n",
    "T = 291.15+dT                       # K\n",
    "\n",
    "# Result\n",
    "print \" Heat of dilution = \",HE,\" kJ/kg original solution   \\nFinal T of resultant solution = \",T,\" K.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 5.61   Page 321"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Heat of dilution =  636.08178112  kJ/kg.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 100 kg of original acid\n",
    "lv = 333.7                      # kJ/kg\n",
    "\n",
    "# Calculation \n",
    "H = -lv-18*4.1868\n",
    "HE = (-64277-H*312.63)/100      # kJ/kg\n",
    "\n",
    "# Result\n",
    "print \" Heat of dilution = \",HE,\" kJ/kg.\"\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "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.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
