summaryrefslogtreecommitdiff
path: root/sample_notebooks/GauravMittal/Ch3.ipynb
blob: 6e94dab7585074ee69500f001a544b9c6b322fd2 (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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 3 - Properties of pure substances"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example: 3.1 Page: 88"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example: 3.1 - Page: 88\n",
      "\n",
      "\n",
      "Molar Volume of the gas is 1.29e-02 cubic metres\n"
     ]
    }
   ],
   "source": [
    "print \"Example: 3.1 - Page: 88\\n\\n\"\n",
    "\n",
    "# Solution\n",
    "\n",
    "#*****Data*****\n",
    "P = 2*10**5## [Pa]\n",
    "T = 273 + 37## [K]\n",
    "R = 8.314## [J/mol K]\n",
    "#****************\n",
    "# Since the gas behaves ideally:\n",
    "V = R*T/P## [cubic metres]\n",
    "print \"Molar Volume of the gas is %.2e cubic metres\"%(V)#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example: 3.2 Page: 89"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example: 3.2 - Page: 89\n",
      "\n",
      "\n",
      "The pressure of air after compression is 1200 kPa\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print \"Example: 3.2 - Page: 89\\n\\n\"\n",
    "\n",
    "# Solution\n",
    "\n",
    "#*****Data*****\n",
    "V1 = 8## [cubic m]\n",
    "P1 = 300## [kPa]\n",
    "V2 = 2## [cubic m]\n",
    "#**************\n",
    "# Apptying  the ideal gas Eqn. & since the Temperature remains constant:\n",
    "P2 = P1*V1/V2## [kPa]\n",
    "print \"The pressure of air after compression is %d kPa\\n\"%(P2)#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example: 3.3 Page: 89"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example: 3.3 - Page: 89\n",
      "\n",
      "\n",
      "The pressure of the remaining air is 0 kPa\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print \"Example: 3.3 - Page: 89\\n\\n\"\n",
    "\n",
    "# Solution\n",
    "\n",
    "#*****Data*****\n",
    "V1 = 6## [cubic m]\n",
    "P1 = 500## [kPa]\n",
    "R = 0.287## [kJ/kg K]\n",
    "#*************\n",
    "# Applying the charectarstic equation to the gas initially:\n",
    "# P1*V1 = m1*R*T1.......................................(i)\n",
    "# Applying the charectarstic equation to the gas which was left in the vessel after one-fifth of the gas has been removed:\n",
    "# P2*V2 = m2*R*T2.......................................(ii)\n",
    "# V2 = V1# T2 = T1# m2 = (4/5)*m1# Eqn (ii) becomes:\n",
    "# P2*V1 = (4/5)*m1*R*T1..................................(iii)\n",
    "# Dividing eqn (i) by eqn (iii), we get:\n",
    "P2 = (4/5)*P1## [kPa]\n",
    "print \"The pressure of the remaining air is %d kPa\\n\"%(P2)#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example: 3.4 Page: 90"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example: 3.4 - Page: 90\n",
      "\n",
      "\n",
      "Final Temperature of the air when the piston reaches stop is 361.5 K\n",
      "\n",
      "Pressure of air inside the cylinder is 2.51 bar\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print \"Example: 3.4 - Page: 90\\n\\n\"\n",
    "\n",
    "# Solution\n",
    "\n",
    "#*****Data*****\n",
    "T1 = 450 + 273## [K]\n",
    "P1 = 3## [bar]\n",
    "#***************\n",
    "# Soluton(a)\n",
    "# From Fig. 3.7, (Page 90)\n",
    "# Since the weight remains the same, therefore, the final pressure is equal to the initial pressure.\n",
    "# Therefore it is a constant pressure process.\n",
    "P2 = P1## [bar]\n",
    "# Volumetric Ratio:\n",
    "V2_by_V1 = 2.5/(2.5 + 2.5)# Applying ideal gas law & P1 = P2\n",
    "T2 = T1*V2_by_V1## [K]\n",
    "print \"Final Temperature of the air when the piston reaches stop is %.1f K\\n\"%(T2)\n",
    "# Solution (b)\n",
    "# When the piston rests ot the stops, the pressure exerted by the weight, air & the atmosphere will be different. But there will beno further decrease in volume.\n",
    "# This is a constant volume process.\n",
    "T3 = 273 + 30## [K]\n",
    "# Applying ideal gas law & V2 = V3\n",
    "P3 = T3*P2/T2## [bar]\n",
    "print \"Pressure of air inside the cylinder is %.2f bar\\n\"%(P3)#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example: 3.5 Page: 95"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example: 3.5 - Page: 95\n",
      "\n",
      "\n",
      "The temperature at which ammonia exists in the cylinder is 321.5 K\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print \"Example: 3.5 - Page: 95\\n\\n\"\n",
    "\n",
    "# Solution\n",
    "\n",
    "#*****Data*****\n",
    "m = 1.373## [kg]\n",
    "P = 1.95*10**(6)## [Pa]\n",
    "V = 0.1## [cubic m]\n",
    "a = 422.546*10**(-3)## [cubic m/square mol]\n",
    "b = 37*10**(-6)## [cubic m/mol]\n",
    "M = 17*10**(-3)## [kg/mol]\n",
    "R = 8.314## [J/mol K]\n",
    "#****************\n",
    "n = m/M## [moles]\n",
    "Vm = V/n## [molar volume, cubic m]\n",
    "# Applying Van der Waals equation of state:\n",
    "T = (P + (a/Vm**2))*((Vm - b)/R)## [K]\n",
    "print \"The temperature at which ammonia exists in the cylinder is %.1f K\\n\"%(T)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example: 3.10 Page: 103"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example: 3.10 - Page: 103\n",
      "\n",
      "\n",
      "Value of derivative is 23.98 bar/OC\n",
      "\n",
      "The pressure generated by heating at constant Volume is 240.84 Pa\n",
      "\n",
      "The change in Volume is -0.038 cubic cm/g\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from math import exp\n",
    "print \"Example: 3.10 - Page: 103\\n\\n\"\n",
    "\n",
    "# Solution\n",
    "\n",
    "#*****Data*****\n",
    "beeta = 1.487*10**(-3)## [1/OC]\n",
    "alpha = 62*10**(-6)## [1/bar]\n",
    "V1 = 1.287## [cubic cm /g]\n",
    "#************\n",
    "# Solution (a)\n",
    "# The value of derivative (dP/dT) at constant V:\n",
    "# dV/V = beeta*dT - alpha*dP\n",
    "# dV = 0\n",
    "# dP/dT = beeta/alpha\n",
    "# Value = dP/dT\n",
    "Value = beeta/alpha## [bar/OC]\n",
    "print \"Value of derivative is %.2f bar/OC\\n\"%(Value)\n",
    "# Solution (b)\n",
    "P1 = 1## [bar]\n",
    "T1 = 20## [OC]\n",
    "T2 = 30## [OC]\n",
    "# Applying the same equation:\n",
    "P2 = P1 +(beeta/alpha)*(T2 - T1)## [bar]\n",
    "print \"The pressure generated by heating at constant Volume is %.2f Pa\\n\"%(P2)\n",
    "# Solution (c)\n",
    "T2 = 0## [OC]\n",
    "T1 = 20## [OC]\n",
    "P2 = 10## [bar]\n",
    "P1 = 1## [bar]\n",
    "# The change in Volume can be obtained as:\n",
    "V2 = V1*exp((beeta*(T2 - T1)) - alpha*(P2 - P1))## [cubic cm/g]\n",
    "deltaV = V2 - V1## [cubic cm/g]\n",
    "print \"The change in Volume is %.3f cubic cm/g\\n\"%(deltaV)#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example: 3.11 Page: 107"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example: 3.11 - Page: 107\n",
      "\n",
      "\n",
      "Acentric factor is 0.6447\n"
     ]
    }
   ],
   "source": [
    "from math import log10\n",
    "print \"Example: 3.11 - Page: 107\\n\\n\"\n",
    "\n",
    "# Solution\n",
    "\n",
    "#*****Data*****\n",
    "Tc = 513.9## [K]\n",
    "Pc = 61.48*10**5## [Pa]\n",
    "#************\n",
    "Tr = 0.7\n",
    "T = Tr*Tc - 273.15## [OC]\n",
    "P_sat = 10**(8.112 - (1592.864/(T + 226.184)))## [mm Hg]\n",
    "P_sat = P_sat*101325/760## [Pa]\n",
    "Pr_sat = P_sat/Pc## [Pa]\n",
    "omega = -1 - log10(Pr_sat)## [Acentric factor]\n",
    "print \"Acentric factor is %.4f\"%(omega)#"
   ]
  }
 ],
 "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
}