summaryrefslogtreecommitdiff
path: root/Thermodynamics_Demystified_by_Merle_C_Potter/Chapter3_2.ipynb
blob: f646fae2694fd755587cc693ea3f1966afcb1f39 (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
{
 "metadata": {
  "name": "",
  "signature": "sha256:f6a6bb505322436c23c138c1e60d951ed65e1f5f903d0d7ef3e7664203b1c411"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 3:Work and Heat"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3.1:PG-45"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#initialization of variables\n",
      "m=1            # mass in kg\n",
      "x=20.0/100.0       #quality of steam\n",
      "P=200          #constant pressure in kPa\n",
      "T1=100         #temperature intitial in degree centigrade\n",
      "T2=400         #temperature final in degree centigrade\n",
      "\n",
      "\n",
      "# first we find initial volume v1 and final volume v2\n",
      "\n",
      "# using table C.2\n",
      "vf=0.001061 # specific volume of saturated liquid in m^3 per kg \n",
      "vg=0.8857   # specific volume of saturated vapour in m^3 per kg \n",
      "\n",
      "v1=vf+x*(vg-vf);\n",
      "\n",
      "v2=1.549   # specific volume of steam in m^3 per kg at T2=400*C and P2=0.2MPa\n",
      "# now calculate work\n",
      "W=m*P*(v2-v1);   # work done in constant pressure process\n",
      "#result\n",
      "print \"Work done is\",round(W,2),\" kJ\" # work is in kJ as pressure was in kPa"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Work done is 274.2  kJ\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3.2:PG-46"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialization of variables\n",
      "D=110.0/1000.0 # diameter of cylinder in m\n",
      "V1=100e-6 # initial volume@ state 1 in m^3\n",
      "T1=60.0 # initial temp @ state 1 in *C\n",
      "T2=200.0 # final temo @ state 2 in *C\n",
      "M=50 # weight of piston in kg\n",
      "g=9.81 # gravitational accleration in m/sec^2\n",
      "Patm=100000 # atmospheric pressure in Pa\n",
      "A=math.pi*(D**2)/4 # area of piston in m^2\n",
      "\n",
      "# BALANCING THE FORCES To GET PRESSURE P\n",
      "# M.g=P.A-Patm\n",
      "P=Patm+(M*g/A) # atm pressure is added to get absolute pressure\n",
      "\n",
      "v1=0.001017 # specific volume at 60*C and 0.15Mpa pressure\n",
      "m=V1/v1; # mass of water in kg\n",
      "\n",
      "# find volume at state 2 \n",
      "v2=1.444 # specific volume of steam at 200*C and 0.15 MPa\n",
      "V2=m*v2 # final volume in m^3\n",
      "\n",
      "W=P*(V2-V1)/1000; # work done divided by 1000 to get in kJ\n",
      "# result\n",
      "print \"The work done is\",round(W,1),\" kJ\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The work done is 21.5  kJ\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3.3:PG-47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#initialization of variables\n",
      "P1=200      # initial pressure in kPa\n",
      "V1=2        # initial volume in m^3\n",
      "P2=100      # final pressure in kPa\n",
      "C=P1*V1 # isothermal process i.e P.V=constant\n",
      "#  find final volume \n",
      "V2=P1*V1/P2 # final volume by P1.V1=P2.V2\n",
      "\n",
      "from scipy.integrate import quad\n",
      " \n",
      "def integrand(v,C):\n",
      "    return C/v\n",
      "W, err =quad(integrand, V1, V2,C ) # itegrating over volume to get work\n",
      "# result\n",
      "print \"The Work done by gas is\",int(W),\" kJ\" # answer is approximated in textbook"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Work done by gas is 277  kJ\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3.4:PG-48"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# initialization of variables\n",
      "M=100 # mass in kg\n",
      "d=3 # depth by which mass drops in m\n",
      "V=0.002 # increased volume in m^3\n",
      "g=9.8 # gravitational accleration in m/sec^2\n",
      "Pgauge=100*1000 # gauge pressure in N/m\n",
      "Patm =100*1000 # atmospheric pressure in N/m\n",
      "P=Pgauge+Patm # to get absolute pressure\n",
      "\n",
      "# calculate work done by paddle wheel\n",
      "Wpaddlewheel=(-M*g*d) # work is negative as it is done on the system\n",
      "\n",
      "# calculate work done on piston it \n",
      "Wboundary=P*V # area mulitiplied by height is volume thus W=P.V \n",
      "\n",
      "#net work\n",
      "\n",
      "Wnet=Wpaddlewheel+Wboundary; # Work in joule as SI units are used\n",
      "print \"The Net Work done is \",round(Wnet),\" J\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Net Work done is  -2540.0  J\n"
       ]
      }
     ],
     "prompt_number": 33
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3.5:PG-51"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "# initialization of variables\n",
      "T=100 # torque of shaft in N.m\n",
      "N=3000 # rotation speed in rpm\n",
      "omega=(N*2*math.pi/60) # angular velocity in rad/sec\n",
      "# calculation of power\n",
      "Wdot=(T*omega); # power is work done per unit time\n",
      "print \"Power transmitted is\",round(Wdot/746,1),\" hp\" # divided by 746 to convert W into hp\n",
      "#answer is approximated in textbook"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power transmitted is 42.1  hp\n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3.6:PG-51"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "# initialization of variables\n",
      "D=10.0/100    # diameter of cylinder in m\n",
      "d=50.0/1000   # compression in spring in m\n",
      "Patm=100000   # atmospheric pressure in Pa\n",
      "K=10.0*1000   # spring constant converted in  N/m\n",
      "w=50*9.81 # weight of piston in Newton =mass*gravitational acceleration\n",
      "\n",
      "# find the initial pressure in cylinder by force balance\n",
      "A=(math.pi*D**2)/4; # area of piston\n",
      "P1=((Patm*A)+w)/A;      # balancing forces on piston P1.A=Patm.A+W\n",
      "\n",
      "# work done by air to raise the piston for 50mm if spring not present\n",
      "Wgas=P1*A*d; # pressure*area= force and Work = Force* displacement\n",
      "\n",
      "# work done on spring to compress\n",
      "Wspring=(K*d**2)/2; # Work in j\n",
      "\n",
      "# now total work done by air is sum of two works\n",
      "Wnet=Wgas+Wspring; # Work in j\n",
      "# result\n",
      "print \"The net work done by air is\",round(Wnet,1),\" J\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The net work done by air is 76.3  J\n"
       ]
      }
     ],
     "prompt_number": 43
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3.7:PG-53"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# variable initialization\n",
      "\n",
      "d=2   # distance travelled by weight in m\n",
      "m=50  # mass of weight in kg\n",
      "g=9.8  # gravitaional acceleration in m/sec^2\n",
      "\n",
      "# calculation of work in non-quasiequilibrium process\n",
      "W=m*g*d; # work in joules\n",
      "\n",
      "# the work done must be transferred as heat\n",
      "Q=W;\n",
      "\n",
      "print \"The heat that must transfer is \",int(Q),\" Joules\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The heat that must transfer is  980  Joules\n"
       ]
      }
     ],
     "prompt_number": 45
    }
   ],
   "metadata": {}
  }
 ]
}