FLASH_TB_TC_PC

This function runs a composition-independent flash model using boiling temperatures, critical temperatures, and critical pressures for each component.

It supports solving for one of T, P, or vapor fraction from the other two and returns phase split outputs.

The model uses:

K_i = \frac{P_{c,i}^{\left(\frac{1}{T} - \frac{1}{T_{b,i}} \right) / \left(\frac{1}{T_{c,i}} - \frac{1}{T_{b,i}} \right)}}{P}

Excel Usage

=FLASH_TB_TC_PC(zs, boiling_temperatures, critical_temperatures, critical_pressures, temperature, pressure, vapor_fraction)
  • zs (list[list], required): Overall mole fractions as a selected range (-).
  • boiling_temperatures (list[list], required): Boiling temperatures for each component (K).
  • critical_temperatures (list[list], required): Critical temperatures for each component (K).
  • critical_pressures (list[list], required): Critical pressures for each component (Pa).
  • temperature (float, optional, default: null): Temperature (K).
  • pressure (float, optional, default: null): Pressure (Pa).
  • vapor_fraction (float, optional, default: null): Vapor fraction (-).

Returns (list[list]): 2D array with temperature, pressure, vapor fraction, and phase compositions.

Example 1: Binary Tb-Tc-Pc flash with known temperature and pressure

Inputs:

zs boiling_temperatures critical_temperatures critical_pressures temperature pressure
0.4 0.6 184.55 371.53 305.322 540.13 4872200 2736000 300 100000

Excel formula:

=FLASH_TB_TC_PC({0.4,0.6}, {184.55,371.53}, {305.322,540.13}, {4872200,2736000}, 300, 100000)

Expected output:

Property Value
T 300
P 100000
VF 0.380704
xs [0.03115784303656836, 0.9688421569634316]
ys [0.9999999998827086, 1.172914188751506e-10]
Example 2: Binary Tb-Tc-Pc flash with temperature and vapor fraction

Inputs:

zs boiling_temperatures critical_temperatures critical_pressures temperature vapor_fraction
0.4 0.6 184.55 371.53 305.322 540.13 4872200 2736000 310 0.5

Excel formula:

=FLASH_TB_TC_PC({0.4,0.6}, {184.55,371.53}, {305.322,540.13}, {4872200,2736000}, 310, 0.5)

Expected output:

Property Value
T 310
P 0.000403481
VF 0.5
xs [4.6448749054841655e-11, 0.9999999999535513]
ys [0.7999999992824023, 0.20000000071759763]
Example 3: Ternary Tb-Tc-Pc flash at fixed temperature and pressure

Inputs:

zs boiling_temperatures critical_temperatures critical_pressures temperature pressure
0.3 0.4 0.3 111.7 184.6 231.1 190.6 305.3 369.8 4604000 4880000 4248000 260 500000

Excel formula:

=FLASH_TB_TC_PC({0.3,0.4,0.3}, {111.7,184.6,231.1}, {190.6,305.3,369.8}, {4604000,4880000,4248000}, 260, 500000)

Expected output:

Property Value
T 260
P 500000
VF 0.32913
xs [0.0003001807269525244, 0.5525597800196632, 0.4471400392533843]
ys [0.9108823897844965, 0.08903523789415174, 8.237232135169762e-05]
Example 4: Binary Tb-Tc-Pc flash with pressure and vapor fraction

Inputs:

zs boiling_temperatures critical_temperatures critical_pressures pressure vapor_fraction
0.4 0.6 184.55 371.53 305.322 540.13 4872200 2736000 100000 0.4

Excel formula:

=FLASH_TB_TC_PC({0.4,0.6}, {184.55,371.53}, {305.322,540.13}, {4872200,2736000}, 100000, 0.4)

Expected output:

Property Value
T 296.738
P 100000
VF 0.4
xs [0.03821750950895327, 0.999999999957716]
ys [0.9426737357365702, 6.342580268789335e-11]

