Skip to content

Streams & properties

The differentiable Stream pytree passed between units, and the property bridge that gives any stream a two-phase-aware enthalpy, entropy, density, and transport properties via fugacio.thermo.

Stream

stream

Material streams: the data passed between flowsheet unit operations.

A Stream carries per-component molar flows together with temperature and pressure. It is registered as a JAX pytree (the flows, T and P are differentiable leaves while the component names are static metadata) so an entire flowsheet built from streams remains end-to-end differentiable. You can take a gradient of any downstream quantity with respect to a feed flow, temperature, or pressure.

Classes:

Name Description
Stream

A process stream of fixed composition basis.

Stream dataclass

Stream(
    n: Array,
    t: Array,
    p: Array,
    components: tuple[str, ...],
)

A process stream of fixed composition basis.

Attributes:

Name Type Description
n Array

Per-component molar flow rates (mol/s), 1-D array aligned with components.

t Array

Temperature (K).

p Array

Pressure (Pa).

components tuple[str, ...]

Canonical component names (static metadata).

Methods:

Name Description
from_fractions

Build a stream from mole fractions z and a total molar flow.

total property

total: Array

Total molar flow rate (mol/s).

z property

z: Array

Mole fractions (the flow normalised to sum to one).

from_fractions classmethod

from_fractions(
    components: tuple[str, ...],
    z: Array,
    flow: ArrayLike,
    t: ArrayLike,
    p: ArrayLike,
) -> Stream

Build a stream from mole fractions z and a total molar flow.

Stream properties

properties

Stream property bridge: enthalpy, entropy, flows, and transport for a Stream.

Unit operations close material and energy balances, so they need a stream's enthalpy and entropy, not just its composition. This module resolves a stream's (static) component names to the array constants the fugacio.thermo kernels expect (caching that lookup, since names never change during a solve) and exposes the resulting molar and total-flow properties.

Enthalpy and entropy are two-phase aware: they run the equilibrium flash at the stream's (T, P) and blend the phase properties, so a subcooled liquid, a superheated vapour, and a flashing two-phase stream are all handled by the same call. Everything stays differentiable with respect to the stream's flows, temperature, and pressure (the component constants are not differentiated, which is exactly right: they are reference data, not decision variables).

Sizing-grade physical properties are surfaced too: phase densities and volumetric flows (liquid_density, vapor_volumetric_flow), viscosities, thermal conductivities, and surface tension, all evaluated at the stream's state through the curated correlations and mixture rules in fugacio.thermo. A stream-aware Souders-Brown helper (column_diameter_for) wires them straight into the equipment-sizing correlations of fugacio.sim.economics.

Functions:

Name Description
molar_enthalpy

Molar enthalpy of the stream (J/mol), relative to the ideal-gas reference.

molar_entropy

Molar entropy of the stream (J/mol/K), relative to the ideal-gas reference.

enthalpy_flow

Total enthalpy flow of the stream (W = J/s).

entropy_flow

Total entropy flow of the stream (W/K).

molar_mass

Mole-fraction-averaged molar mass of the stream (g/mol).

mass_flow

Total mass flow of the stream (kg/s).

liquid_density

Saturated-liquid mass density at the stream's T and composition (kg/m^3).

vapor_density

Vapour mass density from the EOS at the stream's (T, P) (kg/m^3).

liquid_volumetric_flow

Volumetric flow if the stream is all liquid (m^3/s).

vapor_volumetric_flow

Volumetric flow if the stream is all vapour (m^3/s).

liquid_viscosity

Liquid-mixture viscosity at the stream's T (Pa*s), Grunberg-Nissan.

vapor_viscosity

Dilute-gas mixture viscosity at the stream's T (Pa*s), Wilke.

liquid_thermal_conductivity

Liquid-mixture thermal conductivity at the stream's T (W/m/K), DIPPR9H.

vapor_thermal_conductivity

Gas-mixture thermal conductivity at the stream's T (W/m/K), Wassiljewa.

surface_tension

Liquid-mixture surface tension at the stream's T (N/m).

column_diameter_for

Souders-Brown column/drum diameter sized from the actual stream states (m).

molar_enthalpy

molar_enthalpy(
    stream: Stream,
    *,
    eos: CubicEOS = PR,
    kij: Array | None = None,
) -> Array

Molar enthalpy of the stream (J/mol), relative to the ideal-gas reference.

molar_entropy

molar_entropy(
    stream: Stream,
    *,
    eos: CubicEOS = PR,
    kij: Array | None = None,
) -> Array

Molar entropy of the stream (J/mol/K), relative to the ideal-gas reference.

enthalpy_flow

enthalpy_flow(
    stream: Stream,
    *,
    eos: CubicEOS = PR,
    kij: Array | None = None,
) -> Array

Total enthalpy flow of the stream (W = J/s).

entropy_flow

entropy_flow(
    stream: Stream,
    *,
    eos: CubicEOS = PR,
    kij: Array | None = None,
) -> Array

Total entropy flow of the stream (W/K).

molar_mass

molar_mass(stream: Stream) -> Array

Mole-fraction-averaged molar mass of the stream (g/mol).

mass_flow

mass_flow(stream: Stream) -> Array

Total mass flow of the stream (kg/s).

liquid_density

liquid_density(stream: Stream) -> Array

Saturated-liquid mass density at the stream's T and composition (kg/m^3).

vapor_density

vapor_density(
    stream: Stream, *, eos: CubicEOS = PR
) -> Array

Vapour mass density from the EOS at the stream's (T, P) (kg/m^3).

liquid_volumetric_flow

liquid_volumetric_flow(stream: Stream) -> Array

Volumetric flow if the stream is all liquid (m^3/s).

vapor_volumetric_flow

vapor_volumetric_flow(
    stream: Stream, *, eos: CubicEOS = PR
) -> Array

Volumetric flow if the stream is all vapour (m^3/s).

liquid_viscosity

liquid_viscosity(stream: Stream) -> Array

Liquid-mixture viscosity at the stream's T (Pa*s), Grunberg-Nissan.

vapor_viscosity

vapor_viscosity(stream: Stream) -> Array

Dilute-gas mixture viscosity at the stream's T (Pa*s), Wilke.

liquid_thermal_conductivity

liquid_thermal_conductivity(stream: Stream) -> Array

Liquid-mixture thermal conductivity at the stream's T (W/m/K), DIPPR9H.

vapor_thermal_conductivity

vapor_thermal_conductivity(stream: Stream) -> Array

Gas-mixture thermal conductivity at the stream's T (W/m/K), Wassiljewa.

surface_tension

surface_tension(stream: Stream) -> Array

Liquid-mixture surface tension at the stream's T (N/m).

column_diameter_for

column_diameter_for(
    vapor: Stream,
    liquid: Stream | None = None,
    *,
    k_drum: ArrayLike = 0.07,
    flooding: ArrayLike = 0.8,
) -> Array

Souders-Brown column/drum diameter sized from the actual stream states (m).

The vapour density, molar mass, and flow come from vapor; the liquid density from liquid (defaulting to the vapour stream's composition at its own temperature, the saturated-liquid view of the same material, a sensible drum approximation).