SRKMIX
This function initializes an SRK mixture EOS using mixture composition, critical properties, and optional binary interaction parameters.
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
=SRKMIX(critical_temperatures, critical_pressures, omegas, zs, kijs, temperature, pressure, molar_volume, 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).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 SRK 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:
=SRKMIX({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.0000410476 |
| V_g | 0.000711016 |
| fugacities_l | [817841.6430546879, 72382.81925202608] |
| fugacities_g | [442137.12801246054, 361820.7921190941] |
Example 2: Binary SRK mixture EOS without explicit kijs
Inputs:
| critical_temperatures | critical_pressures | omegas | zs | temperature | pressure | ||||
|---|---|---|---|---|---|---|---|---|---|
| 126.1 | 190.6 | 3394000 | 4604000 | 0.04 | 0.011 | 0.5 | 0.5 | 115 | 1000000 |
Excel formula:
=SRKMIX({126.1,190.6}, {3394000,4604000}, {0.04,0.011}, {0.5,0.5}, 115, 1000000)
Expected output:
| Property | Value |
|---|---|
| phase | l/g |
| T | 115 |
| P | 1000000 |
| V_l | 0.0000410476 |
| V_g | 0.000711016 |
| fugacities_l | [817841.6430546879, 72382.81925202608] |
| fugacities_g | [442137.12801246054, 361820.7921190941] |
Example 3: Binary SRK 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.0007110158049 |
| 0 | 0 |
Excel formula:
=SRKMIX({126.1,190.6}, {3394000,4604000}, {0.04,0.011}, {0.5,0.5}, {0,0;0,0}, 115, 0.0007110158049)
Expected output:
| Property | Value |
|---|---|
| phase | g |
| T | 115 |
| P | 1000000 |
| V_l | |
| V_g | 0.000711016 |
| fugacities_l | None |
| fugacities_g | [442137.12804141204, 361820.7921350346] |
Example 4: Binary SRK 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.0007110158049 |
| 0 | 0 |
Excel formula:
=SRKMIX({126.1,190.6}, {3394000,4604000}, {0.04,0.011}, {0.5,0.5}, {0,0;0,0}, 1000000, 0.0007110158049)
Expected output:
| Property | Value |
|---|---|
| phase | g |
| T | 115 |
| P | 1000000 |
| V_l | |
| V_g | 0.000711016 |
| fugacities_l | None |
| fugacities_g | [442137.1280054671, 361820.7921014841] |
Python Code
Show Code
from thermo.eos_mix import SRKMIX as thermo_srkmix
def srkmix(critical_temperatures, critical_pressures, omegas, zs, kijs=None, temperature=None, pressure=None, molar_volume=None, fugacities=True, only_liquid=False, only_vapor=False):
"""
Solve SRK mixture EOS and return key phase and fugacity metrics.
See: https://thermo.readthedocs.io/thermo.eos_mix.html#thermo.eos_mix.SRKMIX
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.
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)
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"
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_srkmix(Tcs=tc_vals, Pcs=pc_vals, omegas=omega_vals, zs=z_vals, kijs=kij_vals, T=temperature, P=pressure, V=molar_volume, 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).
Whether to calculate fugacity properties.
If true, keep only liquid root properties.
If true, keep only vapor root properties.