summaryrefslogtreecommitdiff
path: root/Basic_Engineering_Thermodynamics/ch2.ipynb
blob: e0d9b70ed14ff06bfb3da8bac80f4a0f4a3f0d3b (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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
{
 "metadata": {
  "name": "",
  "signature": "sha256:6899d33957757e53b75082591aa468f495e3dee26f9772aa86059a86f9321499"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2 : Work"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.1 Page No : 28"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "\t\t\t\n",
      "# Variables\n",
      "Force = 180 \t\t\t#in N \t\t\t#horizontal force\n",
      "theta = 30 \t\t\t#in degrees \t\t\t#angle of inclination\n",
      "distance = 12 \t\t\t#in m \t\t\t#distance moved by block along inclined plane.\n",
      " \n",
      "\t\t\t\n",
      "# Calculations and Results\n",
      "Work = Force * (distance * math.cos(math.radians(theta))) \t\t\t#in J \t\t\t# Work done\n",
      "Work = 0.001 * Work \t\t\t# Work done in KJ\n",
      "print \"Work done by block = %.4f KJ\"%(Work);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Work done by block = 1.8706 KJ\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2 Page No : 31"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "mass_body = 2 \t\t\t#in kg \t\t\t#mass of body\n",
      "L = 5 \t\t\t#in m \t\t\t#vertical distance\n",
      "g = 9.8 \t\t\t#in m/s**2 \t\t\t#acceleration due to gravity\n",
      "\n",
      "\t\t\t\n",
      "# Calculations and Results\n",
      "Work_done_by_agent = mass_body * g * L \t\t\t#in Nm \t\t\t#work done by agent\n",
      "Work_done_by_body = -1*Work_done_by_agent\n",
      "print \"Work done by agent = %.0f Nm\"%(Work_done_by_agent);\n",
      "print \"Work done by body = %.0f Nm\"%(Work_done_by_body);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Work done by agent = 98 Nm\n",
        "Work done by body = -98 Nm\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.4 Page No : 39"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from scipy.integrate import quad \n",
      "\t\t\t\n",
      "# Variables\n",
      "p1 = 1.5 * 10**(5) \t\t\t#N/m**2 \t\t\t#initial pressure in ballon\n",
      "d1 = 0.25 \t\t\t#m \t\t\t#initial diameter of balloon\n",
      "d2 = 0.3 \t\t\t#m \t\t\t#final diameter of balloon\n",
      "p_atm = 10**(5) \t\t\t#N/m**2 \t\t\t#atmospheric pressure\n",
      "\t\t\t\n",
      "# Calculations and Results\n",
      "\n",
      "#Part (a)\n",
      "print \"Part a\";\n",
      "print \"As p is proportional to d, p = k*d, where k is proportionality constant\"\n",
      "print \"Therefore,\";\n",
      "\n",
      "k = p1/d1;\n",
      "print \"p1 = k*d1 => k = p1/d1 = %.2f/%.2f) = %.1e N/m**3\"%(p1,d1,k);\n",
      "\n",
      "p2 = k*d2; \t\t\t#N/m**2 \t\t\t#final pressure in balloon\n",
      "print \"p2 = k*d2 = %.2f*%.2f) = %.1e N/m**2\"%(k,d2,p2);\n",
      "\n",
      "\n",
      "def f0(d): \n",
      "\t return k*(math.pi/2)*(d**3)\n",
      "\n",
      "W_air =  quad(f0,d1,d2)[0]\n",
      "\n",
      "print \"Work done by balloon on air = %.0f Nm\"%(W_air);\n",
      "\n",
      "\t\t\t#Part (b)\n",
      "print \"Part b\";\n",
      "\n",
      "def f1(d): \n",
      "\t return p_atm*(0.5*math.pi*(d**2))\n",
      "\n",
      "W_atm =  quad(f1,d2,d1)[0]\n",
      "\n",
      "print \"Work done by atmosphere on balloon = %.2f Nm\"%(W_atm);\n",
      "W_balloon = -1*(W_air+W_atm);\n",
      "print \"Work done by balloon = -Work done by air + Work done by atmosphere = -%.0f %.0f = %.0f Nm\"%(W_air,W_atm,W_balloon);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Part a\n",
        "As p is proportional to d, p = k*d, where k is proportionality constant\n",
        "Therefore,\n",
        "p1 = k*d1 => k = p1/d1 = 150000.00/0.25) = 6.0e+05 N/m**3\n",
        "p2 = k*d2 = 600000.00*0.30) = 1.8e+05 N/m**2\n",
        "Work done by balloon on air = 988 Nm\n",
        "Part b\n",
        "Work done by atmosphere on balloon = -595.59 Nm\n",
        "Work done by balloon = -Work done by air + Work done by atmosphere = -988 -596 = -393 Nm\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.5 Page No : 40"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\n",
      "# Variables\n",
      "p1 = 10 \t\t\t#bar \t\t\t#initial pressure\n",
      "V1 = 0.1 \t\t\t#m**3 \t\t\t#initial volume\n",
      "p2 = 2 \t\t\t#bar \t\t\t#final pressure\n",
      "V2 = 0.35 \t\t\t#m**3 \t\t\t#final volume\n",
      "\n",
      "\t\t\t\n",
      "# Calculations and Results\n",
      "print \"Let the expansion process follow the path pV**n = constant\";\n",
      "print \"Therefore \"\n",
      "n = (math.log(p1/p2))/(math.log(V2/V1));\n",
      "print \"n = lnp1/p2/lnV2/V1 = ln%.2f/%.2f/ln %.2f/%.2f = %.4f\"%(p1,p2,V2,V1,n);\n",
      "W_d = (p1*V1 - p2*V2)*10**5/(n-1) \t\t\t#J \t\t\t#Work interaction for pure substance\n",
      "print \"Work interaction for pure substance = p1V1 - p2V2)/n-1) = %.2f kJ\"%(W_d*.001)\n",
      "\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Let the expansion process follow the path pV**n = constant\n",
        "Therefore \n",
        "n = lnp1/p2/lnV2/V1 = ln10.00/2.00/ln 0.35/0.10 = 1.2847\n",
        "Work interaction for pure substance = p1V1 - p2V2)/n-1) = 105.37 kJ\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.6 Page No : 41"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables\n",
      "p1 = 1.0 \t\t\t#bar \t\t\t#initial pressure\n",
      "V1 = 0.1 \t\t\t#m**3 \t\t\t#initial volume\n",
      "p2 = 6   \t\t\t#bar \t\t\t#final pressure\n",
      "         \t\t\t#and p1*(V1**1.4) = p2*(V2**1.4)\n",
      "\n",
      "\t\t\t\n",
      "# Calculations and Results\n",
      "#Part (a)\n",
      "print \"Part a\";\n",
      "V2 = V1*(p1/p2)**(1/1.4) \t\t\t#m**3 \t\t\t#final volume\n",
      "print \"Final Volume = %.4f m**3\"%(V2);\n",
      "\n",
      "W_d = (10**5)*(p1*V1 - p2*V2)/(1.4-1); \t\t\t#J \t\t\t#Work of compression for air\n",
      "print \"Work of compression for air = %.1f KJ\"%(W_d*.001);\n",
      "\n",
      "#Part (b)\n",
      "print \"Part b\";\n",
      "V2 = (p1/p2)*V1; \t\t\t#m**3 \t\t\t#final volume\n",
      "print \"Final Volume = %.4f m**3\"%(V2);\n",
      "\n",
      "W_d = (10**5)*p1*V1*math.log(V2/V1); \t\t\t#J \t\t\t#Work done on air\n",
      "print \"Work done on air = %.1f KJ\"%(W_d*.001);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Part a\n",
        "Final Volume = 0.0278 m**3\n",
        "Work of compression for air = -16.7 KJ\n",
        "Part b\n",
        "Final Volume = 0.0167 m**3\n",
        "Work done on air = -17.9 KJ\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7 Page No : 43"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables\n",
      "#four-stroke engine\n",
      "x = 3. \t\t\t#number of cylinders\n",
      "y = 1. \t\t\t#engine is math.single-acting\n",
      "n = 500. \t\t\t#rev/min \n",
      "N = n/2 \t\t\t#cycles/min\n",
      "D = 0.075 \t\t\t#m \t\t\t#bore length\n",
      "L = 0.1 \t\t\t#m \t\t\t#stroke length\n",
      "a = 6.*10**(-4) \t\t\t#m**2 \t\t\t#area\n",
      "l = 0.05 \t\t\t#m \t\t\t#length\n",
      "S = 2.*10**8 \t\t\t#N/m**3 \t\t\t#spring constant\n",
      "\n",
      "\t\t\t\n",
      "# Calculations and Results\n",
      "p_m = (a/l)*S \t\t\t#Pa \t\t\t#mep\n",
      "\n",
      "print \"Mean effective pressure, mep{Pm} = %.2f kPa\"%(p_m*.001)\n",
      "A = (math.pi/4)*D**2 \t\t\t#m**2\n",
      "\n",
      "print \"Indicated power{P_ind} = %.2f kW\"%(x*y*p_m*L*A*N/60000)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mean effective pressure, mep{Pm} = 2400.00 kPa\n",
        "Indicated power{P_ind} = 13.25 kW\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.8 Page No : 45"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from numpy import *\n",
      "\t\t\t\n",
      "# Variables\n",
      "N = poly1d([.5,0]) \t\t\t#n is engine speed\n",
      "x = 6 \t\t\t#six cylinders\n",
      "y = 1 \t\t\t#assumed\n",
      "d = 0.1 \t\t\t#m \t\t\t#bore length\n",
      "A = math.pi*(0.1)**2/4 \t\t\t#m**2 \t\t\t#Area\n",
      "L = 0.15 \t\t\t#m \t\t\t#stroke length\n",
      "P_shaft = 24.78 \t\t\t#KW \t\t\t#Power of shaft\n",
      "T = 474.9 \t\t\t#Nm \t\t\t#Torque in the crank shaft\n",
      "l = 0.05 \t\t\t#m \t\t\t#length of indicator diagram\n",
      "a = 9.37*10**(-4) \t\t\t#cm**2 \t\t\t#area of indicator diagram\n",
      "S = 0.5*(10**8) \t\t\t#N/m**3 \t\t\t#spring constant\n",
      "\n",
      "\t\t\t\n",
      "# Calculations and Results\n",
      "p_m = a*S/l \t\t\t#mean pressure difference\n",
      "print \"Mean pressure difference = %.2f N/m**2\"%(p_m);\n",
      "\n",
      "P_ind = (x*y)*p_m*(L*A*N/60000) \t\t\t#indicated power\n",
      "#C = coeff(P_ind)\n",
      "C = poly(P_ind)\n",
      "print \"Indicated Power = %.6f n kW\"%(C[1])\n",
      "\n",
      "P_shaft = 2*math.pi*poly([1,0])*T/60000 \t\t\t#shaft power output\n",
      "print \"Shaft power output in KW)= %.5f n kW\"%(P_shaft[0])\n",
      "\n",
      "#Mechanical_efficiency = poly(P_shaft,1)/coeff(P_ind,1)*100\n",
      "Mechanical_efficiency = poly(P_shaft[1])/poly(P_ind[1])*100\n",
      "print \"Mechanical Efficiency = %.0f %%\"%(-Mechanical_efficiency[1])\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mean pressure difference = 937000.00 N/m**2\n",
        "Indicated Power = -0.055194 n kW\n",
        "Shaft power output in KW)= 0.04973 n kW\n",
        "Mechanical Efficiency = 90 %\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.9 Page No : 46"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables\n",
      "d = 0.4 \t\t\t#m \t\t\t#cylinder diameter\n",
      "t = 10. \t\t\t#min \t\t\t#Time taken for stirring\n",
      "L = 0.49 \t\t\t#m \t\t\t#distance moved by the piston\n",
      "p_atm = 1. \t\t\t#bar \t\t\t#atmospheric pressure\n",
      "W_net = -1965. \t\t\t#Nm \t\t\t#net work done\n",
      "n = 750. \t\t\t#rev/min \t\t\t#rotational velocity of electric motor\n",
      "I = 0.9 \t\t\t#A \t\t\t#current\n",
      "V = 24. \t\t\t#V \t\t\t#voltage\n",
      "\n",
      "\t\t\t\n",
      "# Calculations and Results\n",
      "#Part(a)\n",
      "print \"Part a\";\n",
      "W_d = 10**5*p_atm * (math.pi/4) * d**2 * L; \t\t\t#Nm \t\t\t#work done by fluid on piston\n",
      "print \"Work done by fluid on the piston = %.1f Nm\"%(W_d);\n",
      "W_str = W_net - W_d; \t\t\t#Nm \t\t\t#Work done by stirrer\n",
      "print \"Work done by stirrer on the fluid = %.1f Nm\"%(W_str);\n",
      "P_shaft = abs(W_str)/(t*60); \t\t\t#W \t\t\t#shaft power output\n",
      "print \"Shaft power output = %.2f W\"%(P_shaft);\n",
      "T = (P_shaft*60)/(2*math.pi*n); \t\t\t#Nm \t\t\t#Torque in the driving shaft\n",
      "print \"Torque in the driving shaft = %.3f Nm\"%( T);\n",
      "\n",
      "#Part(b)\n",
      "print \"Part b\";\n",
      "W_bat = I*V*t*60; \t\t\t#Nm \t\t\t#work done by battery\n",
      "print \"Work done by battery = %.1f Nm\"%(W_bat);\n",
      "W_motor = -1*(W_bat+W_str) \t\t\t#Nm \t\t\t#work done by motor\n",
      "print \"Work done by motor = %.1f Nm\"%(W_motor);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Part a\n",
        "Work done by fluid on the piston = 6157.5 Nm\n",
        "Work done by stirrer on the fluid = -8122.5 Nm\n",
        "Shaft power output = 13.54 W\n",
        "Torque in the driving shaft = 0.172 Nm\n",
        "Part b\n",
        "Work done by battery = 12960.0 Nm\n",
        "Work done by motor = -4837.5 Nm\n"
       ]
      }
     ],
     "prompt_number": 9
    }
   ],
   "metadata": {}
  }
 ]
}