def test_NRTL_chemsep(): from thermo.interaction_parameters import IPDB tausB = IPDB.get_ip_asymmetric_matrix('ChemSep NRTL', ['64-17-5', '7732-18-5'], 'bij') alphaC = IPDB.get_ip_asymmetric_matrix('ChemSep NRTL', ['64-17-5', '7732-18-5'], 'alphaij') N = 2 T = 343.15 xs = [0.252, 0.748] tausA = tausE = tausF = tausG = tausH = alphaD = [[0.0] * N for i in range(N)] ABEFGHCD = (tausA, tausB, tausE, tausF, tausG, tausH, alphaC, alphaD) GE = NRTL(T=T, xs=xs, ABEFGHCD=ABEFGHCD) gammas = GE.gammas() assert_close1d(gammas, [1.985383485664009, 1.146380779201308], rtol=1e-7) # Table of values right from ChemSep gammas_ethanol = [ 5.66232, 4.283, 3.3749, 2.75365, 2.31475, 1.99622, 1.75984, 1.58121, 1.44425, 1.33807, 1.25512, 1.19003, 1.13894, 1.09896, 1.06796, 1.0443, 1.02671, 1.0142, 1.00598, 1.00142, 1 ] gammas_water = [ 1, 1.00705, 1.02657, 1.05673, 1.09626, 1.14429, 1.20021, 1.26357, 1.33405, 1.41139, 1.49541, 1.58593, 1.68281, 1.78591, 1.89509, 2.0102, 2.1311, 2.25761, 2.38956, 2.52675, 2.66895 ] pts = 21 xs_ethanol = linspace(0, 1, 21) for i in range(pts): GE2 = GE.to_T_xs(T=T, xs=[xs_ethanol[i], 1 - xs_ethanol[i]]) gammas = GE2.gammas() assert_close(gammas[0], gammas_ethanol[i], rtol=1e-5) assert_close(gammas[1], gammas_water[i], rtol=1e-5)
def test_basic_chemsep_NRTL(): # ethanol water, converted to metric, simple T dependence bijs = IPDB.get_ip_asymmetric_matrix('ChemSep NRTL', ['64-17-5', '7732-18-5'], 'bij') assert_close2d(bijs, [[0.0, -29.166654483541816], [624.8676222389441, 0.0]], rtol=1e-7) alphas_known = [[0.0, 0.2937, 0.3009], [0.2937, 0.0, 0.2999], [0.3009, 0.2999, 0.0]] # Test is works both symmetric and asymmetric alphas = IPDB.get_ip_asymmetric_matrix('ChemSep NRTL', ['64-17-5', '7732-18-5', '67-56-1'], 'alphaij') assert_close2d(alphas, alphas_known) alphas = IPDB.get_ip_symmetric_matrix('ChemSep NRTL', ['64-17-5', '7732-18-5', '67-56-1'], 'alphaij') assert_close2d(alphas, alphas_known)
def test_basic_chemsep_NRTL(): # ethanol water, converted to metric, simple T dependence bijs = IPDB.get_ip_asymmetric_matrix('ChemSep NRTL', ['64-17-5', '7732-18-5'], 'bij') alphas_known = [[0.0, 0.2937, 0.3009], [0.2937, 0.0, 0.2999], [0.3009, 0.2999, 0.0]] # Test is works both symmetric and asymmetric alphas = IPDB.get_ip_asymmetric_matrix('ChemSep NRTL', ['64-17-5', '7732-18-5', '67-56-1'], 'alphaij') assert_allclose(alphas, alphas_known) alphas = IPDB.get_ip_symmetric_matrix('ChemSep NRTL', ['64-17-5', '7732-18-5', '67-56-1'], 'alphaij') assert_allclose(alphas, alphas_known)
def from_data(cls, data, eos_class=None): if eos_class is None: eos_class = tm.PRMIX eos_kwargs = dict(Tcs=data.Tcs, Pcs=data.Pcs, omegas=data.omegas) try: eos_kwargs['kijs'] = IPDB.get_ip_asymmetric_matrix( 'ChemSep PR', data.CASs, 'kij') except: pass return cls(eos_class, eos_kwargs, data.HeatCapacityGases)
def test_Wilson_chemsep(): from thermo.interaction_parameters import IPDB CAS1 = '64-17-5' CAS2 = '7732-18-5' N = 2 T = 273.15 + 70 tausC = tausD = tausE = tausF = [[0.0] * N for _ in range(N)] tausB = IPDB.get_ip_asymmetric_matrix(name='ChemSep Wilson', CASs=[CAS1, CAS2], ip='bij') tausA = IPDB.get_ip_asymmetric_matrix(name='ChemSep Wilson', CASs=[CAS1, CAS2], ip='aij') ABCDEF = (tausA, tausB, tausC, tausD, tausE, tausF) GE = Wilson(T=T, xs=[0.252, 1 - 0.252], ABCDEF=ABCDEF) gammas = GE.gammas() # Checked against ChemSep TPxy plot/data table - shows 5 decimal places assert_close1d(gammas, [1.9573311040154513, 1.1600677182620136], rtol=1e-12)
def test_UNIQUAC_chemsep(): from thermo.interaction_parameters import IPDB xs = [0.252, 0.748] rs = [2.11, 0.92] qs = [1.97, 1.400] N = 2 T = 343.15 tausA = tausC = tausD = tausE = tausF = [[0.0] * N for _ in range(N)] gammas_expect = [1.977454791958557, 1.1397696289861017] tausB = IPDB.get_ip_asymmetric_matrix(name='ChemSep UNIQUAC', CASs=['64-17-5', '7732-18-5'], ip='bij') ABCDEF = (tausA, tausB, tausC, tausD, tausE, tausF) GE = UNIQUAC(T=T, xs=xs, rs=rs, qs=qs, ABCDEF=ABCDEF) gammas = GE.gammas() # Checked against ChemSep TPxy plot/data table - shows 5 decimal places assert_close1d(gammas, gammas_expect, rtol=1e-12) # Partial inputs GE = UNIQUAC(T=T, xs=xs, rs=rs, qs=qs, tau_bs=tausB) assert_close1d(GE.gammas(), gammas_expect, rtol=1e-12)
def test_basic_chemsep_PR(): kij = IPDB.get_ip_specific('ChemSep PR', ['124-38-9', '67-56-1'], 'kij') assert_close(kij, 0.0583) kij_auto = IPDB.get_ip_automatic(['124-38-9', '67-56-1'], 'PR kij', 'kij') assert_close(kij, kij_auto) kij_missing = IPDB.get_ip_specific('ChemSep PR', ['1249-38-9', '67-56-1'], 'kij') assert kij_missing == 0 assert False == IPDB.has_ip_specific('ChemSep PR', ['1249-38-9', '67-56-1'], 'kij') assert True == IPDB.has_ip_specific('ChemSep PR', ['124-38-9', '67-56-1'], 'kij') assert IPDB.get_tables_with_type('PR kij') == ['ChemSep PR'] # interaction parameter matrix kij_C1C4 = IPDB.get_ip_symmetric_matrix('ChemSep PR', ['74-82-8', '74-84-0', '74-98-6', '106-97-8'], 'kij') kij_C1C4_known = [[0.0, -0.0059, 0.0119, 0.0185], [-0.0059, 0.0, 0.0011, 0.0089], [0.0119, 0.0011, 0.0, 0.0033], [0.0185, 0.0089, 0.0033, 0.0]] assert_close2d(kij_C1C4, kij_C1C4_known) # Test for asymetric works the same since the model is asymmetric kij_C1C4 = IPDB.get_ip_symmetric_matrix('ChemSep PR', ['74-82-8', '74-84-0', '74-98-6', '106-97-8'], 'kij') assert_close2d(kij_C1C4, kij_C1C4_known)
def test_basic_chemsep_UNIQUAC(): tausB = IPDB.get_ip_asymmetric_matrix(name='ChemSep UNIQUAC', CASs=['64-17-5', '7732-18-5'], ip='bij') assert_close2d(tausB, [[0.0, -87.46005814161899], [-55.288075960115854, 0.0]], rtol=1e-5)
def run_validate_db(): from thermo.interaction_parameters import ip_files for name in ip_files.keys(): IPDB.validate_table(name)