{
 "metadata": {
  "name": "",
  "signature": "sha256:33e389243f3edbfa798e02801dff08e24da71a0ad10959698b7564f561b867d4"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter17-Ideal solutions"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1-pg 480"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#intilization variables\n",
      "x=0.25\n",
      "pa=40\n",
      "pb=50\n",
      "ya=0.25\n",
      "alpha=1.25\n",
      "#calculation\n",
      "P=x *pa+(1-x)*pb\n",
      "y=x*pa/P\n",
      "yb=(1-y)\n",
      "xa=alpha*y/(1+(alpha-1)*y)\n",
      "xb=(1-x)\n",
      "#results\n",
      "print'%s %.2f %s'%('total pressure of an ideal solution',P,'kpa')\n",
      "print'%s %.2f %s  %.2f %s '%('composition of the gaseous phase',y,'' and ' ',yb,'')\n",
      "print'%s %.2f %s  %.2f %s '%('the composition of last drop',xa,' ' and ' ',xb,'')                   "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "total pressure of an ideal solution 47.50 kpa\n",
        "composition of the gaseous phase 0.21   0.79  \n",
        "the composition of last drop 0.25    0.75  \n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example2-pg484"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "##initialisation of variables\n",
      "T= 290 ##K\n",
      "xa= 0.4\n",
      "xb= 0.6\n",
      "P= 600 ##kPa\n",
      "V= 60 ##L\n",
      "R= 8.314 ##J/mol K\n",
      "Mp= 44 ##kg/kmol\n",
      "Mb= 58.12 ##kg/kmol\n",
      "vp= 0.00171 ##m**3/kg\n",
      "vb= 0.00166 ##m**3/kg\n",
      "na= 0.1 ##kmol\n",
      "nb= 0.15 ##kmol\n",
      "V1= 0.04000 ##m**3\n",
      "xa= 0.4 \n",
      "np= 2\n",
      "Vc= 0.1 ##m**3\n",
      "##CALCULATIONS\n",
      "Pasat= math.e**(14.435-(2255/T))\n",
      "Pbsat= math.e**(14.795-(2770/T))\n",
      "P1= xa*Pasat+xb*Pbsat\n",
      "Na1= P*V/(100*R*T)\n",
      "Vp= vp*Mp\n",
      "Vb= vb*Mb\n",
      "V= na*Vp+nb*Vb\n",
      "Vv= V1-V\n",
      "nv= P1*Vv/(R*T)\n",
      "ya= xa*Pasat/P\n",
      "yb=1-ya\n",
      "Na= na+ya*nv\n",
      "Nb= nb+yb*nv\n",
      "##RESULTS\n",
      "print'%s %.2f %s'% (' initial pressure= ',P1,' kPa')\n",
      "print'%s %.2f %s'% ('  moles of propane= ',Na1,' kmol')\n",
      "print'%s %.2f %s'% ('  initial mole of propane= ',Na,' kmol')\n",
      "print'%s %.2f %s'% ('  initial mole of butane= ',Nb,' kmol')\n",
      "print'%s %.2f %s'% ('  numbar of phases= ',np,'')\n",
      "print'%s %.2f %s'% ('  volume in final state=',Vc,' m^3')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " initial pressure=  874.89  kPa\n",
        "  moles of propane=  0.15  kmol\n",
        "  initial mole of propane=  0.11  kmol\n",
        "  initial mole of butane=  0.15  kmol\n",
        "  numbar of phases=  2.00 \n",
        "  volume in final state= 0.10  m^3\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example3-pg489"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\t\n",
      "#calculate pressure of the phase of pure A\n",
      "##initialisation of variables\n",
      "p0= 10. ##Mpa\n",
      "R= 8.314 ##J/mol K\n",
      "T= 30. ##C\n",
      "va= 0.02 ##m^3/kmol\n",
      "xa= 0.98\n",
      "##CALCULATIONS\n",
      "p= p0+(R*(273.15+T)*math.log(xa)/(va*1000.))\n",
      "##RESULTS\n",
      "print'%s %.2f %s'%('Pressure of the phase of pure A=',p,'Mpa')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure of the phase of pure A= 7.45 Mpa\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example4-pg491"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate the boiling point elevation\n",
      "##initialisation of variables\n",
      "hfg= 2257.0 ##kJ/kg\n",
      "Tb= 100 ##C\n",
      "R= 8.314 ##J/mol K\n",
      "m2= 10 ##gms\n",
      "M2= 58.5 ##gms\n",
      "m1= 90. ##gms\n",
      "M1= 18. ##gms\n",
      "##CALCULATIONS\n",
      "x2= (m2/M2)/((m2/M2)+(m1/M1))\n",
      "dT= R*math.pow(273.15+Tb,2)*x2/(M1*hfg)\n",
      "##RESULTS\n",
      "print'%s %.3f %s'%(' Boiling point elevation=',dT,'C')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Boiling point elevation= 0.942 C\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example5-pg494"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate Osomatic pressures\n",
      "##initialisation of variables\n",
      "M1= 18.02 ##gms\n",
      "m1= 0.965 ##gms\n",
      "m2= 0.035 ##gms\n",
      "M2= 58.5 ##gms\n",
      "R= 8.314 ##J/mol K\n",
      "M= 18.02 ##kg\n",
      "T= 20. ##C\n",
      "vf= 0.001002 ##m^3\n",
      "x21= 0.021856 ##m^3\n",
      "##CALCULATIONS\n",
      "n1= m1/M1\n",
      "n2= m2/M2\n",
      "x1= n1/(n1+n2)\n",
      "x2= n2/(n2+n1)\n",
      "P= R*(273.15+T)*x2/(M*vf)\n",
      "P1=  R*(273.15+T)*x21/(M*vf)\n",
      "##RESULTS\n",
      "print'%s %.1f %s'%('Osmotic pressure=',P,'kpa')\n",
      "print'%s %.1f %s'%('Osmotic pressure=',P1,'kpa')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Osmotic pressure= 1491.4 kpa\n",
        "Osmotic pressure= 2950.2 kpa\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example6-pg495"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#what is useful work in the process and heat interaction and maximum work and irreversibility\n",
      "##initialisation of variables\n",
      "W= 0.\n",
      "Q= 0.\n",
      "R= 8.314 ##J/mol K\n",
      "T0= 300. ##K\n",
      "x= 5./13.\n",
      "n1= 0.5 ##kmol/s\n",
      "n2= 0.8 ##kmol/s\n",
      "##CALCULATIONS\n",
      "W1= (n1+n2)*R*T0*(x*math.log(1/x)+(1-x)*math.log(1./(1.-x)))+470\n",
      "I= W1\n",
      "##RESULTS\n",
      "print'%s %.f %s'%('useful work of the process=',W,'kW') \n",
      "print'%s %.f %s'%('heat interaction=',Q,'kW') \n",
      "print'%s %.1f %s'%('maximum work=',W1,'kW') \n",
      "print'%s %.1f %s'%('irreversibility=',I,'kW')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "useful work of the process= 0 kW\n",
        "heat interaction= 0 kW\n",
        "maximum work= 2630.4 kW\n",
        "irreversibility= 2630.4 kW\n"
       ]
      }
     ],
     "prompt_number": 8
    }
   ],
   "metadata": {}
  }
 ]
}