Activity models and mixing rules¶
Activity models¶
torch_flash.activity
¶
Excess-Gibbs-energy activity models.
NRTL
¶
Bases: Module
Non-random two-liquid excess Gibbs energy model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
interaction
|
Tensor
|
Matrix storing :math: |
required |
nonrandomness
|
Tensor
|
Dimensionless :math: |
required |
trainable
|
bool
|
Register the interaction-energy matrix as a trainable parameter. |
False
|
References
Renon and Prausnitz, AIChE Journal 14 (1968), 135-144, doi:10.1002/aic.690140124.
Source code in src/torch_flash/activity/models.py
excess_gibbs_rt
¶
Evaluate dimensionless molar excess Gibbs energy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
composition
|
Tensor
|
Mole fractions with components on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless |
Source code in src/torch_flash/activity/models.py
log_activity_coefficients
¶
Return component log activity coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
composition
|
Tensor
|
Mole fractions with components on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless |
Source code in src/torch_flash/activity/models.py
AnchoredHuronVidalNRTL
¶
AnchoredHuronVidalNRTL(
tau_at_lower_temperature: Tensor,
tau_at_upper_temperature: Tensor,
nonrandomness: Tensor,
covolumes: Tensor,
*,
lower_temperature: Tensor | float,
upper_temperature: Tensor | float,
trainable_nonrandomness: bool = False,
nonrandomness_bounds: tuple[float, float] = (0.05, 0.6),
)
Bases: Module
Fit-ready HV-NRTL model anchored at two temperatures.
Directly regressing :math:A_{ij} and :math:B_{ij} in
:math:\tau_{ij}=A_{ij}/T+B_{ij} is poorly scaled and can be strongly
correlated over a finite experimental temperature interval. This exactly
equivalent parameterization stores trainable values of :math:\tau_{ij}
at two user-selected temperatures and interpolates linearly in
:math:1/T.
The optional trainable non-randomness matrix is kept symmetric and within
explicit open bounds by a sigmoid transform. Diagonal interactions remain
exactly zero. Call :meth:freeze after fitting to obtain the standard
:class:HuronVidalNRTL representation used by parameter databases.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tau_at_lower_temperature
|
Tensor
|
Dimensionless interaction matrices at the two anchors. |
required |
tau_at_upper_temperature
|
Tensor
|
Dimensionless interaction matrices at the two anchors. |
required |
nonrandomness
|
Tensor
|
Fixed or initially bounded-symmetric nonrandomness matrix. |
required |
covolumes
|
Tensor
|
Positive component cubic covolumes in m3/mol. |
required |
lower_temperature
|
Tensor | float
|
Positive increasing anchor temperatures in K. |
required |
upper_temperature
|
Tensor | float
|
Positive increasing anchor temperatures in K. |
required |
trainable_nonrandomness
|
bool
|
Fit the symmetric nonrandomness matrix through a bounded transform. |
False
|
nonrandomness_bounds
|
tuple[float, float]
|
Open lower/upper bounds for fitted off-diagonal nonrandomness. |
(0.05, 0.6)
|
Source code in src/torch_flash/activity/models.py
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 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 | |
tau_at_lower_temperature
property
¶
Return the lower-anchor interaction matrix with an exact zero diagonal.
tau_at_upper_temperature
property
¶
Return the upper-anchor interaction matrix with an exact zero diagonal.
nonrandomness
property
¶
Return the fixed or bounded-symmetric non-randomness matrix.
temperature_coefficient
property
¶
Return dimensionless :math:B_{ij} for tau = A/T + B.
tau_matrix
¶
Evaluate interactions by interpolation in inverse temperature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Positive temperature in K. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless interaction matrices with trailing component axes. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any temperature is nonpositive. |
Source code in src/torch_flash/activity/models.py
excess_gibbs_rt
¶
Evaluate anchored HV dimensionless excess Gibbs energy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Positive temperature in K. |
required |
composition
|
Tensor
|
Mole fractions on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless molar |
Source code in src/torch_flash/activity/models.py
log_activity_coefficients
¶
Return anchored HV component log activity coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Positive temperature in K. |
required |
composition
|
Tensor
|
Mole fractions on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless |
Source code in src/torch_flash/activity/models.py
freeze
¶
freeze() -> HuronVidalNRTL
Convert fitted anchor parameters to a detached standard HV model.
Returns:
| Type | Description |
|---|---|
HuronVidalNRTL
|
Prediction/storage model containing detached |
Source code in src/torch_flash/activity/models.py
HuronVidalNRTL
¶
HuronVidalNRTL(
energy_over_r: Tensor,
temperature_coefficient: Tensor,
nonrandomness: Tensor,
covolumes: Tensor,
*,
trainable: bool = False,
)
Bases: Module
Covolume-weighted NRTL model used by the original HV formulation.
The dimensionless interaction energy is
.. math::
\tau_{ji}(T) = A_{ji}/T + B_{ji},
where energy_over_r stores :math:A in kelvin and
temperature_coefficient stores the dimensionless linear coefficient
:math:B. The excess Gibbs energy is the modified NRTL expression from
Huron and Vidal (1979), with :math:x_j b_j replacing :math:x_j in the
local-composition sums. Consequently its parameters must be fitted for
the HV infinite-pressure reference; ordinary low-pressure NRTL parameters
are not interchangeable.
Reference: Huron and Vidal, Fluid Phase Equilibria 3 (1979), 255-271, doi:10.1016/0378-3812(79)80001-1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
energy_over_r
|
Tensor
|
Matrix |
required |
temperature_coefficient
|
Tensor
|
Dimensionless matrix |
required |
nonrandomness
|
Tensor
|
Dimensionless NRTL nonrandomness matrix. |
required |
covolumes
|
Tensor
|
Positive component cubic covolumes in m3/mol. |
required |
trainable
|
bool
|
Register |
False
|
Source code in src/torch_flash/activity/models.py
tau_matrix
¶
Evaluate the dimensionless HV-NRTL interaction matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
|
Source code in src/torch_flash/activity/models.py
excess_gibbs_rt
¶
Evaluate covolume-weighted HV excess Gibbs energy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
composition
|
Tensor
|
Mole fractions on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless molar |
Source code in src/torch_flash/activity/models.py
log_activity_coefficients
¶
Return HV-NRTL component log activity coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
composition
|
Tensor
|
Mole fractions on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless |
Source code in src/torch_flash/activity/models.py
Wilson
¶
Bases: Module
Wilson excess Gibbs model with energy and molar-volume parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
interaction
|
Tensor
|
Square energy-difference matrix in J/mol. |
required |
molar_volumes
|
Tensor
|
Positive pure-liquid molar volumes in m3/mol. |
required |
trainable
|
bool
|
Register |
False
|
References
Wilson, Journal of the American Chemical Society 86 (1964), 127-130, doi:10.1021/ja01056a002.
Source code in src/torch_flash/activity/models.py
lambda_matrix
¶
Evaluate the temperature-dependent Wilson Lambda matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless Lambda matrices with trailing component-pair axes. |
Source code in src/torch_flash/activity/models.py
excess_gibbs_rt
¶
Evaluate dimensionless molar excess Gibbs energy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
composition
|
Tensor
|
Mole fractions on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless |
Source code in src/torch_flash/activity/models.py
log_activity_coefficients
¶
Evaluate analytical Wilson log activity coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
composition
|
Tensor
|
Mole fractions on the final axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless |
Source code in src/torch_flash/activity/models.py
UNIFAC
¶
UNIFAC(
group_counts: Tensor,
relative_volume: Tensor,
relative_surface_area: Tensor,
subgroup_main_indices: Tensor,
interaction: Tensor,
*,
coordination_number: float = 10.0,
trainable: bool = False,
)
Bases: Module
Original UNIFAC excess-Gibbs-energy model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group_counts
|
Tensor
|
Component-by-subgroup occurrence matrix :math: |
required |
relative_volume
|
Tensor
|
Selected subgroup :math: |
required |
relative_surface_area
|
Tensor
|
Selected subgroup :math: |
required |
subgroup_main_indices
|
Tensor
|
Zero-based index of the selected main group for each subgroup. |
required |
interaction
|
Tensor
|
Directed selected-main-group matrix :math: |
required |
coordination_number
|
float
|
Lattice coordination number :math: |
10.0
|
trainable
|
bool
|
Store the main-group interaction matrix as an |
False
|
Notes
The model is vectorized over all leading dimensions of temperature and composition. PyTorch autodiff can therefore differentiate activities, excess Gibbs energy, and temperature/composition derivatives on CPU or GPU. Group assignment is discrete and is intentionally not trainable.
Source code in src/torch_flash/activity/unifac.py
molecular_relative_volume
property
¶
Return component molecular relative-volume parameters.
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless |
molecular_relative_surface_area
property
¶
Return component molecular relative-surface parameters.
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless |
interaction_factors
¶
Evaluate directed main-group interaction factors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Positive temperature in K. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless :math: |
Source code in src/torch_flash/activity/unifac.py
combinatorial_log_activity_coefficients
¶
Evaluate the original UNIFAC combinatorial contribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
composition
|
Tensor
|
Mole fractions on the final component axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Component contributions to dimensionless |
Source code in src/torch_flash/activity/unifac.py
residual_log_activity_coefficients
¶
Evaluate the original UNIFAC residual group contribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Positive temperature in K. |
required |
composition
|
Tensor
|
Mole fractions on the final component axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Component residual contributions to |
Source code in src/torch_flash/activity/unifac.py
log_activity_coefficients
¶
Return original-UNIFAC component log activity coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Positive temperature in K. |
required |
composition
|
Tensor
|
Mole fractions on the final component axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Sum of combinatorial and residual |
Source code in src/torch_flash/activity/unifac.py
excess_gibbs_rt
¶
Return dimensionless original-UNIFAC excess Gibbs energy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Positive temperature in K. |
required |
composition
|
Tensor
|
Mole fractions on the final component axis. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
|
Source code in src/torch_flash/activity/unifac.py
activity_model
¶
activity_model(
parameter_set: ParameterSource,
names: tuple[str, ...] | None = None,
*,
dtype: dtype | None = None,
device: device | str | None = None,
trainable: bool = False,
covolumes: Tensor | None = None,
group_assignments: Sequence[GroupAssignment]
| None = None,
) -> ActivityModel
Construct NRTL, HV-NRTL, Wilson, or original UNIFAC from YAML.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameter_set
|
ParameterSource
|
Bundled identifier, YAML path, mapping, or loaded activity parameter set. |
required |
names
|
tuple[str, ...] | None
|
Optional requested component order. Omitting it uses the stored order. |
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 interaction tensors as PyTorch parameters. |
False
|
covolumes
|
Tensor | None
|
Optional HV-NRTL component covolumes in m3/mol. |
None
|
group_assignments
|
Sequence[GroupAssignment] | None
|
Optional explicit UNIFAC subgroup counts, one mapping per component. |
None
|
Returns:
| Type | Description |
|---|---|
ActivityModel
|
Model matching the parameter document's exact identity. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If requested components or UNIFAC groups are unsupported. |
ValueError
|
If component order or model-specific overrides are inconsistent. |
ParameterDatabaseError
|
If model identity, units, or parameter records are malformed. |
Notes
The requested component order may differ from the stored order; vectors
and matrices are permuted consistently. For custom fitting workflows, the
model classes continue to accept explicit tensors directly. UNIFAC uses
bundled fragmentations selected by names or explicit
group_assignments.
Source code in src/torch_flash/activity/named.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 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 | |
unifac_groups_from_identifiers
¶
unifac_groups_from_identifiers(
identifiers: Sequence[str],
*,
identifier_type: str = "smiles",
) -> tuple[dict[int, float], ...]
Fragment molecules with the optional MIT-licensed ugropy package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifiers
|
Sequence[str]
|
Molecular SMILES strings or names. |
required |
identifier_type
|
str
|
|
'smiles'
|
Returns:
| Type | Description |
|---|---|
tuple
|
One mapping of published original-UNIFAC subgroup number to occurrence count per identifier. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If the optional |
ValueError
|
If the identifier type is unsupported or fragmentation is ambiguous or unavailable. |
Notes
SMILES inputs are recommended for reproducibility. Name lookup delegates
to PubChem and therefore requires network access and may change outside
torch-flash. Fragmentation is discrete; inspect every returned map
before using it in regression or safety-critical calculations.
Source code in src/torch_flash/activity/unifac.py
unifac_model
¶
unifac_model(
parameter_set: ParameterSource = "unifac-original",
names: Sequence[str] | None = None,
*,
group_assignments: Sequence[GroupAssignment]
| None = None,
dtype: dtype | None = None,
device: device | str | None = None,
trainable: bool = False,
) -> UNIFAC
Construct original UNIFAC from cached YAML or explicit parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameter_set
|
ParameterSource
|
Original-UNIFAC parameter source. |
'unifac-original'
|
names
|
Sequence[str] | None
|
Optional component names selecting bundled audited fragmentations. |
None
|
group_assignments
|
Sequence[GroupAssignment] | None
|
Optional explicit subgroup counts, one mapping per component. |
None
|
dtype
|
dtype | None
|
Tensor placement. |
None
|
device
|
dtype | None
|
Tensor placement. |
None
|
trainable
|
bool
|
Register the directed main-group interaction matrix as a trainable parameter. |
False
|
Returns:
| Type | Description |
|---|---|
UNIFAC
|
Original-UNIFAC model containing only the groups required by the selected components. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If a component or subgroup is absent. |
ValueError
|
If names and assignments are inconsistent. |
ParameterDatabaseError
|
If the parameter set is not original UNIFAC or lacks required directed group interactions. |
Notes
names select bundled, audited component fragmentations. Arbitrary
molecules use group_assignments, where each mapping may be keyed by
subgroup key, published subgroup number, or an unambiguous subgroup name.
The optional :func:unifac_groups_from_identifiers adapter can generate
these mappings with ugropy.
Source code in src/torch_flash/activity/unifac.py
Cubic mixing rules¶
torch_flash.mixing
¶
Mixing rules for equations of state.
HuronVidalMixing
¶
Bases: Module
Original infinite-pressure Huron-Vidal mixing rule.
The implementation follows Michelsen and Mollerup, chapter 7, Eq. 7:
a/(bRT) = sum(x_i a_i/(b_i RT)) - gE/(Delta RT).
Primary source: Huron and Vidal (1979), doi:10.1016/0378-3812(79)80001-1. The implementation convention follows Michelsen and Mollerup, Thermodynamic Models, 2nd ed. (2007), chapter 7, ISBN 978-87-989961-3-2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
activity_model
|
ActivityModel
|
Excess-Gibbs model compatible with the HV infinite-pressure reference. |
required |
delta1
|
float
|
Distinct generalized-cubic denominator-shape constants. |
required |
delta2
|
float
|
Distinct generalized-cubic denominator-shape constants. |
required |
Source code in src/torch_flash/mixing/rules.py
forward
¶
forward(
temperature: Tensor,
composition: Tensor,
pure_a: Tensor,
pure_b: Tensor,
) -> tuple[Tensor, Tensor]
Return mixture a and b parameters.
Source code in src/torch_flash/mixing/rules.py
PPR78Mixing
¶
PPR78Mixing(
group_fractions: Tensor,
group_a: Tensor,
group_b: Tensor,
*,
reference_temperature: float = 298.15,
trainable: bool = False,
parameter_set: str | None = None,
)
Bases: Module
Predictive PR78 group-contribution attraction mixing.
This is Eq. (5) of Jaubert and Mutelet (2004), doi:10.1016/j.fluid.2004.06.059. For component group fractions \(\alpha_{ik}\), the method evaluates
group_a and group_b are symmetric pressure-valued group
interaction matrices. Only their unique off-diagonal entries are stored,
avoiding redundant degrees of freedom during fitting. The paper derives
the correlation with the conventional linear covolume rule, which this
class preserves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group_fractions
|
Tensor
|
Normalized component-by-group fraction matrix. |
required |
group_a
|
Tensor
|
Symmetric pressure-valued universal interaction matrices in Pa. |
required |
group_b
|
Tensor
|
Symmetric pressure-valued universal interaction matrices in Pa. |
required |
reference_temperature
|
float
|
Positive correlation reference temperature in K. |
298.15
|
trainable
|
bool
|
Register unique off-diagonal group interactions as trainable parameters. |
False
|
parameter_set
|
str | None
|
Optional source parameter-set identifier. |
None
|
Source code in src/torch_flash/mixing/rules.py
group_interaction_energy
¶
Return :math:A_{kl}(298.15/T)^{B_{kl}/A_{kl}-1} in pascals.
Source code in src/torch_flash/mixing/rules.py
kij
¶
Evaluate the symmetric component BIP matrix.
pure_a and pure_b must be the PR78 pure-component parameters
at temperature. This dependence is essential: PPR78 is not a
standalone A + B/T law.
Source code in src/torch_flash/mixing/rules.py
cross_a
¶
Return PPR78 unlike attraction parameters.
Source code in src/torch_flash/mixing/rules.py
partial_b
¶
Return partial covolumes for the PPR78 linear covolume rule.
forward
¶
forward(
temperature: Tensor,
composition: Tensor,
pure_a: Tensor,
pure_b: Tensor,
) -> tuple[Tensor, Tensor]
Return PPR78 mixture a and linear mixture b.
Source code in src/torch_flash/mixing/rules.py
QuadraticMixing
¶
QuadraticMixing(
kij: Tensor,
lij: Tensor | None = None,
*,
trainable: bool = False,
trainable_lij: bool = False,
)
Bases: Module
van der Waals one-fluid mixing with kij and lij parameters.
The unlike attraction and covolume parameters are
aij = sqrt(ai*aj)*(1-kij) and
bij = 0.5*(bi+bj)*(1-lij), respectively.
lij=0 recovers the conventional linear covolume rule exactly and uses
a dedicated O(N) evaluation path.
This convention is also exposed by ThermoPack's get_lij/set_lij
cubic interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kij
|
Tensor
|
Symmetric dimensionless attraction-interaction matrix. |
required |
lij
|
Tensor | None
|
Optional symmetric 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
|
Source code in src/torch_flash/mixing/rules.py
forward
¶
forward(
temperature: Tensor,
composition: Tensor,
pure_a: Tensor,
pure_b: Tensor,
) -> tuple[Tensor, Tensor]
Return mixture a and b parameters.
Source code in src/torch_flash/mixing/rules.py
cross_a
¶
cross_b
¶
partial_b
¶
Return partial molar covolumes d(n*b_mix)/d(n_i).
Source code in src/torch_flash/mixing/rules.py
TemperatureDependentQuadraticMixing
¶
TemperatureDependentQuadraticMixing(
a: Tensor,
b: Tensor,
lij: Tensor | None = None,
*,
trainable: bool = False,
trainable_lij: bool = False,
)
Bases: Module
van der Waals mixing with kij(T) = Aij + Bij/T.
Aij is dimensionless and Bij is in kelvin. This form is used by
Yan et al. for petroleum CPA calculations involving light hydrocarbons
and water (Fluid Phase Equilibria 276, 2009, 75-85,
doi:10.1016/j.fluid.2008.10.007).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Tensor
|
Symmetric dimensionless |
required |
b
|
Tensor
|
Symmetric |
required |
lij
|
Tensor | None
|
Optional symmetric 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
|
Source code in src/torch_flash/mixing/rules.py
kij
¶
Evaluate the interaction matrix at temperature in kelvin.
Source code in src/torch_flash/mixing/rules.py
forward
¶
forward(
temperature: Tensor,
composition: Tensor,
pure_a: Tensor,
pure_b: Tensor,
) -> tuple[Tensor, Tensor]
Return mixture a and b parameters.
Source code in src/torch_flash/mixing/rules.py
cross_a
¶
Return temperature-dependent unlike energy parameters.
cross_b
¶
partial_b
¶
Return partial molar covolumes d(n*b_mix)/d(n_i).