summaryrefslogtreecommitdiff
path: root/Thermodynamics_by_Gaggioli_and_Obert/Ch8.ipynb
blob: 2e3ca6097f10316f524787b3840484a5c0c7fcff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 8 Second and third law topics"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:8.1 Pg:255"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dp by ds at constant volume = 275 F/ft**3/lbm\n",
      "The answer is a bit different due to rounding off error in textbook\n"
     ]
    }
   ],
   "source": [
    "#Initialization of variables\n",
    "P=500 #psia\n",
    "T=700 #F\n",
    "J=778\n",
    "#calculations\n",
    "dpds=1490 *144/J\n",
    "#results\n",
    "print \"dp by ds at constant volume = %d F/ft**3/lbm\"%(dpds)\n",
    "print \"The answer is a bit different due to rounding off error in textbook\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:8.2 Pg:256"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Thermal efficiency = 66.5 percent\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "from math import log\n",
    "#Initialization of variables\n",
    "cp=0.25 #Btu/lbm R\n",
    "T0=520 #R\n",
    "T1=3460 #R\n",
    "#calculations\n",
    "dq=cp*(T0-T1)\n",
    "ds=cp*log(T0/T1)\n",
    "dE=dq-T0*ds\n",
    "eta=dE/dq\n",
    "#results\n",
    "print \"Thermal efficiency = %.1f percent\"%(eta*100)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:8.3 Pg:256"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Loss of available energy = -6774 Btu/lbm\n",
      "The answer is a bit different due to rounding off error in textbook\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "from math import log\n",
    "#Initialization of variables\n",
    "cp=0.25 #Btu/lbm R\n",
    "T0=520 #R\n",
    "T1=3460 #R\n",
    "dG=21069 #Btu/lbm\n",
    "dH=21502 #Btu/lbm\n",
    "#calculations\n",
    "dq=cp*(T0-T1)\n",
    "ds=cp*log(T0/T1)\n",
    "dE=dq-T0*ds\n",
    "eta=dE/dq\n",
    "dw=eta*dH\n",
    "de=-dG+dw\n",
    "#results\n",
    "print \"Loss of available energy = %d Btu/lbm\"%(de)\n",
    "print \"The answer is a bit different due to rounding off error in textbook\""
   ]
  }
 ],
 "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
}