{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 11:Thermodynamic relations Equilibrium and stability"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex11.3:pg-436"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 11.3\n",
      "\n",
      " Vapour pressure of benzene is  17.6682592008  kPa\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "Tb = 353.0 # boiling point of benzene in K\n",
    "T = 303.0 # Operational temperature in K\n",
    "R = 8.3143 #Gas constant\n",
    "P = 101.325*math.exp((88/R)*(1.0-(Tb/T)))\n",
    "\n",
    "print \"\\n Example 11.3\"\n",
    "print \"\\n Vapour pressure of benzene is \",P ,\" kPa\"\n",
    "#The answers vary due to round off error\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex11.4:pg-436"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 11.4\n",
      "\n",
      " Temperature at triple point is  195.197740113  K\n",
      "\n",
      " Pressure at triple point is  44.631622076  mm Hg\n",
      "\n",
      "\n",
      " Latent heat of sublimation is  31211.8822  kJ/kg mol\n",
      "\n",
      " Latent heat of vapourization is is  25466.7009  kJ/kg mol\n",
      "\n",
      " Latent heat of fusion is  5745.1813  kJ/kg mol\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "T = (3754-3063)/(23.03-19.49) # Temperature at triple point in K\n",
    "P = math.exp(23.03-(3754/195.2)) # Pressure at triple point\n",
    "R = 8.3143 # Gas constant\n",
    "Lsub = R*3754 # Latent heat of sublimation\n",
    "Lvap = 3063*R # Latent heat of vaporisation\n",
    "Lfu = Lsub-Lvap # Latent heat of fusion\n",
    "\n",
    "print \"\\n Example 11.4\"\n",
    "print \"\\n Temperature at triple point is \",T ,\" K\"\n",
    "print \"\\n Pressure at triple point is \",P ,\" mm Hg\"\n",
    "print \"\\n\\n Latent heat of sublimation is \",Lsub ,\" kJ/kg mol\"\n",
    "print \"\\n Latent heat of vapourization is is \",Lvap ,\" kJ/kg mol\"\n",
    "print \"\\n Latent heat of fusion is \",Lfu ,\" kJ/kg mol\"\n",
    "#The answers vary due to round off error\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex11.6:pg-438"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 11.6\n",
      "\n",
      "\n",
      " Energy of first system is  1.6212885  kJ,\n",
      " Energy of second system is  2.43193275  kJ,\n",
      " Volume of first system is  0.008  m**3,\n",
      " Volume of second system is  0.012  m**3,\n",
      " Pressure is  135.107375  kN/m**2,\n",
      " Temperature is  260.0  K.\n"
     ]
    }
   ],
   "source": [
    "\n",
    "R = 8.3143 # Gas constant in kJ/kg-mol-K\n",
    "N1 = 0.5 # Mole no. of first system\n",
    "N2 = 0.75 # Mole no. of second system\n",
    "T1 = 200 # Initial temperature of first system in K\n",
    "T2 = 300 # Initial temperature of second system in K\n",
    "v = 0.02 # Total volume in m**3\n",
    "print \"\\n Example 11.6\\n\"\n",
    "Tf = (T2*N2+T1*N1)/(N1+N2)\n",
    "Uf_1 = (3.0/2.0)*(R*N1*Tf)*(10**-3)\n",
    "Uf_2 = (3.0/2.0)*(R*N2*Tf)*(10**-3)\n",
    "pf = (R*Tf*(N1+N2)*(10**-3))/v\n",
    "Vf_1 = R*N1*(10**-3)*Tf/pf\n",
    "Vf_2 = v-Vf_1\n",
    "print \"\\n Energy of first system is \",Uf_1 ,\" kJ,\\n Energy of second system is \",Uf_2 ,\" kJ,\\n Volume of first system is \",Vf_1 ,\" m**3,\\n Volume of second system is \",Vf_2 ,\" m**3,\\n Pressure is \",pf ,\" kN/m**2,\\n Temperature is \",Tf ,\" K.\"\n",
    "#The answers vary due to round off error\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex11.10:pg-446"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 11.10 \n",
      "\n",
      " Power required to run the compressor =  -10.6853713009  kW, \n",
      " The rate at which heat must be removed from the compressor =  -11.9346733668  kW\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "R = 0.082 # Gas constant in litre-atm/gmol-K\n",
    "m = 1.5 # Mass flow rate in kg/s\n",
    "p1 = 1.0 # Pressure in atm\n",
    "t2 = 300.0 # Temperature after compression in K\n",
    "p2 = 400.0 # Pressure after compression in atm\n",
    "Tc = 151.0 # For Argon in K\n",
    "pc = 48.0 # For Argon in atm\n",
    "print \"\\n Example 11.10 \"\n",
    "a = 0.42748*((R*1000)**2)*((Tc)**2)/pc\n",
    "b = 0.08664*(R*1000)*(Tc)/pc\n",
    "# By solving equation v2**2 - 49.24*v2**2 + 335.6*v2 - 43440 = 0\n",
    "v2 = 56.8 # In cm**3/g mol\n",
    "v1 = (R*1000)*(t2)/p1\n",
    "delta_h = -1790 # In J/g mol\n",
    "delta_s = -57 # In J/g mol\n",
    "Q = (t2*delta_s*(10**5)/39.8)/(3600*1000)\n",
    "W = Q - (delta_h*(10**5)/39.8)/(3600*1000)\n",
    "print \"\\n Power required to run the compressor = \",W ,\" kW, \\n The rate at which heat must be removed from the compressor = \",Q ,\" kW\"\n",
    "# Answers vary due to round off error.\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.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
