Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
k_ij = np.asarray([[0, 0.317, 0],
[0.317, 0, -0.25],
[0, -0.25, 0]])
z = np.asarray([1., -1., 0.])
p = 2393.8 # Pa
ref = 298.15 # K, 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.)
s[2] = 2.7927 + 10.11*np.exp(-0.01775*ref) - 1.417*np.exp(-0.01146*ref) # temperature dependent segment diameter for water
k_ij[0,2] = -0.007981*ref + 2.37999
k_ij[2,0] = -0.007981*ref + 2.37999
dielc = dielc_water(ref)
pyargs = {'m':m, 's':s, 'e':e, 'e_assoc':eAB, 'vol_a':volAB, 'k_ij':k_ij, 'z':z, 'dielc':dielc}
xv_guess = np.asarray([0., 0., 1.])
calc, xl, xv = flashPQ(p, 0, x, pyargs, ref)
if print_result:
print('\n########## Test with aqueous NaCl ##########')
print('----- Bubble point temperature at 2393.8 Pa -----')
print(' Reference:', ref, 'K')
print(' PC-SAFT:', calc, 'K')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
assert abs((calc-ref)/ref*100) < 1
print('----- Bubble point temperature at 101330 Pa -----')
print(' Reference:', ref, 'K')
print(' PC-SAFT:', calc, 'K')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
print(' Vapor composition (reference):', xv_ref)
print(' Vapor composition (PC-SAFT):', xv)
print(' Vapor composition relative deviation:', (xv-xv_ref)/xv_ref*100)
assert abs((calc-ref)/ref*100) < 1
assert np.all(abs((xv-xv_ref)/xv_ref*100) < 10)
# dew point
x = np.asarray([0.59400,0.40600])
p = 101330
ref = 327.48 # 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])
calc, xl, xv = flashPQ(p, 1, x, pyargs, t_guess=328.)
if print_result:
print('\n########## Test with methanol-cyclohexane mixture ##########')
print('----- Dew point temperature at 101330 Pa -----')
print(' Reference:', ref, 'K')
print(' PC-SAFT:', calc, 'K')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
print(' Liquid composition (reference):', xl_ref)
print(' Liquid composition (PC-SAFT):', xl)
print(' Liquid composition relative deviation:', (xl-xl_ref)/xl_ref*100)
assert abs((calc-ref)/ref*100) < 1
assert np.all(abs((xl-xl_ref)/xl_ref*100) < 20)
# NaCl in water
# 0 = Na+, 1 = Cl-, 2 = H2O
x = np.asarray([0.0907304774758426, 0.0907304774758426, 0.818539045048315])
m = np.asarray([1, 1, 1.2047])
#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]])
pyargs = {'m':m, 's':s, 'e':e, 'e_assoc':eAB, 'vol_a':volAB, 'k_ij':k_ij}
# bubble point
p = 101330
ref = 327.48 # 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])
calc, xl, xv = flashPQ(p, 0, x, pyargs)
if print_result:
print('\n########## Test with methanol-cyclohexane mixture ##########')
print('----- Bubble point temperature at 101330 Pa -----')
print(' Reference:', ref, 'K')
print(' PC-SAFT:', calc, 'K')
print(' Relative deviation:', (calc-ref)/ref*100, '%')
print(' Vapor composition (reference):', xv_ref)
print(' Vapor composition (PC-SAFT):', xv)
print(' Vapor composition relative deviation:', (xv-xv_ref)/xv_ref*100)
assert abs((calc-ref)/ref*100) < 1
assert np.all(abs((xv-xv_ref)/xv_ref*100) < 10)
# dew point
x = np.asarray([0.59400,0.40600])
p = 101330
ref = 327.48 # 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