How to use the pcsaft.flashTQ 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
assert abs((calc-ref)/ref*100) < 3

    # Binary mixture: methane-benzene
    #0 = methane, 1 = benzene
    x = np.asarray([0.0252,0.9748])
    m = np.asarray([1.0000, 2.4653])
    s = np.asarray([3.7039, 3.6478])
    e = np.asarray([150.03, 287.35])
    k_ij = np.asarray([[0, 0.037],
                       [0.037, 0]])
    pyargs = {'m':m, 's':s, 'e':e, 'k_ij':k_ij}

    t = 421.05
    ref = 1986983.25 # source: H.-M. Lin, H. M. Sebastian, J. J. Simnick, and K.-C. Chao, “Gas-liquid equilibrium in binary mixtures of methane with N-decane, benzene, and toluene,” J. Chem. Eng. Data, vol. 24, no. 2, pp. 146–149, Apr. 1979.
    xv_ref = np.asarray([0.6516,0.3484])
    calc, xl, xv = flashTQ(t, 0, x, pyargs)
    if print_result:
        print('\n##########  Test with methane-benzene mixture  ##########')
        print('----- Bubble point pressure at %s K -----' % t)
        print('    Reference:', ref, 'Pa')
        print('    PC-SAFT:', calc, 'Pa')
        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) < 10
    assert np.all(abs((xv-xv_ref)/xv_ref*100) < 10)

    # # Binary mixture: hydrogen-hexadecane
    # # This does not pass yet. The flash functions still need to be improved.
    # #0 = hydrogen, 1 = hexadecane
    # x = np.asarray([0.0407, 0.9593])
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
#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
    ref = 101330 # 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
    t = 327.48
    xv_ref = np.asarray([0.59400,0.40600])
    calc, xl, xv = flashTQ(t, 0, x, pyargs)
    if print_result:
        print('\n##########  Test with methanol-cyclohexane mixture  ##########')
        print('----- Bubble point pressure at 327.48 K -----')
        print('    Reference:', ref, 'Pa')
        print('    PC-SAFT:', calc, 'Pa')
        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) < 10
    assert np.all(abs((xv-xv_ref)/xv_ref*100) < 10)

    # dew point
    x = np.asarray([0.59400,0.40600])
    ref = 101330 # 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
    t = 327.48
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
print('    Relative deviation:', (calc-ref)/ref*100, '%')
    assert abs((calc-ref)/ref*100) < 5

    ref = 8.3324e5 # source: reference EOS in CoolProp
    t = 293
    calc, xl, xv = flashTQ(t, 0, x, pyargs)
    if print_result:
        print('----- Vapor pressure at {} K -----'.format(t))
        print('    Reference:', ref, 'Pa')
        print('    PC-SAFT:', calc, 'Pa')
        print('    Relative deviation:', (calc-ref)/ref*100, '%')
    assert abs((calc-ref)/ref*100) < 3

    ref = 42.477e5 # source: reference EOS in CoolProp
    t = 369.82
    calc, xl, xv = flashTQ(t, 0, x, pyargs)
    if print_result:
        print('----- Vapor pressure at {} K -----'.format(t))
        print('    Reference:', ref, 'Pa')
        print('    PC-SAFT:', calc, 'Pa')
        print('    Relative deviation:', (calc-ref)/ref*100, '%')
    assert abs((calc-ref)/ref*100) < 3

    # Binary mixture: methane-benzene
    #0 = methane, 1 = benzene
    x = np.asarray([0.0252,0.9748])
    m = np.asarray([1.0000, 2.4653])
    s = np.asarray([3.7039, 3.6478])
    e = np.asarray([150.03, 287.35])
    k_ij = np.asarray([[0, 0.037],
                       [0.037, 0]])
    pyargs = {'m':m, 's':s, 'e':e, 'k_ij':k_ij}
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
print('    Reference:', ref, 'Pa')
        print('    PC-SAFT:', calc, 'Pa')
        print('    Relative deviation:', (calc-ref)/ref*100, '%')
    assert abs((calc-ref)/ref*100) < 3

    # 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 = 193261.515187248 # source: DIPPR correlation
    t = 413.5385
    calc, xl, xv = flashTQ(t, 0, x, pyargs)
    if print_result:
        print('\n##########  Test with acetic acid  ##########')
        print('----- Vapor pressure at 413.5 K -----')
        print('    Reference:', ref, 'Pa')
        print('    PC-SAFT:', calc, 'Pa')
        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}
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
def test_flashTQ(print_result=False):
    """Test the flashTQ 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 = 3255792.76201971 # source: reference EOS in CoolProp
    t = 572.6667
    calc, xl, xv = flashTQ(t, 0, x, pyargs)
    if print_result:
        print('##########  Test with toluene  ##########')
        print('----- Vapor pressure at 572.7 K -----')
        print('    Reference:', ref, 'Pa')
        print('    PC-SAFT:', calc, 'Pa')
        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 = 67171.754576141 # source: IAWPS95 EOS
    t = 362
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
print('----- Vapor pressure at 300 K -----')
        print('    Reference:', ref, 'Pa')
        print('    PC-SAFT:', calc, 'Pa')
        print('    Relative deviation:', (calc-ref)/ref*100, '%')
    assert abs((calc-ref)/ref*100) < 3

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

    ref = 1.7551e-4 # source: reference EOS in CoolProp
    t = 85.525
    calc, xl, xv = flashTQ(t, 0, x, pyargs)
    if print_result:
        print('##########  Test with propane  ##########')
        print('----- Vapor pressure at {} K -----'.format(t))
        print('    Reference:', ref, 'Pa')
        print('    PC-SAFT:', calc, 'Pa')
        print('    Relative deviation:', (calc-ref)/ref*100, '%')
    assert abs((calc-ref)/ref*100) < 5

    ref = 8.3324e5 # source: reference EOS in CoolProp
    t = 293
    calc, xl, xv = flashTQ(t, 0, x, pyargs)
    if print_result:
        print('----- Vapor pressure at {} K -----'.format(t))
        print('    Reference:', ref, 'Pa')
        print('    PC-SAFT:', calc, 'Pa')
        print('    Relative deviation:', (calc-ref)/ref*100, '%')
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
print('    Reference pressure:', ref, 'Pa')
        print('    PC-SAFT pressure:', calc, 'Pa')
        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) < 10
    assert np.all(abs((xv-xv_ref)/xv_ref*100) < 15)

    xl_ref = np.asarray([0.2691800943, 0.7308199057])
    t = 372.774
    s[0] = 3.8395 + 1.2828*np.exp(-0.0074944*t) - 1.3939*np.exp(-0.00056029*t)
    pyargs = {'m':m, 's':s, 'e':e, 'e_assoc':eAB, 'vol_a':volAB, 'k_ij':k_ij}
    ref = 74463. # source: Freeman, J. R.; Wilson, G. M. AIChE Symp. Ser., 1985, 81, 14-25 High temperature vapor-liquid equilibrium measurements on acetic acid/water mixtures
    xv_ref = np.asarray([0.3878269411, 0.6121730589])
    calc, xl, xv = flashTQ(t, 0, xl_ref, pyargs)
    if print_result:
        print('----- Bubble point pressure at %s K -----' % t)
        print('    Liquid composition:', xl_ref)
        print('    Reference pressure:', ref, 'Pa')
        print('    PC-SAFT pressure:', calc, 'Pa')
        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) < 10
    assert np.all(abs((xv-xv_ref)/xv_ref*100) < 15)

    # 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])
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
print('    Reference:', ref, 'Pa')
        print('    PC-SAFT:', calc, 'Pa')
        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 = 67171.754576141 # source: IAWPS95 EOS
    t = 362
    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, xl, xv = flashTQ(t, 0, x, pyargs)
    if print_result:
        print('\n##########  Test with water  ##########')
        print('----- Vapor pressure at 362 K -----')
        print('    Reference:', ref, 'Pa')
        print('    PC-SAFT:', calc, 'Pa')
        print('    Relative deviation:', (calc-ref)/ref*100, '%')
    assert abs((calc-ref)/ref*100) < 3

    # 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}
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
#0 = water, 1 = acetic acid
    m = np.asarray([1.2047, 1.3403])
    s = np.asarray([0, 3.8582])
    e = np.asarray([353.95, 211.59])
    volAB = np.asarray([0.0451, 0.075550])
    eAB = np.asarray([2425.67, 3044.4])
    k_ij = np.asarray([[0, -0.127],
                       [-0.127, 0]])

    xl_ref = np.asarray([0.9898662364, 0.0101337636])
    t = 403.574
    s[0] = 3.8395 + 1.2828*np.exp(-0.0074944*t) - 1.3939*np.exp(-0.00056029*t)
    pyargs = {'m':m, 's':s, 'e':e, 'e_assoc':eAB, 'vol_a':volAB, 'k_ij':k_ij}
    ref = 273722. # source: Othmer, D. F.; Silvis, S. J.; Spiel, A. Ind. Eng. Chem., 1952, 44, 1864-72 Composition of vapors from boiling binary solutions pressure equilibrium still for studying water - acetic acid system
    xv_ref = np.asarray([0.9923666645, 0.0076333355])
    calc, xl, xv = flashTQ(t, 0, xl_ref, pyargs)
    if print_result:
        print('\n##########  Test with water-acetic acid mixture  ##########')
        print('----- Bubble point pressure at %s K -----' % t)
        print('    Liquid composition:', xl_ref)
        print('    Reference pressure:', ref, 'Pa')
        print('    PC-SAFT pressure:', calc, 'Pa')
        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) < 10
    assert np.all(abs((xv-xv_ref)/xv_ref*100) < 15)

    xl_ref = np.asarray([0.2691800943, 0.7308199057])
    t = 372.774
    s[0] = 3.8395 + 1.2828*np.exp(-0.0074944*t) - 1.3939*np.exp(-0.00056029*t)
github zmeri / PC-SAFT / tests / test_cython.py View on Github external
pyargs = {'m':m, 's':s, 'e':e}

    ref = 1.7551e-4 # source: reference EOS in CoolProp
    t = 85.525
    calc, xl, xv = flashTQ(t, 0, x, pyargs)
    if print_result:
        print('##########  Test with propane  ##########')
        print('----- Vapor pressure at {} K -----'.format(t))
        print('    Reference:', ref, 'Pa')
        print('    PC-SAFT:', calc, 'Pa')
        print('    Relative deviation:', (calc-ref)/ref*100, '%')
    assert abs((calc-ref)/ref*100) < 5

    ref = 8.3324e5 # source: reference EOS in CoolProp
    t = 293
    calc, xl, xv = flashTQ(t, 0, x, pyargs)
    if print_result:
        print('----- Vapor pressure at {} K -----'.format(t))
        print('    Reference:', ref, 'Pa')
        print('    PC-SAFT:', calc, 'Pa')
        print('    Relative deviation:', (calc-ref)/ref*100, '%')
    assert abs((calc-ref)/ref*100) < 3

    ref = 42.477e5 # source: reference EOS in CoolProp
    t = 369.82
    calc, xl, xv = flashTQ(t, 0, x, pyargs)
    if print_result:
        print('----- Vapor pressure at {} K -----'.format(t))
        print('    Reference:', ref, 'Pa')
        print('    PC-SAFT:', calc, 'Pa')
        print('    Relative deviation:', (calc-ref)/ref*100, '%')
    assert abs((calc-ref)/ref*100) < 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