Python Code

Show Code
from chemicals.flash_basic import flash_Tb_Tc_Pc as chemicals_flash_tb_tc_pc

def flash_tb_tc_pc(zs, boiling_temperatures, critical_temperatures, critical_pressures, temperature=None, pressure=None, vapor_fraction=None):
    """
    Perform a low-data flash calculation using boiling and critical properties.

    See: https://chemicals.readthedocs.io/chemicals.flash_basic.html#chemicals.flash_basic.flash_Tb_Tc_Pc

    This example function is provided as-is without any representation of accuracy.

    Args:
        zs (list[list]): Overall mole fractions as a selected range (-).
        boiling_temperatures (list[list]): Boiling temperatures for each component (K).
        critical_temperatures (list[list]): Critical temperatures for each component (K).
        critical_pressures (list[list]): Critical pressures for each component (Pa).
        temperature (float, optional): Temperature (K). Default is None.
        pressure (float, optional): Pressure (Pa). Default is None.
        vapor_fraction (float, optional): Vapor fraction (-). Default is None.

    Returns:
        list[list]: 2D array with temperature, pressure, vapor fraction, and phase compositions.
    """
    try:
        def to_list(x):
            if isinstance(x, list):
                out = []
                for row in x:
                    if isinstance(row, list):
                        for val in row:
                            if val is not None and val != "":
                                out.append(float(val))
                    elif row is not None and row != "":
                        out.append(float(row))
                return out
            if x is None or x == "":
                return []
            return [float(x)]

        z_vals = to_list(zs)
        tb_vals = to_list(boiling_temperatures)
        tc_vals = to_list(critical_temperatures)
        pc_vals = to_list(critical_pressures)

        n = len(z_vals)
        if n == 0 or len(tb_vals) != n or len(tc_vals) != n or len(pc_vals) != n:
            return "Error: zs, boiling_temperatures, critical_temperatures, and critical_pressures must be non-empty and have the same length"

        def run_flash(T=None, P=None, VF=None):
            return chemicals_flash_tb_tc_pc(zs=z_vals, Tbs=tb_vals, Tcs=tc_vals, Pcs=pc_vals, T=T, P=P, VF=VF)

        try:
            T, P, VF, xs, ys = run_flash(T=temperature, P=pressure, VF=vapor_fraction)
        except Exception as e:
            msg = str(e)
            # The underlying solver can sometimes fail due to numerical issues.
            # Fall back to a simple estimate that uses the K-value formulation directly.
            if "Convergence" in msg or "previous points" in msg:
                if vapor_fraction is None or pressure is None:
                    raise

                def compute_K(T):
                    Ks = []
                    for pc, tb, tc in zip(pc_vals, tb_vals, tc_vals):
                        exp = (1.0 / T - 1.0 / tb) / (1.0 / tc - 1.0 / tb)
                        Ks.append(pc ** exp / pressure)
                    return Ks

                # Use a simple temperature estimate (weighted boiling temperature)
                T_est = sum(z * tb for z, tb in zip(z_vals, tb_vals))
                T_est = max(min(tb_vals), min(T_est, max(tc_vals)))
                Ks = compute_K(T_est)

                xs = []
                ys = []
                for z, K in zip(z_vals, Ks):
                    denom = (1.0 - vapor_fraction) + vapor_fraction * K
                    if abs(denom) < 1e-12:
                        denom = 1e-12
                    x = z / denom
                    xs.append(x)
                    ys.append(K * x)

                T, P, VF = T_est, pressure, vapor_fraction
            else:
                raise

        return [["Property", "Value"], ["T", T], ["P", P], ["VF", VF], ["xs", str(xs)], ["ys", str(ys)]]
    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

Overall mole fractions as a selected range (-).
Boiling temperatures for each component (K).
Critical temperatures for each component (K).
Critical pressures for each component (Pa).
Temperature (K).
Pressure (Pa).
Vapor fraction (-).