Equations of state¶
The constructors on this page create native PyTorch models. Construct them
after calling configure so parameter tensors inherit the intended dtype and
device.
torch_flash.eos
¶
Equation-of-state implementations.
DEFAULT_LEACHMAN_NORMAL_HYDROGEN
module-attribute
¶
Bundled parameter identifier for the Leachman normal-hydrogen EOS.
EOSCG2021_COMPONENTS
module-attribute
¶
EOSCG2021_COMPONENTS = (
"carbon_dioxide",
"water",
"nitrogen",
"oxygen",
"argon",
"carbon_monoxide",
"hydrogen",
"methane",
"hydrogen_sulfide",
"sulfur_dioxide",
"mea",
"dea",
"hydrogen_chloride",
"chlorine",
"ammonia",
"mdea",
)
Canonical 16-component inventory supported by bundled EOS-CG-2021.
GERG2008_COMPONENTS
module-attribute
¶
GERG2008_COMPONENTS = (
"methane",
"nitrogen",
"carbon_dioxide",
"ethane",
"propane",
"n_butane",
"isobutane",
"n_pentane",
"isopentane",
"n_hexane",
"n_heptane",
"n_octane",
"hydrogen",
"oxygen",
"carbon_monoxide",
"water",
"helium",
"argon",
"hydrogen_sulfide",
"n_nonane",
"n_decane",
)
Canonical 21-component inventory supported by bundled GERG-2008.
GERG2008_HYDROGEN_2021_COMPONENTS
module-attribute
¶
GERG2008_HYDROGEN_2021_COMPONENTS = (
"methane",
"nitrogen",
"carbon_monoxide",
"carbon_dioxide",
"hydrogen",
)
Canonical inventory of the Beckmüller et al. H2-tailored GERG model.
CPAEOS
¶
CPAEOS(
parameters: tuple[CPAComponent, ...],
*,
kij: Tensor | None = None,
kij_a: Tensor | None = None,
kij_b: Tensor | None = None,
lij: Tensor | None = None,
cross_association_energy: Tensor | None = None,
cross_association_volume: Tensor | None = None,
combining_rule: CombiningRule = "ECR",
trainable: bool = False,
trainable_lij: bool = False,
association_iterations: int = 10,
association_newton_iterations: int = 8,
dtype: dtype | None = None,
device: device | str | None = None,
)
Bases: Module
SRK cubic-plus-association mixture model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
tuple[CPAComponent, ...]
|
Ordered pure-component CPA records. Component order defines every composition and interaction tensor axis. |
required |
kij
|
Tensor | None
|
Constant attraction interactions or the temperature-dependent form
|
None
|
kij_a
|
Tensor | None
|
Constant attraction interactions or the temperature-dependent form
|
None
|
kij_b
|
Tensor | None
|
Constant attraction interactions or the temperature-dependent form
|
None
|
lij
|
Tensor | None
|
Optional dimensionless SRK cross-covolume interactions. |
None
|
cross_association_energy
|
Tensor | None
|
Optional symmetric pair overrides in J/mol and dimensionless association volume. Both matrices must be supplied together. |
None
|
cross_association_volume
|
Tensor | None
|
Optional symmetric pair overrides in J/mol and dimensionless association volume. Both matrices must be supplied together. |
None
|
combining_rule
|
CombiningRule
|
Published |
'ECR'
|
trainable
|
bool
|
Register attraction/association or covolume interaction tensors as trainable PyTorch parameters. |
False
|
trainable_lij
|
bool
|
Register attraction/association or covolume interaction tensors as trainable PyTorch parameters. |
False
|
association_iterations
|
int
|
Fixed-point and Newton passes used for association site fractions. |
10
|
association_newton_iterations
|
int
|
Fixed-point and Newton passes used for association site fractions. |
10
|
dtype
|
dtype | None
|
Tensor placement, defaulting to runtime configuration. |
None
|
device
|
dtype | None
|
Tensor placement, defaulting to runtime configuration. |
None
|
Notes
The current volume-root and fugacity path accepts one scalar TP state.
Site-fraction calculations support leading batches. Association
non-convergence raises :class:~torch_flash.exceptions.ConvergenceError;
it is not returned as a valid thermodynamic state.
Source code in src/torch_flash/eos/cpa.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | |
ncomponents
property
¶
Return the number of modeled components.
Returns:
| Type | Description |
|---|---|
int
|
Length of the canonical component-name tuple. |
pure_parameters
¶
Evaluate CPA's fitted pure SRK parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
Attraction |
Source code in src/torch_flash/eos/cpa.py
mixture_parameters
¶
Mix physical-term attraction and covolume parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
composition
|
Tensor
|
Component mole fractions on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
Mixture |
Source code in src/torch_flash/eos/cpa.py
binary_interaction
¶
Evaluate the symmetric physical-term attraction interactions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless |
Source code in src/torch_flash/eos/cpa.py
association_strength
¶
Evaluate component-site association strengths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
molar_density
|
Tensor
|
Homogeneous molar density in mol/m3. |
required |
composition
|
Tensor
|
Mole fractions on the final component axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Association strengths in m3/mol with trailing axes
|
Source code in src/torch_flash/eos/cpa.py
site_fractions
¶
Solve the CPA mass-action equations for unbonded site fractions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
molar_density
|
Tensor
|
Homogeneous molar density in mol/m3. |
required |
composition
|
Tensor
|
Mole fractions with a final component axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless unbonded fractions with trailing axes
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the composition component count is inconsistent. |
ConvergenceError
|
If the configured fixed-point/Newton iterations do not solve the mass-action residual. |
Notes
Leading dimensions are broadcast as independent homogeneous states. The component axis is the final composition dimension.
Source code in src/torch_flash/eos/cpa.py
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | |
residual_helmholtz_rt
¶
Return extensive reduced residual Helmholtz energy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Scalar temperature in K. |
required |
volume
|
Tensor
|
Scalar total volume in m3. |
required |
moles
|
Tensor
|
Component amounts in mol. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless extensive |
Source code in src/torch_flash/eos/cpa.py
pressure
¶
Evaluate CPA pressure at a homogeneous T-v-x state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
molar_volume
|
Tensor
|
Molar volume in m3/mol. |
required |
composition
|
Tensor
|
Mole fractions on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Pressure in Pa. |
Source code in src/torch_flash/eos/cpa.py
molar_volume
¶
molar_volume(
temperature: Tensor,
pressure: Tensor,
composition: Tensor,
phase: PhaseKind = "stable",
) -> Tensor
Solve a scalar CPA molar-volume root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Scalar temperature in K and pressure in Pa. |
required |
pressure
|
Tensor
|
Scalar temperature in K and pressure in Pa. |
required |
composition
|
Tensor
|
One component mole-fraction vector. |
required |
phase
|
PhaseKind
|
Smallest root ( |
'stable'
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Molar volume in m3/mol. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the state is batched or |
ConvergenceError
|
If the pressure-root scan finds no admissible root. |
Source code in src/torch_flash/eos/cpa.py
select_z
¶
select_z(
temperature: Tensor,
pressure: Tensor,
composition: Tensor,
phase: PhaseKind = "stable",
) -> Tensor
Return the CPA compressibility factor for a selected root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Scalar temperature in K and pressure in Pa. |
required |
pressure
|
Tensor
|
Scalar temperature in K and pressure in Pa. |
required |
composition
|
Tensor
|
One mole-fraction vector. |
required |
phase
|
PhaseKind
|
Root-selection request. |
'stable'
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless |
Source code in src/torch_flash/eos/cpa.py
log_fugacity_coefficients
¶
log_fugacity_coefficients(
temperature: Tensor,
pressure: Tensor,
composition: Tensor,
phase: PhaseKind = "stable",
) -> Tensor
Return CPA component log fugacity coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Scalar temperature in K and pressure in Pa. |
required |
pressure
|
Tensor
|
Scalar temperature in K and pressure in Pa. |
required |
composition
|
Tensor
|
One mole-fraction vector. |
required |
phase
|
PhaseKind
|
Root-selection request. |
'stable'
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless |
Notes
Component residual chemical potentials are obtained by differentiating the extensive CPA residual Helmholtz energy at fixed volume.
Source code in src/torch_flash/eos/cpa.py
CPAComponent
dataclass
¶
CPAComponent(
name: str,
critical_temperature: float,
a0: float,
b: float,
c1: float,
association_energy: float = 0.0,
association_volume: float = 0.0,
scheme: AssociationScheme = "none",
critical_pressure: float | None = None,
acentric_factor: float | None = None,
molar_mass: float | None = None,
)
Pure-component CPA parameters and optional petroleum pseudo-properties.
critical_pressure, acentric_factor, and molar_mass normally
come from the shared component database. Petroleum pseudo-components can
instead carry those three initialization properties directly.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Canonical or pseudo-component identifier. |
critical_temperature |
float
|
Critical temperature in K. |
a0 |
float
|
CPA/SRK attraction parameter in Pa m6/mol2. |
b |
float
|
CPA/SRK covolume in m3/mol. |
c1 |
float
|
Dimensionless CPA alpha-function coefficient. |
association_energy |
float
|
Pure association energy in J/mol. |
association_volume |
float
|
Dimensionless pure association volume. |
scheme |
AssociationScheme
|
Association-site scheme. |
critical_pressure |
float | None
|
Optional critical pressure in Pa for initialization. |
acentric_factor |
float | None
|
Optional dimensionless acentric factor for initialization. |
molar_mass |
float | None
|
Optional molar mass in kg/mol. |
CPACharacterizedComponents
dataclass
¶
CPACharacterizedComponents(
components: tuple[CPAComponent, ...],
mole_fractions: Tensor,
monomer_properties: tuple[CPAMonomerProperties, ...],
)
CPA pseudo-components created from analyzed heavy-end cuts.
Attributes:
| Name | Type | Description |
|---|---|---|
components |
tuple[CPAComponent, ...]
|
Non-associating CPA component records in input-cut order. |
mole_fractions |
Tensor
|
Normalized internal cut fractions on the requested dtype and device. |
monomer_properties |
tuple[CPAMonomerProperties, ...]
|
Full characterization diagnostics corresponding to |
CPAHeavyEndCorrelations
dataclass
¶
CPAHeavyEndCorrelations(
normal_boiling_pressure: float,
srk_omega_a: float,
srk_omega_b: float,
srk_m: tuple[float, float, float],
normal_alkane_temperature: tuple[float, float, float],
log_normal_alkane_pressure_bar: tuple[
float, float, float, float, float
],
normal_alkane_acentric: tuple[float, float, float],
normal_alkane_specific_gravity: tuple[
float, float, float, float, float
],
critical_temperature_numerator: tuple[
float, float, float
],
critical_temperature_denominator: tuple[
float, float, float
],
log_critical_pressure_ratio: tuple[
float, float, float, float, float
],
)
Published coefficients used by the CPA C7+ monomer correlations.
Attributes:
| Name | Type | Description |
|---|---|---|
normal_boiling_pressure |
float
|
Normal boiling pressure in Pa. |
srk_omega_a, srk_omega_b, srk_m |
SRK critical constraints and acentric-factor polynomial coefficients. |
|
normal_alkane_temperature, log_normal_alkane_pressure_bar |
Coefficients for the reference normal-alkane vapor-pressure mapping. |
|
normal_alkane_acentric, normal_alkane_specific_gravity |
Reference normal-alkane property correlations. |
|
critical_temperature_numerator, critical_temperature_denominator |
Rational critical-temperature-ratio coefficients. |
|
log_critical_pressure_ratio |
tuple[float, float, float, float, float]
|
Critical-pressure-ratio coefficients. |
CPAMonomerProperties
dataclass
¶
CPAMonomerProperties(
normal_boiling_temperature: float,
specific_gravity: float,
normal_alkane_specific_gravity: float,
specific_gravity_perturbation: float,
normal_alkane_temperature: float,
normal_alkane_pressure: float,
critical_temperature: float,
critical_pressure: float,
acentric_factor: float,
used_boiling_point_match: bool,
correlations: CPAHeavyEndCorrelations,
)
Intermediate and final CPA monomer characterization results.
Attributes:
| Name | Type | Description |
|---|---|---|
normal_boiling_temperature |
float
|
Cut normal boiling temperature in K. |
specific_gravity |
float
|
Cut specific gravity relative to water at the source reference state. |
normal_alkane_specific_gravity, specific_gravity_perturbation |
Reference-alkane value and cut departure used by the correlation. |
|
normal_alkane_temperature, normal_alkane_pressure |
Mapped reference-alkane state in K and Pa. |
|
critical_temperature, critical_pressure |
Predicted critical constants in K and Pa. |
|
acentric_factor |
float
|
Predicted dimensionless acentric factor. |
used_boiling_point_match |
bool
|
Whether acentric factor was obtained by matching the normal boiling condition. |
correlations |
CPAHeavyEndCorrelations
|
Exact coefficient set used. |
CubicConstants
dataclass
¶
CubicConstants(
name: str,
omega_a: float,
omega_b: float,
delta1: float,
delta2: float,
alpha_kind: AlphaKind,
alpha_low: tuple[float, float, float],
alpha_high: tuple[float, float, float, float]
| None = None,
alpha_switch: float | None = None,
parameter_set: str | None = None,
)
Immutable constants defining a generalized two-parameter cubic EOS.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Human-readable model name. |
omega_a, omega_b |
Dimensionless critical constraints for the attraction and covolume parameters. |
|
delta1, delta2 |
Dimensionless denominator-shape constants in the generalized cubic pressure equation. |
|
alpha_kind |
AlphaKind
|
Identifier selecting the SRK, PR76, or PR78 alpha correlation. |
alpha_low, alpha_high |
Polynomial coefficients mapping acentric factor to the alpha-function
exponent. |
|
alpha_switch |
float | None
|
PR78 acentric-factor switch, or |
parameter_set |
str | None
|
Versioned parameter-set identifier when loaded from the database. |
CubicEOS
¶
CubicEOS(
components: ComponentSet,
constants: CubicConstants,
*,
mixing: CubicMixing | None = None,
volume_translation: Tensor
| VolumeTranslation
| None = None,
)
Bases: Module
Generalized cubic equation of state with differentiable parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
components
|
ComponentSet
|
Ordered component set supplying critical temperatures in K, critical pressures in Pa, acentric factors, and molar masses in kg/mol. |
required |
constants
|
CubicConstants
|
Cubic family constants and alpha-function definition. |
required |
mixing
|
CubicMixing | None
|
Mixing-rule module. The default is quadratic mixing with zero binary interactions. |
None
|
volume_translation
|
Tensor | VolumeTranslation | None
|
Additive component molar-volume shifts in m3/mol, or a
temperature-dependent :class: |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
names |
Canonical component names in tensor component-axis order. |
|
critical_temperature, critical_pressure, acentric_factor, molar_mass, |
|
|
critical_volume |
Tensor | None
|
Per-component model buffers. |
mixing |
CubicMixing
|
Active mixing-rule module; its trainable tensors remain registered PyTorch parameters. |
volume_translation |
Tensor
|
Reference additive shifts in m3/mol. |
Notes
Public calculations preserve leading batch dimensions, device, dtype, and
gradients. A requested "stable" root is the admissible root with the
lowest residual Gibbs energy; root selection does not perform a flash.
Source code in src/torch_flash/eos/cubic.py
ncomponents
property
¶
Return the number of components on the final tensor axis.
Returns:
| Type | Description |
|---|---|
int
|
Length of :attr: |
component_volume_translation
¶
Evaluate additive component volume shifts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K with arbitrary leading batch dimensions. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Shifts in m3/mol with shape |
Source code in src/torch_flash/eos/cubic.py
pure_parameters
¶
Evaluate pure-component attraction and covolume parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Positive temperature in K. |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
Attraction parameters |
Raises:
| Type | Description |
|---|---|
InvalidStateError
|
If any temperature is nonpositive. |
Source code in src/torch_flash/eos/cubic.py
mixture_parameters
¶
Mix pure parameters at a homogeneous composition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
composition
|
Tensor
|
Mole fractions with components on the final axis; normalized internally. |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
Mixture attraction |
Source code in src/torch_flash/eos/cubic.py
dimensionless_parameters
¶
dimensionless_parameters(
temperature: Tensor,
pressure: Tensor,
composition: Tensor,
) -> tuple[Tensor, Tensor]
Return conventional dimensionless cubic parameters A and B.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Positive temperature in K. |
required |
pressure
|
Tensor
|
Positive pressure in Pa. |
required |
composition
|
Tensor
|
Mole fractions with components on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
|
Raises:
| Type | Description |
|---|---|
InvalidStateError
|
If pressure is nonpositive, or temperature is rejected by the pure-parameter calculation. |
Source code in src/torch_flash/eos/cubic.py
z_factors
¶
Return all sorted real compressibility-factor root slots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Homogeneous-state temperature in K and pressure in Pa. |
required |
pressure
|
Tensor
|
Homogeneous-state temperature in K and pressure in Pa. |
required |
composition
|
Tensor
|
Mole fractions with components on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Three sorted root slots on the final axis. For a polynomial with one real root, that root is repeated in all three slots. |
Source code in src/torch_flash/eos/cubic.py
select_z
¶
select_z(
temperature: Tensor,
pressure: Tensor,
composition: Tensor,
phase: PhaseKind = "stable",
) -> Tensor
Select an admissible liquid, vapor, or minimum-Gibbs root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Homogeneous-state temperature in K and pressure in Pa. |
required |
pressure
|
Tensor
|
Homogeneous-state temperature in K and pressure in Pa. |
required |
composition
|
Tensor
|
Mole fractions with components on the final axis. |
required |
phase
|
PhaseKind
|
|
'stable'
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Selected dimensionless compressibility factor for each state. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
InvalidStateError
|
If no root exceeds the mixture covolume. |
Source code in src/torch_flash/eos/cubic.py
molar_volume
¶
molar_volume(
temperature: Tensor,
pressure: Tensor,
composition: Tensor,
phase: PhaseKind = "stable",
) -> Tensor
Return translated homogeneous-phase molar volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K and pressure in Pa. |
required |
pressure
|
Tensor
|
Temperature in K and pressure in Pa. |
required |
composition
|
Tensor
|
Mole fractions with components on the final axis. |
required |
phase
|
PhaseKind
|
Cubic root-selection request. |
'stable'
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Physical molar volume in m3/mol. |
Source code in src/torch_flash/eos/cubic.py
pressure
¶
Evaluate pressure at a supplied homogeneous T-v-x state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
molar_volume
|
Tensor
|
Physical, volume-translated molar volume in m3/mol. |
required |
composition
|
Tensor
|
Mole fractions with components on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Pressure in Pa. |
Raises:
| Type | Description |
|---|---|
InvalidStateError
|
If the parent-EOS volume does not exceed the mixture covolume. |
Source code in src/torch_flash/eos/cubic.py
residual_helmholtz_rt
¶
Evaluate the extensive reduced residual Helmholtz energy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
volume
|
Tensor
|
Physical extensive volume in m3. |
required |
moles
|
Tensor
|
Component amounts in mol on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless extensive residual Helmholtz energy |
Notes
The ideal-gas reference-volume correction retains thermodynamic consistency when additive volume translation is active.
Source code in src/torch_flash/eos/cubic.py
log_fugacity_coefficients
¶
log_fugacity_coefficients(
temperature: Tensor,
pressure: Tensor,
composition: Tensor,
phase: PhaseKind = "stable",
) -> Tensor
Return component log fugacity coefficients.
The quadratic rule uses the standard closed form. Non-quadratic mixing rules use an autodifferentiated residual Helmholtz energy, preserving the exact composition dependence of the selected rule.
Source code in src/torch_flash/eos/cubic.py
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 | |
PureFluidHelmholtzEOS
¶
PureFluidHelmholtzEOS(
kernel: MultiparameterEOS,
metadata: PureFluidHelmholtzMetadata,
)
Bases: Module
One-component thermodynamic Helmholtz equation.
The internal kernel shares the differentiable Helmholtz term evaluators used by multiparameter mixture models, while this public wrapper exposes pure-fluid signatures without a redundant composition argument.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kernel
|
MultiparameterEOS
|
One-component native Helmholtz evaluation kernel. |
required |
metadata
|
PureFluidHelmholtzMetadata
|
Published model identity and canonical pure-fluid name. |
required |
Source code in src/torch_flash/eos/helmholtz.py
alpha_ideal
¶
Return dimensionless ideal molar Helmholtz energy.
alpha_residual
¶
Return dimensionless residual molar Helmholtz energy.
alpha_total
¶
Return total dimensionless molar Helmholtz energy.
pressure
¶
Return pressure in Pa at the supplied homogeneous state.
molar_volume
¶
Return the selected molar-volume root in m3/mol.
Source code in src/torch_flash/eos/helmholtz.py
compressibility_factor
¶
Return the homogeneous-state compressibility factor.
Source code in src/torch_flash/eos/helmholtz.py
molar_helmholtz_energy
¶
Return molar Helmholtz energy in J/mol.
Source code in src/torch_flash/eos/helmholtz.py
molar_entropy
¶
molar_internal_energy
¶
Return molar internal energy in J/mol.
Source code in src/torch_flash/eos/helmholtz.py
molar_enthalpy
¶
molar_gibbs_energy
¶
Return molar Gibbs energy in J/mol.
Source code in src/torch_flash/eos/helmholtz.py
molar_heat_capacity_cv
¶
Return isochoric molar heat capacity in J/(mol K).
Source code in src/torch_flash/eos/helmholtz.py
molar_heat_capacity_cp
¶
Return isobaric molar heat capacity in J/(mol K).
Source code in src/torch_flash/eos/helmholtz.py
speed_of_sound
¶
Return homogeneous-phase speed of sound in m/s.
PureFluidHelmholtzMetadata
dataclass
¶
Identity and scope of one pure-fluid fundamental equation.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
str
|
Published equation or parameter-set identity. |
reference |
str
|
Defining bibliographic reference. |
version |
str
|
Version of the serialized coefficient set. |
fluid |
str
|
Canonical pure-fluid name. |
GaoBTerms
dataclass
¶
GaoBTerms(
n: Tensor,
d: Tensor,
t: Tensor,
eta: Tensor,
epsilon: Tensor,
beta: Tensor,
gamma: Tensor,
b: Tensor,
)
Gao-B critical-region residual Helmholtz coefficient arrays.
Attributes:
| Name | Type | Description |
|---|---|---|
n, d, t |
Term amplitude and reduced-density/reduced-temperature exponents. |
|
eta, epsilon, beta, gamma, b |
Critical-region shape parameters. Every tensor must have the same
shape as |
HelmholtzTerms
dataclass
¶
HelmholtzTerms(
n: Tensor,
d: Tensor,
t: Tensor,
decay: Tensor,
eta: Tensor | None = None,
epsilon: Tensor | None = None,
beta: Tensor | None = None,
gamma: Tensor | None = None,
linear_density: Tensor | None = None,
linear_shift: Tensor | None = None,
)
Power, exponential, Gaussian, and GERG-special terms.
The full form is n*delta^d*tau^t*exp(-delta^l
-eta*(delta-epsilon)^2-beta*(tau-gamma)^2
-linear_density*(delta-linear_shift)). Setting the optional arrays to
zero recovers the power-exponential subset. The final linear-density
factor is the binary departure form used by GERG-2008.
Attributes:
| Name | Type | Description |
|---|---|---|
n, d, t, decay |
Term amplitudes, reduced-density exponents, inverse-reduced-temperature exponents, and exponential density powers. |
|
eta, epsilon |
Optional Gaussian density width and center arrays. |
|
beta, gamma |
Optional Gaussian temperature width and center arrays. |
|
linear_density, linear_shift |
Optional GERG linear-density exponential parameters. |
Notes
Every present tensor has the same term-table shape. Pure tables typically use component rows; departure tables use component-pair rows.
IdealHelmholtzTerms
dataclass
¶
IdealHelmholtzTerms(
lead_constant: Tensor,
lead_tau: Tensor,
log_tau: Tensor,
tau_log_tau: Tensor,
power_n: Tensor,
power_t: Tensor,
planck_n: Tensor,
planck_theta: Tensor,
gerg_n: Tensor,
gerg_theta: Tensor,
gerg_sign: Tensor,
gas_scale: Tensor,
)
Canonical pure-fluid ideal Helmholtz term tables.
Every component has lead, logarithmic, power, Planck--Einstein, and
optional GERG sinh/cosh terms. gas_scale is the ratio between the gas
constant of the original pure-fluid equation and the common mixture gas
constant. It multiplies the density-independent part only, preserving the
exact ideal-gas pressure limit.
Attributes:
| Name | Type | Description |
|---|---|---|
lead_constant, lead_tau, log_tau, tau_log_tau |
One leading coefficient of each analytic form per component. |
|
power_n, power_t |
Amplitudes and exponents for pure power terms. |
|
planck_n, planck_theta |
Planck--Einstein amplitudes and characteristic-temperature ratios. |
|
gerg_n, gerg_theta, gerg_sign |
GERG hyperbolic-term amplitudes, arguments, and sinh/cosh selectors. |
|
gas_scale |
Tensor
|
Per-component ratio of the source pure-fluid gas constant to the common mixture gas constant. |
MultiparameterEOS
¶
MultiparameterEOS(
names: tuple[str, ...],
critical_temperature: Tensor,
critical_density: Tensor,
molar_mass: Tensor,
pure_terms: HelmholtzTerms,
departure_terms: HelmholtzTerms,
beta_temperature: Tensor,
gamma_temperature: Tensor,
beta_volume: Tensor,
gamma_volume: Tensor,
departure_scale: Tensor,
metadata: MultiparameterMetadata,
*,
trainable: bool = False,
gas_constant: float = R,
pure_gaob_terms: GaoBTerms | None = None,
pure_nonanalytic_terms: NonAnalyticTerms | None = None,
ideal_terms: IdealHelmholtzTerms | None = None,
critical_pressure: Tensor | None = None,
acentric_factor: Tensor | None = None,
)
Bases: Module
Autodifferentiable multiparameter Helmholtz equation of state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
tuple[str, ...]
|
Canonical component names defining the final tensor axis. |
required |
critical_temperature
|
Tensor
|
Pure-component reducing constants in K, mol/m3, and kg/mol. |
required |
critical_density
|
Tensor
|
Pure-component reducing constants in K, mol/m3, and kg/mol. |
required |
molar_mass
|
Tensor
|
Pure-component reducing constants in K, mol/m3, and kg/mol. |
required |
pure_terms
|
HelmholtzTerms
|
Pure residual and binary departure Helmholtz coefficient tables. |
required |
departure_terms
|
HelmholtzTerms
|
Pure residual and binary departure Helmholtz coefficient tables. |
required |
beta_temperature
|
Tensor
|
Symmetric binary reducing-function matrices. |
required |
gamma_temperature
|
Tensor
|
Symmetric binary reducing-function matrices. |
required |
beta_volume
|
Tensor
|
Symmetric binary reducing-function matrices. |
required |
gamma_volume
|
Tensor
|
Symmetric binary reducing-function matrices. |
required |
departure_scale
|
Tensor
|
Symmetric binary departure-function multipliers. |
required |
metadata
|
MultiparameterMetadata
|
Exact model identity and supported-component scope. |
required |
trainable
|
bool
|
Register coefficient arrays as trainable PyTorch parameters. |
False
|
gas_constant
|
float
|
Model gas constant in J/(mol K). |
R
|
Notes
Property kernels preserve leading batches and gradients. Density inversion
and root selection are iterative; failure raises
:class:~torch_flash.exceptions.ConvergenceError. Float64 is the
reference precision, especially near critical or coalescing roots.
Source code in src/torch_flash/eos/multiparameter.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
reducing_functions
¶
Evaluate composition-dependent mixture reducing functions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
composition
|
Tensor
|
Mole fractions with components on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
Reducing temperature in K and reducing molar density in mol/m3, with the broadcast leading shape. |
Source code in src/torch_flash/eos/multiparameter.py
alpha_residual
¶
Evaluate dimensionless molar residual Helmholtz energy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
molar_density
|
Tensor
|
Molar density in mol/m3. |
required |
composition
|
Tensor
|
Mole fractions with components on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless |
Source code in src/torch_flash/eos/multiparameter.py
alpha_residual_delta
¶
Return the residual Helmholtz derivative with respect to reduced density.
Source code in src/torch_flash/eos/multiparameter.py
alpha_ideal
¶
Evaluate dimensionless molar ideal-gas Helmholtz energy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
molar_density
|
Tensor
|
Molar density in mol/m3. |
required |
composition
|
Tensor
|
Mole fractions with components on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless ideal contribution |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the model was constructed without ideal Helmholtz terms. |
Source code in src/torch_flash/eos/multiparameter.py
alpha_total
¶
Evaluate total dimensionless molar Helmholtz energy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
molar_density
|
Tensor
|
Molar density in mol/m3. |
required |
composition
|
Tensor
|
Mole fractions on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
|
Source code in src/torch_flash/eos/multiparameter.py
residual_helmholtz_rt
¶
Evaluate extensive reduced residual Helmholtz energy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
volume
|
Tensor
|
Total volume in m3. |
required |
moles
|
Tensor
|
Component amounts in mol on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless extensive |
Source code in src/torch_flash/eos/multiparameter.py
helmholtz_rt
¶
Evaluate extensive total reduced Helmholtz energy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
volume
|
Tensor
|
Total volume in m3. |
required |
moles
|
Tensor
|
Component amounts in mol on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless extensive |
Source code in src/torch_flash/eos/multiparameter.py
molar_helmholtz_energy
¶
molar_helmholtz_energy(
temperature: Tensor,
molar_density: Tensor,
composition: Tensor,
) -> Tensor
Return total molar Helmholtz energy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K, density in mol/m3, and final-axis mole fractions. |
required |
molar_density
|
Tensor
|
Temperature in K, density in mol/m3, and final-axis mole fractions. |
required |
composition
|
Tensor
|
Temperature in K, density in mol/m3, and final-axis mole fractions. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Molar Helmholtz energy in J/mol. |
Source code in src/torch_flash/eos/multiparameter.py
molar_entropy
¶
Return total molar entropy by temperature differentiation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K, fixed density in mol/m3, and mole fractions. |
required |
molar_density
|
Tensor
|
Temperature in K, fixed density in mol/m3, and mole fractions. |
required |
composition
|
Tensor
|
Temperature in K, fixed density in mol/m3, and mole fractions. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Molar entropy in J/(mol K). |
Source code in src/torch_flash/eos/multiparameter.py
molar_internal_energy
¶
Return total molar internal energy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K, density in mol/m3, and mole fractions. |
required |
molar_density
|
Tensor
|
Temperature in K, density in mol/m3, and mole fractions. |
required |
composition
|
Tensor
|
Temperature in K, density in mol/m3, and mole fractions. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Molar internal energy in J/mol. |
Source code in src/torch_flash/eos/multiparameter.py
molar_heat_capacity_cv
¶
molar_heat_capacity_cv(
temperature: Tensor,
molar_density: Tensor,
composition: Tensor,
) -> Tensor
Return isochoric molar heat capacity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K, fixed density in mol/m3, and mole fractions. |
required |
molar_density
|
Tensor
|
Temperature in K, fixed density in mol/m3, and mole fractions. |
required |
composition
|
Tensor
|
Temperature in K, fixed density in mol/m3, and mole fractions. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
|
Source code in src/torch_flash/eos/multiparameter.py
molar_heat_capacity_cp
¶
molar_heat_capacity_cp(
temperature: Tensor,
molar_density: Tensor,
composition: Tensor,
) -> Tensor
Return isobaric molar heat capacity from Helmholtz derivatives.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K, density in mol/m3, and mole fractions. |
required |
molar_density
|
Tensor
|
Temperature in K, density in mol/m3, and mole fractions. |
required |
composition
|
Tensor
|
Temperature in K, density in mol/m3, and mole fractions. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
|
Source code in src/torch_flash/eos/multiparameter.py
molar_enthalpy
¶
Return total molar enthalpy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K, density in mol/m3, and mole fractions. |
required |
molar_density
|
Tensor
|
Temperature in K, density in mol/m3, and mole fractions. |
required |
composition
|
Tensor
|
Temperature in K, density in mol/m3, and mole fractions. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Molar enthalpy in J/mol. |
Source code in src/torch_flash/eos/multiparameter.py
molar_gibbs_energy
¶
Return total molar Gibbs energy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K, density in mol/m3, and mole fractions. |
required |
molar_density
|
Tensor
|
Temperature in K, density in mol/m3, and mole fractions. |
required |
composition
|
Tensor
|
Temperature in K, density in mol/m3, and mole fractions. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Molar Gibbs energy in J/mol. |
Source code in src/torch_flash/eos/multiparameter.py
chemical_potentials
¶
Return total component chemical potentials.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
molar_volume
|
Tensor
|
Homogeneous molar volume in m3/mol. |
required |
composition
|
Tensor
|
Mole fractions on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Component chemical potentials in J/mol. |
Source code in src/torch_flash/eos/multiparameter.py
speed_of_sound
¶
Return homogeneous-phase speed of sound.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K, density in mol/m3, and mole fractions. |
required |
molar_density
|
Tensor
|
Temperature in K, density in mol/m3, and mole fractions. |
required |
composition
|
Tensor
|
Temperature in K, density in mol/m3, and mole fractions. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Speed of sound in m/s. |
Source code in src/torch_flash/eos/multiparameter.py
pressure
¶
Return pressure from the exact residual-Helmholtz density derivative.
Source code in src/torch_flash/eos/multiparameter.py
molar_volume
¶
molar_volume(
temperature: Tensor,
pressure: Tensor,
composition: Tensor,
phase: PhaseKind = "stable",
) -> Tensor
Solve and select a homogeneous density root.
Phase-specific states first use a differentiable logarithmic-density Newton solve. If it fails, a logarithmic scan brackets every mechanically admissible positive root before bisection and Newton polishing. This conservative fallback matters because Helmholtz mixture models can have three density roots below the mixture critical locus, and an initial guess can cross a spinodal during phase-envelope calculations.
Source code in src/torch_flash/eos/multiparameter.py
1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 | |
select_z
¶
select_z(
temperature: Tensor,
pressure: Tensor,
composition: Tensor,
phase: PhaseKind = "stable",
) -> Tensor
Return the compressibility factor for a selected density root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K and pressure in Pa. |
required |
pressure
|
Tensor
|
Temperature in K and pressure in Pa. |
required |
composition
|
Tensor
|
Mole fractions on the final axis. |
required |
phase
|
PhaseKind
|
Liquid, vapor, or stable-root request. |
'stable'
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless |
Source code in src/torch_flash/eos/multiparameter.py
log_fugacity_coefficients
¶
log_fugacity_coefficients(
temperature: Tensor,
pressure: Tensor,
composition: Tensor,
phase: PhaseKind = "stable",
) -> Tensor
Return component log fugacity coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K and pressure in Pa. |
required |
pressure
|
Tensor
|
Temperature in K and pressure in Pa. |
required |
composition
|
Tensor
|
Mole fractions on the final axis. |
required |
phase
|
PhaseKind
|
Liquid, vapor, or stable-root request. |
'stable'
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless |
Notes
Residual chemical potentials are obtained by differentiating the extensive residual Helmholtz energy at fixed volume.
Source code in src/torch_flash/eos/multiparameter.py
MultiparameterMetadata
dataclass
¶
MultiparameterMetadata(
model: str,
reference: str,
version: str,
validated_components: tuple[str, ...],
)
Identity and validation scope of one multiparameter coefficient set.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
str
|
Exact published model or fitted-parameter identity. |
reference |
str
|
Defining bibliographic reference. |
version |
str
|
Version of the serialized coefficient set. |
validated_components |
tuple[str, ...]
|
Component inventory for which the parameterization is defined. |
NonAnalyticTerms
dataclass
¶
NonAnalyticTerms(
n: Tensor,
capital_a: Tensor,
capital_b: Tensor,
capital_c: Tensor,
capital_d: Tensor,
a: Tensor,
b: Tensor,
beta: Tensor,
)
Span--Wagner non-analytic critical-region coefficient arrays.
Attributes:
| Name | Type | Description |
|---|---|---|
n |
Tensor
|
Term amplitudes. |
capital_a, capital_b, capital_c, capital_d |
Non-analytic shape coefficients. |
|
a, b, beta |
Critical exponents and crossover parameters. Every tensor must have
the same shape as |
VolumeTranslation
dataclass
¶
VolumeTranslation(
reference_shift: Tensor,
temperature_slope: Tensor,
reference_temperature: float = 288.15,
source: str = "custom",
)
Component translations in the additive torch-flash convention.
reference_shift is in m3/mol, temperature_slope in
m3/(mol K), and reference_temperature in K. A published positive
Péneloux c therefore appears as a negative reference_shift.
Attributes:
| Name | Type | Description |
|---|---|---|
reference_shift |
Tensor
|
Per-component additive shift in m3/mol at |
temperature_slope |
Tensor
|
Per-component linear slope in m3/(mol K). |
reference_temperature |
float
|
Positive reference temperature in K. |
source |
str
|
Parameter or fitting provenance identifier. |
constant
classmethod
¶
constant(
shift: Tensor, *, source: str = "custom"
) -> VolumeTranslation
Construct a temperature-independent additive translation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shift
|
Tensor
|
Per-component additive shifts in m3/mol. |
required |
source
|
str
|
Human-readable provenance identifier. |
'custom'
|
Returns:
| Type | Description |
|---|---|
VolumeTranslation
|
Translation with zero temperature slope. |
Source code in src/torch_flash/eos/volume_translation.py
at_temperature
¶
Evaluate component additive shifts at temperature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K with arbitrary leading batch dimensions. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Shifts in m3/mol with a final component axis. |
Source code in src/torch_flash/eos/volume_translation.py
to
¶
to(
*,
dtype: dtype | None = None,
device: device | str | None = None,
) -> VolumeTranslation
Copy translation coefficients to a dtype and device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype
|
dtype | None
|
Optional PyTorch destination options. |
None
|
device
|
dtype | None
|
Optional PyTorch destination options. |
None
|
Returns:
| Type | Description |
|---|---|
VolumeTranslation
|
New immutable translation preserving metadata. |
Source code in src/torch_flash/eos/volume_translation.py
cpa_eos
¶
cpa_eos(
names: tuple[str, ...],
parameter_set: ParameterSource = "cpa.folas-2005",
*,
kij: Tensor | None = None,
kij_a: Tensor | None = None,
kij_b: Tensor | None = None,
lij: Tensor | None = None,
cross_association_energy: Tensor | None = None,
cross_association_volume: Tensor | None = None,
combining_rule: CombiningRule | None = None,
trainable: bool = False,
trainable_lij: bool = False,
association_iterations: int = 10,
association_newton_iterations: int = 8,
dtype: dtype | None = None,
device: device | str | None = None,
) -> CPAEOS
Construct CPA from a bundled/custom YAML set or use :class:CPAEOS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
tuple[str, ...]
|
Component names in model tensor order. |
required |
parameter_set
|
ParameterSource
|
Bundled identifier, custom YAML path, mapping, or loaded CPA set. |
'cpa.folas-2005'
|
kij
|
Tensor | None
|
Optional physical-term interaction overrides. |
None
|
kij_a
|
Tensor | None
|
Optional physical-term interaction overrides. |
None
|
kij_b
|
Tensor | None
|
Optional physical-term interaction overrides. |
None
|
lij
|
Tensor | None
|
Optional physical-term interaction overrides. |
None
|
cross_association_energy
|
Tensor | None
|
Optional cross-association pair overrides. |
None
|
cross_association_volume
|
Tensor | None
|
Optional cross-association pair overrides. |
None
|
combining_rule
|
CombiningRule | None
|
Override the parameter set's CR1/ECR default. |
None
|
trainable
|
bool
|
Enable fitting of attraction/association or covolume interactions. |
False
|
trainable_lij
|
bool
|
Enable fitting of attraction/association or covolume interactions. |
False
|
association_iterations
|
int
|
Site-fraction solver iteration budgets. |
10
|
association_newton_iterations
|
int
|
Site-fraction solver iteration budgets. |
10
|
dtype
|
dtype | None
|
Tensor placement. |
None
|
device
|
dtype | None
|
Tensor placement. |
None
|
Returns:
| Type | Description |
|---|---|
CPAEOS
|
Configured CPA model. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If a requested component has no pure parameters. |
ParameterDatabaseError
|
If the source model, parameter records, or combining rule is invalid. |
Notes
Direct construction with a tuple of :class:CPAComponent remains the
explicit in-memory API for fitting new species or parameterizations.
lij optionally modifies the physical SRK co-volume rule;
trainable_lij controls it independently of the attraction parameters.
Source code in src/torch_flash/eos/cpa.py
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 | |
cpa_folas_2005
¶
cpa_folas_2005(
names: tuple[str, ...],
*,
kij: Tensor | None = None,
lij: Tensor | None = None,
combining_rule: CombiningRule = "ECR",
trainable: bool = False,
trainable_lij: bool = False,
dtype: dtype | None = None,
device: device | str | None = None,
) -> CPAEOS
Construct CPA with the Folas et al. (2005), Table 1, pure parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
tuple[str, ...]
|
Component names in model order. |
required |
kij
|
Tensor | None
|
Optional physical-term attraction and covolume interactions. |
None
|
lij
|
Tensor | None
|
Optional physical-term attraction and covolume interactions. |
None
|
combining_rule
|
CombiningRule
|
|
'ECR'
|
trainable
|
bool
|
Enable interaction-parameter fitting. |
False
|
trainable_lij
|
bool
|
Enable interaction-parameter fitting. |
False
|
dtype
|
dtype | None
|
Tensor placement. |
None
|
device
|
dtype | None
|
Tensor placement. |
None
|
Returns:
| Type | Description |
|---|---|
CPAEOS
|
Configured Folas-2005 parameterization defined by doi:10.1021/ie048832j. |
Source code in src/torch_flash/eos/cpa.py
cpa_oliveira_2007
¶
cpa_oliveira_2007(
names: tuple[str, ...],
*,
kij: Tensor | None = None,
lij: Tensor | None = None,
cross_association_energy: Tensor | None = None,
cross_association_volume: Tensor | None = None,
trainable: bool = False,
trainable_lij: bool = False,
dtype: dtype | None = None,
device: device | str | None = None,
) -> CPAEOS
Construct the hydrocarbon-water CPA parameterization of Oliveira et al.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
tuple[str, ...]
|
Component names in model order. |
required |
kij
|
Tensor | None
|
Optional physical-term interaction overrides. |
None
|
lij
|
Tensor | None
|
Optional physical-term interaction overrides. |
None
|
cross_association_energy
|
Tensor | None
|
Optional modified-CR1 solvation overrides in J/mol and dimensionless association volume. |
None
|
cross_association_volume
|
Tensor | None
|
Optional modified-CR1 solvation overrides in J/mol and dimensionless association volume. |
None
|
trainable
|
bool
|
Enable interaction-parameter fitting. |
False
|
trainable_lij
|
bool
|
Enable interaction-parameter fitting. |
False
|
dtype
|
dtype | None
|
Tensor placement. |
None
|
device
|
dtype | None
|
Tensor placement. |
None
|
Returns:
| Type | Description |
|---|---|
CPAEOS
|
Configured Oliveira-2007 hydrocarbon-water parameterization. |
Notes
Pure parameters and constant physical-term interactions are from Tables 1-3 of Oliveira, Coutinho, and Queimada, Fluid Phase Equilibria 258 (2007) 58-66, doi:10.1016/j.fluid.2007.05.023. Aromatic-water solvation uses the paper's modified CR-1 cross-association parameters.
Source code in src/torch_flash/eos/cpa.py
cpa_yan_2009
¶
cpa_yan_2009(
names: tuple[str, ...],
*,
kij: Tensor | None = None,
kij_a: Tensor | None = None,
kij_b: Tensor | None = None,
lij: Tensor | None = None,
trainable: bool = False,
trainable_lij: bool = False,
dtype: dtype | None = None,
device: device | str | None = None,
) -> CPAEOS
Construct reservoir-fluid CPA with Yan et al.'s A + B/T water BIPs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
tuple[str, ...]
|
Component names in model order. |
required |
kij
|
Tensor | None
|
Optional constant or |
None
|
kij_a
|
Tensor | None
|
Optional constant or |
None
|
kij_b
|
Tensor | None
|
Optional constant or |
None
|
lij
|
Tensor | None
|
Optional constant or |
None
|
trainable
|
bool
|
Enable interaction-parameter fitting. |
False
|
trainable_lij
|
bool
|
Enable interaction-parameter fitting. |
False
|
dtype
|
dtype | None
|
Tensor placement. |
None
|
device
|
dtype | None
|
Tensor placement. |
None
|
Returns:
| Type | Description |
|---|---|
CPAEOS
|
Yan-2009 reservoir-fluid parameterization from Fluid Phase Equilibria 276 (2009) 75-85, doi:10.1016/j.fluid.2008.10.007. |
Source code in src/torch_flash/eos/cpa.py
cpa_components_from_cuts
¶
cpa_components_from_cuts(
cuts: tuple[PseudoComponentCut, ...],
*,
parameter_set: ParameterSource = "cpa.yan-2009-reservoir-fluids",
dtype: dtype | None = None,
device: device | str | None = None,
) -> CPACharacterizedComponents
Characterize analyzed C7+ cuts and normalize their internal fractions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cuts
|
tuple[PseudoComponentCut, ...]
|
Measured/estimated heavy-end cuts in desired component order. |
required |
parameter_set
|
ParameterSource
|
CPA parameter source containing Yan-style heavy-end correlations. |
'cpa.yan-2009-reservoir-fluids'
|
dtype
|
dtype | None
|
Placement of the normalized fraction tensor. |
None
|
device
|
dtype | None
|
Placement of the normalized fraction tensor. |
None
|
Returns:
| Type | Description |
|---|---|
CPACharacterizedComponents
|
CPA records, normalized internal cut fractions, and complete monomer characterization diagnostics. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no cuts are supplied or their fractions do not define a positive finite distribution. |
Notes
This function covers the EoS-parameter step of a plus-fraction workflow. It deliberately does not invent a carbon-number distribution when only a bulk C7+ molecular weight is known; splitting or lumping must be performed upstream with measured cuts or an explicitly selected Whitson/Pedersen distribution model.
Source code in src/torch_flash/eos/cpa_heavy_end.py
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 | |
cpa_heavy_end_correlations
¶
cpa_heavy_end_correlations(
parameter_set: ParameterSource = "cpa.yan-2009-reservoir-fluids",
) -> CPAHeavyEndCorrelations
Load and validate CPA heavy-end correlation coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameter_set
|
ParameterSource
|
CPA parameter source containing a |
'cpa.yan-2009-reservoir-fluids'
|
Returns:
| Type | Description |
|---|---|
CPAHeavyEndCorrelations
|
Typed coefficient inventory in the SI conventions declared by the parameter document. |
Raises:
| Type | Description |
|---|---|
ParameterDatabaseError
|
If the model kind or any required coefficient is missing, nonnumeric, nonfinite, or outside its required positive domain. |
Source code in src/torch_flash/eos/cpa_heavy_end.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
cpa_monomer_properties
¶
cpa_monomer_properties(
normal_boiling_temperature: float,
specific_gravity: float,
parameter_set: ParameterSource = "cpa.yan-2009-reservoir-fluids",
) -> CPAMonomerProperties
Calculate CPA monomer properties for one narrow heavy-end cut.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
normal_boiling_temperature
|
float
|
Atmospheric normal boiling temperature in K. |
required |
specific_gravity
|
float
|
Dimensionless liquid specific gravity used by the source characterization. |
required |
parameter_set
|
ParameterSource
|
CPA parameter source containing heavy-end correlation coefficients. |
'cpa.yan-2009-reservoir-fluids'
|
Returns:
| Type | Description |
|---|---|
CPAMonomerProperties
|
Intermediate reference-alkane quantities and characterized critical, acentric, attraction, and covolume properties. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If inputs are nonpositive/nonfinite or the correlation leaves its physical domain. |
ConvergenceError
|
If the normal-boiling-point acentric-factor match cannot be solved. |
Source code in src/torch_flash/eos/cpa_heavy_end.py
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | |
cpa_pseudocomponent
¶
cpa_pseudocomponent(
name: str,
normal_boiling_temperature: float,
specific_gravity: float,
molar_mass: float,
parameter_set: ParameterSource = "cpa.yan-2009-reservoir-fluids",
) -> CPAComponent
Create a non-associating CPA pseudo-component for one heavy-end cut.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Nonempty pseudo-component identifier. |
required |
normal_boiling_temperature
|
float
|
Normal boiling temperature in K. |
required |
specific_gravity
|
float
|
Dimensionless specific gravity used by the selected correlation. |
required |
molar_mass
|
float
|
Molar mass in kg/mol. |
required |
parameter_set
|
ParameterSource
|
CPA parameter source containing the heavy-end correlations. |
'cpa.yan-2009-reservoir-fluids'
|
Returns:
| Type | Description |
|---|---|
CPAComponent
|
Characterized monomer with zero association sites. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the name or molar mass is invalid, or the cut lies outside the correlation's physical domain. |
Source code in src/torch_flash/eos/cpa_heavy_end.py
cubic_constants
¶
cubic_constants(source: ParameterSource) -> CubicConstants
Load and validate generalized cubic EOS constants.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
ParameterSource
|
Bundled parameter-set identifier, YAML path, mapping, or an already loaded model parameter set. |
required |
Returns:
| Type | Description |
|---|---|
CubicConstants
|
Typed, immutable constants retaining the source identifier. |
Raises:
| Type | Description |
|---|---|
ParameterDatabaseError
|
If the source is not a cubic parameter set or required alpha and critical-constraint entries are missing or malformed. |
Source code in src/torch_flash/eos/cubic.py
cubic_eos
¶
cubic_eos(
components: ComponentSet,
parameter_set: ParameterSource | CubicConstants,
*,
kij: Tensor | None = None,
kij_a: Tensor | None = None,
kij_b: Tensor | None = None,
lij: Tensor | None = None,
trainable: bool = False,
trainable_lij: bool = False,
mixing: CubicMixing | None = None,
volume_translation: Tensor
| VolumeTranslation
| None = None,
) -> CubicEOS
Construct a cubic EoS from bundled YAML or explicit typed constants.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
components
|
ComponentSet
|
Ordered component set. |
required |
parameter_set
|
ParameterSource | CubicConstants
|
Cubic parameter source or prevalidated :class: |
required |
kij
|
Tensor | None
|
Optional constant dimensionless attraction interactions. |
None
|
kij_a
|
Tensor | None
|
Optional temperature-dependent form |
None
|
kij_b
|
Tensor | None
|
Optional temperature-dependent form |
None
|
lij
|
Tensor | None
|
Optional dimensionless cross-covolume interactions. |
None
|
trainable
|
bool
|
Register attraction or covolume interactions as trainable parameters. |
False
|
trainable_lij
|
bool
|
Register attraction or covolume interactions as trainable parameters. |
False
|
mixing
|
CubicMixing | None
|
Explicit mixing module, mutually exclusive with interaction controls. |
None
|
volume_translation
|
Tensor | VolumeTranslation | None
|
Additive shifts in m3/mol or a :class: |
None
|
Returns:
| Type | Description |
|---|---|
CubicEOS
|
Configured model on the component set's dtype and device. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If mutually exclusive interaction/mixing options are combined or matrix shapes are inconsistent. |
Notes
Supply kij for a constant quadratic interaction matrix, or both
kij_a and kij_b for kij(T) = kij_a + kij_b/T. The latter
coefficients are dimensionless and kelvin, respectively. Supply lij
for bij = 0.5*(bi+bj)*(1-lij); omitting it recovers the conventional
linear covolume rule. trainable controls attraction interactions;
trainable_lij independently enables co-volume fitting from the
supplied matrix or from zero.
Source code in src/torch_flash/eos/cubic.py
802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 | |
enhanced_predictive_peng_robinson_1978
¶
enhanced_predictive_peng_robinson_1978(
components: ComponentSet,
*,
parameter_set: ParameterSource = DEFAULT_EPPR78_GROUP_CONTRIBUTION,
group_counts: Mapping[str, Mapping[str, float]]
| Tensor
| None = None,
trainable: bool = False,
volume_translation: Tensor
| VolumeTranslation
| None = None,
) -> CubicEOS
Construct E-PPR78 with the global 40-group kij(T) correlation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
components
|
ComponentSet
|
Ordered component set. The bundled parameter document supplies decompositions for the package's unambiguous hydrocarbon, permanent gas, water, ammonia, and sulfur-dioxide components. |
required |
parameter_set
|
ParameterSource
|
E-PPR78 group-contribution parameter source. The default is the global 40-group 2022 revision. A custom source must use the same pressure-valued A/B convention and explicitly classify unavailable group pairs. |
DEFAULT_EPPR78_GROUP_CONTRIBUTION
|
group_counts
|
Mapping[str, Mapping[str, float]] | Tensor | None
|
Optional explicit component group counts overriding stored decompositions. Counts are normalized to molecular group fractions. |
None
|
trainable
|
bool
|
Register the active, unique off-diagonal A/B group interactions as PyTorch parameters. |
False
|
volume_translation
|
Tensor | VolumeTranslation | None
|
Optional additive volume translation in m3/mol. |
None
|
Returns:
| Type | Description |
|---|---|
CubicEOS
|
PR78 pure-component equation with
:class: |
Raises:
| Type | Description |
|---|---|
KeyError
|
If a requested component lacks a bundled decomposition. |
ParameterDatabaseError
|
If the parameter document is malformed or an interaction between two active groups is explicitly unavailable. |
Notes
E-PPR78 retains the predictive Peng--Robinson group-contribution equation but uses the refitted group interactions of Jaubert, Qian, Lasala, and Privat, Fluid Phase Equilibria 560 (2022) 113456, doi:10.1016/j.fluid.2022.113456, Eq. (5) and Table S4. The bundled database contains all 40 named groups, 356 available group pairs, and 424 explicitly unavailable pairs from that source. The CCS use case follows Xu et al., International Journal of Greenhouse Gas Control 56 (2017) 126--154, doi:10.1016/j.ijggc.2016.11.015; the default numerical values are the later 2022 global revision.
Only groups active in components are materialized for an incomplete
interaction inventory. This avoids turning an unavailable pair into a
numerical zero and keeps fitting tensors proportional to the selected
problem. E-PPR78 uses the linear covolume rule defined by the published
model.
Source code in src/torch_flash/eos/cubic.py
1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 | |
peng_robinson_1976
¶
peng_robinson_1976(
components: ComponentSet,
*,
kij: Tensor | None = None,
kij_a: Tensor | None = None,
kij_b: Tensor | None = None,
lij: Tensor | None = None,
trainable: bool = False,
trainable_lij: bool = False,
mixing: CubicMixing | None = None,
volume_translation: Tensor
| VolumeTranslation
| None = None,
) -> CubicEOS
Construct the original 1976 Peng--Robinson equation of state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
components
|
ComponentSet
|
Ordered component set. |
required |
kij
|
Tensor | None
|
Optional constant or |
None
|
kij_a
|
Tensor | None
|
Optional constant or |
None
|
kij_b
|
Tensor | None
|
Optional constant or |
None
|
lij
|
Tensor | None
|
Optional constant or |
None
|
trainable
|
bool
|
Make attraction or covolume interaction tensors trainable. |
False
|
trainable_lij
|
bool
|
Make attraction or covolume interaction tensors trainable. |
False
|
mixing
|
CubicMixing | None
|
Explicit mixing rule, mutually exclusive with interaction arguments. |
None
|
volume_translation
|
Tensor | VolumeTranslation | None
|
Optional additive shifts in m3/mol. |
None
|
Returns:
| Type | Description |
|---|---|
CubicEOS
|
Configured PR76 model. |
Source code in src/torch_flash/eos/cubic.py
peng_robinson_1978
¶
peng_robinson_1978(
components: ComponentSet,
*,
kij: Tensor | None = None,
kij_a: Tensor | None = None,
kij_b: Tensor | None = None,
lij: Tensor | None = None,
trainable: bool = False,
trainable_lij: bool = False,
mixing: CubicMixing | None = None,
volume_translation: Tensor
| VolumeTranslation
| None = None,
) -> CubicEOS
Construct the 1978 Peng--Robinson acentric-factor variant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
components
|
ComponentSet
|
Ordered component set. |
required |
kij
|
Tensor | None
|
Optional constant or |
None
|
kij_a
|
Tensor | None
|
Optional constant or |
None
|
kij_b
|
Tensor | None
|
Optional constant or |
None
|
lij
|
Tensor | None
|
Optional constant or |
None
|
trainable
|
bool
|
Make attraction or covolume interaction tensors trainable. |
False
|
trainable_lij
|
bool
|
Make attraction or covolume interaction tensors trainable. |
False
|
mixing
|
CubicMixing | None
|
Explicit mixing rule, mutually exclusive with interaction arguments. |
None
|
volume_translation
|
Tensor | VolumeTranslation | None
|
Optional additive shifts in m3/mol. |
None
|
Returns:
| Type | Description |
|---|---|
CubicEOS
|
Configured PR78 model. |
Source code in src/torch_flash/eos/cubic.py
predictive_peng_robinson_1978
¶
predictive_peng_robinson_1978(
components: ComponentSet,
*,
parameter_set: ParameterSource = DEFAULT_PPR78_GROUP_CONTRIBUTION,
group_counts: Mapping[str, Mapping[str, float]]
| Tensor
| None = None,
trainable: bool = False,
volume_translation: Tensor
| VolumeTranslation
| None = None,
) -> CubicEOS
Construct PPR78 with group-contribution kij(T).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
components
|
ComponentSet
|
Ordered component set. |
required |
parameter_set
|
ParameterSource
|
PPR78 group-contribution parameter source. Use
|
DEFAULT_PPR78_GROUP_CONTRIBUTION
|
group_counts
|
Mapping[str, Mapping[str, float]] | Tensor | None
|
Optional explicit component group decompositions. |
None
|
trainable
|
bool
|
Register universal off-diagonal A/B group interactions as trainable parameters. |
False
|
volume_translation
|
Tensor | VolumeTranslation | None
|
Optional additive volume translation. |
None
|
Returns:
| Type | Description |
|---|---|
CubicEOS
|
PR78 model with :class: |
Notes
The default parameter set is the original six-group saturated-hydrocarbon
fit of Jaubert and Mutelet (2004), doi:10.1016/j.fluid.2004.06.059.
The separate H2/N2/H2O parameter set combines the hydrogen-group
extension of Qian et al. (2013), doi:10.1016/j.supflu.2012.12.014, and
the water-group extension of Qian et al. (2013),
doi:10.1021/ie402541h. Custom YAML parameter sets and explicit component
group counts use the same path. trainable=True exposes the unique
universal A/B group interactions as PyTorch parameters.
PPR78 was derived with the linear covolume rule, so co-volume interactions are intentionally not accepted by this named constructor.
Source code in src/torch_flash/eos/cubic.py
soave_redlich_kwong
¶
soave_redlich_kwong(
components: ComponentSet,
*,
kij: Tensor | None = None,
kij_a: Tensor | None = None,
kij_b: Tensor | None = None,
lij: Tensor | None = None,
trainable: bool = False,
trainable_lij: bool = False,
mixing: CubicMixing | None = None,
volume_translation: Tensor
| VolumeTranslation
| None = None,
) -> CubicEOS
Construct the 1972 Soave--Redlich--Kwong equation of state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
components
|
ComponentSet
|
Ordered component set. |
required |
kij
|
Tensor | None
|
Optional constant or |
None
|
kij_a
|
Tensor | None
|
Optional constant or |
None
|
kij_b
|
Tensor | None
|
Optional constant or |
None
|
lij
|
Tensor | None
|
Optional constant or |
None
|
trainable
|
bool
|
Register supplied/default attraction or covolume interactions as trainable PyTorch parameters. |
False
|
trainable_lij
|
bool
|
Register supplied/default attraction or covolume interactions as trainable PyTorch parameters. |
False
|
mixing
|
CubicMixing | None
|
Explicit mixing rule, mutually exclusive with interaction arguments. |
None
|
volume_translation
|
Tensor | VolumeTranslation | None
|
Optional additive shifts in m3/mol. |
None
|
Returns:
| Type | Description |
|---|---|
CubicEOS
|
Configured SRK model on the component set's dtype and device. |
Source code in src/torch_flash/eos/cubic.py
leachman_normal_hydrogen
¶
leachman_normal_hydrogen(
*,
dtype: dtype | None = None,
device: device | str | None = None,
trainable: bool = False,
parameter_set: ParameterSource = DEFAULT_LEACHMAN_NORMAL_HYDROGEN,
) -> PureFluidHelmholtzEOS
Construct the Leachman et al. normal-hydrogen Helmholtz EOS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype
|
dtype | None
|
Tensor placement, defaulting to the configured runtime policy. |
None
|
device
|
dtype | None
|
Tensor placement, defaulting to the configured runtime policy. |
None
|
trainable
|
bool
|
Register supported Helmholtz coefficients as trainable parameters. |
False
|
parameter_set
|
ParameterSource
|
Compatible standalone normal-hydrogen parameter source. |
DEFAULT_LEACHMAN_NORMAL_HYDROGEN
|
Returns:
| Type | Description |
|---|---|
PureFluidHelmholtzEOS
|
Native PyTorch pure-fluid Helmholtz model for normal hydrogen. |
Raises:
| Type | Description |
|---|---|
ParameterDatabaseError
|
If |
Notes
This constructor covers the thermodynamic Helmholtz equation. It does not add saturation ancillaries, melting or sublimation curves, or transport correlations.
References
J. W. Leachman et al., J. Phys. Chem. Ref. Data 38 (2009) 721--748, doi:10.1063/1.3160306.
Source code in src/torch_flash/eos/leachman.py
eoscg2021
¶
eoscg2021(
names: tuple[str, ...] | None = None,
*,
dtype: dtype | None = None,
device: device | str | None = None,
trainable: bool = False,
parameter_set: ParameterSource = "multiparameter.eos-cg-2021",
) -> MultiparameterEOS
Construct the complete native 16-component EOS-CG-2021 Helmholtz model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
tuple[str, ...] | None
|
Optional ordered subset of the 16 supported components. |
None
|
dtype
|
dtype | None
|
Tensor placement. |
None
|
device
|
dtype | None
|
Tensor placement. |
None
|
trainable
|
bool
|
Register supported coefficient tensors as trainable parameters. |
False
|
parameter_set
|
ParameterSource
|
EOS-CG-2021 parameter source. |
'multiparameter.eos-cg-2021'
|
Returns:
| Type | Description |
|---|---|
MultiparameterEOS
|
Native EOS-CG-2021 model defined by Neumann et al. (2023), doi:10.1007/s10765-023-03263-6, including its supplementary tables. |
Source code in src/torch_flash/eos/named.py
gerg2008
¶
gerg2008(
names: tuple[str, ...] | None = None,
*,
dtype: dtype | None = None,
device: device | str | None = None,
trainable: bool = False,
parameter_set: ParameterSource = "multiparameter.gerg-2008",
) -> MultiparameterEOS
Construct the complete native 21-component GERG-2008 Helmholtz model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
tuple[str, ...] | None
|
Optional ordered subset of the 21 supported components. |
None
|
dtype
|
dtype | None
|
Tensor placement. |
None
|
device
|
dtype | None
|
Tensor placement. |
None
|
trainable
|
bool
|
Register supported coefficient tensors as trainable parameters. |
False
|
parameter_set
|
ParameterSource
|
GERG-2008 parameter source, overridable for an explicitly versioned compatible document. |
'multiparameter.gerg-2008'
|
Returns:
| Type | Description |
|---|---|
MultiparameterEOS
|
Native GERG-2008 model. The defining reference is Kunz and Wagner (2012), doi:10.1021/je300655b. |
Source code in src/torch_flash/eos/named.py
gerg2008_hydrogen_2021
¶
gerg2008_hydrogen_2021(
names: tuple[str, ...] | None = None,
*,
dtype: dtype | None = None,
device: device | str | None = None,
trainable: bool = False,
parameter_set: ParameterSource = "multiparameter.gerg-2008-hydrogen-2021",
) -> MultiparameterEOS
Construct the Beckmüller et al. H2-tailored GERG mixture model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
tuple[str, ...] | None
|
Optional ordered subset of methane, nitrogen, carbon monoxide, carbon dioxide, and hydrogen. |
None
|
dtype
|
dtype | None
|
Tensor placement. |
None
|
device
|
dtype | None
|
Tensor placement. |
None
|
trainable
|
bool
|
Register supported coefficient tensors as trainable parameters. |
False
|
parameter_set
|
ParameterSource
|
Compatible H2-tailored GERG parameter source. |
'multiparameter.gerg-2008-hydrogen-2021'
|
Returns:
| Type | Description |
|---|---|
MultiparameterEOS
|
Five-component H2-tailored GERG model using GERG-2008 pure fluids for CH4, N2, CO, and CO2 and the Leachman normal-hydrogen equation. |
References
Beckmüller et al., J. Phys. Chem. Ref. Data 50, 013102 (2021), doi:10.1063/5.0040533.
Source code in src/torch_flash/eos/named.py
multiparameter_eos
¶
multiparameter_eos(
parameter_set: ParameterSource,
names: tuple[str, ...] | None = None,
*,
dtype: dtype | None = None,
device: device | str | None = None,
trainable: bool = False,
) -> MultiparameterEOS
Construct a native multiparameter EOS from versioned parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameter_set
|
ParameterSource
|
Bundled identifier, custom YAML path, mapping, or loaded multiparameter parameter set. |
required |
names
|
tuple[str, ...] | None
|
Optional ordered component subset. Omitting it selects the complete inventory defined by the parameter set. |
None
|
dtype
|
dtype | None
|
Tensor placement, defaulting to runtime configuration. |
None
|
device
|
dtype | None
|
Tensor placement, defaulting to runtime configuration. |
None
|
trainable
|
bool
|
Register supported coefficient tensors as trainable parameters. |
False
|
Returns:
| Type | Description |
|---|---|
MultiparameterEOS
|
GERG-family or EOS-CG model selected from the source identity. |
Raises:
| Type | Description |
|---|---|
ParameterDatabaseError
|
If the source is not a supported multiparameter model or its coefficient inventory is malformed. |
Source code in src/torch_flash/eos/named.py
density_matched_translation
¶
density_matched_translation(
eos_molar_volume: Tensor,
molar_mass: Tensor,
mass_density: Tensor,
*,
source: str = "density-match",
) -> VolumeTranslation
Match a reference density with an additive component translation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
eos_molar_volume
|
Tensor
|
Parent-EOS pure-component molar volumes in m3/mol. |
required |
molar_mass
|
Tensor
|
Component molar masses in kg/mol. |
required |
mass_density
|
Tensor
|
Target pure-component mass densities in kg/m3. |
required |
source
|
str
|
Provenance label stored on the returned translation. |
'density-match'
|
Returns:
| Type | Description |
|---|---|
VolumeTranslation
|
Constant shifts |
Raises:
| Type | Description |
|---|---|
ValueError
|
If input vectors differ in shape or contain nonfinite/nonpositive values. |
Notes
All inputs use SI units. The returned shift is
M/rho - v_eos, while the equivalent published Péneloux coefficient is
its negative.
Source code in src/torch_flash/eos/volume_translation.py
pedersen_peneloux_translation
¶
pedersen_peneloux_translation(
components: ComponentSet,
eos: VolumeTranslationEOS,
*,
rackett_factor: Tensor | None = None,
source: ParameterSource = _PEDERSEN_SOURCE,
) -> VolumeTranslation
Return the Pedersen light-component SRK/PR Péneloux translation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
components
|
ComponentSet
|
Ordered critical constants and acentric factors. |
required |
eos
|
VolumeTranslationEOS
|
Cubic family, |
required |
rackett_factor
|
Tensor | None
|
Optional per-component dimensionless Rackett factors. |
None
|
source
|
ParameterSource
|
Pedersen volume-translation parameter source. |
_PEDERSEN_SOURCE
|
Returns:
| Type | Description |
|---|---|
VolumeTranslation
|
Temperature-independent additive shifts in m3/mol. |
Notes
SRK uses Pedersen Eq. 4.46 and PR uses the Jhaveri-Youngren Eq. 4.49. These correlations were fitted for nonhydrocarbons and hydrocarbons lighter than C7; heavier fractions should use density matching or a characterized parameter set.
Source code in src/torch_flash/eos/volume_translation.py
pedersen_temperature_dependent_translation
¶
pedersen_temperature_dependent_translation(
model: CubicEOS,
reference_density: Tensor,
*,
pressure: float = 101325.0,
source: ParameterSource = _PEDERSEN_SOURCE,
) -> VolumeTranslation
Fit Pedersen's linear C7+ translation using Eqs. 5.7-5.9.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
CubicEOS
|
Untranslated parent cubic EOS. |
required |
reference_density
|
Tensor
|
One pure-component reference density per component in kg/m3. |
required |
pressure
|
float
|
Positive matching pressure in Pa. |
101325.0
|
source
|
ParameterSource
|
Pedersen temperature-dependent parameter source. |
_PEDERSEN_SOURCE
|
Returns:
| Type | Description |
|---|---|
VolumeTranslation
|
Reference shifts in m3/mol and slopes in m3/(mol K). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If density/pressure inputs are invalid or |
InvalidStateError
|
If the correlation target temperature is not subcritical for every component. |
Notes
reference_density is in kg/m3 at 288.15 K by default. The ASTM
correlation supplies the target density at 353.15 K, and the parent cubic
EoS supplies the unshifted liquid volumes at both temperatures.
Source code in src/torch_flash/eos/volume_translation.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 | |
rackett_compressibility_factor
¶
rackett_compressibility_factor(
acentric_factor: Tensor,
*,
source: ParameterSource = _PEDERSEN_SOURCE,
) -> Tensor
Evaluate the Rackett compressibility-factor correlation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
acentric_factor
|
Tensor
|
Dimensionless component acentric factors. |
required |
source
|
ParameterSource
|
Volume-translation parameter source providing intercept and slope. |
_PEDERSEN_SOURCE
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless Rackett factors with the same shape, dtype, and device
as |
Notes
The bundled Pedersen set evaluates Z_RA = 0.29056 - 0.08775 omega
(Pedersen et al., Eq. 4.47).
Source code in src/torch_flash/eos/volume_translation.py
whitson_volume_translation
¶
whitson_volume_translation(
components: ComponentSet,
eos: VolumeTranslationEOS,
*,
heavy_families: Mapping[str, HydrocarbonFamily]
| None = None,
source: ParameterSource = _WHITSON_SOURCE,
) -> VolumeTranslation
Return Whitson Tables 4.2-4.3 translations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
components
|
ComponentSet
|
Ordered component set. |
required |
eos
|
VolumeTranslationEOS
|
Cubic family, |
required |
heavy_families
|
Mapping[str, HydrocarbonFamily] | None
|
Family assignments for components without tabulated shift factors. |
None
|
source
|
ParameterSource
|
Whitson volume-translation parameter source. |
_WHITSON_SOURCE
|
Returns:
| Type | Description |
|---|---|
VolumeTranslation
|
Temperature-independent additive shifts in m3/mol. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If an untabulated component lacks a heavy-family assignment. |
Notes
Named light components and normal paraffins through n-decane use the
tabulated s_i = c_i/b_i values. Any other component requires a family
entry and uses s_i = 1 - A0/M_i**A1 with M in g/mol.