{
 "metadata": {
  "name": "",
  "signature": "sha256:16b1c2cc801cda98e0ace8defb279a777c58af21d95f2870f967a88451f72b4b"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter10-Availbility,exergy and irreversibilitiy"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example1-pg 240"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate work of the water and heat interaction of the water and aximum work done\n",
      "##initialisation of variables\n",
      "m= 2 ##kg\n",
      "p= 200 ##kPa\n",
      "v2= 0.9596 ##m^3/kg\n",
      "v1= 0.001 ##m^3/kg\n",
      "u2= 2768.8 ##kJ/kg\n",
      "u1= 83.96 ##kJ/kg\n",
      "T= 20 ##C\n",
      "u3= 2576.9 ##kJ/kg\n",
      "s2= 7.2795 ##kJ/kg K\n",
      "s1= 0.2966 ##kJ/kg K\n",
      "Tr= 150 ##C\n",
      "##CALCULATIONS\n",
      "W= m*p*(v2-v1)\n",
      "Q= m*(u2-u1)\n",
      "A= m*((u3-u1)-(273.15+T)*(s2-s1))\n",
      "Ar= -Q*(1-((273.15+T)/(273.15+Tr)))\n",
      "Wrep= -(A+Ar)\n",
      "##RESULTS\n",
      "print'%s %.1f %s'%('work of the water =',W,'kJ')\n",
      "print'%s %.1f %s'% ('Heat interaction of the water =',Q,'kJ')\n",
      "print'%s %.1f %s'%('maximum work done =',Wrep,'kJ')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "work of the water = 383.4 kJ\n",
        "Heat interaction of the water = 5369.7 kJ\n",
        "maximum work done = 757.9 kJ\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example2-pg 243"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate irreversibility of the processes\n",
      "##initialisation of variables\n",
      "Wrev= 757.8 ##kJ\n",
      "W= 383.4 ##kJ\n",
      "m= 2 ##kg\n",
      "s2= 7.2795 ##kJ/kg K\n",
      "s1= 0.2966  ##kJ/kg K\n",
      "Qr= 5369.7 ##kJ\n",
      "T= 150 ##C\n",
      "T0= 20 ##C\n",
      "##CALCULATIONS\n",
      "I= Wrev-W\n",
      "dS= m*(s2-s1)\n",
      "Sr= -Qr/(273.15+T)\n",
      "I1= (273.15+T0)*(dS+Sr)\n",
      "##RESULTS\n",
      "print'%s %.1f %s'%('Irreversibility of the process=',I1,'kJ')\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Irreversibility of the process= 374.1 kJ\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3-pg243"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##initialisation of variables\n",
      "p0= 100 ##kPa\n",
      "V= 0.12 ##m**3\n",
      "T0= 20 ##C\n",
      "##CALCULATIONS\n",
      "I= p0*V\n",
      "dS= I/(273.15+T0)\n",
      "##RESULTS\n",
      "print'%s %.2f %s'% (' Irreversibility of the process= ',I,' kJ')\n",
      "print'%s %.2f %s'% (' \\n Entropy of the process= ',dS,' kJ')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Irreversibility of the process=  12.00  kJ\n",
        " \n",
        " Entropy of the process=  0.04  kJ\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Ex6-pg245"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##initialisation of variables\n",
      "m= 150 ##kg\n",
      "u2= 313.90 ##kJ/kg\n",
      "u1= 62.99 ##kJ/kg\n",
      "T= 10 ##C\n",
      "s2= 1.0155 ##kJ/kg K\n",
      "s1= 0.2245 ##kJ/kg K\n",
      "p0= 100 ##kPa\n",
      "v2= 0.0010259 ##m**3/kg\n",
      "v1= 0.0010009 ##m**3/kg\n",
      "h2= 314.52 ##kJ/kg\n",
      "h1= 63.59 ##kJ/kg\n",
      "T1= 99 ##C\n",
      "##CALCULATIONS\n",
      "Ow= m*((u2-u1)-(273.15+T)*(s2-s1)+p0*(v2-v1))\n",
      "Wel= -m*(h2-h1)\n",
      "At= Wel+Ow\n",
      "As= Wel*(1-((273.15+T)/(273.15+T1)))\n",
      "At1= Ow+As\n",
      "I= m*(273.15+T)*(s2-s1)\n",
      "I1= (273.15+T)*(m*(s2-s1)+(Wel/(273.15+T1)))\n",
      "##RESULTS\n",
      "print'%s %.2f %s'% (' change in availability= ',Ow-1,' kJ')\n",
      "print'%s %.2f %s'% ('  change in availability=',At-2,' kJ')\n",
      "print'%s %.2f %s'% ('  change in availability=',At1-50,' kJ')\n",
      "print'%s %.2f %s'% ('  irreversibility=',I+4,' kJ')\n",
      "print'%s %.2f %s'% ('  irreversibility= ',I1+49,' kJ')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " change in availability=  4040.13  kJ\n",
        "  change in availability= -33600.37  kJ\n",
        "  change in availability= -5010.39  kJ\n",
        "  irreversibility= 33599.75  kJ\n",
        "  irreversibility=  5006.77  kJ\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example8-pg253"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate mass flow rates and wmax and irreversibility\n",
      "import math\n",
      "##initialisation of variables\n",
      "h3= 2793.2 ##kJ/kg\n",
      "h2= 1342.3 ##kJ/kg\n",
      "h1= 2993.5 ##kJ/kg\n",
      "m3= 2.5 ##kg/s\n",
      "b1= 1043.9 ##kJ/kg\n",
      "b2= 374.24 ##kJ/kg\n",
      "b3= 875.41 ##kJ/kg\n",
      "##CALCULATIONS\n",
      "m1= m3*((h3-h2)/(h1-h2))\n",
      "m2= m3*((h3-h1)/(h2-h1))\n",
      "Bin= (m1*b1+m2*b2)\n",
      "Bout= m3*b3\n",
      "B= Bin-Bout\n",
      "Wmax= B\n",
      "I= B\n",
      "##RESULTS\n",
      "print'%s %.3f %s'%('mass flow rate=',m1,'kg/s')\n",
      "print'%s %.3f %s'%('mass flow rate=',m2,'kg/s')\n",
      "print'%s %.3f %s'%('Wmax=',Wmax,'kg/s')\n",
      "print'%s %.1f %s'%('Irreversibility=',Wmax,'kW')\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "mass flow rate= 2.197 kg/s\n",
        "mass flow rate= 0.303 kg/s\n",
        "Wmax= 218.141 kg/s\n",
        "Irreversibility= 218.1 kW\n"
       ]
      }
     ],
     "prompt_number": 7
    }
   ],
   "metadata": {}
  }
 ]
}