summaryrefslogtreecommitdiff
path: root/Thermodynamics_An_Engineering_Approach/Chapter1.ipynb
blob: 3e2c20518d3893bcfcbee9cb8449305947b3b5e0 (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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 1: Introduction and Basic Concepts"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1-2, Page No.8"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given values\n",
      "p=850;# density in kg/m^3\n",
      "V=2;  # volumne of tank in m^3\n",
      "\n",
      "#Calculations\n",
      "m=p*V;# mass, density and volumne corealtion\n",
      "\n",
      "#Result\n",
      "print 'The amount of oil in tank is %i kg' %round(m,0)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The amount of oil in tank is 1700 kg\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1-3, Page No.9"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Constants used\n",
      "g=32.174;# gravitational constant in ft/s^2\n",
      "\n",
      "#given values\n",
      "m=1; # mass of 1.00 lbm is subjected to standard earth gravity\n",
      "\n",
      "#Calculations\n",
      "w=(m*g)/g; # weight is mass times the local value of gravitational acceleration\n",
      "#dimensionally the above equation is represented as lbm * ft/s^2 * (lbf/ft/s^2)\n",
      "\n",
      "#Result\n",
      "print 'The weight on earth is %i lbf' %w\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The weight on earth is 1 lbf\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1-4, Page No.21"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Example 1.4\n",
      "\n",
      "# Given values\n",
      "Tc=10; #change in temp in Celcius\n",
      "\n",
      "# Calculations\n",
      "Tk=Tc;\n",
      "Tr=1.8*Tk;#conversion scale of temperature change from K to R\n",
      "Tf=Tr;\n",
      "# calculated using the corealtions b/w these scales\n",
      "\n",
      "#Results\n",
      "print 'the corresponding change is %i K' %Tk\n",
      "print 'the corresponding change is %i R' %Tr\n",
      "print 'the corresponding change is %i F' %Tf\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the corresponding change is 10 K\n",
        "the corresponding change is 18 R\n",
        "the corresponding change is 18 F\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1-5, Page No.23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given values\n",
      "Patm=14.5; #atmospheric pressure in psi\n",
      "Pvac=5.8;  #vacuum gage reading in psi\n",
      "\n",
      "#Calculations\n",
      "Pabs=Patm-Pvac;#pressure in vaccumm is always treated to be negative\n",
      "\n",
      "#Results\n",
      "print'the absolute pressure in the chamber %f psi'%round(Pabs,1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the absolute pressure in the chamber 8.700000 psi\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1-6, Page No.26"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Constants used\n",
      "pw=1000; # density of water in kg/m^3;\n",
      "g=9.81; # acceleration due to gravity in m/s^2;\n",
      " \n",
      "#Given values\n",
      "SG=0.85;# specific gravity of manometric fluid\n",
      "h=0.55;# converting height from cm to m\n",
      "Patm=96;# atmospheric pressure in kPa\n",
      "\n",
      "# Calculations\n",
      "p=SG*pw;\n",
      "Ptank=Patm+(p*g*h/1000); # calculating pressure using liquid at same height have same pressure\n",
      "\n",
      "#Results\n",
      "print 'absolute pressure in tank %f kPa' %round(Ptank,1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "absolute pressure in tank 100.600000 kPa\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1-7, Page No.28"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Constants used\n",
      "g=9.81;#acceleration due to gravity in m/s^2;\n",
      "\n",
      "#Given values\n",
      "h1=0.1;# distance b/w point 1 at air-water interface and point 2 at mercury-air interface in m\n",
      "h2=0.2;# distance b/w oil-water interface and  mercury-oil interface in m\n",
      "h3=0.35;# distance b/w air-mercury interface and  mercury-oil interface in m\n",
      "pw=1000;# density of water in kg/m^3\n",
      "pHg=13600;# density of mercury in kg/m^3\n",
      "poil=800;# density of oil in kg/m^3\n",
      "Patm=85.6;# atmospheric pressure in kPa\n",
      "\n",
      "#Calculation\n",
      "P1=Patm-(pw*g*h1+poil*g*h2-pHg*g*h3)/1000;#calculating pressure using liquid at same height have same pressure\n",
      "\n",
      "#Results\n",
      "print 'the air pressure in tank %i kPa' %round(P1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the air pressure in tank 130 kPa\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1-8, Page No.31"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Constants used\n",
      "g=9.81;# acceleration due to gravity in m/s^2;\n",
      "\n",
      "#Given values\n",
      "pHg=13570;# density of mercury at 10 C in kg/m^3\n",
      "h=0.74;# converting barometric reading into m from mm\n",
      "\n",
      "#Calculationa\n",
      "Patm=pHg*g*h/1000;# standard  pressure formula\n",
      "\n",
      "#Results\n",
      "print 'the atmospheric pressure %f kPa' %round(Patm,1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the atmospheric pressure 98.500000 kPa\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1-9, Page No.31"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#constants used\n",
      "g=9.81;#acceleration due to gravity in m/s^2;\n",
      "\n",
      "#given values\n",
      "m=60;# mass of piston in kg\n",
      "Patm=0.97;# atmospheric pressure in kPa\n",
      "A=0.04;# cross-sectional area in m^2\n",
      "\n",
      "#calculation\n",
      "P=Patm+(m*g/A)/100000;# standard  pressure formula\n",
      "print 'The pressure inside the cylinder %f bar' %round(P,2)\n",
      "#The volume change will have no effect on the free-body diagram drawn in part (a), and therefore the pressure inside the cylinder will remain the same\n",
      "print('If some heat is transferred to the gas and its volume is doubled, there is no change in pressure');\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The pressure inside the cylinder 1.120000 bar\n",
        "If some heat is transferred to the gas and its volume is doubled, there is no change in pressure\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1-10, Page No.32"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from scipy.integrate import quad \n",
      "from pylab import *\n",
      "\n",
      "#Constants used\n",
      "g=9.81;#acceleration due to gravity in m/s^2;\n",
      "\n",
      "#Given values\n",
      "p=1040;# density on the water surface in kg/m^3\n",
      "h1=0.8;# thickness of surface zone\n",
      "H=4;# thickness of gradient zone\n",
      "x0=0.0;# lower limit of integration\n",
      "x1=4.0;# upper limit of integration\n",
      "\n",
      "\n",
      "#Calculations\n",
      "P1=p*g*h1/1000;#standard  pressure determination formula\n",
      "#P2 = integration of the exp. p*g*(math.sqrt(1+(math.tan(math.pi*z/4/H)^2))) b/w 0-4\n",
      "def intgrnd1(z): \n",
      " return (p*g*(math.sqrt(1+(math.tan(math.pi*(z)/4/H)**2))) )#integrant\n",
      "P2, err = quad(intgrnd1, x0, x1) \n",
      "P2=P2/1000;#converting into kPa\n",
      "P=P1+P2;\n",
      "\n",
      "#Results\n",
      "print 'the gage pressure at the bottom of gradient zone %f kPa' %round(P)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the gage pressure at the bottom of gradient zone 54.000000 kPa\n"
       ]
      }
     ],
     "prompt_number": 17
    }
   ],
   "metadata": {}
  }
 ]
}