Activity & group contribution¶
Excess-Gibbs / activity-coefficient models (Margules, van Laar, Wilson, NRTL,
UNIQUAC, regular-solution and Flory-Huggins), available both as plain functions
and as differentiable ActivityModel objects, plus the predictive group
contribution methods (UNIFAC, modified UNIFAC/Dortmund, and Joback).
Activity-coefficient models¶
activity
¶
Activity-coefficient models for non-ideal liquid mixtures.
The package collects excess-Gibbs / activity-coefficient models that share a
common, differentiable jax.numpy implementation:
margulesandvanlaar: two-parameter binary models;wilson,nrtlanduniquac: multicomponent local-composition models;regular_solution: Scatchard-Hildebrand regular-solution and Flory-Huggins models from pure-component descriptors.
Each model exposes *_ln_gamma and *_gamma functions; the local-
composition models additionally provide builders that assemble their interaction
matrices from temperature and physical parameters.
For a uniform, object-oriented interface (used by the gamma-phi equilibrium
engine and the parameter regressor), models
wraps each kernel in a differentiable model object implementing
ActivityModel.
Modules:
| Name | Description |
|---|---|
margules |
Two-parameter Margules activity-coefficient model for binary mixtures. |
models |
Object-oriented activity-coefficient models with a uniform, differentiable API. |
nrtl |
Multicomponent NRTL (non-random two-liquid) activity-coefficient model. |
regular_solution |
Regular-solution and Flory-Huggins activity-coefficient models. |
uniquac |
Multicomponent UNIQUAC activity-coefficient model. |
vanlaar |
Van Laar activity-coefficient model for binary mixtures. |
wilson |
Multicomponent Wilson activity-coefficient model. |
Classes:
| Name | Description |
|---|---|
NRTL |
NRTL model with the standard |
UNIQUAC |
UNIQUAC model with |
ActivityModel |
Structural type for a liquid activity-coefficient model. |
FloryHuggins |
Athermal Flory-Huggins size-asymmetry model. |
Hildebrand |
Flory-Huggins-Hildebrand model: regular-solution enthalpy + FH entropy. |
Margules |
Two-parameter Margules binary model with |
RegularSolution |
Scatchard-Hildebrand regular-solution model (cohesive-energy descriptors). |
VanLaar |
Two-parameter van Laar binary model with |
Wilson |
Wilson model built from molar volumes and interaction energies. |
Functions:
| Name | Description |
|---|---|
margules_excess_gibbs |
Dimensionless excess Gibbs energy |
margules_gamma |
Activity coefficients |
margules_ln_gamma |
Natural log of the activity coefficients for a binary Margules mixture. |
excess_gibbs |
Dimensionless excess Gibbs energy |
gamma |
Activity coefficients |
nrtl_from_energies |
Build a temperature-independent |
uniquac_from_energies |
Build a temperature-dependent |
van_laar |
Build a |
nrtl_excess_gibbs |
Dimensionless excess Gibbs energy |
nrtl_g |
Compute |
nrtl_gamma |
Activity coefficients |
nrtl_ln_gamma |
Log activity coefficients |
nrtl_tau |
Build the |
flory_huggins_gamma |
Activity coefficients from the athermal Flory-Huggins model. |
flory_huggins_ln_gamma |
Athermal Flory-Huggins (size-asymmetry) log activity coefficients. |
hildebrand_ln_gamma |
Flory-Huggins-Hildebrand |
regular_solution_gamma |
Activity coefficients from regular-solution theory. |
regular_solution_ln_gamma |
Log activity coefficients from Scatchard-Hildebrand regular-solution theory. |
volume_fractions |
Volume (segment) fractions |
uniquac_gamma |
Activity coefficients for a multicomponent UNIQUAC mixture. |
uniquac_ln_gamma |
Log activity coefficients for a multicomponent UNIQUAC mixture. |
uniquac_tau |
Build |
van_laar_gamma |
Activity coefficients |
van_laar_ln_gamma |
Natural log of the activity coefficients for a binary van Laar mixture. |
wilson_excess_gibbs |
Dimensionless excess Gibbs energy |
wilson_gamma |
Activity coefficients for a multicomponent Wilson mixture. |
wilson_lambda |
Build the Wilson |
wilson_ln_gamma |
Log activity coefficients for a multicomponent Wilson mixture. |
NRTL
dataclass
¶
NRTL model with the standard tau_ij = a_ij + b_ij/T + e_ij ln T law.
Attributes:
| Name | Type | Description |
|---|---|---|
a |
Array
|
Constant part of |
b |
Array
|
|
alpha |
Array
|
Non-randomness factors |
e |
Array
|
|
Methods:
| Name | Description |
|---|---|
tau |
Temperature-dependent |
ln_gamma |
Log activity coefficients |
UNIQUAC
dataclass
¶
UNIQUAC model with tau_ij = exp(a_ij + b_ij/T).
Attributes:
| Name | Type | Description |
|---|---|---|
r |
Array
|
Volume (size) parameters |
q |
Array
|
Surface-area parameters |
a |
Array
|
Constant part of |
b |
Array
|
|
Methods:
| Name | Description |
|---|---|
tau |
Temperature-dependent |
ln_gamma |
Log activity coefficients |
ActivityModel
¶
Bases: Protocol
Structural type for a liquid activity-coefficient model.
A model maps a liquid composition and temperature to the vector of log
activity coefficients ln(gamma_i). That single method is all the
equilibrium engines require.
Methods:
| Name | Description |
|---|---|
ln_gamma |
Log activity coefficients |
ln_gamma
¶
Log activity coefficients ln(gamma_i) at composition x, temperature t.
FloryHuggins
dataclass
¶
Athermal Flory-Huggins size-asymmetry model.
Attributes:
| Name | Type | Description |
|---|---|---|
volume |
Array
|
Molecular size descriptors |
Methods:
| Name | Description |
|---|---|
ln_gamma |
Log activity coefficients |
ln_gamma
¶
Log activity coefficients ln(gamma_i) (the combinatorial part).
Hildebrand
dataclass
¶
Flory-Huggins-Hildebrand model: regular-solution enthalpy + FH entropy.
Attributes:
| Name | Type | Description |
|---|---|---|
volume |
Array
|
Liquid molar volumes |
delta |
Array
|
Solubility parameters |
Methods:
| Name | Description |
|---|---|
ln_gamma |
Log activity coefficients |
Margules
dataclass
¶
Two-parameter Margules binary model with A = a + b/T.
Attributes:
| Name | Type | Description |
|---|---|---|
a12 |
Array
|
Constant part of |
a21 |
Array
|
Constant part of |
Methods:
| Name | Description |
|---|---|
ln_gamma |
Log activity coefficients |
ln_gamma
¶
Log activity coefficients [ln(gamma_1), ln(gamma_2)] for the binary.
RegularSolution
dataclass
¶
Scatchard-Hildebrand regular-solution model (cohesive-energy descriptors).
Attributes:
| Name | Type | Description |
|---|---|---|
volume |
Array
|
Liquid molar volumes |
delta |
Array
|
Solubility parameters |
Methods:
| Name | Description |
|---|---|
ln_gamma |
Log activity coefficients |
ln_gamma
¶
Log activity coefficients ln(gamma_i) (all non-negative).
VanLaar
dataclass
¶
Two-parameter van Laar binary model with A = a + b/T.
Attributes:
| Name | Type | Description |
|---|---|---|
a12 |
Array
|
Constant part of |
a21 |
Array
|
Constant part of |
Methods:
| Name | Description |
|---|---|
ln_gamma |
Log activity coefficients |
ln_gamma
¶
Log activity coefficients [ln(gamma_1), ln(gamma_2)] for the binary.
Wilson
dataclass
¶
Wilson model built from molar volumes and interaction energies.
Attributes:
| Name | Type | Description |
|---|---|---|
volume |
Array
|
Liquid molar volumes |
energy |
Array
|
Energy differences |
Methods:
| Name | Description |
|---|---|
lam |
Temperature-dependent Wilson |
ln_gamma |
Log activity coefficients |
margules_excess_gibbs
¶
Dimensionless excess Gibbs energy g^E / (R T) of a binary mixture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x1
|
ArrayLike
|
Mole fraction of component 1, in |
required |
a12
|
ArrayLike
|
Margules parameter |
required |
a21
|
ArrayLike
|
Margules parameter |
required |
Returns:
| Type | Description |
|---|---|
Array
|
The dimensionless excess Gibbs energy. |
margules_gamma
¶
margules_gamma(
x1: ArrayLike, a12: ArrayLike, a21: ArrayLike
) -> tuple[Array, Array]
Activity coefficients (gamma_1, gamma_2) for a binary Margules mixture.
margules_ln_gamma
¶
margules_ln_gamma(
x1: ArrayLike, a12: ArrayLike, a21: ArrayLike
) -> tuple[Array, Array]
Natural log of the activity coefficients for a binary Margules mixture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x1
|
ArrayLike
|
Mole fraction of component 1, in |
required |
a12
|
ArrayLike
|
Margules parameter |
required |
a21
|
ArrayLike
|
Margules parameter |
required |
Returns:
| Type | Description |
|---|---|
tuple[Array, Array]
|
A tuple |
excess_gibbs
¶
excess_gibbs(
model: ActivityModel, x: Array, t: ArrayLike
) -> Array
Dimensionless excess Gibbs energy g^E/(RT) = sum_i x_i ln(gamma_i).
This identity holds for every activity model (the log activity coefficients
are the partial molar excess Gibbs energies), so it gives a single, exact,
model-independent g^E, handy for plotting and for stability tests.
gamma
¶
gamma(
model: ActivityModel, x: Array, t: ArrayLike
) -> Array
Activity coefficients gamma_i from any ActivityModel.
nrtl_from_energies
¶
nrtl_from_energies(dg: Array, alpha: Array) -> NRTL
Build a temperature-independent NRTL from energies dg_ij (J/mol).
Uses tau_ij = dg_ij / (R T) (i.e. a = 0, b = dg / R), the common
"g_ij - g_jj" parameterisation.
uniquac_from_energies
¶
uniquac_from_energies(
r: Array, q: Array, du: Array
) -> UNIQUAC
Build a temperature-dependent UNIQUAC from energies du_ij (J/mol).
Uses tau_ij = exp(-du_ij / (R T)) (a = 0, b = -du / R).
van_laar
¶
van_laar(
a12: ArrayLike,
a21: ArrayLike,
b12: ArrayLike = 0.0,
b21: ArrayLike = 0.0,
) -> VanLaar
Build a VanLaar binary model (constant A unless b given).
nrtl_excess_gibbs
¶
Dimensionless excess Gibbs energy g^E / (R T) for an NRTL mixture.
nrtl_g
¶
Compute G_ij = exp(-alpha_ij * tau_ij) from tau and alpha.
nrtl_gamma
¶
Activity coefficients gamma_i for a multicomponent NRTL mixture.
nrtl_ln_gamma
¶
Log activity coefficients ln(gamma_i) for a multicomponent NRTL mixture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array
|
Mole fractions, shape |
required |
tau
|
Array
|
Interaction parameter matrix |
required |
alpha
|
Array
|
Non-randomness matrix |
required |
Returns:
| Type | Description |
|---|---|
Array
|
|
nrtl_tau
¶
Build the tau matrix from the common temperature correlation.
tau_ij = a_ij + b_ij / T + c_ij * ln(T). Pass arrays of shape (n, n)
for a and b (and optionally c); the diagonal should be zero.
flory_huggins_gamma
¶
Activity coefficients from the athermal Flory-Huggins model.
flory_huggins_ln_gamma
¶
Athermal Flory-Huggins (size-asymmetry) log activity coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array
|
Mole fractions, shape |
required |
volume
|
Array
|
Molecular size descriptors |
required |
Returns:
| Type | Description |
|---|---|
Array
|
|
hildebrand_ln_gamma
¶
Flory-Huggins-Hildebrand ln(gamma): regular-solution enthalpy + FH entropy.
The sum of regular_solution_ln_gamma (enthalpic) and
flory_huggins_ln_gamma (combinatorial/entropic), giving a model that
handles both energetic and size-asymmetry effects with pure-component data.
regular_solution_gamma
¶
Activity coefficients from regular-solution theory.
regular_solution_ln_gamma
¶
Log activity coefficients from Scatchard-Hildebrand regular-solution theory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array
|
Mole fractions, shape |
required |
volume
|
Array
|
Liquid molar volumes |
required |
delta
|
Array
|
Solubility parameters |
required |
t
|
ArrayLike
|
Temperature (K). |
required |
Returns:
| Type | Description |
|---|---|
Array
|
|
volume_fractions
¶
Volume (segment) fractions phi_i = x_i v_i / sum_j x_j v_j.
uniquac_gamma
¶
Activity coefficients for a multicomponent UNIQUAC mixture.
uniquac_ln_gamma
¶
Log activity coefficients for a multicomponent UNIQUAC mixture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array
|
Mole fractions, shape |
required |
r
|
Array
|
Volume (size) parameters |
required |
q
|
Array
|
Surface-area parameters |
required |
tau
|
Array
|
Interaction matrix |
required |
Returns:
| Type | Description |
|---|---|
Array
|
|
uniquac_tau
¶
Build tau_ij = exp(-Delta u_ij / (R T)) from interaction energies (J/mol).
van_laar_gamma
¶
van_laar_gamma(
x1: ArrayLike, a12: ArrayLike, a21: ArrayLike
) -> tuple[Array, Array]
Activity coefficients (gamma_1, gamma_2) for a binary van Laar mixture.
van_laar_ln_gamma
¶
van_laar_ln_gamma(
x1: ArrayLike, a12: ArrayLike, a21: ArrayLike
) -> tuple[Array, Array]
Natural log of the activity coefficients for a binary van Laar mixture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x1
|
ArrayLike
|
Mole fraction of component 1, in |
required |
a12
|
ArrayLike
|
Infinite-dilution value |
required |
a21
|
ArrayLike
|
Infinite-dilution value |
required |
Returns:
| Type | Description |
|---|---|
tuple[Array, Array]
|
A tuple |
wilson_excess_gibbs
¶
Dimensionless excess Gibbs energy g^E / (R T) for a Wilson mixture.
wilson_gamma
¶
Activity coefficients for a multicomponent Wilson mixture.
wilson_lambda
¶
Build the Wilson Lambda matrix from molar volumes and energy parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
ArrayLike
|
Temperature (K). |
required |
volume
|
Array
|
Liquid molar volumes |
required |
energy
|
Array
|
Energy differences |
required |
Returns:
| Type | Description |
|---|---|
Array
|
|
wilson_ln_gamma
¶
Log activity coefficients for a multicomponent Wilson mixture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array
|
Mole fractions, shape |
required |
lam
|
Array
|
Wilson interaction matrix |
required |
Returns:
| Type | Description |
|---|---|
Array
|
|
Group contribution¶
groupcontrib
¶
Group-contribution methods for parameter-free property prediction.
unifacpredicts liquid-phase activity coefficients from functional-group interactions.jobackestimates pure-component constants (critical properties, boiling point, formation properties, ideal-gas Cp) from a count of functional groups.
These let Fugacio cover mixtures and species for which curated, fitted parameters are unavailable, the role the project README assigns to group contribution.
Modules:
| Name | Description |
|---|---|
dortmund |
Modified UNIFAC (Dortmund): predictive activity coefficients with T-dependence. |
joback |
Joback group-contribution estimation of pure-component constants. |
unifac |
UNIFAC group-contribution model for predictive activity coefficients. |
Classes:
| Name | Description |
|---|---|
JobackGroup |
A single Joback functional-group contribution row. |
Functions:
| Name | Description |
|---|---|
modified_unifac_activity |
Predict |
modified_unifac_ln_gamma |
Log activity coefficients from modified UNIFAC (Dortmund), given group tables. |
joback_estimate |
Estimate pure-component constants from Joback groups and return a Component. |
unifac_activity |
Predict |
unifac_ln_gamma |
Log activity coefficients from UNIFAC, given explicit group tables. |
JobackGroup
dataclass
¶
JobackGroup(
tc: float,
pc: float,
vc: float,
tb: float,
tm: float,
hform: float,
gform: float,
cpa: float,
cpb: float,
cpc: float,
cpd: float,
)
A single Joback functional-group contribution row.
modified_unifac_activity
¶
Predict ln(gamma) for named database components with modified UNIFAC.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
components
|
list[str]
|
Component names with assignments in |
required |
x
|
Array
|
Mole fractions aligned with |
required |
t
|
ArrayLike
|
Temperature (K). |
required |
Returns:
| Type | Description |
|---|---|
Array
|
|
modified_unifac_ln_gamma
¶
modified_unifac_ln_gamma(
x: Array,
nu: Array,
r: Array,
q: Array,
main_index: Array,
a_main: Array,
b_main: Array,
c_main: Array,
t: ArrayLike,
) -> Array
Log activity coefficients from modified UNIFAC (Dortmund), given group tables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array
|
Mole fractions, shape |
required |
nu
|
Array
|
Subgroup counts, shape |
required |
r
|
Array
|
Subgroup |
required |
q
|
Array
|
Subgroup |
required |
main_index
|
Array
|
Each subgroup's main-group index, shape |
required |
a_main
|
Array
|
Constant interaction-coefficient matrix, shape |
required |
b_main
|
Array
|
Linear-in- |
required |
c_main
|
Array
|
Quadratic-in- |
required |
t
|
ArrayLike
|
Temperature (K). |
required |
Returns:
| Type | Description |
|---|---|
Array
|
|
joback_estimate
¶
joback_estimate(
groups: dict[str, int],
n_atoms: int,
*,
name: str = "estimated",
formula: str = "",
mw: float = 0.0,
) -> Component
Estimate pure-component constants from Joback groups and return a Component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
groups
|
dict[str, int]
|
Mapping of group label (see |
required |
n_atoms
|
int
|
Total number of atoms in the molecule (hydrogens included), required by the critical-pressure correlation. |
required |
name
|
str
|
Name to assign to the resulting component. |
'estimated'
|
formula
|
str
|
Optional molecular formula. |
''
|
mw
|
float
|
Optional molar mass (g/mol); Joback does not estimate it. |
0.0
|
Returns:
| Type | Description |
|---|---|
Component
|
A |
Component
|
(K), |
Component
|
(J/mol), and an ideal-gas |
Raises:
| Type | Description |
|---|---|
KeyError
|
if any group label is not in |
unifac_activity
¶
Predict ln(gamma) for named database components using bundled tables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
components
|
list[str]
|
Component names with UNIFAC assignments in |
required |
x
|
Array
|
Mole fractions aligned with |
required |
t
|
ArrayLike
|
Temperature (K). |
required |
Returns:
| Type | Description |
|---|---|
Array
|
|
unifac_ln_gamma
¶
unifac_ln_gamma(
x: Array,
nu: Array,
r: Array,
q: Array,
main_index: Array,
a_main: Array,
t: ArrayLike,
) -> Array
Log activity coefficients from UNIFAC, given explicit group tables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array
|
Mole fractions, shape |
required |
nu
|
Array
|
Subgroup counts, integer-valued array of shape |
required |
r
|
Array
|
Subgroup |
required |
q
|
Array
|
Subgroup |
required |
main_index
|
Array
|
Index of each subgroup's main group into |
required |
a_main
|
Array
|
Main-group interaction matrix |
required |
t
|
ArrayLike
|
Temperature (K). |
required |
Returns:
| Type | Description |
|---|---|
Array
|
|