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
|
{
"metadata": {
"name": "",
"signature": "sha256:c42287d60d2420025e9cb75cd5a29fe499f8ec6aad7d7b81c5d1437599962d5d"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Chapter 5 : Relationships among thermodynamic properties - Graphical representation of properties and processes"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 5.5 page : 208"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from scipy.optimize import fsolve\n",
"\t\t\t\n",
"# Variables\n",
"R = 8314.3\n",
"b = 0.0306 \t\t\t#m**3/kmol\n",
"a = 0.548*10**6 \t\t\t#pa m**6/kmol**6\n",
"T = 973.1\n",
"P = 25*10**6 \t\t\t#Pa\n",
"\t\t\t\n",
"# Calculations\n",
"Vi = R*T/P\n",
"#x = poly(0,'x')\n",
"def f(x):\n",
" return P*x**2 *(x-b) +a*(x-b) - R*T*(x**2)\n",
"#vec = roots(P*x**2 *(x-b) +a*(x-b) - R*T*(x**2))\n",
"#vec = roots([P,(P*b+R*T),a,-a*b])\n",
"vec = fsolve(f,0,full_output=1)\n",
"volume = vec[0]\n",
"dH = 8.0906*10**6 -P*volume +0.548*10**6 /volume\n",
"\t\t\t\n",
"# Results\n",
"print \"Change in enthalpy = %.2e J/kmol\"%(dH)\n",
"\n",
"\n",
"# Note : Answer is different because fsolve function calculates differently. Please check manually.\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Change in enthalpy = 2.21e+07 J/kmol\n"
]
}
],
"prompt_number": 1
}
],
"metadata": {}
}
]
}
|