summaryrefslogtreecommitdiff
path: root/Engineering_Thermodynamics/ch4.ipynb
blob: d353eb40e318f153433e94f6d1f09915829c9fb2 (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
{
 "metadata": {
  "name": "",
  "signature": "sha256:eafe81375ae6bd6abb8d4dff5b78c1d88df56b904362e7f55dc57c603062c8b9"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 4 : First Law of Thermodynamics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.1 Page No : 78"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "V1 = 0.3; \t\t\t# Initial volume in m3\n",
      "V2 = 0.15; \t\t\t# Final volume in m3\n",
      "P = 0.105e06; \t\t\t# Pressure in Pa\n",
      "Q = -37.6e03; \t\t\t# Heat tranferred in J\n",
      "\n",
      "# Calculation\n",
      "W = P*(V2-V1); \t\t\t# Work done\n",
      "U = Q-W; \t\t\t# Internal energy change\n",
      "\n",
      "# Results\n",
      "print \"Change in the internal energy of the system is %.2f kJ\"%(U/1000)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in the internal energy of the system is -21.85 kJ\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.2 Page No : 78"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "Qacb = 84e03;\n",
      "Wacb = 32e03;\n",
      "Uba = Qacb-Wacb; \t\t\t# Ub-Ua\n",
      "\n",
      "# Calculation and Results\n",
      "# Part (a)\n",
      "Wadb = 10.5e03; \n",
      "Qadb = Uba+Wadb; \n",
      "print \"The heat flow into the system along the path adb\",(Qadb/1000),\"kJ\"\n",
      "\n",
      "# Part (b)\n",
      "Wb_a = -21e03;\n",
      "Uab = - Uba;\n",
      "Qb_a = Uab+Wb_a;\n",
      "print \"The heat liberated along the path b-a is\",round(Qb_a/1000),\"kJ\"\n",
      "\n",
      "# Part (c)\n",
      "Wdb = 0.; \t\t\t# Constant volume\n",
      "Wad = 10.4e03; \n",
      "Wadb = Wdb-Wad; \n",
      "Ud = 42e03;\n",
      "Ua = 0.;\n",
      "Qad = Ud-Ua+Wad;\n",
      "Qdb = Qadb-Qad; \n",
      "print \"The heat absorbed in the path ad and db are\",round(Qdb/1000),\"kJ\",\"and\",round(Qad/1000),\"kJ\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The heat flow into the system along the path adb 62.5 kJ\n",
        "The heat liberated along the path b-a is -73.0 kJ\n",
        "The heat absorbed in the path ad and db are 10.0 kJ and 52.0 kJ\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.3 Page No : 79"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "# Process a-b\n",
      "Qab = 0;\n",
      "Wab = 2170; \t\t\t# in KJ/min\n",
      "Eab = Qab-Wab; \n",
      "\n",
      "# Process b-c\n",
      "Qbc = 21000;\n",
      "Wbc = 0; \n",
      "Ebc = Qbc-Wbc;\n",
      "\n",
      "# Process c-d\n",
      "Qcd = -2100;\n",
      "Ecd = -36600; \n",
      "Wcd = Qcd-Ecd;\n",
      "\n",
      "# Calculation\n",
      "# Process d-a\n",
      "Q = -17000; \t\t\t# Total heat transfer\n",
      "Qda = Q-Qab-Qbc-Qcd; \n",
      "Eda = -Eab-Ebc-Ecd;\n",
      "Wda = Qda-Eda;\n",
      "M = [[Qab, Wab, Eab],[Qbc, Wbc ,Ebc],[Qcd, Wcd, Ecd],[Qda, Wda, Eda]];\n",
      "process = [\"a-b\",\"b-c\",\"c-d\",\"d-a\"]\n",
      "# Results\n",
      "print \"The completed table is\"\n",
      "print \"    process        Q          W         deltaE\"\n",
      "for i in range(4):\n",
      "    print \"%10s\"%process[i],\n",
      "    for j in range(3):\n",
      "        print \"%10d\"%M[i][j],\n",
      "\n",
      "    print \"\"\n",
      "print \"\\nRate of work output : %.f kJ/min\"%(sum([M[0][0],M[1][0],M[2][0],M[3][0]]))\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The completed table is\n",
        "    process        Q          W         deltaE\n",
        "       a-b          0       2170      -2170 \n",
        "       b-c      21000          0      21000 \n",
        "       c-d      -2100      34500     -36600 \n",
        "       d-a     -35900     -53670      17770 \n",
        "\n",
        "Rate of work output : -17000 kJ/min\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.4 Page No : 80"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Part (a)\n",
      "import math \n",
      "\n",
      "# Variables\n",
      "m = 3.;\n",
      "V1 = 0.22;     #volume m^3\n",
      "P1 = 500.e03;  #initial pressure Pa\n",
      "P2 = 100.e03;  #final pressure Pa\n",
      "\n",
      "# Calculation\n",
      "V2 = V1*(P1/P2)**(1./1.2);\n",
      "dU = 3.56*(P2*V2-P1*V1);\n",
      "gama = 1.2;\n",
      "W = (P2*V2-P1*V1)/(1-gama);\n",
      "Q = dU+W;\n",
      "\n",
      "# Results\n",
      "print \"Q,W and dU of the quasi static process are\",int(dU/1000),round(W/1000),round(Q/1000),\"kJ respectively\"\n",
      "\n",
      "# Part (b)\n",
      "Qb = 30e03;\n",
      "Wb = Qb-dU; \n",
      "print \"Work transfer for the process is\",round(Wb/1000),\"kJ\"\n",
      "\n",
      "# Part (c)\n",
      "print \"Wb is not equal to integral(p*dv) .since the process is not quasi static\"\n",
      "\n",
      "# rounding off error. please check"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Q,W and dU of the quasi static process are -92 129.0 37.0 kJ respectively\n",
        "Work transfer for the process is 122.0 kJ\n",
        "Wb is not equal to integral(p*dv) .since the process is not quasi static\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.5 Page No : 81"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy.linalg import inv\n",
      "from numpy import *\n",
      "from scipy.integrate import *\n",
      "\n",
      "# Variables\n",
      "V1 = 0.03;    #initial volume m^3\n",
      "P1 = 170e03;  #initial pressure Pa\n",
      "P2 = 400e03;  #final pressure Pa\n",
      "V2 = 0.06;    #final volume m^3\n",
      "U = 3.15*(P2*V2-P1*V1);\n",
      "B = array([P1, P2]);\n",
      "B= B.transpose()\n",
      "\n",
      "A = [[1, V1],[1, V2]];\n",
      "A = array(A)\n",
      "x =  inv(A)*B;\n",
      "\n",
      "a = -60000\n",
      "b = 7666666.7;\n",
      "\n",
      "# Calculation\n",
      "def pressure(V):\n",
      "    return a+b*V;\n",
      "\n",
      "W = quad(pressure,V1,V2)[0]\n",
      "Q = U+W;\n",
      "\n",
      "# Results\n",
      "print \"The work done by the system is\",round(W/1000,2),\"kJ\"\n",
      "print \"The internal energy change of the system is\",round(U/1000,1),\"J\"\n",
      "print \"The heat flow into the system is\",round(Q/1000,2),\"kJ\"\n",
      "\n",
      "# rounding off error. please check."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The work done by the system is 8.55 kJ\n",
        "The internal energy change of the system is 59.5 J\n",
        "The heat flow into the system is 68.09 kJ\n"
       ]
      }
     ],
     "prompt_number": 36
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.6 Page No : 82"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Process 1-2\n",
      "import math \n",
      "\n",
      "# Variables\n",
      "Q12 = 235; \t\t\t# in KJ/Kg\n",
      "W12 = 0 ;\n",
      "\n",
      "# Calculation\n",
      "U12 = Q12-W12;\n",
      "# Process 2-3\n",
      "Q23 = 0; \n",
      "U23 = -70 ;\n",
      "W23 = Q23-U23;\n",
      "\n",
      "# Process 3-1\n",
      "Q31 = - 200; \n",
      "U31 = -U12-U23;\n",
      "W31 = Q31-U31;\n",
      "W = W12 + W23 + W31;\n",
      "Q = Q12 + Q23 + Q31;\n",
      "\n",
      "# Results\n",
      "print \"Heat trasfer in the cycle is\",Q,\"KJ/Kg\"\n",
      "print \"Work done during the the cycle is\",W,\"KJ/Kg\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat trasfer in the cycle is 35 KJ/Kg\n",
        "Work done during the the cycle is 35 KJ/Kg\n"
       ]
      }
     ],
     "prompt_number": 39
    }
   ],
   "metadata": {}
  }
 ]
}