{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 8: Second Law of Thermodynamics"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 8.1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "maximum theotrical efficiency (percentage)((Claim is not valid)) =  23.33\n",
      "press enter key to exit\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#You are asked to comment on an inventor's claim that he has an engine which \n",
    "#delivers 25 Btu of work from an input if 100 Btu when it operates between \n",
    "#140F and 0F. Is the claim valid?\n",
    "#initialisation of variables\n",
    "W= 25 \t\t\t\t\t#Btu\n",
    "W1= 100 \t\t\t\t#Btu\n",
    "T1= 140 \t\t\t\t#R\n",
    "T2= 0 \t\t\t\t\t#R\n",
    "#CALCULATIONS\n",
    "Th= T1+460. \t\t\t#T hot in Rankine\n",
    "Tl= T2+460. \t\t\t#T cold in Rankine\n",
    "nt= (Th-Tl)/Th \t\t\t#Max. efficieny\n",
    "n= nt*100.\n",
    "#RESULTS\n",
    "print '%s %.2f' % ('maximum theotrical efficiency (percentage)((Claim is not valid)) = ',n)\n",
    "raw_input('press enter key to exit')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 8.2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Change in Entropy (J/gm K) =  2.856\n",
      "press enter key to exit\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Saturated steam in a rigid vessel is initially at 10 bar. heat is added\n",
    "#until the steam s superheated at 38 bar and 310 C. What is the change in entropy?\n",
    "#initialisation of variables\n",
    "P= 10 \t\t\t\t\t\t#bar\n",
    "P1= 38 \t\t\t\t\t\t#bar\n",
    "T= 310 \t\t\t\t\t\t#C\n",
    "v= 64.03 \t\t\t\t\t#cm^3/gm\n",
    "s= 6.4415 \t\t\t\t\t#J/gm K\n",
    "vf= 1.12773 \t\t\t\t#cm^3/gm\n",
    "vg= 194.44 \t\t\t\t\t#cm^3/gm\n",
    "sf= 2.1387 \t\t\t\t\t#J/gm K\n",
    "sfg= 4.4478 \t\t\t\t#J/gm K\n",
    "#CALCULATIONS \n",
    "x= (v-vf)/(vg-vf) \t\t\t#x\n",
    "sx= sf+x*sfg \t\t\t\t#Entropy\n",
    "S= s-sx \t\t\t\t\t#Change in entropy\n",
    "#RESULTS\n",
    "print '%s %.3f' % ('Change in Entropy (J/gm K) = ',S)\n",
    "raw_input('press enter key to exit')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 8.3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Minimum power required to drive the heat pump (Btu/hr) =  7500.00\n",
      "press enter key to exit\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#If heat must be pumped at the rate of 70k Btu/hr to keep a house at 72F when\n",
    "#the outside temperature is 15 F, What is the minimum power required to drive\n",
    "#the heat pump?\n",
    "#initialisation of variables\n",
    "Qh= 70000. \t\t\t\t\t\t\t#Btu/hr\n",
    "T= 15. \t\t\t\t\t\t\t\t#F\n",
    "T1= 72. \t\t\t\t\t\t\t#F\n",
    "#CALCULATIONS\n",
    "COP= (T1+460)/((T1+460)-(T+460))\t#Carnot efficiency\n",
    "W= Qh/COP \t\t\t\t\t\t\t#Work\n",
    "#RESULTS\n",
    "print '%s %.2f' % ('Minimum power required to drive the heat pump (Btu/hr) = ',W)\n",
    "raw_input('press enter key to exit')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 8.4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Minimum electrical  requirement (KW) =  3.54\n",
      " \n",
      " Elctrical requirement if an electrical heater used (KW) =  26.00\n",
      "press enter key to exit\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Heat must be pumped at the rate of 26kW to maintain a temperature of 43F\n",
    "#in an air stream while the outside temperature is 0C. Determine \n",
    "#(a)the minimum electrical equipment in Kilowatts and \n",
    "#(b)the electrical requirement if an electric heater is used.\n",
    "#initialisation of variables\n",
    "h= 26. \t\t\t\t\t\t\t\t#KW\n",
    "T= 43. \t\t\t\t\t\t\t\t#C\n",
    "To= 0 \t\t\t\t\t\t\t\t#C\n",
    "#CALCULATIONS\n",
    "COP= (T+273)/((T+273.)-(To+273.))\t#Carnot efficiency\n",
    "W= h/COP \t\t\t\t\t\t\t#Work\n",
    "Qh=h \t\t\t\t\t\t\t\t#Heat\n",
    "#RESULTS\n",
    "print '%s %.2f' % ('Minimum electrical  requirement (KW) = ',W)\n",
    "print '%s %.2f' % (' \\n Elctrical requirement if an electrical heater used (KW) = ',Qh)\n",
    "raw_input('press enter key to exit')"
   ]
  }
 ],
 "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.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
