summaryrefslogtreecommitdiff
path: root/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch2.ipynb
blob: aa52001ebe94b4aa4da950debf0416f031356cd6 (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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
{
 "metadata": {
  "name": "",
  "signature": "sha256:0a185017fb6d8b2f89e2c9757a0bd5f1ee2fdeb7cbf86205eb93a1d0a3214502"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "\n",
      "Chapter 2 : Basic Thermodynamics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.1  Page: 27"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "\n",
      "# Variables\n",
      "m = 1.          #[lbm] Mass of the steam\n",
      "T_1 = 300.      #[F] Initial temperature\n",
      "P_1 = 14.7      #[psia] Initial pressure\n",
      "P_sorronding = 14.7     #[psia]\n",
      "Q = 50.         #[Btu] Amount of the energy added to the system as heat\n",
      "\n",
      "# This is a closed system and we can apply the following equations\n",
      "# delta_U_system = sum(dQ_in_minus_out) + sum(dW_in_minus_out)                                (A)\n",
      "# dS_system = (m*ds)_system = sum((dQ)/T)_in_minus_out + dS_reversible                        (B)\n",
      "\n",
      "# From the steam tables, we look up the properties of steam at temperature 300F and pressure 14.7 psia and find \n",
      "u_initial = 1109.6      #[Btu/lbm] Internal energy of the steam\n",
      "h_initial = 1192.6      #[Btu/lbm] Enthalpy of the steam\n",
      "s_initial = 1.8157      #[Btu/(lbm*R)] Entropy of the steam\n",
      "\n",
      "# The work here is done by the system, equal to\n",
      "#  -delta_w = P*A_piston*delta_x = P*m*delta_v\n",
      "\n",
      "# Calculations\n",
      "# Substituting this in the equation (A) and rearranging, we have\n",
      "#  m*delta_(u + P*v) = m*delta_h = delta_Q\n",
      "# From which we can solve for the final specific enthalpy\n",
      "h_final = h_initial + Q     #[Btu/lbm]\n",
      "\n",
      "# Now, by the linear interpolation we find that at h = 1242.6 Btu/lbm and P = 1 atm, temperature of the steam is given \n",
      "T_2 = 405.7                 #[F] Final temperature\n",
      "\n",
      "# At this final temperature and pressure we have the steam properties \n",
      "u_final = 1147.7            #[Btu/lbm]\n",
      "s_final = 1.8772            #[Btu/(lbm*R)]\n",
      "\n",
      "# Thus, increase in the internal energy, enthalpy and entropy are \n",
      "delta_u = u_final - u_initial       #[Btu/lbm]\n",
      "delta_s = s_final - s_initial       #[Btu/(lbm*R)]\n",
      "delta_h = Q                         #[Btu/lbm]\n",
      "\n",
      "# The work done on the atmosphere is given by\n",
      "w = delta_h - delta_u               #[Btulbm]\n",
      "\n",
      "# Results\n",
      "print \"The increase in internal energy of the steam by adding the heat is %0.2f Btu/lbm\"%(delta_u)\n",
      "print \"The increase in enthalpy of the steam by adding the heat is        %0.2f Btu/lbm\"%(delta_h)\n",
      "print \"The increase in entropy of the steam by adding the heat is         %0.4f Btu/lbm\"%(delta_s)\n",
      "print \"Work done by the piston expanding against the atmosphere is       %0.2f Btu/lbm\"%(w)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The increase in internal energy of the steam by adding the heat is 38.10 Btu/lbm\n",
        "The increase in enthalpy of the steam by adding the heat is        50.00 Btu/lbm\n",
        "The increase in entropy of the steam by adding the heat is         0.0615 Btu/lbm\n",
        "Work done by the piston expanding against the atmosphere is       11.90 Btu/lbm\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.2  Page: 28\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "\n",
      "# Variables\n",
      "T_in = 600.      #[F] Input steam temperature\n",
      "P_in = 200.      #[psia] Input steam pressure\n",
      "P_exit = 50.     #[psia]\n",
      "\n",
      "# Because this is a steady-state, steady-flow process, we use \n",
      "# (work per pound) = W/m = -( h_in - h_out )\n",
      "\n",
      "# From the steam table we can read the the inlet enthalpy and entropy as \n",
      "h_in = 1322.1       #[Btu/lbm]\n",
      "s_in = 1.6767       #[Btu/(lb*R)]\n",
      "\n",
      "# Now, we need the value of h_out\n",
      "\n",
      "# For a reversible adiabatic steady-state, steady-flow process, we have\n",
      "# sum(s*m_in_minus_out) = ( s_in - s_out ) = 0\n",
      "\n",
      "# Which indicates that inlet and outlet entropies are same\n",
      "# We can find the outlet temperature by finding the value of the temperature in the steam table\n",
      "# For which the inlet entropy at 50 psia is the same as the inlet entropy, 1.6767 Btu/(lb*R). \n",
      "# By linear interpolation in the table we find \n",
      "T_in = 307.1        #[R]\n",
      "\n",
      "# and by the linear interpolation in the same table we find that\n",
      "h_out = 1188.1      #[Btu/lb]\n",
      "\n",
      "# Calculations\n",
      "# Thus, we find \n",
      "W_per_pound = (h_in - h_out)       #[Btu/lb]\n",
      "\n",
      "# Results\n",
      "print \" The work output of the turbine of steam is %0.1f Btu/lb\"%(-W_per_pound)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The work output of the turbine of steam is -134.0 Btu/lb\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.3   Page: 38"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "\n",
      "\n",
      "# Variables\n",
      "T = 500.        #[F]\n",
      "P = 680.        #[psi]\n",
      "\n",
      "# Calculations\n",
      "# It is reported in the book in the table A.1(page 417) that for water \n",
      "# We know that T_r = T/T_c and P_r = P/P_c, so\n",
      "T_c = 647.1*1.8     #[R]\n",
      "P_c = 220.55*14.51  #[psia]\n",
      "w = 0.345\n",
      "T_r = (T+459.67)/T_c\n",
      "P_r = P/P_c\n",
      "z_0 = 1+P_r/T_r*(0.083-0.422/T_r**(1.6))\n",
      "z_1 = P_r/T_r*(0.139-0.172/T_r**(4.2))\n",
      "z = z_0+w*z_1\n",
      "\n",
      "# Results\n",
      "print \"The compressibility factor of steam at the given state is %0.3f\"%(z)\n",
      "# Based on the steam table (which may be considered as reliable as the experimental data, the value of z is 0.804.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The compressibility factor of steam at the given state is 0.851\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}