{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter6: Evaporation"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example no:6.1,Page no:6.19"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Boiling point of elevation of the solution is 7 K\n",
      "Driving forve for heat transfer is 19 K\n"
     ]
    }
   ],
   "source": [
    "#Boiling point Elevation\n",
    "#Variable declaration\n",
    "T=380       #B.P of solution[K]\n",
    "T_dash=373      #B.P of water [K]\n",
    "Ts=399      #Saturating temperature in [K]\n",
    "#Calculation\n",
    "BPE=T-T_dash        #Boiling point elevation in [K]\n",
    "DF=Ts-T     #Driving force in [K]\n",
    "#Result\n",
    "print\"Boiling point of elevation of the solution is\",BPE,\"K\"\n",
    "print\"Driving forve for heat transfer is\",DF,\"K\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example no:6.2 ,Page no:6.20"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Capacity of evaporator is 8400.0 kg/h\n"
     ]
    }
   ],
   "source": [
    "#Capacity of evaporator\n",
    "#Variable declaration\n",
    "m_dot=10000     #Weak liquor entering in [kg/h]\n",
    "fr_in=0.04       #Fraciton of caustic soda IN i.e 4%\n",
    "fr_out=0.25    #Fraciton of caustic soda OUT i.e 25%\n",
    "#Let mdash_dot be the kg/h of thick liquor leaving\n",
    "\n",
    "#Calculation\n",
    "mdash_dot=fr_in*m_dot/fr_out        #[kg/h]\n",
    "\n",
    "#Overall material balance\n",
    "#kg/h of feed=kg/h of water evaporated +kg/h of thick liquor\n",
    "#we=water evaporated in kg/h\n",
    "#Therefore\n",
    "we=m_dot-mdash_dot      #[kg/h]\n",
    "\n",
    "#Result\n",
    "\n",
    "print\"Capacity of evaporator is\",we,\"kg/h\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example no: 6.3,Page no:6.20"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ANSWER:Economoy pf evaporator is  0.808\n",
      "Heat tarnsfer area to be provided =  57.07 m^2\n"
     ]
    }
   ],
   "source": [
    "#Economy of Evaporator\n",
    "#Variable declaration\n",
    "ic=0.05     #Initial concentration (5%)\n",
    "fc=0.2      #Final concentration   (20%)\n",
    "T_dash=373      #B.P of water in [K]\n",
    "bpe=5       #Boiling point elevation[K]\n",
    "mf_dot=5000       #[Basis] feed to evaporator in [kg/h]\n",
    "\n",
    "#Calculation\n",
    "\n",
    "#Material balance of solute\n",
    "mdash_dot=ic*mf_dot/fc       #[kg/h]\n",
    "#Overall material balance\n",
    "mv_dot=mf_dot-mdash_dot      #Water evaporated [kg/h]\n",
    "lambda_s=2185        #Latent heat of condensation of steam[kJ/kg]\n",
    "lambda_v=2257       #Latent heat of vaporisation of water [kJ/kg]\n",
    "lambda1=lambda_v     #[kJ/kg]\n",
    "T=T_dash+bpe        #Temperature of thick liquor[K]\n",
    "Tf=298      #Temperature of feed [K]\n",
    "Cpf=4.187       #Sp. heat of feed in [kJ/kg.K]\n",
    "#Heat balance over evaporator=ms_dot\n",
    "ms_dot=(mf_dot*Cpf*(T-Tf)+mv_dot*lambda1)/lambda_s   #Steam consumption [kg/h]\n",
    "Eco=mv_dot/ms_dot       #Economy of evaporator\n",
    "Ts=399      #Saturation temperature of steam in [K]\n",
    "dT=Ts-T     #Temperature driving force [K]        \n",
    "U=2350      #[W/sq m.K]\n",
    "Q=ms_dot*lambda_s       #Rate of heat transfer in [kJ/kg]\n",
    "Q=Q*1000/3600           #[J/s]=[W]\n",
    "A=Q/(U*dT)              #Heat transfer area in [sq m]\n",
    "\n",
    "#Result\n",
    "print\"ANSWER:Economoy pf evaporator is \",round(Eco,3)\n",
    "print\"Heat tarnsfer area to be provided = \",round(A,2),\"m^2\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example no: 6.4,Page no:6.22"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "When Feed introduced at 293 K ,Steam economy is  0.87\n",
      "ANSWER-(i) At 293 K,Heat transfer area required is 83.16 m^2\n",
      "ANSWER-(ii) When T=308 K,Economy of evaporator is  0.896\n",
      "ANSWER-(iii) When T=308 K,Heat transfer Area required is  80.71 m^2\n"
     ]
    }
   ],
   "source": [
    "#Steam economy\n",
    "\n",
    "#Variable declaration\n",
    "\n",
    "Cpf=3.98        #Specific heat of feed in kJ/(kg.K)\n",
    "lambda_s=2202    #Latent heat of conds of heat at 0.2MPa in [kJ/kg]\n",
    "lambda1=2383     #Latent heat of vaporisation of water aty 323 [kJ/kg\n",
    "ic=0.1          #Initial concentration of soilds in [%]\n",
    "fc=0.5          #Final concentration\n",
    "m_dot=30000     #Feed to evaporator in [kg/h]\n",
    "\n",
    "#Calculation\n",
    "\n",
    "mdash_dot=ic* m_dot/fc  #Mass flow rate of thick liquor in [kg/h]\n",
    "mv_dot=m_dot-mdash_dot      #Water evaporated in [kg/h]\n",
    "\n",
    "#Case 1: Feed at 293K\n",
    "mf_dot=30000        #[kg/h]\n",
    "mv_dot=24000        #[kg/h]\n",
    "Cpf=3.98        #[kJ/(kg.K)]\n",
    "Ts=393      #Saturation temperature of steam in [K]\n",
    "T=323       #Boiling point of solution [K]\n",
    "lambda_s=2202       #Latent heat of condensation [kJ/kg]\n",
    "lambda1=2383     #Latent heat of vaporisation[kJ/kg]\n",
    "Tf=293          #Feed temperature\n",
    "#Enthalpy balance over the evaporator:\n",
    "ms_dot=(mf_dot*Cpf*(T-Tf)+mv_dot*lambda1)/lambda_s       #Steam consumption[kg/h]\n",
    "eco=(mv_dot/ms_dot)         #Steam economy\n",
    "print\"When Feed introduced at 293 K ,Steam economy is \",round(eco,2) \n",
    "dT=Ts-T                     #[K]\n",
    "U=2900          #[W/sq m.K]\n",
    "Q=ms_dot*lambda_s           #Heat load =Rate of heat transfer in [kJ/h]\n",
    "Q=Q*1000/3600               #[J/s]\n",
    "A=Q/(U*dT)              #Heat transfer area required [sq m]\n",
    "\n",
    "#Result\n",
    "print\"ANSWER-(i) At 293 K,Heat transfer area required is\",round(A,2),\"m^2\"\n",
    "\n",
    "#Case2: Feed at 308K\n",
    "Tf=308      #[Feed temperature][K]\n",
    "\n",
    "#Calculation\n",
    "ms_dot=(mf_dot*Cpf*(T-Tf)+mv_dot*lambda1)/lambda_s           #Steam consumption in [kg/h]\n",
    "eco=mv_dot/ms_dot               #Economy of evaporator\n",
    "Q=ms_dot*lambda_s               #[kJ/h]\n",
    "Q=Q*1000/3600                   #[J/s]\n",
    "A=Q/(U*dT)                      #Heat transfer area required [sq m]\n",
    "#Result\n",
    "print\"ANSWER-(ii) When T=308 K,Economy of evaporator is \",round(eco,3)\n",
    "print\"ANSWER-(iii) When T=308 K,Heat transfer Area required is \",round(A,2),\"m^2\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example no: 6.5,Page no:6.24"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Heat transfer area to be provided is 45.33 m^2\n"
     ]
    }
   ],
   "source": [
    "#Evaporator economy\n",
    "#Variable declaration\n",
    "m_dot=5000  #Feed to the evaporator [kg/h]\n",
    "Cpf=4.187           #Cp of feed in [kJ/kg.K]\n",
    "ic=0.10             #Initial concentration\n",
    "fc=0.4              #Final concentration\n",
    "lambda_s=2162           #Latent heat of condensing steam [kJ/kg]\n",
    "P=101.325       #Pressure in the evaporator[kPa]\n",
    "bp=373          #[K]\n",
    "Hv=2676     #Enthalpy of water vapor [kJ/kg]\n",
    "H_dash=419          #[kJ/kg]\n",
    "Hf=170          #[kJ/kg]\n",
    "U=1750          #[W/sq m.K]\n",
    "dT=34           #[K]\n",
    "#Calculation\n",
    "mdash_dot=m_dot*ic/fc           #[kg/h] of thick liquor\n",
    "mv_dot=m_dot-mdash_dot          #Water evaporated in[kg/h]\n",
    "ms_dot=(mv_dot*Hv+mdash_dot*H_dash-m_dot*Hf)/lambda_s          #Steam consumption in [kg/h]\n",
    "eco=mv_dot/ms_dot           #Steam economy of evaporator\n",
    "Q=ms_dot*lambda_s           #[kJ/h]\n",
    "Q=Q*1000/3600               #[J/s]\n",
    "A=Q/(U*dT)                  #[sq m]\n",
    "#Result\n",
    "print\"Heat transfer area to be provided is\",round(A,2),\"m^2\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example no:6.6 ,Page no:6.26"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Steam economy is 0.784\n",
      "Overall heat transfer coefficient is 2862.0 W/m^2.K\n"
     ]
    }
   ],
   "source": [
    "#Single effect Evaporator\n",
    "#Variable declaration\n",
    "mf_dot=5000           #[kg/h]\n",
    "ic=0.01             #Initial concentration [kg/h]\n",
    "fc=0.02             #Final concentration  [kg/h]\n",
    "T=373               #Boiling pt of saturation in [K]\n",
    "Ts=383              #Saturation temperature of steam in [K]  \n",
    "Hf=125.79           #[kJ/kg]\n",
    "Hdash=419.04            #[kJ/kg]\n",
    "Hv=2676.1           #[kJ/kg]\n",
    "lambda_s=2230.2     #[kJ/kg]\n",
    "#Calculation\n",
    "mdash_dot=ic*mf_dot/fc   #[kg/h]\n",
    "mv_dot=mf_dot-mdash_dot      #Water evaporated in [kg/h]\n",
    "ms_dot=(mdash_dot*Hdash+mv_dot*Hv-mf_dot*Hf)/lambda_s   #Steam flow rate in [kg/h]\n",
    "eco=mv_dot/ms_dot           #Steam economy\n",
    "Q=ms_dot*lambda_s           #Rate of heat transfer in [kJ/h]\n",
    "Q=Q*1000/3600               #[J/s]\n",
    "dT=Ts-T                     #[K]\n",
    "\n",
    "A=69            #Heating area of evaporator in [sq m]\n",
    "U=Q/(A*dT)      #Overall heat transfer coeff in [W/sq m.K]\n",
    "\n",
    "#Result\n",
    "print\"Steam economy is\",round(eco,3)\n",
    "print\"Overall heat transfer coefficient is\",round(U),\"W/m^2.K\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example no: 6.7,Page no:6.27"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The heat transfer area in this case is 18.7 m^2\n",
      "NOTE :There is a calculation mistake in the book at the line12 of this code,ms_dot value is written as 2320.18,which is wrong\n"
     ]
    }
   ],
   "source": [
    "#Single efect evaporator reduced pressure\n",
    "#From previous example:\n",
    "#Variable declaration\n",
    "mf_dot=5000         #[kg/h]\n",
    "Hf=125.79           #[kJ/kg]\n",
    "lambda_s=2230.2     #[kJ/kg]\n",
    "mdash_dot=2500   #[kg/h]\n",
    "Hdash=313.93         #[kJ/kg]\n",
    "mv_dot=2500         #[kg/h]\n",
    "Hv=2635.3           #[kJ/kg]\n",
    "U=2862              #[W/sq m.K]\n",
    "dT=35       #[K]\n",
    "#Calculation\n",
    "ms_dot=(mdash_dot*Hdash+mv_dot*Hv-mf_dot*Hf)/lambda_s   #Steam flow rate in [kg/h]\n",
    "Q=ms_dot*lambda_s           #[kJ/h]\n",
    "Q=Q*1000/3600           #[W]\n",
    "A=Q/(U*dT)      #[sq m]\n",
    "#Result\n",
    "print\"The heat transfer area in this case is\",round(A,2),\"m^2\"\n",
    "print\"NOTE :There is a calculation mistake in the book at the line12 of this code,ms_dot value is written as 2320.18,which is wrong\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example no: 6.8,Page no:6.27"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Mass flow rate of product is 3629.9 kg/h\n",
      "The product concentration is 1.653 % by weight\n"
     ]
    }
   ],
   "source": [
    "#Mass flow rate\n",
    "#Variable declaration\n",
    "mf_dot=6000         #Feed rate in [kg/h]\n",
    "#Taking the given values from previous example(6.6)\n",
    "Hf=125.79           #[kJ/kg]\n",
    "ms_dot=3187.56      #[kg/h]\n",
    "lambda_s=2230.2         #[kJ/kg]\n",
    "Hdash=419.04        #[kJ/kg]\n",
    "Hv=2676.1           #[kJ/kg]\n",
    "#Calculation\n",
    "mv_dot=(mf_dot*Hf+ms_dot*lambda_s-6000*Hdash)/(Hv-Hdash)  #Water evaporated in [kg/h]\n",
    "mdash_dot=6000-mv_dot       #Mass flow rate of product [kg/h]\n",
    "x=(0.01*mf_dot)*100/mdash_dot       #Wt % of solute in products\n",
    "#Result\n",
    "print\"Mass flow rate of product is\",round(mdash_dot,1),\"kg/h\"\n",
    "print\"The product concentration is\",round(x,3),\"% by weight\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example no:6.9 ,Page no:6.28"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Heat load is 11226389.0 W or J/s\n",
      "Economy of evaporator is  0.811\n",
      "NOTE:Again there is a calcualtion mistake in book at line 19 of code,it is written as 4041507.1 instead of 40415071\n"
     ]
    }
   ],
   "source": [
    "#Heat load in single effect evaporator\n",
    "#Variable declaration\n",
    "Tf=298      #Feed temperature in [K]\n",
    "T_dash=373      #[K]\n",
    "Cpf=4       #[kJ/kg.K]\n",
    "fc=0.2      #Final concentration of salt\n",
    "ic=0.05     #Initial concentration\n",
    "mf_dot=20000    #[kg/h] Feed to evaporator\n",
    "#Calculation\n",
    "mdash_dot=ic*mf_dot/fc      #Thick liquor [kg/h]\n",
    "mv_dot=mf_dot-mdash_dot     #Water evaporated in [kg/h]\n",
    "lambda_s=2185       #[kJ/kg]\n",
    "lambda1=2257       #[kJ/kg]\n",
    "bpr=7       #Boiling point rise[K]\n",
    "T=T_dash+bpr     #Boiling point of solution in[K]\n",
    "Ts=39       #Temperature of condensing steam in [K]\n",
    "ms_dot=(mf_dot*Cpf*(T-Tf)+mv_dot*lambda1)/lambda_s   #Steam consumption in [kg/h]\n",
    "eco=mv_dot/ms_dot           #Economy of evaporator \n",
    "Q=ms_dot*lambda_s               #[kJ/h]\n",
    "Q=Q*1000/3600           #[J/s]\n",
    "#Result\n",
    "print\"Heat load is\",round(Q),\"W or J/s\"\n",
    "print\"Economy of evaporator is \",round(eco,3)\n",
    "print\"NOTE:Again there is a calcualtion mistake in book at line 19 of code,it is written as 4041507.1 instead of 40415071\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example no:6.10 ,Page no:6.32"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Boiling point of solution in first effect = 369.55 K\n",
      "Boiling point of solution in second effect = 354.6 K\n"
     ]
    }
   ],
   "source": [
    "#Triple efect evaporator\n",
    "#Variable declaration\n",
    "Ts=381.3        #[K]\n",
    "dT=56.6      #[K]\n",
    "U1=2800.0  #Overall heat transfer coeff in first effect\n",
    "U2=2200.0  #Overall heat transfer coeff in first effect\n",
    "U3=1100.0  #Overall heat transfer coeff in first effect\n",
    "#Calculation\n",
    "dT1=dT/(1+(U1/U2)+(U1/U3))  #/[K]\n",
    "dT2=dT/(1+(U2/U1)+(U2/U3))  #/[K]\n",
    "dT3=dT-(dT1+dT2)             #[K]\n",
    "#dT1=Ts-T1_dash      #[K]\n",
    "T1dash=Ts-dT1\n",
    "#dT2=T1_dash-T2_dash         #[K]\n",
    "T2_dash=T1dash-dT2             #[K]\n",
    "#Result\n",
    "print\"Boiling point of solution in first effect =\",round(T1dash,2),\"K\"\n",
    "print\"Boiling point of solution in second effect =\",round(T2_dash,1),\"K\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example no:6.11,Page no:6.33"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A1( 24.9 )=A2( 23.0 ),So the area in each effect can be 24.9 m^2\n",
      "Heat transfer surface in each effect is 24.9 m^2\n",
      "Steam consumption= 5517.0 (approx)kg/h\n",
      "Evaporation in the first effect is 4343.0 kg/h\n",
      "Evaporation in  2nd effect is 3742.0 kg/h\n"
     ]
    }
   ],
   "source": [
    "#Double effect evaporator\n",
    "#Variable declaration\n",
    "mf_dot=10000.0        #[kg/h] of feed\n",
    "ic=0.09     #Initial concentration \n",
    "fc=0.47     #Final concentration\n",
    "m1dot_dash=ic*mf_dot/fc     #[kg/h]\n",
    "Ps=686.616      #Steam pressure [kPa.g]\n",
    "Ps=Ps+101.325       #[kPa]\n",
    "Ts=442.7        #Saturation temperature in [K]\n",
    "P2=86.660       #Vacuum in second effect in [kPa]\n",
    "U1=2326.0     #Overall heat transfer in first effect [W/sq m.K]\n",
    "U2=1744.5   #Overall heat transfer in 2nd effect [W/sqm.K]\n",
    "P2_abs=101.325-P2   #Absolute pressure in second effect[kPa]\n",
    "T2=326.3        #Temperature in 2nd effect in [K]\n",
    "dT=Ts-T2        #[K]\n",
    "Tf=309.0      #Feed temperature in[K]\n",
    "T=273.0       #[K]\n",
    "Cpf=3.77        #kJ/kg.K  Specific heat for all caustic streams\n",
    "#Q1=Q2\n",
    "#U1*A1*dT1=U2*A2*dT2\n",
    "#Calculation\n",
    "dT2=dT/1.75     #[K]\n",
    "dT1=(U2/U1)*dT2     #[K]\n",
    "#Since there is no B.P.R\n",
    "Tv1=Ts-dT1      #Temperature in vapor space of first effect in [K]\n",
    "Tv2=Tv1-dT2     #Second effect [K]\n",
    "Hf=Cpf*(Tf-T)       #Feed enthalpy[kJ/kg]\n",
    "H1dash=Cpf*(Tv1-T)      #Enthalpy of final product[kJ/kg]\n",
    "H2dash=Cpf*(Tv2-T)      #kJ/kg\n",
    "#For steam at 442.7 K\n",
    "lambda_s=2048.7     #[kJ/kg]\n",
    "#For vapour at 392.8 K\n",
    "Hv1=2705.22     #[kJ/kg]\n",
    "lambda_v1=2202.8        #[kJ/kg]\n",
    "#for vapour at 326.3 K:\n",
    "Hv2=2597.61     #[kJ/kg]\n",
    "lambda_v2=2377.8        #[kJ/kg]\n",
    "\n",
    "#Overall material balance:\n",
    "mv_dot=mf_dot-m1dot_dash        #[kg/h]\n",
    "\n",
    "#Equation 4 becomes:\n",
    "#mv1_dot*lambda_v1+mf_dot*Hf=(mv_dot-mv1_dot)*Hv2+(mf_dot-mv2_dot)*H2_dash\n",
    "mv1_dot=(H2dash*(mf_dot-mv_dot)-mf_dot*Hf+mv_dot*Hv2)/(Hv2+lambda_v1-H2dash)  \n",
    "mv2_dot=mv_dot-mv1_dot              #[kg/h]\n",
    "\n",
    "#From equation 2\n",
    "\n",
    "m2dot_dash=m1dot_dash+mv1_dot           #First effect material balance[kg/h]\n",
    "ms_dot=(mv1_dot*Hv1+m1dot_dash*H1dash-m2dot_dash*H2dash)/lambda_s     #[kg/h]\n",
    "\n",
    "\n",
    "#Heat transfer Area\n",
    "#First effect\n",
    "A1=ms_dot*lambda_s*(10.0**3.0)/(3600.0*U1*dT1)     #[sq m]\n",
    "\n",
    "#Second effect\n",
    "lambda_v1=lambda_v1*(10**3.0)/3600.0\n",
    "A2=mv1_dot*lambda_v1/(U2*dT2)       #[sq m]\n",
    "\n",
    "#Since A1 not= A2\n",
    "\n",
    "#SECOND TRIAL\n",
    "Aavg=(A1+A2)/2          #[sq m]\n",
    "dT1_dash=dT1*A1/Aavg        #[K]\n",
    "dT2_dash=dT-dT1         #/[K]\n",
    "\n",
    "#Temperature distribution\n",
    "Tv1=Ts-dT1_dash         #[K]\n",
    "Tv2=Tv1-dT2_dash            #[K]\n",
    "Hf=135.66       #[kJ/kg]\n",
    "H1dash=Cpf*(Tv1-T)      #[kJ/kg]\n",
    "H2dash=200.83          #[kJ/kg]\n",
    "\n",
    "#Vapour at 388.5 K\n",
    "Hv1=2699.8      #[kJ/kg]\n",
    "lambda_v1=2214.92       #[kJ/kg]\n",
    "mv1_dot=(H2dash*(mf_dot-mv_dot)-mf_dot*Hf+mv_dot*Hv2)/(Hv2+lambda_v1-H2dash)  \n",
    "mv2_dot=mv_dot-mv1_dot  #[kg/h]\n",
    "\n",
    "#First effect Energy balance\n",
    "ms_dot=((mv1_dot*Hv1+m1dot_dash*H1dash)-(mf_dot-mv2_dot)*H2dash)/lambda_s   #[kg/h]\n",
    "\n",
    "#Area of heat transfer\n",
    "lambda_s=lambda_s*1000.0/3600.0     \n",
    "A1=ms_dot*lambda_s/(U1*dT1_dash)        #[sq m]\n",
    "\n",
    "#Second effect:\n",
    "A2=(mv1_dot*lambda_v1*1000)/(3600.0*U2*dT2_dash)        #[sq m]\n",
    "\n",
    "#Result\n",
    "\n",
    "print\"A1(\",round(A1,1),\")=A2(\",round(A2),\"),So the area in each effect can be\",round(A1,1),\"m^2\"\n",
    "print\"Heat transfer surface in each effect is\",round(A1,1),\"m^2\"\n",
    "print\"Steam consumption=\",round(ms_dot),\"(approx)kg/h\"\n",
    "print\"Evaporation in the first effect is\",round(mv1_dot),\"kg/h\"\n",
    "print\"Evaporation in  2nd effect is\",round(mv2_dot),\"kg/h\" \n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example no:6.12 ,Page no:6.37"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ANSWER:Area in each effect 200.2 sq m\n",
      "Steam economy is 2.55\n",
      "Cooling water rate is 66.63 t/h\n"
     ]
    }
   ],
   "source": [
    "#lye in Triple effect evaporator\n",
    "#Variable declaration\n",
    "Tf=353.0           #[K]\n",
    "T=273.0           #[K]\n",
    "mf_dot=10000.0          #Feed [kg/h]\n",
    "ic=0.07          #Initial conc of glycerine \n",
    "fc=0.4           #FinaL CONC OF GLYCERINE\n",
    "#Overall glycerine balance\n",
    "P=313.0            #Steam pressure[kPa]\n",
    "Ts=408.0       #[from steam table][K]\n",
    "P1=15.74         #[Pressure in last effect][kPa]\n",
    "Tv3=328.0          #[Vapour temperature]\n",
    "#Calculation\n",
    "m3dot_dash=(ic/fc)*mf_dot           #[kg/h]\n",
    "mv_dot=mf_dot-m3dot_dash            #/[kg/h]\n",
    "dT=Ts-Tv3      #Overall apparent [K]\n",
    "bpr1=10.0          #[K]\n",
    "bpr2=bpr1 \n",
    "bpr3=bpr2 \n",
    "sum_bpr=bpr1+bpr2+bpr3      #[K]\n",
    "dT=dT-sum_bpr               #True_Overall\n",
    "dT1=14.5             #[K]\n",
    "dT2=16.0               #[K]\n",
    "dT3=19.5             #[K]\n",
    "Cpf=3.768            #[kJ/(kg.K)]\n",
    "#Enthalpies of various streams\n",
    "Hf=Cpf*(Tf-T)           #[kJ/kg]\n",
    "H1=Cpf*(393.5-T)           #[kJ/kg]\n",
    "H2=Cpf*(367.5-T)           #[kJ/kg]\n",
    "H3=Cpf*(338.0-T)           #[kJ/kg]\n",
    "#For steam at 40K\n",
    "lambda_s=2160.0       #[kJ/kg]\n",
    "Hv1=2692.0        #[kJ/kg]\n",
    "lambda_v1=2228.3        #[kJ/kg]\n",
    "Hv2=2650.8          #[kJ/kg]\n",
    "lambda_v2=2297.4        #[kJ/kg]\n",
    "Hv3=2600.5              #[kJ/kg]\n",
    "lambda_v3=2370.0      #[kJ/kg]\n",
    "\n",
    "#MATERIAL AND EBERGY BALANCES\n",
    "#First effect\n",
    "#Material balance\n",
    "\n",
    "#m1dot_dash=mf_dot-mv1_dot\n",
    "#m1dot_dash=1750+mv2_dot+mv3_dot           \n",
    "\n",
    "#Energy balance\n",
    "#ms_dot*lambda_s+mf_Dot*hf=mv1_dot*Hv1+m1dot_dash*H1\n",
    "#2160*ms_dot+2238*(mv2_dot+mv3_dot)=19800500\n",
    "\n",
    "#Second effect\n",
    "#Energy balance:\n",
    "#mv3_dot=8709.54-2.076*mv2_dot\n",
    "\n",
    "#Third effect:\n",
    "#m2dot_dash=mv3_dot+m3dot_dash\n",
    "#m2dot_dash=mv3_dot+1750\n",
    "#From eqn 8 we get\n",
    "mv2_dot=(8709.54*2600.5+1750*244.92-8790.54*356.1-356.1*1750)/(-2.076*356.1+2297.4+2600.5*2.076)\n",
    "#From eqn 8:\n",
    "mv3_dot=8709.54-2.076*mv2_dot           #[kg/h]\n",
    "mv1_dot=mv_dot-(mv2_dot+mv3_dot)        #[kg/h]\n",
    "#From equation 4:\n",
    "#m1dot_dash=mf_dot-mv1_dot\n",
    "#ms_dot=(mv1_dot*Hv1+m1dot_dash*H1-mf_dot*Hf)/lambda_s   #[kg/h]\n",
    "ms_dot=(19800500.0-2238.0*(mv2_dot+mv3_dot))/2160.0           #[kg/h]\n",
    "\n",
    "#Heat transfer Area is\n",
    "U1=710.0          #[W/sq m.K]\n",
    "U2=490.0          #[W/sq m.K]\n",
    "U3=454.0          #[W/sq m.K]\n",
    "A1=(ms_dot*lambda_s*1000.0)/(3600.0*U1*dT1)     #[sq m]\n",
    "A2=mv1_dot*lambda_v1*1000.0/(3600.0*U2*dT2)   #[sq m]\n",
    "A3=mv2_dot*lambda_v2*1000.0/(3600.0*U3*dT3)   #[sq m]\n",
    "#The deviaiton is within +-10%\n",
    "#Hence maximum A1 area can be recommended\n",
    "\n",
    "eco=(mv_dot/ms_dot)     #[Steam economy]\n",
    "\n",
    "Qc=mv3_dot*lambda_v3        #[kJ/h]\n",
    "dT=25.0           #Rise in water temperature\n",
    "Cp=4.187\n",
    "mw_dot=Qc/(Cp*dT)\n",
    "#Result\n",
    "print\"ANSWER:Area in each effect\",round(A3,1),\"sq m\" \n",
    "print\"Steam economy is\",round(eco,2) \n",
    "print\"Cooling water rate is\",round(mw_dot/1000,2),\"t/h\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example no:6.13 ,Page no:6.42"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Steam economy is 2.0\n",
      "Area pf heat transfer in each effect is 65.3 m^2\n"
     ]
    }
   ],
   "source": [
    "#Triple effect unit\n",
    "#Variable declaration\n",
    "Cpf=4.18        #[kJ/kg.K]\n",
    "dT1=18          #[K]\n",
    "dT2=17          #[K]\n",
    "dT3=34          #[K]\n",
    "mf_dot=4        #[kg/s]\n",
    "Ts=394          #[K]\n",
    "bp=325      #Bp of water at 13.172 kPa [K]\n",
    "dT=Ts-bp        #[K]\n",
    "lambda_s=2200           #[kJ/kg]\n",
    "T1=Ts-dT1           #[K]\n",
    "lambda1=2249        #[kJ/kg]\n",
    "lambda_v1=lambda1       #[kJ/kg]\n",
    "#Calculation\n",
    "T2=T1-dT2           #[K]\n",
    "lambda2=2293        #[kJ/kg]\n",
    "lambda_v2=lambda2       #[kJ/kg]\n",
    "\n",
    "T3=T2-dT3           #[K]\n",
    "lambda3=2377        #[kJ/kg]\n",
    "lambda_v3=lambda3       #[kJ/kg]\n",
    "\n",
    "ic=0.1      #Initial conc of solids\n",
    "fc=0.5      #Final conc of solids\n",
    "m3dot_dash=(ic/fc)*mf_dot       #[kg/s]\n",
    "mv_dot=mf_dot-m3dot_dash        #Total evaporation in [kg/s]\n",
    "#Material balance over first effect\n",
    "#mf_dot=mv1_dot_m1dot_dash\n",
    "#Energy balance:\n",
    "#ms_dot*lambda_s=mf_dot*(Cpf*(T1-Tf)+mv1_dot*lambda_v1)\n",
    "\n",
    "#Material balance over second effect\n",
    "#m1dot_dash=mv2_dot+m2dot_dash\n",
    "#Enthalpy balance:\n",
    "#mv1_dot*lambda_v1+m1dot_dash(cp*(T1-T2)=mv2_dot*lambda_v2)\n",
    "\n",
    "#Material balance over third effect\n",
    "#m2dot_dash=mv3_dot+m3dot+dash\n",
    "\n",
    "#Enthalpy balance:\n",
    "#mv2_lambda_v2+m2dot_dash*cp*(T2-T3)=mv3_dot*lambda_v3\n",
    "294\n",
    "mv2_dot=3.2795/3.079        #[kg/s]\n",
    "mv1_dot=1.053*mv2_dot-0.1305     #[kg/s]\n",
    "mv3_dot=1.026*mv2_dot+0.051     #[kg/s]\n",
    "ms_dot=(mf_dot*Cpf*(T1-294)+mv1_dot*lambda_v1)/lambda_s      #[kg/s]\n",
    "eco=mv_dot/ms_dot           #Steam economy      \n",
    "eco=round(eco)\n",
    "U1=3.10     #[kW/sq m.K]\n",
    "U2=2     #[kW/sq m.K]\n",
    "U3=1.10     #[kW/sq m.K]\n",
    "#First effect:\n",
    "A1=ms_dot*lambda_s/(U1*dT1)         #[sq m]\n",
    "A2=mv1_dot*lambda_v1/(U2*dT2)        #[sq m]\n",
    "A3=mv2_dot*lambda_v2/(U3*dT3)        #[sq m]\n",
    "#Areas are calculated witha  deviation of +-10%\n",
    "#Result\n",
    "print\"Steam economy is\",eco \n",
    "print\"Area pf heat transfer in each effect is\",round(A3,1),\"m^2\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example no: 6.14,Page no:6.45"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Steam economy is 1.957 evaporation/kg steam\n"
     ]
    }
   ],
   "source": [
    "#Quadruple effect evaporator\n",
    "#Variable declaration\n",
    "mf_dot=1060     #[kg/h]\n",
    "ic=0.04     #Initial concentration\n",
    "fc=0.25         #Final concentration\n",
    "m4dot_dash=(ic/fc)*mf_dot       #[kg/h]\n",
    "#Total evaporation=\n",
    "mv_dot=mf_dot-m4dot_dash        #[kg/h]\n",
    "\n",
    "#Fromsteam table:\n",
    "P1=370      #[kPa.g]\n",
    "T1=422.6        #[K]\n",
    "lambda1=2114.4      #[kJ/kg]\n",
    "\n",
    "P2=235      #[kPa.g]\n",
    "T2=410.5        #[K]\n",
    "lambda2=2151.5      #[kJ/kg]\n",
    "\n",
    "P3=80      #[kPa.g]\n",
    "T3=390.2        #[K]\n",
    "lambda3=2210.2      #[kJ/kg]\n",
    "\n",
    "P4=50.66      #[kPa.g]\n",
    "T4=354.7        #[K]\n",
    "lambda4=2304.6      #[kJ/kg]\n",
    "\n",
    "P=700       #Latent heat of steam[kPa .g]\n",
    "lambda_s=2046.3         #[kJ/kg]\n",
    "\n",
    "#Calculation\n",
    "#FIRST EFFECT\n",
    "#Enthalpy balance:\n",
    "#ms_dot=mf_dot*Cpf*(T1-Tf)+mv1_dot*lambda1\n",
    "#ms_dot=1345.3-1.033*m1dot_dash\n",
    "\n",
    "#SECOND EFFECT\n",
    "#m1dot_dash=m2dot_dash+mdot_v2\n",
    "#Enthalpy balance:\n",
    "#m1dot_dash=531.38+0.510*m2dot_dash\n",
    "\n",
    "#THIRD EFFECT\n",
    "#Material balance:\n",
    "#m2dot_dash-m3dot_dash+mv3_dot\n",
    "\n",
    "#FOURTH EFFECT\n",
    "#m3dot_dash=m4dot_dash+mv4_dot\n",
    "mv4dot_dash=169.6           #[kg/h]\n",
    "m3dot_dash=416.7        #[kg/h]\n",
    "\n",
    "#From eq n 4:\n",
    "m2dot_dash=-176.84+1.98*m3dot_dash      #[kg/h]\n",
    "\n",
    "#From eqn 2:\n",
    "m1dot_dash=531.38+0.510*m2dot_dash      #[kg/h]\n",
    "\n",
    "#From eqn 1:\n",
    "ms_dot=1345.3-1.033*m1dot_dash\n",
    "eco=mv_dot/ms_dot           #[kg evaporation /kg steam]\n",
    "#Result\n",
    "print\"Steam economy is\",round(eco,3),\"evaporation/kg steam\" \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example no:6.15 ,Page no:6.48"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "NOTE:In textbook this value of hio is wrongly calculated as 3975.5..So we will take this\n",
      "Steam consumption is 24531.0 kg/h\n",
      "Capacity is 20000.0 kg/h\n",
      "Steam economy is  0.815\n",
      " No. of tubes required is  722.0\n"
     ]
    }
   ],
   "source": [
    "#Single effect Calendria\n",
    "import math\n",
    "#Variable declaration\n",
    "m1_dot=5000     #[kg/h]\n",
    "ic=0.1      #Initial concentration\n",
    "fc=0.5      #Final concentration\n",
    "mf_dot=(fc/ic)*m1_dot       #[kg/h]\n",
    "mv_dot=mf_dot-m1_dot        #Water evaporated[kg/h]\n",
    "P=357       #Steam pressure[kN/sq m]\n",
    "Ts=412       #[K]\n",
    "H=2732      #[kJ/kg]\n",
    "lambda1=2143     #[kJ/kg]\n",
    "bpr=18.5            #[K]\n",
    "T_dash=352+bpr      #[K]\n",
    "Hf=138      #[kJ/kg]\n",
    "lambda_s=2143       #[kJ/kg]\n",
    "Hv=2659     #[kJ/kg]\n",
    "H1=568      #[kJ/kg]\n",
    "#Calculation\n",
    "ms_dot=(mv_dot*Hv+m1_dot*H1-mf_dot*Hf)/lambda_s         #Steam consumption in kg/h\n",
    "eco=mv_dot/ms_dot       #Economy\n",
    "dT=Ts-T_dash        #[K]\n",
    "hi=4500     #[W/sq m.K]\n",
    "ho=9000     #[W/sq m.K]\n",
    "Do=0.032        #[m]\n",
    "Di=0.028        #[m]\n",
    "x1=(Do-Di)/2        #[m]\n",
    "Dw=(Do-Di)/math.log(32.0/28.0)   #[m]\n",
    "x2=0.25*10**-3      #[m]\n",
    "L=2.5       #Length [m]\n",
    "hio=hi*(Di/Do)        #[W/sq m.K]\n",
    "print\"NOTE:In textbook this value of hio is wrongly calculated as 3975.5..So we will take this\"\n",
    "hio=3975.5\n",
    "k1=45.0       #Tube material in [W/sq m.K]\n",
    "k2=2.25     #For scale[W/m.K]\n",
    "Uo=1.0/(1.0/ho+1.0/hio+(x1*Dw)/(k1*Do)+(x2/k2))     #Overall heat transfer coeff in W/sq m.K\n",
    "Q=ms_dot*lambda_s       #[kJ/h]\n",
    "Q=Q*1000.0/3600.0           #[W]\n",
    "\n",
    "A=Q/(Uo*dT)             #[sq m]\n",
    "n=A/(math.pi*Do*L)          #from A=n*math.pi*Do*L \n",
    "#Result\n",
    "print\"Steam consumption is\",round(ms_dot),\"kg/h\" \n",
    "print\"Capacity is\",round(mv_dot),\"kg/h\"\n",
    "print\"Steam economy is \",round(eco,3)\n",
    "print\" No. of tubes required is \",round(n)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "## Example no:6.16 ,Page no:6.50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Steam consumption is 3159.6 kg/h\n",
      "Heat transfer area is 47.91 m^2\n",
      " Now,Steam consumption is 3253.42 kg/h\n",
      "Economy of evaporator  0.84\n",
      "Now,Area is 49.33\n",
      "If enthalpy of water vapour Hv were based on the saturated vapour at the pressure\n",
      "the error introduced is only 2.97 percent\n"
     ]
    }
   ],
   "source": [
    "#Single effect evaporator\n",
    "#Variable declaration\n",
    "bpr=40.6         #[K]\n",
    "Cpf=1.88        #[kJ/kg.K]\n",
    "Hf=214      #[kJ/kg]\n",
    "H1=505      #[kJ/kg]\n",
    "mf_dot=4536     #[kg/h] of feed solution\n",
    "ic=0.2       #Initial conc\n",
    "fc=0.5       #Final concentration\n",
    "m1dot_dash=(ic/fc)*mf_dot       #Thisck liquor flow arte[kg/h]\n",
    "mv_dot=mf_dot-m1dot_dash        #[kg/H]\n",
    "Ts=388.5         #Saturation temperature of steam in [K]\n",
    "bp=362.5        #b.P of solution in [K]\n",
    "lambda_s=2214      #[kJ/kg]\n",
    "P=21.7       #Vapor space in [kPa]\n",
    "Hv=2590.3        #[kJ/kg]\n",
    "\n",
    "#Calculation\n",
    "#Enthalpy balance over evaporator\n",
    "ms_dot=(m1dot_dash*H1+mv_dot*Hv-mf_dot*Hf)/lambda_s     #[kg/h\n",
    "print\"Steam consumption is\",round(ms_dot,1),\"kg/h\" \n",
    "dT=Ts-bp        #[K]\n",
    "U=1560      #[W/sq m.K]\n",
    "Q=ms_dot*lambda_s           #[kJ/h]\n",
    "Q=Q*1000/3600               #[W]\n",
    "A=Q/(U*dT)      #[sq m]\n",
    "print\"Heat transfer area is\",round(A,2),\"m^2\"\n",
    "\n",
    "#Calculations considering enthalpy of superheated vapour\n",
    "\n",
    "Hv=Hv+Cpf*bpr   #[kJ/kg]\n",
    "ms_dot=(m1dot_dash*H1+mv_dot*Hv-mf_dot*Hf)/lambda_s     #[kg/h]\n",
    "print\" Now,Steam consumption is\",round(ms_dot,2),\"kg/h\" \n",
    "eco=mv_dot/ms_dot       #Steam economy\n",
    "print\"Economy of evaporator \",round(eco,2)\n",
    "Q=ms_dot*lambda_s       #[kJ/h]\n",
    "Q=Q*1000.0/3600.0           #[w]\n",
    "A2=Q/(U*dT)              #Area\n",
    "print\"Now,Area is\",round(A2,2) \n",
    "perc=(A2-A)*100/A           #%error in the heat transfer area \n",
    "#Result\n",
    "print\"If enthalpy of water vapour Hv were based on the saturated vapour at the pressure\\nthe error introduced is only\",round(perc,2),\"percent\"\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
}