How to use the pcsaft.pcsaft_dadt function in pcsaft

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
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
print('    Relative deviation:', (dadt_eos-dadt_num)/dadt_num*100, '%')
    assert abs((dadt_eos-dadt_num)/dadt_num*100) < 2e-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}

    p = 100000.
    t = 310.

    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 acetic acid  ##########')
        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

    # Water
    m = np.asarray([1.2047])
    e = np.asarray([353.95])
    volAB = np.asarray([0.0451])
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

    # 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}

    p = 100000.
    t = 370.

    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 dimethyl ether  ##########')
        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

    # Aqueous NaCl
    # 0 = Na+, 1 = Cl-, 2 = H2O
    x = np.asarray([0.0907304774758426, 0.0907304774758426, 0.818539045048315])
    m = np.asarray([1, 1, 1.2047])
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
def test_dadt(print_result=False):
    """Test the function for the temperature derivative of the Helmholtz energy."""
    # 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}

    p = 100000.
    t = 330.

    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 toluene  ##########')
        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

    # Acetic acid
    m = np.asarray([1.3403])
    s = np.asarray([3.8582])
    e = np.asarray([211.59])
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
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])
    e = np.asarray([210.29])

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