summaryrefslogtreecommitdiff
path: root/Thermodynamics_by_Gaggioli_and_Obert/ch7.ipynb
blob: 54e862313ac81fa40d3c61aa54ae9f43f596b71d (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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 7 The second law"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:7.2 Pg:192"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Entropy in ab part = 0.1213 Btu/lbm R\n",
      "\n",
      " Entropy in ac part = 0.1688 Btu/lbm R\n",
      "\n",
      " Efficiency = 9.80 percent\n",
      "The answers are a bit different due to rounding off error in textbook\n"
     ]
    }
   ],
   "source": [
    "from math import log\n",
    "#Initialization of variables\n",
    "cv=0.175 #Btu/lbm R\n",
    "R0=1.986\n",
    "M=29\n",
    "T2=1040 #R\n",
    "T1=520 #R\n",
    "#calculations\n",
    "cp=cv+R0/M\n",
    "sab=cv*log(T2/T1)\n",
    "sac=cp*log(T2/T1)\n",
    "dqab=cv*(T2-T1)\n",
    "dqca=cp*(T1-T2)\n",
    "dqrev=T2*(sac-sab)\n",
    "eta=(dqab+dqrev+dqca)/(dqab+dqrev)\n",
    "#results\n",
    "print \"Entropy in ab part = %.4f Btu/lbm R\"%(sab)\n",
    "print \"\\n Entropy in ac part = %.4f Btu/lbm R\"%(sac)\n",
    "print \"\\n Efficiency = %.2f percent\"%(eta*100)\n",
    "print \"The answers are a bit different due to rounding off error in textbook\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:7.3 Pg:193"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Change in entropy of the process = 0.0192 Btu/R\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",
    "tc=32 #F\n",
    "th=80 #F\n",
    "mw=5 #lbm\n",
    "mi=1 #lbm\n",
    "P=14.7 #psia\n",
    "cp=1\n",
    "#calculations\n",
    "t= (-144*mi+tc*mi+th*mw)/(mw+mi)\n",
    "ds1=144/(tc+460)\n",
    "ds2=cp*log((460+t)/(460+tc))\n",
    "dsice=ds1+ds2\n",
    "dswater=mw*cp*log((t+460)/(460+th))\n",
    "ds=dsice+dswater\n",
    "#results\n",
    "print \"Change in entropy of the process = %.4f Btu/R\"%(ds)\n",
    "print \"The answer is a bit different due to rounding off error in textbook\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:7.4 Pg:194"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Change in available energy = -3.5 Btu/lbm\n",
      "\n",
      " The available energy of the isolated system decreased in the amount of  -36.5 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",
    "\n",
    "#Initialization of variables\n",
    "cp=1\n",
    "T2=60 #F\n",
    "T1=100 #F\n",
    "ta=32 #F\n",
    "#calculations\n",
    "dq=cp*(T2-T1)\n",
    "ds=cp*log((460+T2)/(460+T1))\n",
    "dE=dq-ds*(ta+460)\n",
    "dec=dq-dE\n",
    "#results\n",
    "print \"Change in available energy = %.1f Btu/lbm\"%(dE)\n",
    "print \"\\n The available energy of the isolated system decreased in the amount of  %.1f Btu/lbm\"%(dec)\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
}