forked from simonmb/PC-SAFT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpc-saft tests.py
496 lines (428 loc) · 20.4 KB
/
pc-saft tests.py
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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
# -*- coding: utf-8 -*-
"""
Tests for checking that the PC-SAFT functions are working correctly.
@author: Zach Baird
"""
import numpy as np
from pcsaft_electrolyte import pcsaft_den, pcsaft_hres, pcsaft_gres, pcsaft_sres, pcsaft_Hvap
from pcsaft_electrolyte import pcsaft_vaporP, pcsaft_bubbleP, dielc_water, pcsaft_PTz
def test_hres():
"""Test the residual enthalpy function to see if it is working correctly."""
print('------ 325 K ------')
print('\t\t\t PC-SAFT\t Reference')
t = 325 # K
p = 101325 # Pa
# all reference values are from PC-SAFT implemented in Aspen Plus
# Toluene ----------
x = np.asarray([1.])
m = np.asarray([2.8149])
s = np.asarray([3.7169])
e = np.asarray([285.69])
den = pcsaft_den(x, m, s, e, t, p, phase='liq')
calc = pcsaft_hres(x, m, s, e, t, den)
print('Toluene, liquid:\t\t', calc, -36809.39, 'J/mol')
den = pcsaft_den(x, m, s, e, t, p, phase='vap')
calc = pcsaft_hres(x, m, s, e, t, den)
print('Toluene, vapor:\t\t', calc, -362.6777, 'J/mol')
# Acetic acid ---------
m = np.asarray([1.3403])
s = np.asarray([3.8582])
e = np.asarray([211.59])
volAB = np.asarray([0.075550])
eAB = np.asarray([3044.4])
den = pcsaft_den(x, m, s, e, t, p, phase='liq', e_assoc=eAB, vol_a=volAB)
calc = pcsaft_hres(x, m, s, e, t, den, e_assoc=eAB, vol_a=volAB)
print('Acetic acid, liquid:\t\t', calc, -38924.64, 'J/mol')
den = pcsaft_den(x, m, s, e, t, p, phase='vap', e_assoc=eAB, vol_a=volAB)
calc = pcsaft_hres(x, m, s, e, t, den, e_assoc=eAB, vol_a=volAB)
print('Acetic acid, vapor:\t\t', calc, -15393.63, 'J/mol')
# Butyl acetate ---------
m = np.asarray([2.76462805])
s = np.asarray([4.02244938])
e = np.asarray([263.69902915])
dpm = np.asarray([1.84])
dip_num = np.asarray([4.99688339])
den = pcsaft_den(x, m, s, e, t, p, phase='liq', dipm=dpm, dip_num=dip_num)
calc = pcsaft_hres(x, m, s, e, t, den, dipm=dpm, dip_num=dip_num)
print('Butyl acetate, liquid:\t', calc, -43443.19, 'J/mol')
den = pcsaft_den(x, m, s, e, t, p, phase='vap', dipm=dpm, dip_num=dip_num)
calc = pcsaft_hres(x, m, s, e, t, den, dipm=dpm, dip_num=dip_num)
print('Butyl acetate, vapor:\t\t', calc, -516.4779, 'J/mol')
return None
def test_sres():
"""Test the residual entropy function to see if it is working correctly."""
print('------ 325 K ------')
print('\t\t\t PC-SAFT\t Reference')
t = 325 # K
p = 101325 # Pa
# all reference values are from PC-SAFT implemented in Aspen Plus
# Toluene ----------
x = np.asarray([1.])
m = np.asarray([2.8149])
s = np.asarray([3.7169])
e = np.asarray([285.69])
den = pcsaft_den(x, m, s, e, t, p, phase='liq')
calc = pcsaft_sres(x, m, s, e, t, den)
print('Toluene, liquid:\t\t', calc, -96.3692, 'J/mol/K')
den = pcsaft_den(x, m, s, e, t, p, phase='vap')
calc = pcsaft_sres(x, m, s, e, t, den)
print('Toluene, vapor:\t\t', calc, -0.71398, 'J/mol/K')
# Acetic acid ---------
m = np.asarray([1.3403])
s = np.asarray([3.8582])
e = np.asarray([211.59])
volAB = np.asarray([0.075550])
eAB = np.asarray([3044.4])
den = pcsaft_den(x, m, s, e, t, p, phase='liq', e_assoc=eAB, vol_a=volAB)
calc = pcsaft_sres(x, m, s, e, t, den, e_assoc=eAB, vol_a=volAB)
print('Acetic acid, liquid:\t\t', calc, -98.1127, 'J/mol/K')
den = pcsaft_den(x, m, s, e, t, p, phase='vap', e_assoc=eAB, vol_a=volAB)
calc = pcsaft_sres(x, m, s, e, t, den, e_assoc=eAB, vol_a=volAB)
print('Acetic acid, vapor:\t\t', calc, -40.8743, 'J/mol/K')
# Butyl acetate ---------
m = np.asarray([2.76462805])
s = np.asarray([4.02244938])
e = np.asarray([263.69902915])
dpm = np.asarray([1.84])
dip_num = np.asarray([4.99688339])
den = pcsaft_den(x, m, s, e, t, p, phase='liq', dipm=dpm, dip_num=dip_num)
calc = pcsaft_sres(x, m, s, e, t, den, dipm=dpm, dip_num=dip_num)
print('Butyl acetate, liquid:\t', calc, -108.9615, 'J/mol/K')
den = pcsaft_den(x, m, s, e, t, p, phase='vap', dipm=dpm, dip_num=dip_num)
calc = pcsaft_sres(x, m, s, e, t, den, dipm=dpm, dip_num=dip_num)
print('Butyl acetate, vapor:\t\t', calc, -1.0361, 'J/mol/K')
return None
def test_gres():
"""Test the residual Gibbs energy function to see if it is working correctly."""
print('------ 325 K ------')
print('\t\t\t PC-SAFT\t Reference')
t = 325 # K
p = 101325 # Pa
# all reference values are from PC-SAFT implemented in Aspen Plus
# Toluene ----------
x = np.asarray([1.])
m = np.asarray([2.8149])
s = np.asarray([3.7169])
e = np.asarray([285.69])
den = pcsaft_den(x, m, s, e, t, p, phase='liq')
calc = pcsaft_gres(x, m, s, e, t, den)
print('Toluene, liquid:\t\t', calc, -5489.384, 'J/mol')
den = pcsaft_den(x, m, s, e, t, p, phase='vap')
calc = pcsaft_gres(x, m, s, e, t, den)
print('Toluene, vapor:\t\t', calc, -130.6339, 'J/mol')
# Acetic acid ---------
m = np.asarray([1.3403])
s = np.asarray([3.8582])
e = np.asarray([211.59])
volAB = np.asarray([0.075550])
eAB = np.asarray([3044.4])
den = pcsaft_den(x, m, s, e, t, p, phase='liq', e_assoc=eAB, vol_a=volAB)
calc = pcsaft_gres(x, m, s, e, t, den, e_assoc=eAB, vol_a=volAB)
print('Acetic acid, liquid:\t\t', calc, -7038.004, 'J/mol')
den = pcsaft_den(x, m, s, e, t, p, phase='vap', e_assoc=eAB, vol_a=volAB)
calc = pcsaft_gres(x, m, s, e, t, den, e_assoc=eAB, vol_a=volAB)
print('Acetic acid, vapor:\t\t', calc, -2109.459, 'J/mol')
# Butyl acetate ---------
m = np.asarray([2.76462805])
s = np.asarray([4.02244938])
e = np.asarray([263.69902915])
dpm = np.asarray([1.84])
dip_num = np.asarray([4.99688339])
den = pcsaft_den(x, m, s, e, t, p, phase='liq', dipm=dpm, dip_num=dip_num)
calc = pcsaft_gres(x, m, s, e, t, den, dipm=dpm, dip_num=dip_num)
print('Butyl acetate, liquid:\t', calc, -8030.709, 'J/mol')
den = pcsaft_den(x, m, s, e, t, p, phase='vap', dipm=dpm, dip_num=dip_num)
calc = pcsaft_gres(x, m, s, e, t, den, dipm=dpm, dip_num=dip_num)
print('Butyl acetate, vapor:\t\t', calc, -179.7519, 'J/mol')
return None
def test_density():
"""Test the density function to see if it is working correctly."""
# Toluene
print('########## Test with toluene ##########')
x = np.asarray([1.])
m = np.asarray([2.8149])
s = np.asarray([3.7169])
e = np.asarray([285.69])
ref = 9135.590853014008 # source: reference EOS in CoolProp
calc = pcsaft_den(x, m, s, e, 320, 101325, phase='liq')
print('----- Density at 320 K and 101325 Pa -----')
print(' Reference:', ref, 'mol m^-3')
print(' PC-SAFT:', calc, 'mol m^-3')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
# Water
print('\n########## Test with water ##########')
m = np.asarray([1.2047])
e = np.asarray([353.95])
volAB = np.asarray([0.0451])
eAB = np.asarray([2425.67])
ref = 55502.5970532902 # source: IAWPS95 EOS
t = 274
s = np.asarray([2.7927 + 10.11*np.exp(-0.01775*t) - 1.417*np.exp(-0.01146*t)])
calc = pcsaft_den(x, m, s, e, t, 101325, phase='liq', e_assoc=eAB, vol_a=volAB)
print('----- Density at 274 K and 101325 Pa -----')
print(' Reference:', ref, 'mol m^-3')
print(' PC-SAFT:', calc, 'mol m^-3')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
# Acetic acid
print('\n########## Test with acetic acid ##########')
m = np.asarray([1.3403])
s = np.asarray([3.8582])
e = np.asarray([211.59])
volAB = np.asarray([0.075550])
eAB = np.asarray([3044.4])
ref = 17240. # source: DIPPR correlation
calc = pcsaft_den(x, m, s, e, 305, 101325, phase='liq', e_assoc=eAB, vol_a=volAB)
print('----- Density at 305 K and 101325 Pa -----')
print(' Reference:', ref, 'mol m^-3')
print(' PC-SAFT:', calc, 'mol m^-3')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
# Butyl acetate
print('\n########## Test with butyl acetate ##########')
m = np.asarray([2.76462805])
s = np.asarray([4.02244938])
e = np.asarray([263.69902915])
dpm = np.asarray([1.84])
dip_num = np.asarray([4.99688339])
ref = 8021. # source: DIPPR correlation
calc = pcsaft_den(x, m, s, e, 240, 101325, phase='liq', dipm=dpm, dip_num=dip_num)
print('----- Density at 240 K and 101325 Pa -----')
print(' Reference:', ref, 'mol m^-3')
print(' PC-SAFT:', calc, 'mol m^-3')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
# Binary mixture: methanol-cyclohexane
print('\n########## Test with methanol-cyclohexane mixture ##########')
#0 = methanol, 1 = cyclohexane
x = np.asarray([0.0550, 0.945])
m = np.asarray([1.5255, 2.5303])
s = np.asarray([3.2300, 3.8499])
e = np.asarray([188.90, 278.11])
volAB = np.asarray([0.035176, 0.])
eAB = np.asarray([2899.5, 0.])
k_ij = np.asarray([[0, 0.051],
[0.051, 0]])
ref = 9506.1 # source: J. Canosa, A. Rodríguez, and J. Tojo, “Liquid−Liquid Equilibrium and Physical Properties of the Ternary Mixture (Dimethyl Carbonate + Methanol + Cyclohexane) at 298.15 K,” J. Chem. Eng. Data, vol. 46, no. 4, pp. 846–850, Jul. 2001.
calc = pcsaft_den(x, m, s, e, 298.15, 101325, phase='liq', k_ij=k_ij, e_assoc=eAB, vol_a=volAB)
print('----- Density at 298.15 K and 101325 Pa -----')
print(' Reference:', ref, 'mol m^-3')
print(' PC-SAFT:', calc, 'mol m^-3')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
# NaCl in water
print('\n########## Test with aqueous NaCl ##########')
# 0 = Na+, 1 = Cl-, 2 = H2O
x = np.asarray([0.010579869455908, 0.010579869455908, 0.978840261088184])
m = np.asarray([1, 1, 1.2047])
s = np.asarray([2.8232, 2.7599589, 0.])
e = np.asarray([230.00, 170.00, 353.9449])
volAB = np.asarray([0, 0, 0.0451])
eAB = np.asarray([0, 0, 2425.67])
k_ij = np.asarray([[0, 0.317, 0],
[0.317, 0, -0.25],
[0, -0.25, 0]])
z = np.asarray([1., -1., 0.])
ref = 55507.23 # source: Rodriguez H.; Soto A.; Arce A.; Khoshkbarchi M.K.: Apparent Molar Volume, Isentropic Compressibility, Refractive Index, and Viscosity of DL-Alanine in Aqueous NaCl Solutions. J.Solution Chem. 32 (2003) 53-63
t = 298.15 # K
s[2] = 2.7927 + 10.11*np.exp(-0.01775*t) - 1.417*np.exp(-0.01146*t) # temperature dependent segment diameter for water
k_ij[0,2] = -0.007981*t + 2.37999
k_ij[2,0] = -0.007981*t + 2.37999
dielc = dielc_water(t)
calc = pcsaft_den(x, m, s, e, t, 101325, phase='liq', k_ij=k_ij, e_assoc=eAB, vol_a=volAB, z=z, dielc=dielc)
print('----- Density at 298.15 K and 101325 Pa -----')
print(' Reference:', ref, 'mol m^-3')
print(' PC-SAFT:', calc, 'mol m^-3')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
return None
def test_vaporP():
"""Test the vapor pressure function to see if it is working correctly."""
# Toluene
print('########## Test with toluene ##########')
x = np.asarray([1.])
m = np.asarray([2.8149])
s = np.asarray([3.7169])
e = np.asarray([285.69])
ref = 3255792.76201971 # source: reference EOS in CoolProp
calc = pcsaft_vaporP(ref, x, m, s, e, 572.6667)
print('----- Vapor pressure at 572.7 K -----')
print(' Reference:', ref, 'Pa')
print(' PC-SAFT:', calc, 'Pa')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
# Water
print('\n########## Test with water ##########')
m = np.asarray([1.2047])
e = np.asarray([353.95])
volAB = np.asarray([0.0451])
eAB = np.asarray([2425.67])
ref = 67171.754576141 # source: IAWPS95 EOS
t = 362
s = np.asarray([2.7927 + 10.11*np.exp(-0.01775*t) - 1.417*np.exp(-0.01146*t)])
calc = pcsaft_vaporP(ref, x, m, s, e, t, e_assoc=eAB, vol_a=volAB)
print('----- Vapor pressure at 362 K -----')
print(' Reference:', ref, 'Pa')
print(' PC-SAFT:', calc, 'Pa')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
# Acetic acid
print('\n########## Test with acetic acid ##########')
m = np.asarray([1.3403])
s = np.asarray([3.8582])
e = np.asarray([211.59])
volAB = np.asarray([0.075550])
eAB = np.asarray([3044.4])
ref = 193261.515187248 # source: DIPPR correlation
calc = pcsaft_vaporP(ref, x, m, s, e, 413.5385, e_assoc=eAB, vol_a=volAB)
print('----- Vapor pressure at 413.5 K -----')
print(' Reference:', ref, 'Pa')
print(' PC-SAFT:', calc, 'Pa')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
# Butyl acetate
print('\n########## Test with butyl acetate ##########')
m = np.asarray([2.76462805])
s = np.asarray([4.02244938])
e = np.asarray([263.69902915])
dpm = np.asarray([1.84])
dip_num = np.asarray([4.99688339])
ref = 219.6 # source: DIPPR correlation
calc = pcsaft_vaporP(ref, x, m, s, e, 270, dipm=dpm, dip_num=dip_num)
print('----- Vapor pressure at 270 K -----')
print(' Reference:', ref, 'Pa')
print(' PC-SAFT:', calc, 'Pa')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
return None
def test_bubbleP():
"""Test the bubble point pressure function to see if it is working correctly."""
# Binary mixture: methanol-cyclohexane
print('\n########## Test with methanol-cyclohexane mixture ##########')
#0 = methanol, 1 = cyclohexane
x = np.asarray([0.3,0.7])
m = np.asarray([1.5255, 2.5303])
s = np.asarray([3.2300, 3.8499])
e = np.asarray([188.90, 278.11])
volAB = np.asarray([0.035176, 0.])
eAB = np.asarray([2899.5, 0.])
k_ij = np.asarray([[0, 0.051],
[0.051, 0]])
ref = 101330 # source: Marinichev A.N.; Susarev M.P.: Investigation of Liquid-Vapor Equilibrium in the System Methanol-Cyclohexane at 35, 45 and 55°C and 760 mm Hg. J.Appl.Chem.USSR 38 (1965) 1582-1584
xv_ref = np.asarray([0.59400,0.40600])
result = pcsaft_bubbleP(ref, xv_ref, x, m, s, e, 327.48, k_ij=k_ij, e_assoc=eAB, vol_a=volAB)
calc = result[0]
xv = result[1]
print('----- Bubble point pressure at 327.48 K -----')
print(' Reference:', ref, 'Pa')
print(' PC-SAFT:', calc, 'Pa')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
print(' Vapor composition (reference):', xv_ref)
print(' Vapor composition (PC-SAFT):', xv)
# NaCl in water
print('\n########## Test with aqueous NaCl ##########')
# 0 = Na+, 1 = Cl-, 2 = H2O
x = np.asarray([0.0907304774758426, 0.0907304774758426, 0.818539045048315])
m = np.asarray([1, 1, 1.2047])
s = np.asarray([2.8232, 2.7599589, 0.])
e = np.asarray([230.00, 170.00, 353.9449])
volAB = np.asarray([0, 0, 0.0451])
eAB = np.asarray([0, 0, 2425.67])
k_ij = np.asarray([[0, 0.317, 0],
[0.317, 0, -0.25],
[0, -0.25, 0]])
z = np.asarray([1., -1., 0.])
ref = 2393.8 # average of repeat data points from source: A. Apelblat and E. Korin, “The vapour pressures of saturated aqueous solutions of sodium chloride, sodium bromide, sodium nitrate, sodium nitrite, potassium iodate, and rubidium chloride at temperatures from 227 K to 323 K,” J. Chem. Thermodyn., vol. 30, no. 1, pp. 59–71, Jan. 1998. (Solubility calculated using equation from Yaws, Carl L.. (2008). Yaws' Handbook of Properties for Environmental and Green Engineering.)
t = 298.15 # K
s[2] = 2.7927 + 10.11*np.exp(-0.01775*t) - 1.417*np.exp(-0.01146*t) # temperature dependent segment diameter for water
k_ij[0,2] = -0.007981*t + 2.37999
k_ij[2,0] = -0.007981*t + 2.37999
dielc = dielc_water(t)
xv_guess = np.asarray([0., 0., 1.])
result = pcsaft_bubbleP(ref, xv_guess, x, m, s, e, t, k_ij=k_ij, e_assoc=eAB, vol_a=volAB, z=z, dielc=dielc)
calc = result[0]
print('----- Bubble point pressure at 298.15 K -----')
print(' Reference:', ref, 'Pa')
print(' PC-SAFT:', calc, 'Pa')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
return None
def test_PTz():
"""Test the function for PTz data to see if it is working correctly."""
# Binary mixture: methanol-cyclohexane
print('\n########## Test with methanol-cyclohexane mixture ##########')
#0 = methanol, 1 = cyclohexane
m = np.asarray([1.5255, 2.5303])
s = np.asarray([3.2300, 3.8499])
e = np.asarray([188.90, 278.11])
volAB = np.asarray([0.035176, 0.])
eAB = np.asarray([2899.5, 0.])
k_ij = np.asarray([[0, 0.051],
[0.051, 0]])
mol = 1.
t = 327.48
p_ref = 101330 # source: Marinichev A.N.; Susarev M.P.: Investigation of Liquid-Vapor Equilibrium in the System Methanol-Cyclohexane at 35, 45 and 55°C and 760 mm Hg. J.Appl.Chem.USSR 38 (1965) 1582-1584
xl_ref = np.asarray([0.3,0.7])
xv_ref = np.asarray([0.59400,0.40600])
beta_ref = 0.6
xtot = (beta_ref*mol*xv_ref + (1-beta_ref)*mol*xl_ref)/mol
rho_l = pcsaft_den(xl_ref, m, s, e, t, p_ref, phase='liq', k_ij=k_ij, e_assoc=eAB, vol_a=volAB)
rho_v = pcsaft_den(xv_ref, m, s, e, t, p_ref, phase='vap', k_ij=k_ij, e_assoc=eAB, vol_a=volAB)
vol = rho_v*beta_ref*mol + rho_l*(1-beta_ref)*mol
result = pcsaft_PTz(p_ref, xl_ref, beta_ref, mol, vol, xtot, m, s, e, t, k_ij=k_ij, e_assoc=eAB, vol_a=volAB)
p_calc = result[0]
xl_calc = result[1]
xv_calc = result[2]
beta_calc = result[3]
print('----- Pressure at 327.48 K -----')
print(' Reference:', p_ref, 'Pa')
print(' PC-SAFT:', p_calc, 'Pa')
print(' Relative deviation:', (p_calc-p_ref)/p_ref*100, '%')
print('----- Liquid phase composition -----')
print(' Reference:', xl_ref, 'Pa')
print(' PC-SAFT:', xl_calc, 'Pa')
print(' Relative deviation:', (xl_calc-xl_ref)/xl_ref*100, '%')
print('----- Vapor phase composition -----')
print(' Reference:', xv_ref, 'Pa')
print(' PC-SAFT:', xv_calc, 'Pa')
print(' Relative deviation:', (xv_calc-xv_ref)/xv_ref*100, '%')
print('----- Beta -----')
print(' Reference:', beta_ref, 'Pa')
print(' PC-SAFT:', beta_calc, 'Pa')
print(' Relative deviation:', (beta_calc-beta_ref)/beta_ref*100, '%')
return None
def test_Hvap():
"""Test the enthalpy of vaporization function to see if it is working correctly."""
# Toluene
print('########## Test with toluene ##########')
x = np.asarray([1.])
m = np.asarray([2.8149])
s = np.asarray([3.7169])
e = np.asarray([285.69])
ref = 33500. # source: DIPPR correlation
p = 90998. # source: reference equation of state from Polt, A.; Platzer, B.; Maurer, G., Parameter der thermischen Zustandsgleichung von Bender fuer 14 mehratomige reine Stoffe, Chem. Tech. (Leipzig), 1992, 44, 6, 216-224.
calc = pcsaft_Hvap(p, x, m, s, e, 380.)[0]
print('----- Enthalpy of vaporization at 380 K -----')
print(' Reference:', ref, 'J mol^-1')
print(' PC-SAFT:', calc, 'J mol^-1')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
# Water
print('\n########## Test with water ##########')
m = np.asarray([1.2047])
e = np.asarray([353.95])
volAB = np.asarray([0.0451])
eAB = np.asarray([2425.67])
ref = 44761.23 # source: IAWPS95 EOS
p = 991.82 # source: IAWPS95 EOS
t = 280
s = np.asarray([2.7927 + 10.11*np.exp(-0.01775*t) - 1.417*np.exp(-0.01146*t)])
calc = pcsaft_Hvap(p, x, m, s, e, t, e_assoc=eAB, vol_a=volAB)[0]
print('----- Enthalpy of vaporization at 280 K -----')
print(' Reference:', ref, 'J mol^-1')
print(' PC-SAFT:', calc, 'J mol^-1')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
# Butyl acetate
print('\n########## Test with butyl acetate ##########')
m = np.asarray([2.76462805])
s = np.asarray([4.02244938])
e = np.asarray([263.69902915])
dpm = np.asarray([1.84])
dip_num = np.asarray([4.99688339])
ref = 32280. # source: DIPPR correlation
p = 362200. # source: DIPPR correlation
calc = pcsaft_Hvap(p, x, m, s, e, 450., dipm=dpm, dip_num=dip_num)[0]
print('----- Enthalpy of vaporization at 450 K -----')
print(' Reference:', ref, 'J mol^-1')
print(' PC-SAFT:', calc, 'J mol^-1')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
return None