Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
print(' PC-SAFT:', calc, 'J mol^-1')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
assert abs((calc-ref)/ref*100) < 3
# 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)])
pyargs = {'m':m, 's':s, 'e':e, 'e_assoc':eAB, 'vol_a':volAB}
calc = pcsaft_Hvap(t, x, pyargs)[0]
if print_result:
print('\n########## Test with water ##########')
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, '%')
assert abs((calc-ref)/ref*100) < 3
# Dimethyl ether
m = np.asarray([2.2634])
s = np.asarray([3.2723])
e = np.asarray([210.29])
dpm = np.asarray([1.3])
dip_num = np.asarray([1.0])
pyargs = {'m':m, 's':s, 'e':e, 'dipm':dpm, 'dip_num':dip_num}
print(' Reference:', ref, 'J mol^-1')
print(' PC-SAFT:', calc, 'J mol^-1')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
assert abs((calc-ref)/ref*100) < 3
# Dimethyl ether
m = np.asarray([2.2634])
s = np.asarray([3.2723])
e = np.asarray([210.29])
dpm = np.asarray([1.3])
dip_num = np.asarray([1.0])
pyargs = {'m':m, 's':s, 'e':e, 'dipm':dpm, 'dip_num':dip_num}
ref = 17410. # source: DIPPR correlation
p = 937300. # source: DIPPR correlation
calc = pcsaft_Hvap(315., x, pyargs)[0]
if print_result:
print('\n########## Test with dimethyl ether ##########')
print('----- Enthalpy of vaporization at 315 K -----')
print(' Reference:', ref, 'J mol^-1')
print(' PC-SAFT:', calc, 'J mol^-1')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
assert abs((calc-ref)/ref*100) < 3
def test_Hvap(print_result=False):
"""Test the enthalpy of vaporization function to see if it is working correctly."""
# Toluene
x = np.asarray([1.])
m = np.asarray([2.8149])
s = np.asarray([3.7169])
e = np.asarray([285.69])
pyargs = {'m':m, 's':s, 'e':e}
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(380., x, pyargs)[0]
if print_result:
print('########## Test with toluene ##########')
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, '%')
assert abs((calc-ref)/ref*100) < 3
# 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