kups.mcmc.fugacity
¶
Fugacity calculations for real gas mixtures.
This module provides fugacity coefficient calculations for non-ideal gases and mixtures. Fugacity is a measure of chemical potential that accounts for deviations from ideal gas behavior, essential for accurate phase equilibria and grand canonical Monte Carlo simulations.
Currently implements the Peng-Robinson cubic equation of state, which provides good accuracy for hydrocarbons and many other fluids. The framework supports extension to other equations of state (e.g., Soave-Redlich-Kwong, virial equations).
LogFugacityResult
¶
Bases: NamedTuple
Result of fugacity calculation.
Attributes:
| Name | Type | Description |
|---|---|---|
log_fugacity |
Array
|
Natural logarithm of fugacity for each component [ln(Pa)] |
compressibility |
Array
|
Compressibility factor Z = PV/(nRT) [-] |
Source code in src/kups/mcmc/fugacity.py
peng_robinson_log_fugacity(pressure, temperature, critical_pressure, critical_temperature, acentric_factor, composition=jnp.ones((1,)), interaction=jnp.zeros((1, 1)))
¶
Compute log fugacity coefficients using Peng-Robinson equation of state.
Public API for Peng-Robinson fugacity calculations with automatic vectorization over batched inputs. This function wraps the internal implementation with convenient defaults for single-component systems.
The Peng-Robinson equation of state is:
where \(a\) and \(b\) are component-specific parameters, and \(\alpha(T)\) is a temperature- dependent correction factor based on the acentric factor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pressure
|
Array
|
System pressure [Pa] |
required |
temperature
|
Array
|
System temperature [K] |
required |
critical_pressure
|
Array
|
Critical pressure for each component [Pa], shape |
required |
critical_temperature
|
Array
|
Critical temperature for each component [K], shape |
required |
acentric_factor
|
Array
|
Acentric factor for each component [-], shape |
required |
composition
|
Array
|
Mole fraction of each component [-], shape |
ones((1,))
|
interaction
|
Array
|
Binary interaction parameters [-], shape |
zeros((1, 1))
|
Returns:
| Type | Description |
|---|---|
LogFugacityResult
|
LogFugacityResult containing log fugacity and compressibility factor |
Example
import jax.numpy as jnp
from kups.mcmc.fugacity import peng_robinson_log_fugacity
# CO2 properties
P = 1e6 # 10 bar in Pa
T = 300.0 # K
Pc = jnp.array([7.38e6]) # Critical pressure
Tc = jnp.array([304.2]) # Critical temperature
omega = jnp.array([0.228]) # Acentric factor
result = peng_robinson_log_fugacity(P, T, Pc, Tc, omega)
fugacity = jnp.exp(result.log_fugacity) # Convert from log
Z = result.compressibility