summaryrefslogtreecommitdiff
path: root/Basic_Engineering_Thermodynamics/ch4.ipynb
blob: 9d364f3af9ad8b78b990d68aef9f14e2db6f5009 (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
{
 "metadata": {
  "name": "",
  "signature": "sha256:796b0d55d49c3a8708377f5eda9102cc03f40afdc4e2bd80f2e4fc59de97aea2"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 4 : The First Law of Thermodynamics for Systems-Pure Substances"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.1 Page No : 93"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "#four heat transfer\n",
      "Q_1 = 900 \t\t\t#J\n",
      "Q_2 = 80 \t\t\t#J\n",
      "Q_3 = -800 \t\t\t#J\n",
      "Q_4 = 150 \t\t\t#J\n",
      "#four work interactions\n",
      "W_1 = 200 \t\t\t#J\n",
      "W_2 = 150 \t\t\t#J\n",
      "W_3 = 300 \t\t\t#J\n",
      "\t\t\t#W_4\n",
      "\t\t\t\n",
      "# Calculations and Results\n",
      "W_4 = Q_1 +Q_2 +Q_3 +Q_4 -W_1 -W_2 -W_3  \n",
      "print \"Magnitude and Direction of the fourth work interaction, W4 = %.0f J\"%(W_4)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Magnitude and Direction of the fourth work interaction, W4 = -320 J\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.2 Page No : 94"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "Q_a = -50 \t\t\t#KJ \t\t\t#heat transferred from the system along path A\n",
      "W_a = -65 \t\t\t#KJ \t\t\t#work done along path A\n",
      "Q_b = 0 \t\t\t#KJ \t\t\t#heat transferred from the system along path B\n",
      "\t\t\t#W_b work done along path B\n",
      "\n",
      "\t\t\t\n",
      "# Calculations and Results\n",
      "\n",
      "#Part(a)\n",
      "print \"Part a\";\n",
      "delE_a = Q_a - W_a \t\t\t#KJ \t\t\t#Change in energy along path A\n",
      "print \"Change in energy of the system = %.0f KJ\"%(delE_a);\n",
      "\n",
      "#Part(b)\n",
      "print \"Part b\";\n",
      "delE_b = -1*delE_a \t\t\t#KJ \t\t\t#Change in energy along path B\n",
      "W_b = delE_b - Q_b \t\t\t#KJ \t\t\t#work done along path B\n",
      "print \"Magnitude and direction of work done during B, W_b = %.0f KJ\"%(W_b)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Part a\n",
        "Change in energy of the system = 15 KJ\n",
        "Part b\n",
        "Magnitude and direction of work done during B, W_b = -15 KJ\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.3 Page No : 99"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables\n",
      "m = 2.3 \t\t\t#kg \t\t\t#mass of substance\n",
      "u = 21 * 10**3 \t\t\t#J/kg \t\t\t#internal energy\n",
      "V = 110. \t\t\t#m/s \t\t\t#velocity \n",
      "z = 1500. \t\t\t#m \t\t\t#elevation above sea level\n",
      "g = 9.81 \t\t\t#m/s**2 \t\t\t#acceleration due to gravity\n",
      "\n",
      "\n",
      "\t\t\t\n",
      "# Calculations and Results\n",
      "E = m*(g*z + V**2/2 + u) \t\t\t#J/kg \t\t\t#Total energy of the system\n",
      "print \"The total energy of the system with respect to an observer at rest at sea level, E = %.4f KJ\"%(0.001*E);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The total energy of the system with respect to an observer at rest at sea level, E = 96.0595 KJ\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.4 Page No : 103"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import *\n",
      "from sympy import Derivative\n",
      "\t\t\t\n",
      "# Variables\n",
      "t = poly1d(0); \t\t\t#C \t\t\t#Temperature in C\n",
      "u = 196. + .718*t; \t\t\t#KJ/kg \t\t\t#specific internal energy\n",
      "pv = 287*(t+273.); \t\t\t#Nm/kg \t\t\t#p is pressure and v = specific volume\n",
      "\n",
      "\t\t\t\n",
      "# Calculations and Results\n",
      "Cv = poly(u);\n",
      "print \"Specific heat at constant volume,Cv = %.3f kJ/kgK\"%(Cv[0])\n",
      "\n",
      "h = u + pv*.001 \t\t\t#KJ/kg \t\t\t#enthalpy\n",
      "Cp = poly(h);\n",
      "print \"Specific heat at constant pressure,Cp = %.3f kJ/kgK\"%(Cp[0])\n",
      "\n",
      "# Note: Poly function gives different result then book has."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Specific heat at constant volume,Cv = 1.000 kJ/kgK\n",
        "Specific heat at constant pressure,Cp = 1.000 kJ/kgK\n"
       ]
      }
     ],
     "prompt_number": 6
    }
   ],
   "metadata": {}
  }
 ]
}