PRSVMIX

This function initializes a PRSV mixture EOS using composition, critical properties, optional binary interaction parameters, and optional component \kappa_1 values.

With two of temperature, pressure, and molar volume specified, it solves the mixture state and returns key phase, volume-root, and fugacity outputs.

Excel Usage

=PRSVMIX(critical_temperatures, critical_pressures, omegas, zs, kijs, temperature, pressure, molar_volume, kappa_ones, fugacities, only_liquid, only_vapor)
  • critical_temperatures (list[list], required): Critical temperatures for all components (K).
  • critical_pressures (list[list], required): Critical pressures for all components (Pa).
  • omegas (list[list], required): Acentric factors for all components (-).
  • zs (list[list], required): Overall component mole fractions (-).
  • kijs (list[list], optional, default: null): Binary interaction matrix as an n by n range (-).
  • temperature (float, optional, default: null): Temperature (K).
  • pressure (float, optional, default: null): Pressure (Pa).
  • molar_volume (float, optional, default: null): Molar volume (m^3/mol).
  • kappa_ones (list[list], optional, default: null): Optional PRSV kappa1 values by component (-).
  • fugacities (bool, optional, default: true): Whether to calculate fugacity properties.
  • only_liquid (bool, optional, default: false): If true, keep only liquid root properties.
  • only_vapor (bool, optional, default: false): If true, keep only vapor root properties.

Returns (list[list]): 2D array with phase label, solved state variables, roots, and fugacity vectors.

Example 1: Binary PRSV mixture EOS with temperature and pressure

Inputs:

critical_temperatures critical_pressures omegas zs kijs temperature pressure
126.1 190.6 3394000 4604000 0.04 0.011 0.5 0.5 0 0 115 1000000
0 0

Excel formula:

=PRSVMIX({126.1,190.6}, {3394000,4604000}, {0.04,0.011}, {0.5,0.5}, {0,0;0,0}, 115, 1000000)

Expected output:

Property Value
phase l/g
T 115
P 1000000
V_l 0.0000362355
V_g 0.000700242
fugacities_l [794057.5831840492, 72851.22327178437]
fugacities_g [436553.6561835043, 357878.1106688994]
Example 2: Binary PRSV mixture EOS with kappa1 values

Inputs:

critical_temperatures critical_pressures omegas zs kijs temperature pressure kappa_ones
126.1 190.6 3394000 4604000 0.04 0.011 0.5 0.5 0 0 115 1000000 0 0
0 0

Excel formula:

=PRSVMIX({126.1,190.6}, {3394000,4604000}, {0.04,0.011}, {0.5,0.5}, {0,0;0,0}, 115, 1000000, {0,0})

Expected output:

Property Value
phase l/g
T 115
P 1000000
V_l 0.0000362355
V_g 0.000700242
fugacities_l [794057.5831840492, 72851.22327178437]
fugacities_g [436553.6561835043, 357878.1106688994]
Example 3: Binary PRSV mixture EOS with temperature and volume

Inputs:

critical_temperatures critical_pressures omegas zs kijs temperature molar_volume
126.1 190.6 3394000 4604000 0.04 0.011 0.5 0.5 0 0 115 0.0007
0 0

Excel formula:

=PRSVMIX({126.1,190.6}, {3394000,4604000}, {0.04,0.011}, {0.5,0.5}, {0,0;0,0}, 115, 0.0007)

Expected output:

Property Value
phase g
T 115
P 1000230
V_l
V_g 0.0007
fugacities_l None
fugacities_g [436641.52794603555, 357926.50637318793]
Example 4: Binary PRSV mixture EOS with pressure and volume

Inputs:

critical_temperatures critical_pressures omegas zs kijs pressure molar_volume
126.1 190.6 3394000 4604000 0.04 0.011 0.5 0.5 0 0 1000000 0.0007
0 0

Excel formula:

=PRSVMIX({126.1,190.6}, {3394000,4604000}, {0.04,0.011}, {0.5,0.5}, {0,0;0,0}, 1000000, 0.0007)

Expected output:

Property Value
phase g
T 114.983
P 1000000
V_l
V_g 0.0007
fugacities_l None
fugacities_g [436531.1021185319, 357823.7636471351]

