{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 6:Thermo dynamic Properties of pure substance"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.1;pg no: 174"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.1, Page:174  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 1\n",
      "NOTE=>In question no. 1 expression for various quantities is derived which cannot be solve using python software.\n"
     ]
    }
   ],
   "source": [
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.1, Page:174  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 1\")\n",
    "print(\"NOTE=>In question no. 1 expression for various quantities is derived which cannot be solve using python software.\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.2;pg no: 175"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.2, Page:175  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 2\n",
      "during throttling,h1=h2\n",
      "at state 2,enthalpy can be seen for superheated steam using Table 4 at 0.05 Mpa and 100 degree celcius\n",
      "thus h2=2682.5 KJ/kg\n",
      "at state 1,before throttling\n",
      "hf_10Mpa=1407.56 KJ/kg\n",
      "hfg_10Mpa=1317.1 KJ/kg\n",
      "h1=hf_10Mpa+x1*hfg_10Mpa\n",
      "dryness fraction(x1)may be given as\n",
      "x1= 0.97\n"
     ]
    }
   ],
   "source": [
    "#cal of dryness fraction\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.2, Page:175  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 2\")\n",
    "print(\"during throttling,h1=h2\")\n",
    "print(\"at state 2,enthalpy can be seen for superheated steam using Table 4 at 0.05 Mpa and 100 degree celcius\")\n",
    "print(\"thus h2=2682.5 KJ/kg\")\n",
    "h2=2682.5;\n",
    "print(\"at state 1,before throttling\")\n",
    "print(\"hf_10Mpa=1407.56 KJ/kg\")\n",
    "hf_10Mpa=1407.56;\n",
    "print(\"hfg_10Mpa=1317.1 KJ/kg\")\n",
    "hfg_10Mpa=1317.1;\n",
    "print(\"h1=hf_10Mpa+x1*hfg_10Mpa\")\n",
    "h1=h2;#during throttling\n",
    "print(\"dryness fraction(x1)may be given as\")\n",
    "x1=(h1-hf_10Mpa)/hfg_10Mpa\n",
    "print(\"x1=\"),round(x1,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.3;pg no: 176"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.3, Page:176  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 3\n",
      "internal energy(u)=in KJ/kg 2644.0\n"
     ]
    }
   ],
   "source": [
    "#cal of internal energy\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.3, Page:176  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 3\")\n",
    "h=2848;#enthalpy in KJ/kg\n",
    "p=12*1000;#pressure in Kpa\n",
    "v=0.017;#specific volume in m^3/kg\n",
    "u=h-p*v\n",
    "print(\"internal energy(u)=in KJ/kg\"),round(u,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.4;pg no: 176"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.4, Page:176  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 4\n",
      "steam state 2 Mpa and 300 degree celcius lies in superheated region as saturation temperature at 2 Mpa is 212.42 degree celcius and hfg=1890.7 KJ/kg\n",
      "entropy of unit mass of superheated steam with reference to absolute zero(S)in KJ/kg K\n",
      "S= 6.65\n",
      "entropy of 5 kg of steam(S)in KJ/K\n",
      "S=m*S 33.23\n"
     ]
    }
   ],
   "source": [
    "#cal of entropy of 5 kg of steam\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "import math\n",
    "print\"Example 6.4, Page:176  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 4\")\n",
    "m=5;#mass of steam in kg\n",
    "p=2;#pressure of steam in Mpa\n",
    "T_superheat=(300+273.15);#temperature of superheat steam in K\n",
    "Cp_water=4.18;#specific heat of water at constant pressure in KJ/kg K\n",
    "Cp_superheat=2.1;#specific heat of superheat steam at constant pressure in KJ/kg K\n",
    "print(\"steam state 2 Mpa and 300 degree celcius lies in superheated region as saturation temperature at 2 Mpa is 212.42 degree celcius and hfg=1890.7 KJ/kg\")\n",
    "T_sat=(212.42+273.15);#saturation temperature at 2 Mpa in K\n",
    "hfg_2Mpa=1890.7;\n",
    "print(\"entropy of unit mass of superheated steam with reference to absolute zero(S)in KJ/kg K\")\n",
    "S=Cp_water*math.log(T_sat/273.15)+(hfg_2Mpa/T_sat)+(Cp_superheat*math.log(T_superheat/T_sat))\n",
    "print(\"S=\"),round(S,2)\n",
    "print(\"entropy of 5 kg of steam(S)in KJ/K\")\n",
    "S=m*S\n",
    "print(\"S=m*S\"),round(S,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.5;pg no: 176"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.5, Page:176  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 5\n",
      "boiling point =110 degree celcius,pressure at which it boils=143.27 Kpa(from steam table,sat. pressure for 110 degree celcius)\n",
      "at further depth of 50 cm the pressure(p)in Kpa\n",
      "p= 138.37\n",
      "boiling point at this depth=Tsat_138.365\n",
      "from steam table this temperature=108.866=108.87 degree celcius\n",
      "so boiling point = 108.87 degree celcius\n"
     ]
    }
   ],
   "source": [
    "#cal of boiling point\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.5, Page:176  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 5\")\n",
    "rho=1000;#density of water in kg/m^3\n",
    "g=9.81;#acceleration due to gravity in m/s^2\n",
    "h=0.50;#depth from above mentioned level in m\n",
    "print(\"boiling point =110 degree celcius,pressure at which it boils=143.27 Kpa(from steam table,sat. pressure for 110 degree celcius)\")\n",
    "p_boil=143.27;#pressure at which pond water boils in Kpa\n",
    "print(\"at further depth of 50 cm the pressure(p)in Kpa\")\n",
    "p=p_boil-((rho*g*h)*10**-3)\n",
    "print(\"p=\"),round(p,2)\n",
    "print(\"boiling point at this depth=Tsat_138.365\")\n",
    "print(\"from steam table this temperature=108.866=108.87 degree celcius\")\n",
    "print(\"so boiling point = 108.87 degree celcius\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.6;pg no: 177"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.6, Page:177  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 6\n",
      "in a rigid vessel it can be treated as constant volume process.\n",
      "so v1=v2\n",
      "since final state is given to be critical state,then specific volume at critical point,\n",
      "v2=0.003155 m^3/kg\n",
      "at 100 degree celcius saturation temperature,from steam table\n",
      "vf_100=0.001044 m^3/kg,vg_100=1.6729 m^3/kg\n",
      "and vfg_100=in m^3/kg= 1.67\n",
      "thus for initial quality being x1\n",
      "v1=vf_100+x1*vfg_100\n",
      "so x1= 0.001\n",
      "mass of water initially=total mass*(1-x1)\n",
      "total mass of fluid/water(m) in kg= 158.48\n",
      "volume of water(v) in m^3= 0.1655\n"
     ]
    }
   ],
   "source": [
    "#cal of mass and volume of water\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.6, Page:177  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 6\")\n",
    "V=0.5;#capacity of rigid vessel in m^3\n",
    "print(\"in a rigid vessel it can be treated as constant volume process.\")\n",
    "print(\"so v1=v2\")\n",
    "print(\"since final state is given to be critical state,then specific volume at critical point,\")\n",
    "print(\"v2=0.003155 m^3/kg\")\n",
    "v2=0.003155;#specific volume at critical point in m^3/kg\n",
    "print(\"at 100 degree celcius saturation temperature,from steam table\")\n",
    "print(\"vf_100=0.001044 m^3/kg,vg_100=1.6729 m^3/kg\")\n",
    "vf_100=0.001044;\n",
    "vg_100=1.6729;\n",
    "vfg_100=vg_100-vf_100\n",
    "print(\"and vfg_100=in m^3/kg=\"),round(vfg_100,2)\n",
    "print(\"thus for initial quality being x1\")\n",
    "v1=v2;#rigid vessel\n",
    "x1=(v1-vf_100)/vfg_100\n",
    "print(\"v1=vf_100+x1*vfg_100\")\n",
    "print(\"so x1=\"),round(x1,3)\n",
    "print(\"mass of water initially=total mass*(1-x1)\")\n",
    "m=V/v2\n",
    "print(\"total mass of fluid/water(m) in kg=\"),round(m,2)\n",
    "v=m*vf_100\n",
    "print(\"volume of water(v) in m^3=\"),round(v,4)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.7;pg no: 177"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.7, Page:177  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 7\n",
      "on mollier diadram(h-s diagram)the slope of isobaric line may be given as\n",
      "(dh/ds)_p=cons =slope of isobar\n",
      "from 1st and 2nd law combined;\n",
      "T*ds=dh-v*dp\n",
      "(dh/ds)_p=cons = T\n",
      "here temperature,T=773.15 K\n",
      "here slope=(dh/ds))p=cons = 773.15\n"
     ]
    }
   ],
   "source": [
    "#cal of slope\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.7, Page:177  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 7\")\n",
    "print(\"on mollier diadram(h-s diagram)the slope of isobaric line may be given as\")\n",
    "print(\"(dh/ds)_p=cons =slope of isobar\")\n",
    "print(\"from 1st and 2nd law combined;\")\n",
    "print(\"T*ds=dh-v*dp\")\n",
    "print(\"(dh/ds)_p=cons = T\")\n",
    "print(\"here temperature,T=773.15 K\")\n",
    "print(\"here slope=(dh/ds))p=cons = 773.15\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.8;pg no: 178"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.8, Page:178  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 8\n",
      "at 0.15Mpa,from steam table;\n",
      "hf=467.11 KJ/kg,hg=2693.6 KJ/kg\n",
      "and hfg in KJ/kg= 2226.49\n",
      "vf=0.001053 m^3/kg,vg=1.1593 m^3/kg\n",
      "and vfg in m^3/kg= 1.16\n",
      "sf=1.4336 KJ/kg,sg=7.2233 KJ/kg\n",
      "and sfg=in KJ/kg K= 5.79\n",
      "enthalpy at x=.10(h)in KJ/kg\n",
      "h= 689.76\n",
      "specific volume,(v)in m^3/kg\n",
      "v= 0.12\n",
      "entropy (s)in KJ/kg K\n",
      "s= 2.01\n"
     ]
    }
   ],
   "source": [
    "#cal of entropy\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.8, Page:178  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 8\")\n",
    "x=.10;#quality is 10%\n",
    "print(\"at 0.15Mpa,from steam table;\")\n",
    "print(\"hf=467.11 KJ/kg,hg=2693.6 KJ/kg\")\n",
    "hf=467.11;\n",
    "hg=2693.6;\n",
    "hfg=hg-hf\n",
    "print(\"and hfg in KJ/kg=\"),round(hfg,2)\n",
    "print(\"vf=0.001053 m^3/kg,vg=1.1593 m^3/kg\")\n",
    "vf=0.001053;\n",
    "vg=1.1593;\n",
    "vfg=vg-vf\n",
    "print(\"and vfg in m^3/kg=\"),round(vfg,2)\n",
    "print(\"sf=1.4336 KJ/kg,sg=7.2233 KJ/kg\")\n",
    "sf=1.4336;\n",
    "sg=7.2233;\n",
    "sfg=sg-sf\n",
    "print(\"and sfg=in KJ/kg K=\"),round(sfg,2)\n",
    "print(\"enthalpy at x=.10(h)in KJ/kg\")\n",
    "h=hf+x*hfg\n",
    "print(\"h=\"),round(h,2)\n",
    "print(\"specific volume,(v)in m^3/kg\")\n",
    "v=vf+x*vfg\n",
    "print(\"v=\"),round(v,2)\n",
    "print(\"entropy (s)in KJ/kg K\")\n",
    "s=sf+x*sfg\n",
    "print(\"s=\"),round(s,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.9;pg no: 178"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.9, Page:178  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 9\n",
      "work done during constant pressure process(W)=p1*(V2-V1)in KJ\n",
      "now from steam table at p1,vf=0.001127 m^3/kg,vg=0.19444 m^3/kg,uf=761.68 KJ/kg,ufg=1822 KJ/kg\n",
      "so v1 in m^3/kg=\n",
      "now mass of steam(m) in kg= 0.32\n",
      "specific volume at final state(v2)in m^3/kg\n",
      "v2= 0.62\n",
      "corresponding to this specific volume the final state is to be located for getting the internal energy at final state at 1 Mpa\n",
      "v2>vg_1Mpa\n",
      "hence state lies in superheated region,from the steam table by interpolation we get temperature as;\n",
      "state lies between temperature of 1000 degree celcius and 1100 degree celcius\n",
      "so exact temperature at final state(T)in K= 1077.61\n",
      "thus internal energy at final state,1 Mpa,1077.61 degree celcius;\n",
      "u2=4209.6 KJ/kg\n",
      "internal energy at initial state(u1)in KJ/kg\n",
      "u1= 2219.28\n",
      "from first law of thermodynamics,Q-W=deltaU\n",
      "so heat added(Q)=(U2-U1)+W=m*(u2-u1)+W in KJ= 788.83\n"
     ]
    }
   ],
   "source": [
    "#cal of heat added\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.9, Page:178  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 9\")\n",
    "p1=1*1000;#initial pressure of steam in Kpa\n",
    "V1=0.05;#initial volume of steam in m^3\n",
    "x1=.8;#dryness fraction is 80%\n",
    "V2=0.2;#final volume of steam in m^3\n",
    "p2=p1;#constant pressure process\n",
    "print(\"work done during constant pressure process(W)=p1*(V2-V1)in KJ\")\n",
    "W=p1*(V2-V1)\n",
    "print(\"now from steam table at p1,vf=0.001127 m^3/kg,vg=0.19444 m^3/kg,uf=761.68 KJ/kg,ufg=1822 KJ/kg\")\n",
    "vf=0.001127;\n",
    "vg=0.19444;\n",
    "uf=761.68;\n",
    "ufg=1822;\n",
    "v1=vf+x1*vg\n",
    "print(\"so v1 in m^3/kg=\")\n",
    "m=V1/v1\n",
    "print(\"now mass of steam(m) in kg=\"),round(m,2)\n",
    "m=0.32097;#take m=0.32097 approx.\n",
    "print(\"specific volume at final state(v2)in m^3/kg\")\n",
    "v2=V2/m\n",
    "print(\"v2=\"),round(v2,2)\n",
    "print(\"corresponding to this specific volume the final state is to be located for getting the internal energy at final state at 1 Mpa\")\n",
    "print(\"v2>vg_1Mpa\")\n",
    "print(\"hence state lies in superheated region,from the steam table by interpolation we get temperature as;\")\n",
    "print(\"state lies between temperature of 1000 degree celcius and 1100 degree celcius\")\n",
    "T=1000+((100*(.62311-.5871))/(.6335-.5871))\n",
    "print(\"so exact temperature at final state(T)in K=\"),round(T,2)\n",
    "print(\"thus internal energy at final state,1 Mpa,1077.61 degree celcius;\")\n",
    "print(\"u2=4209.6 KJ/kg\")\n",
    "u2=4209.6;\n",
    "print(\"internal energy at initial state(u1)in KJ/kg\")\n",
    "u1=uf+x1*ufg\n",
    "print(\"u1=\"),round(u1,2)\n",
    "print(\"from first law of thermodynamics,Q-W=deltaU\")\n",
    "Q=m*(u2-u1)+W\n",
    "print(\"so heat added(Q)=(U2-U1)+W=m*(u2-u1)+W in KJ=\"),round(Q,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.10;pg no: 179"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.10, Page:179  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 10\n",
      "here steam is kept in rigid vessel,therefore its specific volume shall remain constant\n",
      "it is superheated steam as Tsat=170.43 degree celcius at 800 Kpa\n",
      "from superheated steam table;v1=0.2404 m^3/kg\n",
      "at begining of condensation specific volume = 0.2404 m^3/kg\n",
      "v2=0.2404 m^3/kg\n",
      "this v2 shall be specific volume corresponding to saturated vapour state for condensation.\n",
      "thus v2=vg=0.2404 m^3/kg\n",
      "looking into steam table vg=0.2404 m^3/kg shall lie between temperature 175 degree celcius(vg=0.2168 m^3/kg)and 170 degree celcius(vg=0.2428 m^3/kg)and pressure 892 Kpa(175 degree celcius)and 791.7 Kpa(170 degree celcius).\n",
      "by interpolation,temperature at begining of condensation(T2)in K\n",
      "similarily,pressure(p2)in Kpa= 800.96\n"
     ]
    }
   ],
   "source": [
    "#cal of pressure\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.10, Page:179  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 10\")\n",
    "p1=800;#initial pressure of steam in Kpa\n",
    "T1=200;#initial temperature of steam in degree celcius\n",
    "print(\"here steam is kept in rigid vessel,therefore its specific volume shall remain constant\")\n",
    "print(\"it is superheated steam as Tsat=170.43 degree celcius at 800 Kpa\")\n",
    "print(\"from superheated steam table;v1=0.2404 m^3/kg\")\n",
    "print(\"at begining of condensation specific volume = 0.2404 m^3/kg\")\n",
    "print(\"v2=0.2404 m^3/kg\")\n",
    "v2=0.2404;\n",
    "print(\"this v2 shall be specific volume corresponding to saturated vapour state for condensation.\")\n",
    "print(\"thus v2=vg=0.2404 m^3/kg\")\n",
    "vg=v2;\n",
    "print(\"looking into steam table vg=0.2404 m^3/kg shall lie between temperature 175 degree celcius(vg=0.2168 m^3/kg)and 170 degree celcius(vg=0.2428 m^3/kg)and pressure 892 Kpa(175 degree celcius)and 791.7 Kpa(170 degree celcius).\")\n",
    "print(\"by interpolation,temperature at begining of condensation(T2)in K\")\n",
    "T2=175-((175-170)*(0.2404-0.2167))/(0.2428-.2168)\n",
    "p=892-(((892-791.7)*(0.2404-0.2168))/(0.2428-0.2168))\n",
    "print(\"similarily,pressure(p2)in Kpa=\"),round(p,2)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.11;pg no: 180"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.11, Page:180  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 11\n",
      "from 1st and 2nd law;\n",
      "T*ds=dh-v*dp\n",
      "for isentropic process,ds=0\n",
      "hence dh=v*dp\n",
      "i.e (h2-h1)=v1*(p2-p1)\n",
      "corresponding to initial state of saturated liquid at 30 degree celcius;from steam table;\n",
      "p1=4.25 Kpa,vf=v1=0.001004 m^3/kg\n",
      "therefore enthalpy change(deltah)=(h2-h1) in KJ/kg= 0.2\n"
     ]
    }
   ],
   "source": [
    "#cal of enthalpy change\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.11, Page:180  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 11\")\n",
    "p2=200;#feed water pump pressure in Kpa\n",
    "print(\"from 1st and 2nd law;\")\n",
    "print(\"T*ds=dh-v*dp\")\n",
    "print(\"for isentropic process,ds=0\")\n",
    "print(\"hence dh=v*dp\")\n",
    "print(\"i.e (h2-h1)=v1*(p2-p1)\")\n",
    "print(\"corresponding to initial state of saturated liquid at 30 degree celcius;from steam table;\")\n",
    "print(\"p1=4.25 Kpa,vf=v1=0.001004 m^3/kg\")\n",
    "p1=4.25;\n",
    "v1=0.001004;\n",
    "deltah=v1*(p2-p1)\n",
    "print(\"therefore enthalpy change(deltah)=(h2-h1) in KJ/kg=\"),round(deltah,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.12;pg no: 180"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.12, Page:180  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 12\n",
      "from steam table at 150 degree celcius\n",
      "vf=0.001091 m^3/kg,vg=0.3928 m^3/kg\n",
      "so volume occupied by water(Vw)=3*V/(3+2) in m^3 1.2\n",
      "and volume of steam(Vs) in m^3= 0.8\n",
      "mass of water(mf)=Vw/Vf in kg 1099.91\n",
      "mass of steam(mg)=Vs/Vg in kg 2.04\n",
      "total mass in tank(m) in kg= 1101.95\n",
      "quality or dryness fraction(x)\n",
      "x= 0.002\n",
      "NOTE=>answer given in book for mass=1103.99 kg is incorrect and correct answer is 1101.945 which is calculated above.\n"
     ]
    }
   ],
   "source": [
    "#cal of quality or dryness fraction\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.12, Page:180  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 12\")\n",
    "V=2.;#volume of vessel in m^3\n",
    "print(\"from steam table at 150 degree celcius\")\n",
    "print(\"vf=0.001091 m^3/kg,vg=0.3928 m^3/kg\")\n",
    "Vf=0.001091;\n",
    "Vg=0.3928;\n",
    "Vw=3*V/(3+2)\n",
    "print(\"so volume occupied by water(Vw)=3*V/(3+2) in m^3\"),round(Vw,2)\n",
    "Vs=2*V/(3+2)\n",
    "print(\"and volume of steam(Vs) in m^3=\"),round(Vs,2)\n",
    "mf=Vw/Vf\n",
    "print(\"mass of water(mf)=Vw/Vf in kg\"),round(mf,2)\n",
    "mg=Vs/Vg\n",
    "print(\"mass of steam(mg)=Vs/Vg in kg\"),round(mg,2)\n",
    "m=mf+mg\n",
    "print(\"total mass in tank(m) in kg=\"),round(m,2)\n",
    "print(\"quality or dryness fraction(x)\")\n",
    "x=mg/m\n",
    "print(\"x=\"),round(x,3)\n",
    "print(\"NOTE=>answer given in book for mass=1103.99 kg is incorrect and correct answer is 1101.945 which is calculated above.\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.13;pg no: 181"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.13, Page:181  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 13\n",
      "fron S.F.S.E on steam turbine;\n",
      "W=h1-h2\n",
      "initially at 4Mpa,300 degree celcius the steam is super heated so enthalpy from superheated steam or mollier diagram\n",
      "h1=2886.2 KJ/kg,s1=6.2285 KJ/kg K\n",
      "reversible adiabatic expansion process has entropy remaining constant.on mollier diagram the state 2 can be simply located at intersection of constant temperature line for 50 degree celcius and isentropic expansion line.\n",
      "else from steam tables at 50 degree celcius saturation temperature;\n",
      "hf=209.33 KJ/kg,sf=0.7038 KJ/kg K\n",
      "hfg=2382.7 KJ/kg,sfg=7.3725 KJ/kg K\n",
      "here s1=s2,let dryness fraction at 2 be x2\n",
      "x2= 0.75\n",
      "hence enthalpy at state 2\n",
      "h2 in KJ/kg= 1994.84\n",
      "steam turbine work(W)in KJ/kg\n",
      "W=h1-h2\n",
      "so turbine output=W 891.36\n"
     ]
    }
   ],
   "source": [
    "#cal of turbine output\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.13, Page:181  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 13\")\n",
    "print(\"fron S.F.S.E on steam turbine;\")\n",
    "print(\"W=h1-h2\")\n",
    "print(\"initially at 4Mpa,300 degree celcius the steam is super heated so enthalpy from superheated steam or mollier diagram\")\n",
    "print(\"h1=2886.2 KJ/kg,s1=6.2285 KJ/kg K\")\n",
    "h1=2886.2;\n",
    "s1=6.2285;\n",
    "print(\"reversible adiabatic expansion process has entropy remaining constant.on mollier diagram the state 2 can be simply located at intersection of constant temperature line for 50 degree celcius and isentropic expansion line.\")\n",
    "print(\"else from steam tables at 50 degree celcius saturation temperature;\")\n",
    "print(\"hf=209.33 KJ/kg,sf=0.7038 KJ/kg K\")\n",
    "hf=209.33;\n",
    "sf=0.7038;\n",
    "print(\"hfg=2382.7 KJ/kg,sfg=7.3725 KJ/kg K\")\n",
    "hfg=2382.7;\n",
    "sfg=7.3725;\n",
    "print(\"here s1=s2,let dryness fraction at 2 be x2\")\n",
    "x2=(s1-sf)/sfg\n",
    "print(\"x2=\"),round(x2,2)\n",
    "print(\"hence enthalpy at state 2\")\n",
    "h2=hf+x2*hfg\n",
    "print(\"h2 in KJ/kg=\"),round(h2,2)\n",
    "print(\"steam turbine work(W)in KJ/kg\")\n",
    "W=h1-h2\n",
    "print(\"W=h1-h2\")\n",
    "print(\"so turbine output=W\"),round(W,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.14;pg no: 181"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.14, Page:181  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 14\n",
      "it is constant volume process\n",
      "volume of vessel(V)=mass of vapour * specific volume of vapour\n",
      "initial specific volume,v1\n",
      "v1=vf_100Kpa+x1*vfg_100 in m^3/kg\n",
      "at 100 Kpa from steam table;\n",
      "hf_100Kpa=417.46 KJ/kg,uf_100Kpa=417.36 KJ/kg,vf_100Kpa=0.001043 m^3/kg,hfg_100Kpa=2258 KJ/kg,ufg_100Kpa=2088.7 KJ/kg,vg_100Kpa=1.6940 m^3/kg\n",
      " here vfg_100Kpa= in m^3/kg= 1.69\n",
      "so v1= in m^3/kg= 0.85\n",
      "and volume of vessel(V) in m^3= 42.38\n",
      "enthalpy at 1,h1=hf_100Kpa+x1*hfg_100Kpa in KJ/kg 1546.46\n",
      "internal energy in the beginning=U1=m1*u1 in KJ 146171.0\n",
      "let the mass of dry steam added be m,final specific volume inside vessel,v2\n",
      "v2=vf_1000Kpa+x2*vfg_1000Kpa\n",
      "at 2000 Kpa,from steam table,\n",
      "vg_2000Kpa=0.09963 m^3/kg,ug_2000Kpa=2600.3 KJ/kg,hg_2000Kpa=2799.5 KJ/kg\n",
      "total mass inside vessel=mass of steam at2000 Kpa+mass of mixture at 100 Kpa\n",
      "V/v2=V/vg_2000Kpa+V/v1\n",
      "so v2 in m^3/kg= 0.09\n",
      "here v2=vf_1000Kpa+x2*vfg_1000Kpa in m^3/kg\n",
      "at 1000 Kpa from steam table,\n",
      "hf_1000Kpa=762.81 KJ/kg,hfg_1000Kpa=2015.3 KJ/kg,vf_1000Kpa=0.001127 m^3/kg,vg_1000Kpa=0.19444 m^3/kg\n",
      "here vfg_1000Kpa= in m^3/kg= 0.19\n",
      "so x2= 0.46\n",
      "for adiabatic mixing,(100+m)*h2=100*h1+m*hg_2000Kpa\n",
      "so mass of dry steam at 2000 Kpa to be added(m)in kg\n",
      "m=(100*(h1-h2))/(h2-hg_2000Kpa)= 11.97\n",
      "quality of final mixture x2= 0.46\n"
     ]
    }
   ],
   "source": [
    "#cal of quality of final mixture\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.14, Page:181  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 14\")\n",
    "x1=0.5;#dryness fraction \n",
    "m1=100;#mass of steam in kg\n",
    "v1=0.8475;#\n",
    "print(\"it is constant volume process\")\n",
    "print(\"volume of vessel(V)=mass of vapour * specific volume of vapour\")\n",
    "print(\"initial specific volume,v1\")\n",
    "print(\"v1=vf_100Kpa+x1*vfg_100 in m^3/kg\")\n",
    "print(\"at 100 Kpa from steam table;\")\n",
    "print(\"hf_100Kpa=417.46 KJ/kg,uf_100Kpa=417.36 KJ/kg,vf_100Kpa=0.001043 m^3/kg,hfg_100Kpa=2258 KJ/kg,ufg_100Kpa=2088.7 KJ/kg,vg_100Kpa=1.6940 m^3/kg\")\n",
    "hf_100Kpa=417.46;\n",
    "uf_100Kpa=417.36;\n",
    "vf_100Kpa=0.001043;\n",
    "hfg_100Kpa=2258;\n",
    "ufg_100Kpa=2088.7;\n",
    "vg_100Kpa=1.6940;\n",
    "vfg_100Kpa=vg_100Kpa-vf_100Kpa\n",
    "print(\" here vfg_100Kpa= in m^3/kg=\"),round(vfg_100Kpa,2)\n",
    "v1=vf_100Kpa+x1*vfg_100Kpa\n",
    "print(\"so v1= in m^3/kg=\"),round(v1,2)\n",
    "V=m1*x1*v1\n",
    "print(\"and volume of vessel(V) in m^3=\"),round(V,2)\n",
    "h1=hf_100Kpa+x1*hfg_100Kpa\n",
    "print(\"enthalpy at 1,h1=hf_100Kpa+x1*hfg_100Kpa in KJ/kg\"),round(h1,2)\n",
    "U1=m1*(uf_100Kpa+x1*ufg_100Kpa)\n",
    "print(\"internal energy in the beginning=U1=m1*u1 in KJ\"),round(U1,2)\n",
    "print(\"let the mass of dry steam added be m,final specific volume inside vessel,v2\")\n",
    "print(\"v2=vf_1000Kpa+x2*vfg_1000Kpa\")\n",
    "print(\"at 2000 Kpa,from steam table,\")\n",
    "print(\"vg_2000Kpa=0.09963 m^3/kg,ug_2000Kpa=2600.3 KJ/kg,hg_2000Kpa=2799.5 KJ/kg\")\n",
    "vg_2000Kpa=0.09963;\n",
    "ug_2000Kpa=2600.3;\n",
    "hg_2000Kpa=2799.5;\n",
    "print(\"total mass inside vessel=mass of steam at2000 Kpa+mass of mixture at 100 Kpa\")\n",
    "print(\"V/v2=V/vg_2000Kpa+V/v1\")\n",
    "v2=1/((1/vg_2000Kpa)+(1/v1))\n",
    "print(\"so v2 in m^3/kg=\"),round(v2,2)\n",
    "print(\"here v2=vf_1000Kpa+x2*vfg_1000Kpa in m^3/kg\")\n",
    "print(\"at 1000 Kpa from steam table,\")\n",
    "print(\"hf_1000Kpa=762.81 KJ/kg,hfg_1000Kpa=2015.3 KJ/kg,vf_1000Kpa=0.001127 m^3/kg,vg_1000Kpa=0.19444 m^3/kg\")\n",
    "hf_1000Kpa=762.81;\n",
    "hfg_1000Kpa=2015.3;\n",
    "vf_1000Kpa=0.001127;\n",
    "vg_1000Kpa=0.19444;\n",
    "vfg_1000Kpa=vg_1000Kpa-vf_1000Kpa\n",
    "print(\"here vfg_1000Kpa= in m^3/kg=\"),round(vfg_1000Kpa,2)\n",
    "x2=(v2-vf_1000Kpa)/vfg_1000Kpa\n",
    "print(\"so x2=\"),round(x2,2)\n",
    "print(\"for adiabatic mixing,(100+m)*h2=100*h1+m*hg_2000Kpa\")\n",
    "print(\"so mass of dry steam at 2000 Kpa to be added(m)in kg\")\n",
    "m=(100*(h1-(hf_1000Kpa+x2*hfg_1000Kpa)))/((hf_1000Kpa+x2*hfg_1000Kpa)-hg_2000Kpa)\n",
    "print(\"m=(100*(h1-h2))/(h2-hg_2000Kpa)=\"),round(m,2)\n",
    "print(\"quality of final mixture x2=\"),round(x2,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.15;pg no: 183"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.15, Page:183  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 15\n",
      "from dalton law of partial pressure the total pressure inside condenser will be sum of partial pressures of vapour and liquid inside.\n",
      "condenser pressure(p_condenser) in Kpa= 7.3\n",
      "partial pressure of steam corresponding to35 degree celcius from steam table;\n",
      "p_steam=5.628 Kpa\n",
      "enthalpy corresponding to 35 degree celcius from steam table,\n",
      "hf=146.68 KJ/kg,hfg=2418.6 KJ/kg\n",
      "let quality of steam entering be x\n",
      "from energy balance;\n",
      "mw*(To-Ti)*4.18=m_cond*(hf+x*hfg-4.18*T_hotwell)\n",
      "so dryness fraction of steam entering(x)is given as\n",
      "x= 0.97\n"
     ]
    }
   ],
   "source": [
    "#cal of  dryness fraction of steam entering\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.15, Page:183  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 15\")\n",
    "p_vaccum=71.5;#recorded condenser vaccum in cm of mercury\n",
    "p_barometer=76.8;#barometer reading in cm of mercury\n",
    "T_cond=35;#temperature of condensation in degree celcius\n",
    "T_hotwell=27.6;#temperature of hot well in degree celcius\n",
    "m_cond=1930;#mass of condensate per hour\n",
    "m_w=62000;#mass of cooling water per hour\n",
    "Ti=8.51;#initial temperature in degree celcius\n",
    "To=26.24;#outlet temperature in degree celcius\n",
    "print(\"from dalton law of partial pressure the total pressure inside condenser will be sum of partial pressures of vapour and liquid inside.\")\n",
    "p_condenser=(p_barometer-p_vaccum)*101.325/73.55\n",
    "print(\"condenser pressure(p_condenser) in Kpa=\"),round(p_condenser,2)\n",
    "print(\"partial pressure of steam corresponding to35 degree celcius from steam table;\")\n",
    "print(\"p_steam=5.628 Kpa\")\n",
    "p_steam=5.628;#partial pressure of steam\n",
    "print(\"enthalpy corresponding to 35 degree celcius from steam table,\")\n",
    "print(\"hf=146.68 KJ/kg,hfg=2418.6 KJ/kg\")\n",
    "hf=146.68;\n",
    "hfg=2418.6;\n",
    "print(\"let quality of steam entering be x\")\n",
    "print(\"from energy balance;\")\n",
    "print(\"mw*(To-Ti)*4.18=m_cond*(hf+x*hfg-4.18*T_hotwell)\")\n",
    "print(\"so dryness fraction of steam entering(x)is given as\")\n",
    "x=(((m_w*(To-Ti)*4.18)/m_cond)-hf+4.18*T_hotwell)/hfg\n",
    "print(\"x=\"),round(x,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.16;pg no: 184"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.16, Page:184  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 16\n",
      "heating of water in vessel as described above is a constant pressure heating. pressure at which process occurs(p)=F/A+P_atm in Kpa\n",
      "area(A) in m^2= 0.03\n",
      "so p1=in Kpa= 419.61\n",
      "now at 419.61 Kpa,hf=612.1 KJ/kg,hfg=2128.7 KJ/kg,vg=0.4435 m^3/kg\n",
      "volume of water contained(V1) in m^3= 0.001\n",
      "mass of water(m) in kg= 0.63\n",
      "heat supplied shall cause sensible heating and latent heating\n",
      "hence,enthalpy change=heat supplied\n",
      "Q=((hf+x*hfg)-(4.18*T)*m)\n",
      "so dryness fraction of steam produced(x)can be calculated as\n",
      "so x= 0.46\n",
      "internal energy of water(U1)in KJ,initially\n",
      "U1= 393.69\n",
      "finally,internal energy of wet steam(U2)in KJ\n",
      "U2=m*h2-p2*V2\n",
      "here V2 in m^3= 0.13\n",
      "hence U2= 940.68\n",
      "hence change in internal energy(U) in KJ= 547.21\n",
      "work done(W) in KJ= 53.01\n"
     ]
    }
   ],
   "source": [
    "#cal of change in internal energy and work done\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "import math\n",
    "print\"Example 6.16, Page:184  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 16\")\n",
    "F=10;#force applied externally upon piston in KN\n",
    "d=.2;#diameter in m\n",
    "h=0.02;#depth to which water filled in m \n",
    "P_atm=101.3;#atmospheric pressure in Kpa\n",
    "rho=1000;#density of water in kg/m^3\n",
    "Q=600;#heat supplied to water in KJ\n",
    "T=150;#temperature of water in degree celcius\n",
    "print(\"heating of water in vessel as described above is a constant pressure heating. pressure at which process occurs(p)=F/A+P_atm in Kpa\")\n",
    "A=math.pi*d**2/4\n",
    "print(\"area(A) in m^2=\"),round(A,2)\n",
    "p1=F/A+P_atm\n",
    "print(\"so p1=in Kpa=\"),round(p1,2)\n",
    "print(\"now at 419.61 Kpa,hf=612.1 KJ/kg,hfg=2128.7 KJ/kg,vg=0.4435 m^3/kg\")\n",
    "hf=612.1;\n",
    "hfg=2128.7;\n",
    "vg=0.4435;\n",
    "V1=math.pi*d**2*h/4\n",
    "print(\"volume of water contained(V1) in m^3=\"),round(V1,3)\n",
    "m=V1*rho\n",
    "print(\"mass of water(m) in kg=\"),round(m,2)\n",
    "print(\"heat supplied shall cause sensible heating and latent heating\")\n",
    "print(\"hence,enthalpy change=heat supplied\")\n",
    "print(\"Q=((hf+x*hfg)-(4.18*T)*m)\")\n",
    "print(\"so dryness fraction of steam produced(x)can be calculated as\")\n",
    "x=((Q/m)+4.18*T-hf)/hfg\n",
    "print(\"so x=\"),round(x,2)\n",
    "print(\"internal energy of water(U1)in KJ,initially\")\n",
    "h1=4.18*T;#enthalpy of water in KJ/kg\n",
    "U1=m*h1-p1*V1\n",
    "print(\"U1=\"),round(U1,2)\n",
    "U1=393.5;#approx.\n",
    "print(\"finally,internal energy of wet steam(U2)in KJ\")\n",
    "print(\"U2=m*h2-p2*V2\")\n",
    "V2=m*x*vg\n",
    "print(\"here V2 in m^3=\"),round(V2,2)\n",
    "p2=p1;#constant pressure process\n",
    "U2=(m*(hf+x*hfg))-p2*V2\n",
    "print(\"hence U2=\"),round(U2,2)\n",
    "U2=940.71;#approx.\n",
    "U=U2-U1\n",
    "print(\"hence change in internal energy(U) in KJ=\"),round(U,2)\n",
    "p=p1;\n",
    "W=p*(V2-V1)\n",
    "print(\"work done(W) in KJ=\"),round(W,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.17;pg no: 185"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.17, Page:185  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 17\n",
      "consider throttling calorimeter alone,\n",
      "degree of superheat(T_sup)in degree celcius\n",
      "T_sup= 18.2\n",
      "enthalpy of superheated steam(h_sup)in KJ/kg\n",
      "h_sup= 2711.99\n",
      "at 120 degree celcius,h=2673.95 KJ/kg from steam table\n",
      "now enthalpy before throttling = enthalpy after throttling\n",
      "hf+x2*hfg=h_sup\n",
      "here at 1.47 Mpa,hf=840.513 KJ/kg,hfg=1951.02 KJ/kg from steam table\n",
      "so x2= 0.96\n",
      "for seperating calorimeter alone,dryness fraction,x1=(ms-mw)/ms\n",
      "overall dryness fraction(x)= 0.91\n"
     ]
    }
   ],
   "source": [
    "#cal of overall dryness fraction\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.17, Page:185  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 17\")\n",
    "ms=40;#mass of steam in kg\n",
    "mw=2.2;#mass of water in kg\n",
    "p1=1.47;#pressure before throttling in Mpa\n",
    "T2=120;#temperature after throttling in degree celcius\n",
    "p2=107.88;#pressure after throttling in Kpa\n",
    "Cp_sup=2.09;#specific heat of superheated steam in KJ/kg K\n",
    "print(\"consider throttling calorimeter alone,\")\n",
    "print(\"degree of superheat(T_sup)in degree celcius\")\n",
    "T_sup=T2-101.8\n",
    "print(\"T_sup=\"),round(T_sup,2)\n",
    "print(\"enthalpy of superheated steam(h_sup)in KJ/kg\")\n",
    "h=2673.95;\n",
    "h_sup=h+T_sup*Cp_sup\n",
    "print(\"h_sup=\"),round(h_sup,2)\n",
    "print(\"at 120 degree celcius,h=2673.95 KJ/kg from steam table\")\n",
    "print(\"now enthalpy before throttling = enthalpy after throttling\")\n",
    "print(\"hf+x2*hfg=h_sup\")\n",
    "print(\"here at 1.47 Mpa,hf=840.513 KJ/kg,hfg=1951.02 KJ/kg from steam table\")\n",
    "hf=840.513;\n",
    "hfg=1951.02;\n",
    "x2=(h_sup-hf)/hfg\n",
    "print(\"so x2=\"),round(x2,2)\n",
    "print(\"for seperating calorimeter alone,dryness fraction,x1=(ms-mw)/ms\")\n",
    "x1=(ms-mw)/ms\n",
    "x=x1*x2\n",
    "print(\"overall dryness fraction(x)=\"),round(x,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.18;pg no: 185"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.18, Page:185  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 18\n",
      "here heat addition to part B shall cause evaporation of water and subsequently the rise in pressure.\n",
      "final,part B has dry steam at 15 bar.In order to have equilibrium the part A shall also have pressure of 15 bar.thus heat added\n",
      "Q in KJ= 200.0\n",
      "final enthalpy of dry steam at 15 bar,h2=hg_15bar\n",
      "h2=2792.2 KJ/kg from steam table\n",
      "let initial dryness fraction be x1,initial enthalpy,\n",
      "h1=hf_10bar+x1*hfg_10bar.........eq1\n",
      "here at 10 bar,hf_10bar=762.83 KJ/kg,hfg_10bar=2015.3 KJ/kg from steam table\n",
      "also heat balance yields,\n",
      "h1+Q=h2\n",
      "so h1=h2-Q in KJ/kg\n",
      "so by eq 1=>x1= 0.91\n",
      "heat added(Q)in KJ= 200.0\n",
      "and initial quality(x1) 0.91\n"
     ]
    }
   ],
   "source": [
    "#cal of heat added and initial quality\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.18, Page:185  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 18\")\n",
    "v=0.4;#volume of air in part A and part B in m^3\n",
    "p1=10*10**5;#initial pressure of steam in pa\n",
    "p2=15*10**5;#final pressure of steam in pa\n",
    "print(\"here heat addition to part B shall cause evaporation of water and subsequently the rise in pressure.\")\n",
    "print(\"final,part B has dry steam at 15 bar.In order to have equilibrium the part A shall also have pressure of 15 bar.thus heat added\")\n",
    "Q=v*(p2-p1)/1000\n",
    "print(\"Q in KJ=\"),round(Q,2)\n",
    "print(\"final enthalpy of dry steam at 15 bar,h2=hg_15bar\")\n",
    "print(\"h2=2792.2 KJ/kg from steam table\")\n",
    "h2=2792.2;\n",
    "print(\"let initial dryness fraction be x1,initial enthalpy,\")\n",
    "print(\"h1=hf_10bar+x1*hfg_10bar.........eq1\")\n",
    "print(\"here at 10 bar,hf_10bar=762.83 KJ/kg,hfg_10bar=2015.3 KJ/kg from steam table\")\n",
    "hf_10bar=762.83;\n",
    "hfg_10bar=2015.3;\n",
    "print(\"also heat balance yields,\")\n",
    "print(\"h1+Q=h2\")\n",
    "print(\"so h1=h2-Q in KJ/kg\")\n",
    "h1=h2-Q\n",
    "x1=(h1-hf_10bar)/hfg_10bar\n",
    "print(\"so by eq 1=>x1=\"),round(x1,2)\n",
    "print(\"heat added(Q)in KJ=\"),round(Q,2)\n",
    "print(\"and initial quality(x1)\"),round(x1,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.19;pg no: 186"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.19, Page:186  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 19\n",
      "from steam table,vg=1.2455 m^3/kg,hf=457.99 KJ/kg,hfg=2232.3 KJ/kg\n",
      "specific volume of wet steam in cylinder,v1 in m^3/kg= 0.75\n",
      "dryness fraction of initial steam(x1)= 0.6\n",
      "initial enthalpy of wet steam,h1 in KJ/kg= 1801.83\n",
      "at 400 degree celcius specific volume of steam,v2 in m^3/kg= 1.55\n",
      "for specific volume of 1.55 m^3/kg at 400 degree celcius the pressure can be seen from the steam table.From superheated steam tables the specific volume of 1.55 m^3/kg lies between the pressure of 0.10 Mpa (specific volume 3.103 m^3/kg at400 degree celcius)and 0.20 Mpa(specific volume 1.5493 m^3/kg at 400 degree celcius)\n",
      "actual pressure can be obtained by interpolation\n",
      "p2=0.20 MPa(approx.)\n",
      "saturation temperature at 0.20 Mpa(t)=120.23 degree celcius from steam table\n",
      "finally the degree of superheat(T_sup)in K\n",
      "T_sup=T-t\n",
      "final enthalpy of steam at 0.20 Mpa and 400 degree celcius,h2=3276.6 KJ/kg from steam table\n",
      "heat added during process(deltaQ)in KJ\n",
      "deltaQ=m*(h2-h1)\n",
      "internal energy of initial wet steam,u1=uf+x1*ufg in KJ/kg\n",
      "here at 1.4 bar,from steam table,uf=457.84 KJ/kg,ufg=2059.34 KJ/kg\n",
      "internal energy of final state,u2=u at 0.2 Mpa,400 degree celcius\n",
      "u2=2966.7 KJ/kg\n",
      "change in internal energy(deltaU)in KJ\n",
      "deltaU= 3807.41\n",
      "form first law of thermodynamics,work done(deltaW)in KJ\n",
      "deltaW=deltaQ-deltaU 616.88\n",
      "so heat transfer(deltaQ)in KJ 4424.3\n",
      "and work transfer(deltaW)in KJ 616.88\n",
      "NOTE=>In book value of u1=1707.86 KJ/kg is calculated wrong taking x1=0.607,hence correct value of u1 using x1=0.602 is 1697.5627 KJ/kg\n",
      "and corresponding values of heat transfer= 4424.2962 KJ and work transfer=616.88424 KJ.\n"
     ]
    }
   ],
   "source": [
    "#cal of heat and work transfer \n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.19, Page:186  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 19\")\n",
    "m=3;#mass of wet steam in kg\n",
    "p=1.4;#pressure of wet steam in bar\n",
    "V1=2.25;#initial volume in m^3\n",
    "V2=4.65;#final volume in m^3\n",
    "T=400;#temperature of steam in degreee celcius\n",
    "print(\"from steam table,vg=1.2455 m^3/kg,hf=457.99 KJ/kg,hfg=2232.3 KJ/kg\")\n",
    "vg=1.2455;\n",
    "hf=457.99;\n",
    "hfg=2232.3;\n",
    "v1=V1/m\n",
    "print(\"specific volume of wet steam in cylinder,v1 in m^3/kg=\"),round(v1,2)\n",
    "x1=v1/vg\n",
    "print(\"dryness fraction of initial steam(x1)=\"),round(x1,2)\n",
    "x1=0.602;#approx.\n",
    "h1=hf+x1*hfg\n",
    "print(\"initial enthalpy of wet steam,h1 in KJ/kg=\"),round(h1,2)\n",
    "v2=V2/m\n",
    "print(\"at 400 degree celcius specific volume of steam,v2 in m^3/kg=\"),round(v2,2)\n",
    "print(\"for specific volume of 1.55 m^3/kg at 400 degree celcius the pressure can be seen from the steam table.From superheated steam tables the specific volume of 1.55 m^3/kg lies between the pressure of 0.10 Mpa (specific volume 3.103 m^3/kg at400 degree celcius)and 0.20 Mpa(specific volume 1.5493 m^3/kg at 400 degree celcius)\")\n",
    "print(\"actual pressure can be obtained by interpolation\")\n",
    "p2=.1+((0.20-0.10)/(1.5493-3.103))*(1.55-3.103)\n",
    "print(\"p2=0.20 MPa(approx.)\")\n",
    "p2=0.20;\n",
    "print(\"saturation temperature at 0.20 Mpa(t)=120.23 degree celcius from steam table\")\n",
    "t=120.23;\n",
    "print(\"finally the degree of superheat(T_sup)in K\")\n",
    "print(\"T_sup=T-t\")\n",
    "T_sup=T-t\n",
    "print(\"final enthalpy of steam at 0.20 Mpa and 400 degree celcius,h2=3276.6 KJ/kg from steam table\")\n",
    "h2=3276.6;\n",
    "print(\"heat added during process(deltaQ)in KJ\")\n",
    "print(\"deltaQ=m*(h2-h1)\")\n",
    "deltaQ=m*(h2-h1)\n",
    "print(\"internal energy of initial wet steam,u1=uf+x1*ufg in KJ/kg\")\n",
    "print(\"here at 1.4 bar,from steam table,uf=457.84 KJ/kg,ufg=2059.34 KJ/kg\")\n",
    "uf=457.84;\n",
    "ufg=2059.34;\n",
    "u1=uf+x1*ufg\n",
    "print(\"internal energy of final state,u2=u at 0.2 Mpa,400 degree celcius\")\n",
    "print(\"u2=2966.7 KJ/kg\")\n",
    "u2=2966.7;\n",
    "print(\"change in internal energy(deltaU)in KJ\")\n",
    "deltaU=m*(u2-u1)\n",
    "print(\"deltaU=\"),round(deltaU,2)\n",
    "print(\"form first law of thermodynamics,work done(deltaW)in KJ\")\n",
    "deltaW=deltaQ-deltaU\n",
    "print(\"deltaW=deltaQ-deltaU\"),round(deltaW,2)\n",
    "print(\"so heat transfer(deltaQ)in KJ\"),round(deltaQ,2)\n",
    "print(\"and work transfer(deltaW)in KJ\"),round(deltaW,2)\n",
    "print(\"NOTE=>In book value of u1=1707.86 KJ/kg is calculated wrong taking x1=0.607,hence correct value of u1 using x1=0.602 is 1697.5627 KJ/kg\")\n",
    "print(\"and corresponding values of heat transfer= 4424.2962 KJ and work transfer=616.88424 KJ.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.20;pg no: 187"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.20, Page:187  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 20\n",
      "here throttling process is occuring therefore enthalpy before and after expansion remains same.Let initial and final states be given by 1 and 2.Initial enthalpy,from steam table.\n",
      "at 500 degree celcius,h1_10bar_500oc=3478.5 KJ/kg,s1_10bar_500oc=7.7622 KJ/kg K,v1_10bar_500oc=0.3541 m^3/kg\n",
      "finally pressure becomes 1 bar so finally enthalpy(h2) at this pressure(of 1 bar)is also 3478.5 KJ/kg which lies between superheat temperature of 400 degree celcius and 500 degree celcius at 1 bar.Let temperature be T2,\n",
      "h_1bar_400oc=3278.2 KJ/kg,h_1bar_500oc=3488.1 KJ/kg from steam table\n",
      "h2=h_1bar_400oc+(h_1bar_500oc-h_1bar_400oc)*(T2-400)/(500-400)\n",
      "so final temperature(T2)in K\n",
      "T2= 495.43\n",
      "entropy for final state(s2)in KJ/kg K\n",
      "s2= 8.82\n",
      "here from steam table,s_1bar_400oc=8.5435 KJ/kg K,s_1bar_500oc=8.8342 KJ/kg K\n",
      "so change in entropy(deltaS)in KJ/kg K\n",
      "deltaS= 1.06\n",
      "final specific volume,v2=v_1bar_400oc+((v_1bar_500oc-v_1bar_400oc)*(95.43)/(500-400)) in m^3/kg\n",
      "here from steam table,v_1bar_500oc=3.565 m^3/kg,v_1bar_400oc=3.103 m^3/kg\n",
      "percentage of vessel volume initially occupied by steam(V)= 9.99\n"
     ]
    }
   ],
   "source": [
    "#cal of percentage of vessel volume initially occupied by steam\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.20, Page:187  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 20\")\n",
    "print(\"here throttling process is occuring therefore enthalpy before and after expansion remains same.Let initial and final states be given by 1 and 2.Initial enthalpy,from steam table.\")\n",
    "print(\"at 500 degree celcius,h1_10bar_500oc=3478.5 KJ/kg,s1_10bar_500oc=7.7622 KJ/kg K,v1_10bar_500oc=0.3541 m^3/kg\")\n",
    "h1_10bar_500oc=3478.5;\n",
    "s1_10bar_500oc=7.7622;\n",
    "v1_10bar_500oc=0.3541;\n",
    "print(\"finally pressure becomes 1 bar so finally enthalpy(h2) at this pressure(of 1 bar)is also 3478.5 KJ/kg which lies between superheat temperature of 400 degree celcius and 500 degree celcius at 1 bar.Let temperature be T2,\")\n",
    "h2=h1_10bar_500oc;\n",
    "print(\"h_1bar_400oc=3278.2 KJ/kg,h_1bar_500oc=3488.1 KJ/kg from steam table\")\n",
    "h_1bar_400oc=3278.2;\n",
    "h_1bar_500oc=3488.1;\n",
    "print(\"h2=h_1bar_400oc+(h_1bar_500oc-h_1bar_400oc)*(T2-400)/(500-400)\")\n",
    "print(\"so final temperature(T2)in K\")\n",
    "T2=400+((h2-h_1bar_400oc)*(500-400)/(h_1bar_500oc-h_1bar_400oc))\n",
    "print(\"T2=\"),round(T2,2)\n",
    "print(\"entropy for final state(s2)in KJ/kg K\")\n",
    "s_1bar_400oc=8.5435;\n",
    "s_1bar_500oc=8.8342;\n",
    "s2=s_1bar_400oc+((s_1bar_500oc-s_1bar_400oc)*(495.43-400)/(500-400))\n",
    "print(\"s2=\"),round(s2,2)\n",
    "print(\"here from steam table,s_1bar_400oc=8.5435 KJ/kg K,s_1bar_500oc=8.8342 KJ/kg K\")\n",
    "print(\"so change in entropy(deltaS)in KJ/kg K\")\n",
    "deltaS=s2-s1_10bar_500oc\n",
    "print(\"deltaS=\"),round(deltaS,2)\n",
    "print(\"final specific volume,v2=v_1bar_400oc+((v_1bar_500oc-v_1bar_400oc)*(95.43)/(500-400)) in m^3/kg\")\n",
    "print(\"here from steam table,v_1bar_500oc=3.565 m^3/kg,v_1bar_400oc=3.103 m^3/kg\")\n",
    "v_1bar_500oc=3.565;\n",
    "v_1bar_400oc=3.103;\n",
    "v2=v_1bar_400oc+((v_1bar_500oc-v_1bar_400oc)*(95.43)/(500-400))\n",
    "V=v1_10bar_500oc*100/v2\n",
    "print(\"percentage of vessel volume initially occupied by steam(V)=\"),round(V,2)\n",
    "\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.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}