summaryrefslogtreecommitdiff
path: root/Thermodynamics:_From_concepts_to_applications/Chapter17_1.ipynb
blob: 2d6dc101055c661bc025575252fd11ce011870c0 (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
{
 "metadata": {
  "name": "",
  "signature": "sha256:0bd1584504a5182c99f46d576a77cfaa07f83a047faf3b55eaafd0cea74518f2"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter17-Ideal solutions"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example1-pg367"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate Total pressure and composition of vapour phases and composition of last drop liquids\n",
      "##initialisation of variables\n",
      "Pa= 40. ##kPa\n",
      "Pb= 50. ##kPa\n",
      "na= 2. ##moles\n",
      "nb= 6. ##moles\n",
      "##CALCULATIONS\n",
      "a= Pb/Pa\n",
      "xa= na/(na+nb)\n",
      "xb= 1.-xa\n",
      "p= xa*Pa+xb*Pb\n",
      "y= (xa*Pa)/p\n",
      "ya= 1.-y\n",
      "Xa= a*xa/(1+(a-1)*xa)\n",
      "Xb= 1.-Xa\n",
      "##RESULTS\n",
      "print'%s %.1f %s'%('Total pressure=',p,'kPa')\n",
      "print'%s %.4f %s'%('composition of vapour phase=',y,'')\n",
      "print'%s %.4f %s'%('composition of vapour phase=',ya,'')\n",
      "print'%s %.4f %s'%('composition of last drop of liquid=',Xa,'')\n",
      "print'%s %.4f %s'%('composition of last drop of liquid=',Xb,'')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total pressure= 47.5 kPa\n",
        "composition of vapour phase= 0.2105 \n",
        "composition of vapour phase= 0.7895 \n",
        "composition of last drop of liquid= 0.2941 \n",
        "composition of last drop of liquid= 0.7059 \n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example2-pg371"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\t\n",
      "#calculate pressure of the phase of pure A\n",
      "##initialisation of variables\n",
      "p0= 10. ##Mpa\n",
      "R= 8.314 ##J/mol K\n",
      "T= 30. ##C\n",
      "va= 0.02 ##m^3/kmol\n",
      "xa= 0.98\n",
      "##CALCULATIONS\n",
      "p= p0+(R*(273.15+T)*math.log(xa)/(va*1000.))\n",
      "##RESULTS\n",
      "print'%s %.2f %s'%('Pressure of the phase of pure A=',p,'Mpa')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure of the phase of pure A= 7.45 Mpa\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example3-pg373"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate the boiling point elevation\n",
      "##initialisation of variables\n",
      "hfg= 2257.0 ##kJ/kg\n",
      "Tb= 100 ##C\n",
      "R= 8.314 ##J/mol K\n",
      "m2= 10 ##gms\n",
      "M2= 58.5 ##gms\n",
      "m1= 90. ##gms\n",
      "M1= 18. ##gms\n",
      "##CALCULATIONS\n",
      "x2= (m2/M2)/((m2/M2)+(m1/M1))\n",
      "dT= R*math.pow(273.15+Tb,2)*x2/(M1*hfg)\n",
      "##RESULTS\n",
      "print'%s %.3f %s'%(' Boiling point elevation=',dT,'C')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Boiling point elevation= 0.942 C\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example4-pg376"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate Osomatic pressures\n",
      "##initialisation of variables\n",
      "M1= 18.02 ##gms\n",
      "m1= 0.965 ##gms\n",
      "m2= 0.035 ##gms\n",
      "M2= 58.5 ##gms\n",
      "R= 8.314 ##J/mol K\n",
      "M= 18.02 ##kg\n",
      "T= 20. ##C\n",
      "vf= 0.001002 ##m^3\n",
      "x21= 0.021856 ##m^3\n",
      "##CALCULATIONS\n",
      "n1= m1/M1\n",
      "n2= m2/M2\n",
      "x1= n1/(n1+n2)\n",
      "x2= n2/(n2+n1)\n",
      "P= R*(273.15+T)*x2/(M*vf)\n",
      "P1=  R*(273.15+T)*x21/(M*vf)\n",
      "##RESULTS\n",
      "print'%s %.1f %s'%('Osmotic pressure=',P,'kpa')\n",
      "print'%s %.1f %s'%('Osmotic pressure=',P1,'kpa')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Osmotic pressure= 1491.4 kpa\n",
        "Osmotic pressure= 2950.2 kpa\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example5-pg377"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#what is useful work in the process and heat interaction and maximum work and irreversibility\n",
      "##initialisation of variables\n",
      "W= 0.\n",
      "Q= 0.\n",
      "R= 8.314 ##J/mol K\n",
      "T0= 300. ##K\n",
      "x= 5./13.\n",
      "n1= 0.5 ##kmol/s\n",
      "n2= 0.8 ##kmol/s\n",
      "##CALCULATIONS\n",
      "W1= (n1+n2)*R*T0*(x*math.log(1/x)+(1-x)*math.log(1/(1-x)))\n",
      "I= W1\n",
      "##RESULTS\n",
      "print'%s %.f %s'%('useful work of the process=',W,'kW') \n",
      "print'%s %.f %s'%('heat interaction=',Q,'kW') \n",
      "print'%s %.1f %s'%('maximum work=',W1,'kW') \n",
      "print'%s %.1f %s'%('irreversibility=',I,'kW')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "useful work of the process= 0 kW\n",
        "heat interaction= 0 kW\n",
        "maximum work= 2160.4 kW\n",
        "irreversibility= 2160.4 kW\n"
       ]
      }
     ],
     "prompt_number": 7
    }
   ],
   "metadata": {}
  }
 ]
}