Activity Models¶
Excess Gibbs energy and activity coefficients¶
An activity-coefficient model represents liquid-phase nonideality through excess Gibbs energy:
For a thermodynamically consistent model, component activity coefficients are partial-molar derivatives of the extensive excess Gibbs energy. In a liquid-phase fugacity formulation,
where the reference fugacity may also include vapor-pressure, fugacity, and Poynting corrections. An activity model by itself therefore does not define a complete flash: the standard state and vapor-phase model must also be named.
The excess-Gibbs framework and local-composition interpretation are developed in Kontogeorgis and Folas, chapters 4-6 (book DOI).
Wilson¶
The Wilson model uses local-composition ratios \(\Lambda_{ij}\):
Its asymmetric interaction parameters combine energetic and molar-volume effects. Wilson's original formulation is given in Wilson (1964).
NRTL¶
For NRTL,
and
\(\tau_{ij}\) is a directed interaction and \(\alpha_{ij}\) controls nonrandomness. Parameter units and temperature dependence are part of the model definition, not interchangeable implementation details. See Renon and Prausnitz (1968).
Original UNIFAC¶
Original UNIFAC decomposes the activity coefficient into combinatorial and residual contributions:
The combinatorial term uses molecular group volumes and surfaces. The residual term uses subgroup counts and directed main-group interaction energies. A component fragmentation is therefore scientific input: the same name with a different structural assignment is a different calculation.
torch-flash provides the original VLE-UNIFAC form and does not treat
Dortmund UNIFAC, PSRK, or other variants as parameter substitutions. The
defining and revision sources are
Fredenslund et al. (1975),
Hansen et al. (1991), and
Wittig et al. (2003).
Huron-Vidal coupling¶
Huron-Vidal mixing uses an excess-Gibbs model to define the attractive mixing term of a cubic equation of state at an infinite-pressure reference. This provides an EoS fugacity model for strongly nonideal mixtures rather than merely adding a standalone \(\gamma_i\) to a cubic calculation. The original mixing rule is due to Huron and Vidal (1979).
The activity_model constructor supports NRTL, Wilson, original UNIFAC, and
Huron-Vidal NRTL parameter documents. The bundled release contains the
public original-UNIFAC table and the documented Huron-Vidal sets; custom NRTL
and Wilson documents use the same versioned schema. Use the parameter-set
identifier to keep the model, units, components, source, and fit identity
explicit.
Runnable original-UNIFAC example¶
"""Evaluate an original-UNIFAC activity model and differentiate it."""
import torch
from torch_flash import activity_model, configure
runtime = configure(device="cpu", dtype=torch.float64)
model = activity_model(
"activity.unifac-original-public-2026",
("ethanol", "n_heptane"),
)
temperature = runtime.tensor(323.15, requires_grad=True) # K
composition = runtime.tensor([0.40, 0.60], requires_grad=True)
log_gamma = model.log_activity_coefficients(temperature, composition)
excess_gibbs_rt = model.excess_gibbs_rt(temperature, composition)
gradient = torch.autograd.grad(excess_gibbs_rt, (temperature, composition))
print("ln(gamma) =", log_gamma)
print("g^E/(RT) =", excess_gibbs_rt)
print("d[g^E/(RT)]/dT =", gradient[0])
print("d[g^E/(RT)]/dx =", gradient[1])
The example differentiates \(g^E/(RT)\) with respect to both temperature and composition. The unconstrained PyTorch composition gradient is not the same object as a derivative restricted to the normalized composition simplex; choose coordinates appropriate to the downstream calculation.
Model-selection cautions¶
- Do not combine interaction parameters from different model variants.
- Check the parameter temperature range and component identities.
- A calibration fit is not independent validation.
- A standalone activity model does not define vapor fugacity or a complete phase-equilibrium standard state.
- For high-pressure work, use a documented EoS mixing rule or fugacity formulation rather than extrapolating a low-pressure shortcut without evidence.