{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 16 - Gas Cycles"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1a - Pg 279"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the efficiency and work done per pound of fluid\n",
      "#initialization of varaibles\n",
      "import math\n",
      "Pb=75. #psia\n",
      "Pc=15. #psia\n",
      "k=1.4\n",
      "Td=550. #R\n",
      "Tb=1700.  #R\n",
      "cp=0.24\n",
      "#calculations\n",
      "print '%s' %(\"Gas law solution\")\n",
      "Pratio=Pb/Pc\n",
      "Ta=Td*math.pow((Pratio),((k-1)/k))\n",
      "Tc=Tb/math.pow((Pratio),((k-1)/k))\n",
      "Q1=cp*(Tb-Ta)\n",
      "Q2=cp*(Tc-Td)\n",
      "Wnet=Q1-Q2\n",
      "eta=Wnet/Q1\n",
      "eta2=1-Td/Ta\n",
      "#results\n",
      "print '%s %.3f' %(\"Efficiency in 1= \",eta)\n",
      "print '%s %.2f' %(\"\\n Efficiency in 2 = \",eta2)\n",
      "print '%s %d %s' %(\"\\n Work per pound of fluid =\",Wnet,\"B/lb\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Gas law solution\n",
        "Efficiency in 1=  0.369\n",
        "\n",
        " Efficiency in 2 =  0.37\n",
        "\n",
        " Work per pound of fluid = 73 B/lb\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1b - Pg 280"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the efficiency and work done per pound of fluid\n",
      "#initialization of variables\n",
      "import math\n",
      "Pb=75. #psia\n",
      "Pc=15. #psia\n",
      "k=1.4\n",
      "Td=550. #R\n",
      "Tb=1700.  #R\n",
      "cp=0.24\n",
      "#calculations\n",
      "Prd=1.4779\n",
      "hd=131.46 #B/lb\n",
      "Prb=90.95\n",
      "hb=422.59 #B/lb\n",
      "Pratio=Pb/Pc\n",
      "Pra=Pratio*(Prd)\n",
      "Ta=868 #R\n",
      "ha=208.41\n",
      "Prc=Prb/Pratio\n",
      "Tc=1113 #R\n",
      "hc=269.27\n",
      "Q1=hb-ha\n",
      "Q2=hc-hd\n",
      "Wnet=Q1-Q2\n",
      "eta=Wnet/Q1\n",
      "#results\n",
      "print '%s %.3f' %(\"Efficiency = \",eta)\n",
      "print '%s %.2f %s' %(\"\\n Work per pound of fluid =\",Wnet,\"B/lb\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Efficiency =  0.357\n",
        "\n",
        " Work per pound of fluid = 76.37 B/lb\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2 - Pg 282"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the work done and efficiency of the process\n",
      "#initialization of varaibles\n",
      "e=0.75\n",
      "Ta=870.  #R\n",
      "Tc=1075. #R\n",
      "cp=0.24\n",
      "Td=550.  #R\n",
      "Tb=1700. #R\n",
      "#calculations\n",
      "Tadash=e*(Tc-Ta) +Ta\n",
      "Tcdash=Tc+Ta-Tadash\n",
      "Q1=cp*(Tb-Tadash)\n",
      "Q2=cp*(Tcdash-Td)\n",
      "Wnet=Q1-Q2\n",
      "eta=Wnet/Q1\n",
      "#results\n",
      "print '%s %d %s' %(\"Net work done =\",Wnet,\"B/lb\")\n",
      "print '%s %.2f' %(\"\\n efficiency = \",eta)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Net work done = 73 B/lb\n",
        "\n",
        " efficiency =  0.45\n"
       ]
      }
     ],
     "prompt_number": 3
    }
   ],
   "metadata": {}
  }
 ]
}