How to use pcsaft - 10 common examples

To help you get started, we’ve selected a few pcsaft examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zmeri / PC-SAFT / tests / test_cython.py View on Github external
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)

    pyargs = {'m':m, 's':s, 'e':e, 'e_assoc':eAB, 'vol_a':volAB, 'k_ij':k_ij, 'z':z, 'dielc':dielc}

    calc = pcsaft_den(t, 101325, x, pyargs, phase='liq')
    if print_result:
        print('\n##########  Test with aqueous NaCl  ##########')
        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, '%')
    assert abs((calc-ref)/ref*100) < 2

    # Propane
    x = np.asarray([1.])
    m = np.asarray([2.0020])
    s = np.asarray([3.6184])
    e = np.asarray([208.11])
    pyargs = {'m':m, 's':s, 'e':e}

    t = 85.525 # K
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
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.])

    t = 298.15 # K
    p = 100000. # Pa
    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)

    pyargs = {'m':m, 's':s, 'e':e, 'e_assoc':eAB, 'vol_a':volAB, 'k_ij':k_ij, 'z':z, 'dielc':dielc}

    rho = pcsaft_den(t, p, x, pyargs, phase='liq')
    dadt_eos = pcsaft_dadt(t, rho, x, pyargs)

    # calculating numerical derivative
    der1 = pcsaft_ares(t-1, rho, x, pyargs)
    der2 = pcsaft_ares(t+1, rho, x, pyargs)
    dadt_num = (der2-der1)/2.
    if print_result:
        print('\n##########  Test with aqueous NaCl  ##########')
        print('    Numerical derivative:', dadt_num)
        print('    PC-SAFT derivative:', dadt_eos)
        print('    Relative deviation:', (dadt_eos-dadt_num)/dadt_num*100, '%')
    assert abs((dadt_eos-dadt_num)/dadt_num*100) < 2e-2
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
t = 85.525 # K
    p = 1.7551e-4 # Pa
    ref = 16621.0 # source: reference EOS in CoolProp
    calc = pcsaft_den(t, p, x, pyargs, phase='liq')
    if print_result:
        print('##########  Test with propane  ##########')
        print('----- Density at {} K and {} Pa -----'.format(t, p))
        print('    Reference:', ref, 'mol m^-3')
        print('    PC-SAFT:', calc, 'mol m^-3')
        print('    Relative deviation:', (calc-ref)/ref*100, '%')
    assert abs((calc-ref)/ref*100) < 2

    t = 85.525 # K
    p = 1.39e-4 # Pa
    ref = 1.9547e-7 # source: reference EOS in CoolProp
    calc = pcsaft_den(t, p, x, pyargs, phase='vap')
    if print_result:
        print('----- Density at {} K and {} Pa -----'.format(t, p))
        print('    Reference:', ref, 'mol m^-3')
        print('    PC-SAFT:', calc, 'mol m^-3')
        print('    Relative deviation:', (calc-ref)/ref*100, '%')
    assert abs((calc-ref)/ref*100) < 2

    t = 293 # K
    p = 833240 # Pa
    ref = 11346.0 # source: reference EOS in CoolProp
    calc = pcsaft_den(t, p, x, pyargs, phase='liq')
    if print_result:
        print('----- Density at {} K and {} Pa -----'.format(t, p))
        print('    Reference:', ref, 'mol m^-3')
        print('    PC-SAFT:', calc, 'mol m^-3')
        print('    Relative deviation:', (calc-ref)/ref*100, '%')
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
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, '%')
    assert abs((calc-ref)/ref*100) < 2

    # 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 = 16110. # source: DIPPR correlation
    calc = pcsaft_den(240, 101325, x, pyargs, phase='liq')
    if print_result:
        print('\n##########  Test with dimethyl ether  ##########')
        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, '%')
    assert abs((calc-ref)/ref*100) < 2

    # Binary mixture: methanol-cyclohexane
    #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.])
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
# # print('    PC-SAFT:', calc, 'J mol^-1 K^-1')
    # # print('    Relative deviation:', (calc-ref)/ref*100, '%')

    # 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])
    cnsts = np.asarray([57431., 94494, 895.51, 65065, 2467.4]) # constants for Aly-Lee equation (obtained from DIPPR)
    pyargs = {'m':m, 's':s, 'e':e, 'dipm':dpm, 'dip_num':dip_num}

    ref = 102.2 # source: DIPPR correlation
    p = 100000.
    t = 240.
    rho = pcsaft_den(t, p, x, pyargs, phase='liq')
    calc = pcsaft_cp(t, rho, cnsts, x, pyargs)
    if print_result:
        print('\n##########  Test with dimethyl ether  ##########')
        print('----- Heat capacity at 240 K -----')
        print('    Reference:', ref, 'J mol^-1 K^-1')
        print('    PC-SAFT:', calc, 'J mol^-1 K^-1')
        print('    Relative deviation:', (calc-ref)/ref*100, '%')
    assert abs((calc-ref)/ref*100) < 3
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
print('    Relative deviation:', (dadt_eos-dadt_num)/dadt_num*100, '%')
    assert abs((dadt_eos-dadt_num)/dadt_num*100) < 2e-2

    # Water
    m = np.asarray([1.2047])
    e = np.asarray([353.95])
    volAB = np.asarray([0.0451])
    eAB = np.asarray([2425.67])

    p = 100000.
    t = 290.

    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}

    rho = pcsaft_den(t, p, x, pyargs, phase='liq')
    dadt_eos = pcsaft_dadt(t, rho, x, pyargs)

    # calculating numerical derivative
    der1 = pcsaft_ares(t-1, rho, x, pyargs)
    der2 = pcsaft_ares(t+1, rho, x, pyargs)
    dadt_num = (der2-der1)/2.
    if print_result:
        print('\n##########  Test with water  ##########')
        print('    Numerical derivative:', dadt_num)
        print('    PC-SAFT derivative:', dadt_eos)
        print('    Relative deviation:', (dadt_eos-dadt_num)/dadt_num*100, '%')
    assert abs((dadt_eos-dadt_num)/dadt_num*100) < 2e-2

    # Dimethyl ether
    m = np.asarray([2.2634])
    s = np.asarray([3.2723])
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
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, '%')
    assert abs((calc-ref)/ref*100) < 2

    # 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])
    pyargs = {'m':m, 's':s, 'e':e, 'e_assoc':eAB, 'vol_a':volAB}

    ref = 17240. # source: DIPPR correlation
    calc = pcsaft_den(305, 101325, x, pyargs, phase='liq')
    if print_result:
        print('\n##########  Test with acetic acid  ##########')
        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, '%')
    assert abs((calc-ref)/ref*100) < 2

    # 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}
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
def test_cp(print_result=False):
    """Test the heat capacity function to see if it is working correctly."""
    # Benzene
    x = np.asarray([1.])
    m = np.asarray([2.4653])
    s = np.asarray([3.6478])
    e = np.asarray([287.35])
    cnsts = np.asarray([55238., 173380, 764.25, 72545, 2445.7]) # constants for Aly-Lee equation (obtained from DIPPR)
    pyargs = {'m':m, 's':s, 'e':e}

    ref = 140.78 # source: Equation of state from Polt et al. (1992) (available at https://webbook.nist.gov/chemistry/fluid/)
    p = 100000.
    t = 330.
    rho = pcsaft_den(t, p, x, pyargs, phase='liq')
    calc = pcsaft_cp(t, rho, cnsts, x, pyargs)
    if print_result:
        print('\n##########  Test with benzene  ##########')
        print('----- Heat capacity at 330 K -----')
        print('    Reference:', ref, 'J mol^-1 K^-1')
        print('    PC-SAFT:', calc, 'J mol^-1 K^-1')
        print('    Relative deviation:', (calc-ref)/ref*100, '%')
    assert abs((calc-ref)/ref*100) < 3

    # Toluene
    x = np.asarray([1.])
    m = np.asarray([2.8149])
    s = np.asarray([3.7169])
    e = np.asarray([285.69])
    cnsts = np.asarray([58140., 286300, 1440.6, 189800, 650.43]) # constants for Aly-Lee equation (obtained from DIPPR)
    pyargs = {'m':m, 's':s, 'e':e}
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
# 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])
    pyargs = {'m':m, 's':s, 'e':e, 'e_assoc':eAB, 'vol_a':volAB}

    den = pcsaft_den(t, p, x, pyargs, phase='liq')
    ref = -7038.004 # J mol^-1
    calc = pcsaft_gres(t, den, x, pyargs)
    if print_result:
        print('Acetic acid, liquid:\t\t', calc, ref, (calc-ref)/ref*100, 'J/mol')
    assert abs((calc-ref)/ref*100) < 1e-2
    den = pcsaft_den(t, p, x, pyargs, phase='vap')
    ref = -2109.459 # J mol^-1
    calc = pcsaft_gres(t, den, x, pyargs)
    if print_result:
        print('Acetic acid, vapor:\t\t', calc, ref, (calc-ref)/ref*100, 'J/mol')
    assert abs((calc-ref)/ref*100) < 1e-2
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
print('    Reference:', ref, 'mol m^-3')
        print('    PC-SAFT:', calc, 'mol m^-3')
        print('    Relative deviation:', (calc-ref)/ref*100, '%')
    assert abs((calc-ref)/ref*100) < 2

    # Propane
    x = np.asarray([1.])
    m = np.asarray([2.0020])
    s = np.asarray([3.6184])
    e = np.asarray([208.11])
    pyargs = {'m':m, 's':s, 'e':e}

    t = 85.525 # K
    p = 1.7551e-4 # Pa
    ref = 16621.0 # source: reference EOS in CoolProp
    calc = pcsaft_den(t, p, x, pyargs, phase='liq')
    if print_result:
        print('##########  Test with propane  ##########')
        print('----- Density at {} K and {} Pa -----'.format(t, p))
        print('    Reference:', ref, 'mol m^-3')
        print('    PC-SAFT:', calc, 'mol m^-3')
        print('    Relative deviation:', (calc-ref)/ref*100, '%')
    assert abs((calc-ref)/ref*100) < 2

    t = 85.525 # K
    p = 1.39e-4 # Pa
    ref = 1.9547e-7 # source: reference EOS in CoolProp
    calc = pcsaft_den(t, p, x, pyargs, phase='vap')
    if print_result:
        print('----- Density at {} K and {} Pa -----'.format(t, p))
        print('    Reference:', ref, 'mol m^-3')
        print('    PC-SAFT:', calc, 'mol m^-3')

pcsaft

The PC-SAFT equation of state, including dipole, association and ion terms.

GPL-3.0
Latest version published 2 years ago

Package Health Score

39 / 100
Full package analysis

Similar packages