{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 3 : Properties of Pure Substances"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.1 page no : 76"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "m_s = 50. \t\t\t#kg\n",
      "m_w = 1.5; \t\t\t#kg\n",
      "\n",
      "# Calculations\n",
      "x = m_s/(m_s+m_w);\n",
      "\n",
      "# Results\n",
      "print (\"dryness fraction = %.3f\")%(x)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "dryness fraction = 0.971\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.2 page no : 76"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "V = 0.6; \t\t\t#m**3\n",
      "m = 3.0; \t\t\t#kg\n",
      "p = 5.; \t\t\t#bar\n",
      "v = V/m;\n",
      "\n",
      "# At 5 bar: From steam tables\n",
      "v_g = 0.375; \t\t\t#m**3/kg\n",
      "v_f = 0.00109; \t\t\t#m**3/kg\n",
      "\n",
      "# Calculations\n",
      "v_fg = v_g - v_f;\n",
      "x = 1-((v_g - v)/v_fg);\n",
      "\n",
      "# Results\n",
      "print (\"(i) Mass and volume of liquid\")\n",
      "m_liq = m*(1-x);\n",
      "print (\"mass of liquid = %.3f\")%(m_liq),(\"kg\")\n",
      "V_liq = m_liq*v_f;\n",
      "print (\"volume of liquid = %.3f\")%(V_liq),(\"m**3\")\n",
      "\n",
      "print (\"(ii) Mass and volume of vapour\")\n",
      "m_vap = m*x;\n",
      "print (\"mass of vapour = %.3f\")%(m_vap),(\"kg\")\n",
      "V_vap = m_vap*v_g;\n",
      "print (\"volume of vapour = %.3f\")%(V_vap),(\"m**3\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Mass and volume of liquid\n",
        "mass of liquid = 1.404 kg\n",
        "volume of liquid = 0.002 m**3\n",
        "(ii) Mass and volume of vapour\n",
        "mass of vapour = 1.596 kg\n",
        "volume of vapour = 0.598 m**3\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.3 page no : 76"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "V = 0.05; \t\t\t#m**3\n",
      "m_f = 10.; \t\t\t#kg\n",
      "# From steam tables corresponding to 245 0C\n",
      "p_sat = 36.5; \t\t\t#bar\n",
      "v_f = 0.001239; \t\t\t#m**3/kg\n",
      "v_g = 0.0546; \t\t\t#m**3/kg\n",
      "h_f = 1061.4; \t\t\t#kJ/kg\n",
      "h_fg = 1740.2; \t\t\t#kJ/kg\n",
      "s_f = 2.7474; \t\t\t#kJ/kg.K\n",
      "s_fg = 3.3585; \t\t\t#kJ/kg.K\n",
      "\n",
      "# Calculations and Results\n",
      "print (\"(i) The pressure = \"),(p_sat),(\"bar\")\n",
      "\n",
      "print (\"(ii) The mass\")\n",
      "V_f = m_f*v_f;\n",
      "V_g = V - V_f;\n",
      "m_g = V_g/v_g;\n",
      "m = m_f+m_g;\n",
      "print (\"The total mass of mixture = %.3f\")%(m),(\"kg\")\n",
      "\n",
      "print (\"(iii) The specific volume\")\n",
      "v_fg = v_g-v_f;\n",
      "x =  m_g/(m_g+ m_f);\n",
      "v = v_f+x*v_fg;\n",
      "print (\"specific volume = %.3f\")%(v),(\"m**3/kg\")\n",
      "\n",
      "print (\"(iv)The specific enthalpy\")\n",
      "h = h_f+x*h_fg;\n",
      "print (\"specific enthalpy = %.3f\")%(h),(\"kJ/kg\")\n",
      "\n",
      "print (\"(v)The specific entropy\")\n",
      "s = s_f+x*s_fg;\n",
      "print (\"specific entropy  = %.3f\")%(s),(\"kJ/kg.K\")\n",
      "\n",
      "print (\"(vi)The specific internal enegy\")\n",
      "u = h-(p_sat*v*10**2); \t\t\t#kJ/kg\n",
      "print (\"specific internal energy = %.3f\")%(u),(\"kJ/kg\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) The pressure =  36.5 bar\n",
        "(ii) The mass\n",
        "The total mass of mixture = 10.689 kg\n",
        "(iii) The specific volume\n",
        "specific volume = 0.005 m**3/kg\n",
        "(iv)The specific enthalpy\n",
        "specific enthalpy = 1173.545 kJ/kg\n",
        "(v)The specific entropy\n",
        "specific entropy  = 2.964 kJ/kg.K\n",
        "(vi)The specific internal enegy\n",
        "specific internal energy = 1156.471 kJ/kg\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.4 page no : 77"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "m_w = 2.; \t\t\t#kg\n",
      "t_w = 25.; \t\t\t#0C\n",
      "p = 5.; \t\t\t#bar\n",
      "x = 0.9;\n",
      "c_pw = 4.18;\n",
      "# at 5 bar; from steam tables\n",
      "h_f = 640.1; \t\t\t#kJ/kg\n",
      "h_fg = 2107.4; \t\t\t#kJ/kg\n",
      "\n",
      "# Calculations and Results\n",
      "h = h_f+x*h_fg;\n",
      "\n",
      "Qw = c_pw*(t_w-0);\n",
      "print (\"Sensible heat associated with 1kg of water, Qw = %.3f\")%(Qw),(\"kJ\")\n",
      "\n",
      "Q = h-Qw;\n",
      "print (\"Net quantity of heat to be supplies per kg of water, Q = %.3f\")%(Q),(\"kJ\")\n",
      "\n",
      "Q_total = m_w*Q;\n",
      "print (\"Total amount of heat supplied, Q_total = \"),(Q_total),(\"kJ\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Sensible heat associated with 1kg of water, Qw = 104.500 kJ\n",
        "Net quantity of heat to be supplies per kg of water, Q = 2432.260 kJ\n",
        "Total amount of heat supplied, Q_total =  4864.52 kJ\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.5 page no : 78"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "m = 4.4; \t\t\t#kg\n",
      "p = 6.; \t\t\t#bar\n",
      "t_sup = 250.; \t\t\t#0C\n",
      "t_w =  30.; \t\t\t#0C\n",
      "c_ps = 2.2; \t\t\t#kJ/kg\n",
      "c_pw = 4.18;\n",
      "# At 6 bar, 250 0C; From steam tables\n",
      "t_s = 158.8; \t\t\t#0C\n",
      "h_f = 670.4; \t\t\t#kJ/kg\n",
      "h_fg = 2085; \t\t\t#kJ/kg\n",
      "\n",
      "# Calculations and Results\n",
      "h_sup = h_f+h_fg+ c_ps*(t_sup-t_s);\n",
      "\n",
      "Qw = c_pw*(t_w-0);\n",
      "print (\"Amount of heat added per kg of water, Qw = \"),(Qw)\n",
      "\n",
      "Q = h_sup-Qw;\n",
      "print (\"Net amount of heat required to be supplied per kg, Q = \"),(Q)\n",
      "\n",
      "Q_total = m*Q;\n",
      "print (\"Total amount of heat required, Q_total = \"),(Q_total),(\"kJ\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Amount of heat added per kg of water, Qw =  125.4\n",
        "Net amount of heat required to be supplied per kg, Q =  2830.64\n",
        "Total amount of heat required, Q_total =  12454.816 kJ\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.6 page no : 78"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "v = 0.15; \t\t\t#m**3\n",
      "p = 4.; \t\t\t#bar\n",
      "x = 0.8;\n",
      "# At 4 bar: From steam tables\n",
      "v_g = 0.462; \t\t\t#m**3/kg\n",
      "h_f =  604.7; \t\t\t#kJ/kg\n",
      "h_fg = 2133.; \t\t\t#kJ/kg\n",
      "\n",
      "# Calculations and Results\n",
      "density = 1/x/v_g;\n",
      "\n",
      "m = v*density;\n",
      "print (\"mass of 0.15 m**3 steam, m = %.3f\")%(m),(\"kg\")\n",
      "\n",
      "Q = density*(h_f+x*h_fg);\n",
      "print (\"Total heat of 1 m3 of steam which has a mass of 2.7056 kg, Q = %.3f\")%(Q),(\"kJ\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "mass of 0.15 m**3 steam, m = 0.406 kg\n",
        "Total heat of 1 m3 of steam which has a mass of 2.7056 kg, Q = 6252.976 kJ\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.7 page no : 78"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "m = 1000.; \t\t\t#kJ/kg.K\n",
      "p = 16.; \t\t\t#bar\n",
      "x = 0.9;\n",
      "T_sup = 653.; \t\t\t#K\n",
      "T_w = 30.; \t\t\t#0C\n",
      "c_ps = 2.2; \t\t\t#kJ/kg\n",
      "c_pw = 4.18;\n",
      "# At 16 bar:From steam tables\n",
      "T_s = 474.4; \t\t\t#K\n",
      "h_f = 858.6; \t\t\t#kJ/kg\n",
      "h_fg = 1933.2; \t\t\t#kJ/kg\n",
      "\n",
      "# Calculations and Results\n",
      "H = m*((h_f+x*h_fg)-c_pw*(T_w-0));\n",
      "print (\"(i) Heat supplied to feed water per hour to produce wet steam is given by\"),(H),(\"kJ\")\n",
      "\n",
      "Q = m*((1-x)*h_fg+c_ps*(T_sup-T_s));\n",
      "print (\"(ii) Heat absorbed by superheater per hour, Q = \"),(Q),(\"kJ\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Heat supplied to feed water per hour to produce wet steam is given by 2473080.0 kJ\n",
        "(ii) Heat absorbed by superheater per hour, Q =  586240.0 kJ\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.8 page no : 79"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print (\"(i) at 0.75 bar, between 100\u00b0C and 150\u00b0C\")\n",
      "\n",
      "# Variables\n",
      "# At 100 \u00b0C\n",
      "T1 = 100.; \t\t\t#\u00b0C\n",
      "h_sup1 = 2679.4; \t\t\t#kJ/kg\n",
      "# At 150 \u00b0C\n",
      "T2 = 150.; \t\t\t#\u00b0C\n",
      "h_sup2 = 2778.2; \t\t\t#kJ/kg\n",
      "\n",
      "# Calculations and Results\n",
      "c_ps = (h_sup2-h_sup1)/(T2-T1);\n",
      "print (\"mean specific heat = \"),(c_ps)\n",
      "\n",
      "print (\"(ii) at 0.5 bar, between 300\u00b0C and 400\u00b0C\")\n",
      "T1 = 300; \t\t\t#\u00b0C\n",
      "h_sup1 = 3075.5; \t#kJ/kg\n",
      "T2 = 400; \t\t\t#\u00b0C\n",
      "h_sup2 = 3278.9; \t#kJ/kg\n",
      "\n",
      "c_ps = (h_sup2-h_sup1)/(T2-T1);\n",
      "print (\"mean specific heat c_ps = \"),(c_ps)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) at 0.75 bar, between 100\u00b0C and 150\u00b0C\n",
        "mean specific heat =  1.976\n",
        "(ii) at 0.5 bar, between 300\u00b0C and 400\u00b0C\n",
        "mean specific heat c_ps =  2.034\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.9 page no : 79"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "m = 1.5; \t\t\t#kg\n",
      "p = 5.; \t\t\t#bar\n",
      "x1 = 1.;\n",
      "x2 = 0.6;\n",
      "p1 = 5.*10**5; \t\t\t#N/m\n",
      "# At 5 bar: From steam tables\n",
      "t_s = 151.8; \t\t\t#0C\n",
      "h_f = 640.1; \t\t\t#kJ/kg\n",
      "h_fg = 2107.4; \t\t\t#kJ/kg\n",
      "v_g = 0.375; \t\t\t#m**3/kg\n",
      "v_g1 = 0.375*10**(-3);\n",
      "\n",
      "# Calculations and Results\n",
      "h1 = h_f+h_fg;\n",
      "V = m*v_g;\n",
      "u1 = h1-p1*v_g1;\n",
      "v_g2 = V/m/x2; \t\t\t#m**3/kg\n",
      "\n",
      "# From steam table corresponding to 0.625 m**3/kg\n",
      "p2 = 2.9; \t\t\t#bar\n",
      "print (\"Pressure at new state  = \"),(p2),(\"bar\")\n",
      "\n",
      "t_s = 132.4; \t\t\t#0C\n",
      "print (\"Temperature at new state  = \"),(t_s),(\"\u00b0C\")\n",
      "h_f2 = 556.5; \t\t\t#kJ/kg\n",
      "h_fg2 = 2166.6; \t\t\t#kJ/kg\n",
      "u2 = (h_f2+x2*h_fg2)-p2*x2*v_g2*10**2;\n",
      "\n",
      "Q = u2-u1; \t\t\t#heat transferred at consmath.tant volume per kg\n",
      "\n",
      "Q_total = m*Q;\n",
      "print (\"Total heat transfered,Q_total = \"),(Q_total),(\"kJ\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure at new state  =  2.9 bar\n",
        "Temperature at new state  =  132.4 \u00b0C\n",
        "Total heat transfered,Q_total =  -1218.435 kJ\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.10 page no : 80"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "V = 0.9; \t\t\t#m**3\n",
      "p1 = 8.; \t\t\t#bar\n",
      "x1 = 0.9;\n",
      "p2 = 4.; \t\t\t#bar\n",
      "p3 = 3.; \t\t\t#bar\n",
      "v_g1 = 0.24; \t\t#m**3/kg\n",
      "\n",
      "print (\"(i) The mass of steam blown off :\")\n",
      "m1 = V/x1/v_g1;\n",
      "h_f1 = 720.9; \t\t\t#kJ/kg\n",
      "h_fg1 = 2046.5; \t\t#kJ/kg\n",
      "h_f2 = 604.7; \t\t\t#kJ/kg\n",
      "h_fg2 = 2133; \t\t\t#kJ/kg\n",
      "v_g2 = 0.462; \t\t\t#m**3/kg\n",
      "\n",
      "# Calculations and Results\n",
      "h1 = h_f1+x1*h_fg1; \t\t\t#The enthalpy of steam before blowing off\n",
      "h2 = h1;\n",
      "x2 = (h1-h_f2)/h_fg2;\n",
      "m2 = x1/(x2*v_g2);\n",
      "\n",
      "m = m1-m2;\n",
      "print (\"Mass of steam blown off  = %.3f\")%(m),(\"kg\")\n",
      "\n",
      "print (\"(ii) Dryness fraction of steam in the vessel after cooling\")\n",
      "v_g3 = 0.606; \t\t\t#m**3/kg\n",
      "x3 = x2*v_g2/v_g3;\n",
      "print (\"dryness fraction  = %.4f\")%(x3)\n",
      "x3 = 0.699\n",
      "\n",
      "print (\"(iii) Heat lost during cooling\")\n",
      "h_f3 = 561.4; \t\t\t    #kJ/kg\n",
      "h_fg3 = 2163.2; \t\t\t#kJ/kg\n",
      "h3 = h_f3+x3*h_fg3;\n",
      "u2 = h2-p2*x2*v_g2*10**2; \t\t\t#kJ/kg\n",
      "u3 = h3-p3*x3*v_g3*10**2; \t\t\t#kJ/kg\n",
      "Q = m*(u3-u2);\n",
      "print (\"Heat lost during cooling = %.3f\")%(-Q),(\"kJ\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) The mass of steam blown off :\n",
        "Mass of steam blown off  = 2.045 kg\n",
        "(ii) Dryness fraction of steam in the vessel after cooling\n",
        "dryness fraction  = 0.6998\n",
        "(iii) Heat lost during cooling\n",
        "Heat lost during cooling = 913.322 kJ\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.11 page no : 82"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "p = 8*10**5; \t\t\t#Pa\n",
      "x = 0.8; \n",
      "v_g = 0.240; \t\t\t#m**3/kg\n",
      "h_fg = 2046.5; \t\t\t#kJ/kg\n",
      "\n",
      "# Calculations and Results\n",
      "print (\"(i) External work done during evaporation\")\n",
      "W = p*x*v_g/10**3; \t\t\t#kJ\n",
      "print (\"W = \"),(W),(\"kJ\")\n",
      "\n",
      "print (\"(ii) Internal latent heat\")\n",
      "Q = x*h_fg-W;\n",
      "print (\"Q = \"),(Q),(\"kJ\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) External work done during evaporation\n",
        "W =  153.6 kJ\n",
        "(ii) Internal latent heat\n",
        "Q =  1483.6 kJ\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.12 page no : 82"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "p1 = 10; \t\t\t#bar\n",
      "import math \n",
      "p2 = 10; \t\t\t#bar\n",
      "x1 = 0.85;\n",
      "V1 = 0.15; \t\t\t#m**3\n",
      "t_sup2 = 300; \t\t\t#0C\n",
      "t_sup1 = 179.9; \t\t\t#0C\n",
      "c_ps = 2.2; \t\t\t#kJ/kg.K\n",
      "v_g1 = 0.194; \t\t\t#m**3/kg\n",
      "m = V1/(x1*v_g1);\n",
      "h_fg1 = 2013.6; \t\t\t#kJ/kg\n",
      "Q = (1-x1)*h_fg1+c_ps*(t_sup2-t_sup1);\n",
      "Q_total = m*Q;\n",
      "\n",
      "print (\"Total heat supplied = %.3f\")%(Q_total),(\"kJ\")\n",
      "\n",
      "v_sup2 = v_g1*(t_sup2+273)/(t_sup1+273)\n",
      "W = p1*(v_sup2 - (x1*v_g1))*10**2;\n",
      "Percentage = W/Q*100;\n",
      "\n",
      "print (\"Percentage of total heat supplied = %.3f\")%(Percentage),(\"%\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total heat supplied = 515.094 kJ\n",
        "Percentage of total heat supplied = 14.224 %\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.13 page no : 83"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "p = 18.; \t\t\t#bar\n",
      "x = 0.85;\n",
      "h_f = 884.6; \t\t\t#kJ/kg\n",
      "h_fg = 1910.3; \t\t\t#kJ/kg\n",
      "v_g = 0.110; \t\t\t#m**3/kg\n",
      "u_f = 883.; \t\t\t#kJ/kg\n",
      "u_g = 2598.; \t\t\t#kJ/kg\n",
      "\n",
      "# Calculations and Results\n",
      "v = x*v_g;\n",
      "print (\"Specific volume of wet steam = \"),(v),(\"m**3/kg\")\n",
      "\n",
      "h = h_f+x*h_fg;\n",
      "print (\"Specific enthalpy of wet steam = \"),(h),(\"kJ/kg\")\n",
      "u = (1-x)*u_f+ x*u_g;\n",
      "print (\"Specific internal energy of wet steam  = \"),(u),(\"kJ/kg\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Specific volume of wet steam =  0.0935 m**3/kg\n",
        "Specific enthalpy of wet steam =  2508.355 kJ/kg\n",
        "Specific internal energy of wet steam  =  2340.75 kJ/kg\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.14 page no : 83"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "p = 7.; \t\t\t#bar\n",
      "h = 2550.; \t\t\t#kJ/kg\n",
      "h_f = 697.1; \t\t\t#kJ/kg\n",
      "h_fg = 2064.9; \t\t\t#kJ/kg\n",
      "v_g = 0.273; \t\t\t#m**3/kg\n",
      "u_f = 696.; \t\t\t#kJ/kg\n",
      "u_g = 2573.; \t\t\t#kJ/kg\n",
      "\n",
      "# Calculations and Results\n",
      "x = (h-h_f)/h_fg;\n",
      "print (\"(i) Dryness fraction = %.3f\")%(x)\n",
      "\n",
      "v = x*v_g;\n",
      "print (\"(ii) Specific volume of wet steam  = %.3f\")%(v),(\"m**3/kg\")\n",
      "\n",
      "u = (1-x)*u_f+ x*u_g;\n",
      "print (\"(iii) Specific internal energy of wet steam = %.3f\")%(u),(\"kJ/kg\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Dryness fraction = 0.897\n",
        "(ii) Specific volume of wet steam  = 0.245 m**3/kg\n",
        "(iii) Specific internal energy of wet steam = 2380.291 kJ/kg\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.15 page no : 84"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "p = 120.; \t\t\t#bar\n",
      "v = 0.01721; \t\t\t#m**3/kg\n",
      "\n",
      "T = 350.; \t\t\t#\u00b0C\n",
      "print (\"Temperature = \"), (T),(\"\u00b0C\")\n",
      "\n",
      "h = 2847.7; \t\t\t#kJ/kg\n",
      "print (\"specific enthalpy = \"), (h),(\"kJ/kg\")\n",
      "\n",
      "u = h-p*v*10**2; \t\t\t#kJ/kg\n",
      "print (\"Internal energy = \"), (u),(\"kJ/kg\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Temperature =  350.0 \u00b0C\n",
        "specific enthalpy =  2847.7 kJ/kg\n",
        "Internal energy =  2641.18 kJ/kg\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.16 page no : 84"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "p = 140.; \t\t\t#bar\n",
      "h = 3001.9; \t\t\t#kJ/kg\n",
      "T = 400; \t\t\t#0C\n",
      "\n",
      "# Calculations and Results\n",
      "print (\"Temperature = \"),(T), (\"\u00b0C\")\n",
      "\n",
      "v = 0.01722; \t\t\t#m**3/kg\n",
      "print (\"The specific volume %.3f\")%(v), (\"m**3/kg\")\n",
      "\n",
      "u = h-p*v*10**2;\n",
      "print (\"specific internal energy = \"),(u),(\"kJ/kg\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Temperature =  400 \u00b0C\n",
        "The specific volume 0.017 m**3/kg\n",
        "specific internal energy =  2760.82 kJ/kg\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.17 page no : 85"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# At 10 bar: From steam table for superheated steam\n",
      "\n",
      "# Variables\n",
      "h_sup = 3051.2; \t\t\t#kJ/kg\n",
      "T_sup = 573; \t\t\t#K\n",
      "T_s = 452.9; \t\t\t#K\n",
      "v_g = 0.194; \t\t\t#m**3/kg\n",
      "v_sup = v_g*T_sup/T_s;\n",
      "p = 10.; \t\t\t#bar\n",
      "\n",
      "# Calculations and Results\n",
      "u1 = h_sup-p*v_sup*10**2; \t\t\t#kJ/kg\n",
      "print (\"Internal energy of superheated steam at 10 bar =  %.3f\")%(u1), (\"kJ/kg\")\n",
      "\n",
      "# At 1.4 bar: From steam tables\n",
      "p = 1.4; \t\t\t#bar\n",
      "h_f = 458.4; \t\t\t#kJ/kg\n",
      "h_fg = 2231.9; \t\t\t#kJ/kg\n",
      "v_g = 1.236; \t\t\t#m**3/kg\n",
      "x = 0.8;\n",
      "h = h_f+x*h_fg;\n",
      "u2 = h-p*x*v_g*10**2; \t\t\t#kJ\n",
      "du = u2-u1;\n",
      "print (\"Change in internal energy = %.3f\")%(du),(\"kJ\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Internal energy of superheated steam at 10 bar =  2805.755 kJ/kg\n",
        "Change in internal energy = -700.267 kJ\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.18 page no : 85"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "m = 1.; \t\t\t#kg\n",
      "p = 20.; \t\t\t#bar\n",
      "T_sup = 400.; \t\t\t#0C\n",
      "x = 0.9;\n",
      "c_ps = 2.3; \t\t\t#kJ/kg.K\n",
      "\n",
      "print (\"(i) Internal energy of 1 kg of superheated steam\")\n",
      "# At 20 bar: From steam tables\n",
      "T_s = 212.4; \t\t\t#0C\n",
      "h_f = 908.6; \t\t\t#kJ/kg\n",
      "h_fg = 1888.6; \t\t\t#kJ/kg\n",
      "v_g = 0.0995; \t\t\t#m**3/kg\n",
      "\n",
      "# Calculations and Results\n",
      "h_sup  =  h_f+h_fg+c_ps*(T_sup-T_s);\n",
      "v_sup = v_g*(T_sup+273)/(T_s+273);\n",
      "u = h_sup-p*v_sup*10**2;\n",
      "print (\"Internal energy = %.3f\")%(u),(\"kJ/kg\")\n",
      "\n",
      "print (\"(ii) Internal energy of 1 kg of wet steam\")\n",
      "h = h_f+x*h_fg;\n",
      "u = h-p*x*v_g*10**2;\n",
      "print (\"Internal energy = %.3f\")%(u),(\"kJ/kg\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Internal energy of 1 kg of superheated steam\n",
        "Internal energy = 2952.769 kJ/kg\n",
        "(ii) Internal energy of 1 kg of wet steam\n",
        "Internal energy = 2429.240 kJ/kg\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.19 page no : 86"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "h_g1 = 2797.2; \t\t\t#kJ/kg\n",
      "c_ps =  2.25;\n",
      "T_sup = 350.; \t\t\t#0C\n",
      "T_s = 212.4; \t\t\t#0C\n",
      "\n",
      "# Calculations\n",
      "h1 = h_g1+c_ps*(T_sup-T_s);\n",
      "h_f2 = 908.6; \t\t\t#kJ/kg\n",
      "h_fg2 = 1888.6; \t\t\t#kJ/kg\n",
      "\n",
      "# Main:20 bar, 250 0C\n",
      "T_sup = 250.; \t\t\t#0C\n",
      "Q = 2*(h_g1+c_ps*(T_sup-T_s));\n",
      "x2 = (Q-h1-h_f2)/h_fg2;\n",
      "\n",
      "# Results\n",
      "print (\"Quality of steam %.3f\")%(x2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Quality of steam 0.926\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.20 page no : 87"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Variables\n",
      "m = 1.; \t\t\t#kg\n",
      "p = 6.; \t\t\t#bar\n",
      "x = 0.8;\n",
      "T_s = 473.; \t\t\t#K\n",
      "h_fg = 2085.; \t\t\t#kJ/kg\n",
      "c_pw = 4.18;\n",
      "\n",
      "# Calculations\n",
      "s_wet = c_pw*math.log(T_s/273)+x*h_fg/T_s;\n",
      "\n",
      "# Results\n",
      "print (\"Entropy of wet steam = %.3f\")%(s_wet),(\"kJ/kg.K\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Entropy of wet steam = 5.824 kJ/kg.K\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.21 page no : 87"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "p1 = 10.; \t\t\t#bar\n",
      "t_sup = 400.; \t\t#0C\n",
      "p2 = 0.2; \t\t\t#bar\n",
      "x2 = 0.9;\n",
      "h_sup = 3263.9; \t\t\t#kJ/kg\n",
      "s_sup = 7.465;  \t\t\t#kJ/kg\n",
      "h1 = 3263.9; \t\t\t#kJ/kg\n",
      "s1 = s_sup;\n",
      "h_f2 = 251.5; \t\t\t#kJ/kg\n",
      "h_fg2 = 2358.4; \t\t#kJ/kg\n",
      "s_f2 = 0.8321; \t\t\t#kJ/kg.K\n",
      "s_g2 = 7.9094; \t\t\t#kJ/kg.K\n",
      "\n",
      "# Calculations and Results\n",
      "s_fg2 = s_g2-s_f2;\n",
      "h2 = h_f2+x2*h_fg2;\n",
      "s2 = s_f2+x2*s_fg2;\n",
      "\n",
      "print (\"(i) Drop in enthalpy\")\n",
      "dh = h1-h2;\n",
      "print (\"Drop in enthalpy  =  %.3f\")%(dh),(\"kJ/kg\")\n",
      "\n",
      "print (\"(ii) Change in entropy\")\n",
      "ds = s1-s2;\n",
      "print (\"Change in entropy  =  %.3f\")%(ds),(\"kJ/kg.K\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Drop in enthalpy\n",
        "Drop in enthalpy  =  889.840 kJ/kg\n",
        "(ii) Change in entropy\n",
        "Change in entropy  =  0.263 kJ/kg.K\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.22 page no : 88"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "m = 1.; \t\t    \t    #kg\n",
      "p = 12.; \t\t    \t#bar\n",
      "T_sup = 523.; \t\t\t#K\n",
      "c_ps = 2.1; \t\t\t#kJ/kg.K\n",
      "T_s = 461.; \t\t\t#K\n",
      "h_fg = 1984.3; \t\t\t#kJ/kg\n",
      "c_pw = 4.18;\n",
      "\n",
      "# Calculations\n",
      "s_sup = c_pw*math.log(T_s/273)+h_fg/T_s+c_ps*math.log(T_sup/T_s);\n",
      "\n",
      "# Results\n",
      "print (\"Entropy  = %.3f\")%(s_sup),(\"kJ/kg.K\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Entropy  = 6.759 kJ/kg.K\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.23 page no : 88"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "m = 3.; \t\t\t#kg\n",
      "v1 = 0.75; \t\t\t#m**3/kg\n",
      "v2 = 1.2363; \t\t\t#m**3/kg\n",
      "x = v1/v2;\n",
      "h_f = 458.4; \t\t\t#kJ/kg\n",
      "h_fg = 2231.9; \t\t\t#kJ/kg\n",
      "h_s = m*(h_f+x*h_fg); \t\t\t#kJ\n",
      "v_sup = 1.55; \t\t\t#m**3/kg\n",
      "p = 2; \t\t\t#bar\n",
      "t_s = 120.2; \t\t\t#0C\n",
      "t_sup = 400; \t\t\t#0C\n",
      "h = 3276.6; \t\t\t#kJ/kg\n",
      "U = 1708.; \t\t\t#kJ/kg\n",
      "\n",
      "# Calculations and Results\n",
      "Degree = t_sup-t_s;\n",
      "h_sup = m*h;\n",
      "\n",
      "Q_added = h_sup - h_s;\n",
      "print (\"Heat added  = %.3f\")%(Q_added),(\"kJ\")\n",
      "\n",
      "U_s = m*U;\n",
      "U_sup = m*(h-p*v_sup*10**2);\n",
      "dU =  U_sup - U_s;\n",
      "W = Q_added - dU;\n",
      "print (\"work done  =  %.3f\")%(W),(\"kJ\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat added  = 4392.661 kJ\n",
        "work done  =  616.861 kJ\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.24 page no : 91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "p = 5.; \t\t\t#bar\n",
      "m = 50.; \t\t\t#kg\n",
      "T1 = 20.; \t\t\t#0C\n",
      "m_s = 3.; \t\t\t#kg\n",
      "T2 = 40.; \t\t\t#0C\n",
      "m_eq = 1.5; \t\t\t#kg\n",
      "h_f = 640.1; \t\t\t#kJ/kg\n",
      "h_fg = 2107.4; \t\t\t#kJ/kg\n",
      "c_pw = 4.18;\n",
      "\n",
      "# Calculations\n",
      "m_w = m+m_eq;\n",
      "x = ((m_w*c_pw*(T2-T1))/m_s + c_pw*T2 - h_f)/h_fg;\n",
      "\n",
      "# Results\n",
      "print (\"Dryness fraction of steam %.3f\")%(x)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Dryness fraction of steam 0.457\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.25 page no : 91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "p = 1.1; \t\t\t#bar\n",
      "x = 0.95;\n",
      "c_pw = 4.18;\n",
      "m1 = 90.; \t\t\t#kg\n",
      "m2 = 5.25; \t\t\t#kg\n",
      "T1 = 25.; \t\t\t#0C\n",
      "T2 = 40.; \t\t\t#0C\n",
      "\n",
      "# Calculations\n",
      "m = m1+m2;\n",
      "h_f = 428.8; \t\t\t#kJ/kg\n",
      "h_fg =  2250.8; \t\t\t#kJ/kg\n",
      "m_s =  (m*c_pw*(T2-T1))/((h_f + x*h_fg) - c_pw*T2)\n",
      "\n",
      "# Results\n",
      "print (\"Mass of steam condensed = %.3f\")%(m_s),(\"kg\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mass of steam condensed = 2.489 kg\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.26 page no : 93"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "p1 = 8.; \t\t\t#bar\n",
      "p2 = 1.; \t\t\t#bar\n",
      "T_sup2 = 115.; \t\t#0C\n",
      "T_s2 = 99.6; \t\t#0C\n",
      "h_f1 = 720.9; \t\t#kJ/kg\n",
      "h_fg1 = 2046.5; \t#kJ/kg\n",
      "h_f2 = 417.5; \t\t#kJ/kg\n",
      "h_fg2 = 2257.9; \t#kJ/kg\n",
      "c_ps = 2.1;\n",
      "\n",
      "# Calculations\n",
      "x1 = (h_f2+h_fg2+c_ps*(T_sup2-T_s2)-h_f1)/h_fg1;\n",
      "\n",
      "# Results\n",
      "print (\"Dryness fraction of the steam in the main  =  %.3f\")%(x1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Dryness fraction of the steam in the main  =  0.971\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.27 page no : 94"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "m_w = 2.; \t\t\t#kg\n",
      "m_s = 20.5; \t\t#kg\n",
      "t_sup = 110.; \t\t#0C\n",
      "p1 = 12.; \t\t\t#bar\n",
      "p3 = 1.; \t\t\t#bar\n",
      "p2 = p1;\n",
      "h_f2 = 798.4; \t\t#kJ/kg\n",
      "h_fg2 = 1984.3; \t#kJ/kg\n",
      "T_s = 99.6; \t\t#0C\n",
      "h_f3 = 417.5; \t\t#kJ/kg\n",
      "h_fg3 = 2257.9; \t#kJ/kg\n",
      "T_sup = 110.; \t\t#0C\n",
      "c_ps = 2.; \t\t\t#kJ/kg.K\n",
      "\n",
      "# Calculations\n",
      "x2 = (h_f3+h_fg3 + c_ps*(T_sup-T_s) - h_f2)/h_fg2;\n",
      "x1 = x2*m_s/(m_w+m_s);\n",
      "\n",
      "# Results\n",
      "print (\"Quality of steam supplied  =  %.3f\")%(x1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Quality of steam supplied  =  0.871\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.28 page no : 95"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "p1 = 15.; \t\t\t#bar\n",
      "p2 = p1;\n",
      "p3 = 1.; \t\t\t#bar\n",
      "t_sup3 = 150.; \t\t#0C\n",
      "m_w = 0.5; \t\t\t#kg/min\n",
      "m_s = 10.; \t\t\t#kg/min\n",
      "h_f2 = 844.7; \t\t#kJ/kg\n",
      "h_fg2 = 1945.2; \t#kJ/kg\n",
      "h_sup3 = 2776.4; \t#kJ/kg\n",
      "\n",
      "# Calculations\n",
      "x2 = (h_sup3 - h_f2)/h_fg2;\n",
      "x1 = x2*m_s/(m_s + m_w);\n",
      "\n",
      "\n",
      "# Results\n",
      "print (\"Quality of steam supplied  =  %.3f\")%(x1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Quality of steam supplied  =  0.946\n"
       ]
      }
     ],
     "prompt_number": 30
    }
   ],
   "metadata": {}
  }
 ]
}