Skip to content

Thermodynamic models

package_for turns component names into a ready property package for any of the methods in METHODS (cubic, NRTL, UNIQUAC, UNIFAC, Dortmund, PC-SAFT, or a reference fluid), with explicit parameter provenance. Every model= argument in fugacio.sim takes its result. The page also covers the lightweight modified-Raoult helpers for quick ideal-ish estimates.

Model builders

models

Model bridge: turn component names + a method choice into a property package.

A flowsheet works in component names. package_for resolves those names to the curated constants (reusing the cached lookup in fugacio.sim.properties), assembles the activity model from the curated binary database (NRTL / UNIQUAC) or predictive group contribution (UNIFAC / modified UNIFAC), or the PC-SAFT and reference-fluid parameters, and returns a ready, differentiable fugacio.thermo.PropertyPackage (equilibrium and energy) with explicit parameter provenance. Its result is what every unit operation, the rigorous column, the phase diagrams, and the equation-oriented engine accept through their model argument, so a flowsheet switches from Peng-Robinson to NRTL by changing one method name, and stays end-to-end differentiable, including with respect to the thermodynamic parameters.

Classes:

Name Description
UnifacModel

An ActivityModel adapter over predictive UNIFAC.

Functions:

Name Description
resolve_package

Pick the property package a unit should use for components.

helmholtz_package_for

One-component reference-fluid package for a named pure fluid (water, CO2, ...).

package_for

Build the property package for named components by method.

UnifacModel dataclass

UnifacModel(components: tuple[str, ...], dortmund: bool)

An ActivityModel adapter over predictive UNIFAC.

Wraps fugacio.thermo.unifac_activity (classic, Hansen VLE parameters) or fugacio.thermo.modified_unifac_activity (Dortmund, T-dependent) so that group-contribution predictions present the same ln_gamma(x, T) API as the fitted activity models. Carries no fitted leaves: it is a pure predictor keyed by the (static) component names.

Methods:

Name Description
ln_gamma

Log activity coefficients predicted by (modified) UNIFAC.

ln_gamma

ln_gamma(x: Array, t: ArrayLike) -> Array

Log activity coefficients predicted by (modified) UNIFAC.

resolve_package

resolve_package(
    components: Sequence[str], model: Model = None
) -> PropertyPackage

Pick the property package a unit should use for components.

model wins when given; otherwise the Peng-Robinson default.

Raises:

Type Description
TypeError

if model isn't a property package.

ValueError

if the package's components don't match the stream's.

helmholtz_package_for

helmholtz_package_for(component: str) -> HelmholtzPackage

One-component reference-fluid package for a named pure fluid (water, CO2, ...).

The name is resolved through fugacio.thermo.reference_fluid, so any of the 26 vendored multiparameter formulations is accepted.

package_for

package_for(
    components: Sequence[str],
    method: str = "pr",
    *,
    parameter_policy: str = "strict",
    measured_fit: Any = None,
    **options: Any,
) -> PropertyPackage

Build the property package for named components by method.

This is the constructor a flowsheet author reaches for; every unit operation, the rigorous column, the two-sided heat exchanger, the phase diagrams, and the equation-oriented engine take its result through their model argument.

Parameters:

Name Type Description Default
components Sequence[str]

Component names (from the curated database).

required
method str

One of METHODS:

  • "pr" / "srk" / "rk" / "vdw": phi-phi cubic package (options: kij, use_database_kij);
  • "nrtl" / "uniquac": gamma-phi package with the curated binary parameters (options: vapor, poynting, phi_saturation, eos, kij, and alpha_default for NRTL);
  • "unifac" / "dortmund": gamma-phi package with predictive (modified) UNIFAC (same options, no fitted parameters);
  • "pcsaft": PC-SAFT package (options: kij, use_database_kij);
  • "iapws": a single reference fluid (one component only).
'pr'
parameter_policy str

"strict" (default) raises for missing NRTL/UNIQUAC interactions; "allow_ideal" explicitly permits zero interactions. Cubic zero-kij assumptions remain visible in the package evidence.

'strict'
measured_fit Any

A converged fugacio.thermo.measured_regression.MeasuredFit for binary NRTL. Its observed bounds travel with the package, and checked calculations reject extrapolation unless their acceptance policy explicitly permits it.

None
**options Any

Method options as listed above.

{}

Returns:

Type Description
PropertyPackage

A fugacio.thermo.PropertyPackage with explicit provenance.

Raises:

Type Description
ValueError

For an unknown method, an invalid policy, or an unusable fit.

TypeError

For an option the method doesn't accept.

KeyError

For missing curated parameters under the strict policy.

Modified-Raoult helpers

vle

Vapor-liquid equilibrium for binary mixtures (modified Raoult's law).

A deliberately small but real vertical slice that sits on top of fugacio.thermo: it combines Antoine vapor pressures with Margules activity coefficients to compute a bubble-point pressure. Everything is differentiable end-to-end with respect to composition, temperature, and the activity-model parameters.

Functions:

Name Description
antoine_psat

Saturation pressure from the base-10 Antoine equation.

bubble_pressure

Bubble-point pressure and vapor composition for a binary at fixed T, x.

antoine_psat

antoine_psat(
    temperature: ArrayLike,
    a: ArrayLike,
    b: ArrayLike,
    c: ArrayLike,
) -> Array

Saturation pressure from the base-10 Antoine equation.

log10(Psat) = a - b / (temperature + c)

Pressure and temperature units follow whatever convention the Antoine constants were fit in; Fugacio does not impose one here.

bubble_pressure

bubble_pressure(
    x1: ArrayLike,
    temperature: ArrayLike,
    antoine1: Antoine,
    antoine2: Antoine,
    a12: ArrayLike = 0.0,
    a21: ArrayLike = 0.0,
) -> tuple[Array, Array]

Bubble-point pressure and vapor composition for a binary at fixed T, x.

Uses modified Raoult's law p_i = x_i * gamma_i * Psat_i with two-parameter Margules activity coefficients. Setting a12 = a21 = 0 recovers ideal (Raoult's law) behaviour.

Returns:

Type Description
tuple[Array, Array]

(pressure, y1), where y1 is the vapor mole fraction of component 1.