{
 "metadata": {
  "name": "",
  "signature": "sha256:e4631603aed69918db75e330f3c0e7e2d262143fadfa182241f038adb18aceb6"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter7-Heat engines and the second law of thermodynamics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example1 pg- 146"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate heat and efficency\n",
      "##initialisation of variables\n",
      "m= 0.35 ##kg\n",
      "u2= 211.785 ##kJ/kg\n",
      "u1= 182.267 ##kJ/kg\n",
      "p2= 300. ##kPa\n",
      "v3= 0.085566 ##kJ/kg\n",
      "v2= 0.076218 ##kJ/kg\n",
      "h3= 260.391 ##kJ/kg\n",
      "h2= 234.650 ##kJ/kg\n",
      "u4= 199.460 ##kJ/kg\n",
      "u3= 234.721 ##kJ/kg\n",
      "p4= 250.##kPa\n",
      "v1= 0.076218 ##kJ/kg\n",
      "v4= 0.085566 ##kJ/kg\n",
      "h1= 201.322 ##kJ/kg\n",
      "h4= 220.851 ##kJ/kg\n",
      "##CALCULATIONS\n",
      "Q12= m*(u2-u1)\n",
      "W23= m*p2*(v3-v2)\n",
      "Q23= m*(h3-h2)\n",
      "W34= 0.\n",
      "Q34= m*(u4-u3)\n",
      "W41= m*p4*(v1-v4)\n",
      "Q41= m*(h1-h4)\n",
      "dW= W23+W41\n",
      "dQ= Q12+Q23+Q34+Q41\n",
      "Qh= Q12+Q23\n",
      "n= dW*100./Qh\n",
      "##RESULTS\n",
      "print'%s %.2f %s'%('heat = ',Qh,'kj')\n",
      "print'%s %.2f %s'%('efficiency =',n, 'percent')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "heat =  19.34 kj\n",
        "efficiency = 0.85 percent\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example4 pg-156"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate effiecncy of heat engine and efficency\n",
      "##initialisation of variables\n",
      "Qc= 9 ##kW\n",
      "W= 7.5 ##kW\n",
      "Qh= Qc+W\n",
      "Tc= 50 ##C\n",
      "Th= 400 ##C\n",
      "##CALCULATIONS\n",
      "n= W/Qh\n",
      "nrev= 1-((273.15+Tc)/(273.15+Th))\n",
      "##RESULTS\n",
      "print'%s %.3f %s'% ('efficiency of heat engine = ',n,'')\n",
      "print'%s %.3f %s'%('efficiency =',nrev,'')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "efficiency of heat engine =  0.455 \n",
        "efficiency = 0.520 \n"
       ]
      }
     ],
     "prompt_number": 2
    }
   ],
   "metadata": {}
  }
 ]
}