Python Code

Show Code
from thermo.eos_mix import PRSVMIX as thermo_prsvmix

def prsvmix(critical_temperatures, critical_pressures, omegas, zs, kijs=None, temperature=None, pressure=None, molar_volume=None, kappa_ones=None, fugacities=True, only_liquid=False, only_vapor=False):
    """
    Solve PRSV mixture EOS and return key phase and fugacity metrics.

    See: https://thermo.readthedocs.io/thermo.eos_mix.html#thermo.eos_mix.PRSVMIX

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

    Args:
        critical_temperatures (list[list]): Critical temperatures for all components (K).
        critical_pressures (list[list]): Critical pressures for all components (Pa).
        omegas (list[list]): Acentric factors for all components (-).
        zs (list[list]): Overall component mole fractions (-).
        kijs (list[list], optional): Binary interaction matrix as an n by n range (-). Default is None.
        temperature (float, optional): Temperature (K). Default is None.
        pressure (float, optional): Pressure (Pa). Default is None.
        molar_volume (float, optional): Molar volume (m^3/mol). Default is None.
        kappa_ones (list[list], optional): Optional PRSV kappa1 values by component (-). Default is None.
        fugacities (bool, optional): Whether to calculate fugacity properties. Default is True.
        only_liquid (bool, optional): If true, keep only liquid root properties. Default is False.
        only_vapor (bool, optional): If true, keep only vapor root properties. Default is False.

    Returns:
        list[list]: 2D array with phase label, solved state variables, roots, and fugacity vectors.
    """
    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)]

        def to_matrix(x):
            if x is None:
                return None
            if not isinstance(x, list):
                return None
            matrix = []
            for row in x:
                if isinstance(row, list):
                    clean_row = []
                    for val in row:
                        if val is None or val == "":
                            clean_row.append(0.0)
                        else:
                            clean_row.append(float(val))
                    if len(clean_row) > 0:
                        matrix.append(clean_row)
            return matrix if len(matrix) > 0 else None

        tc_vals = to_list(critical_temperatures)
        pc_vals = to_list(critical_pressures)
        omega_vals = to_list(omegas)
        z_vals = to_list(zs)
        kij_vals = to_matrix(kijs)
        kappa_vals = to_list(kappa_ones)
        if len(kappa_vals) == 0:
            kappa_vals = None

        n = len(z_vals)
        if n == 0 or len(tc_vals) != n or len(pc_vals) != n or len(omega_vals) != n:
            return "Error: critical_temperatures, critical_pressures, omegas, and zs must be non-empty and have the same length"
        if kappa_vals is not None and len(kappa_vals) != n:
            return "Error: kappa_ones must be empty or have one value per component"

        specified = 0
        for value in [temperature, pressure, molar_volume]:
            if value is not None:
                specified += 1
        if specified < 2:
            return "Error: At least two of temperature, pressure, and molar_volume must be provided"

        eos = thermo_prsvmix(Tcs=tc_vals, Pcs=pc_vals, omegas=omega_vals, zs=z_vals, kijs=kij_vals, T=temperature, P=pressure, V=molar_volume, kappa1s=kappa_vals, fugacities=fugacities, only_l=only_liquid, only_g=only_vapor)

        return [
            ["Property", "Value"],
            ["phase", str(getattr(eos, "phase", ""))],
            ["T", getattr(eos, "T", None)],
            ["P", getattr(eos, "P", None)],
            ["V_l", getattr(eos, "V_l", None)],
            ["V_g", getattr(eos, "V_g", None)],
            ["fugacities_l", str(getattr(eos, "fugacities_l", None))],
            ["fugacities_g", str(getattr(eos, "fugacities_g", None))]
        ]
    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

Critical temperatures for all components (K).
Critical pressures for all components (Pa).
Acentric factors for all components (-).
Overall component mole fractions (-).
Binary interaction matrix as an n by n range (-).
Temperature (K).
Pressure (Pa).
Molar volume (m^3/mol).
Optional PRSV kappa1 values by component (-).
Whether to calculate fugacity properties.
If true, keep only liquid root properties.
If true, keep only vapor root properties.