Transport properties¶
torch_flash.transport
¶
Transport-property correlations.
HeavyOilCSPCalibrationResult
dataclass
¶
HeavyOilCSPCalibrationResult(
third_csp: Tensor,
fourth_csp: Tensor,
prediction: Tensor,
fit: FitResult,
sensitivity_matrix: Tensor,
sensitivity_singular_values: Tensor,
sensitivity_rank: int,
sensitivity_condition_number: float,
)
Joint bounded calibration of the two Lindeloff CSP factors.
Attributes:
| Name | Type | Description |
|---|---|---|
third_csp, fourth_csp |
Selected positive dimensionless factors in Pedersen et al. (2024), Eqs. 10.34-10.35. |
|
prediction |
Tensor
|
Fitted dynamic viscosities in Pa s at every calibration state. |
fit |
FitResult
|
PyTorch optimizer history and stopping diagnostics. |
sensitivity_matrix |
Tensor
|
Jacobian of log viscosity with respect to the two physical factors,
with shape |
sensitivity_singular_values |
Tensor
|
Singular values of the sensitivity matrix. |
sensitivity_rank |
int
|
Dtype-aware numerical rank. |
sensitivity_condition_number |
float
|
Largest-to-smallest singular-value ratio, or infinity for a rank-deficient calibration. |
Notes
Agreement with the supplied observations is calibration evidence, not independent validation.
HeavyOilCSPProfile
dataclass
¶
HeavyOilCSPProfile(
viscosity: Tensor,
liquid_composition: Tensor,
bubble_pressure: Tensor,
vapor_fraction: Tensor,
converged: Tensor,
residual_norm: Tensor,
)
Phase-aware heavy-oil viscosity states and numerical diagnostics.
Attributes:
| Name | Type | Description |
|---|---|---|
viscosity |
Tensor
|
Dynamic viscosity in Pa s, one value per requested state. |
liquid_composition |
Tensor
|
Feed composition above the bubble point and equilibrium liquid
composition below it, with shape |
bubble_pressure |
Tensor
|
Bubble pressure in Pa at the corresponding state temperature. |
vapor_fraction |
Tensor
|
Equilibrium vapor fraction below the bubble point and zero above it. |
converged |
Tensor
|
Per-state phase-boundary and sub-bubble flash convergence flag. |
residual_norm |
Tensor
|
Maximum dimensionless log-fugacity residual for each sub-bubble flash; zero for homogeneous states above the bubble point. |
hayduk_minhas_n_paraffin_diffusion_coefficient
¶
hayduk_minhas_n_paraffin_diffusion_coefficient(
temperature: Tensor,
dynamic_viscosity: Tensor,
solute_molar_volume: Tensor,
) -> Tensor
Estimate infinite-dilution n-paraffin diffusion in an n-paraffin liquid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Liquid temperature in K. |
required |
dynamic_viscosity
|
Tensor
|
Solvent or bulk-phase dynamic viscosity in Pa s. |
required |
solute_molar_volume
|
Tensor
|
Diffusing solute molar volume at its normal boiling point in m3/mol. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Diffusion coefficient in m2/s with the broadcast input shape. |
Raises:
| Type | Description |
|---|---|
InvalidStateError
|
If any input is nonfinite or nonpositive. |
Notes
Implements Hayduk and Minhas, "Correlations for prediction of molecular diffusivities in liquids," Canadian Journal of Chemical Engineering 60 (1982), 295-299, doi:10.1002/cjce.5450600213, normal-paraffin correlation, as reproduced in Pedersen et al. (2024), Eq. 10.100. The defining equation uses solvent viscosity in cP and solute normal-boiling molar volume in cm3/mol; this SI API performs both conversions. It applies to infinite-dilution n-paraffin solutes in n-paraffin solvents, not concentrated multicomponent diffusion.
Source code in src/torch_flash/transport/diffusion.py
evaluate_heavy_oil_corresponding_states_profile
¶
evaluate_heavy_oil_corresponding_states_profile(
model: StateModel,
temperature: Tensor,
pressure: Tensor,
feed_composition: Tensor,
components: ComponentSet,
*,
third_csp: Tensor | float = 1.0,
fourth_csp: Tensor | float = 1.0,
initial_bubble_pressure: Tensor | float | None = None,
tolerance: float = 1e-08,
saturation_iterations: int = 50,
substitution_iterations: int = 20,
newton_iterations: int = 20,
raise_on_failure: bool = True,
) -> HeavyOilCSPProfile
Evaluate a phase-aware live-heavy-oil viscosity pressure profile.
A liquid-vapor bubble point is solved once per unique temperature. States
at or above that boundary retain the feed composition. All sub-bubble
states at the same temperature are flashed simultaneously with
:func:torch_flash.batched_two_phase_flash, and their equilibrium liquid
compositions are passed in one batch to the heavy-oil CSP correlation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
StateModel
|
Homogeneous-state fugacity model used for bubble points and flashes. |
required |
temperature
|
Tensor
|
One-dimensional state batches in K and Pa with matching shapes. |
required |
pressure
|
Tensor
|
One-dimensional state batches in K and Pa with matching shapes. |
required |
feed_composition
|
Tensor
|
One strictly positive feed mole-fraction vector. |
required |
components
|
ComponentSet
|
Transport critical properties and molar masses in the same order as the model and feed. |
required |
third_csp
|
Tensor | float
|
Dimensionless Lindeloff calibration factors. Tensor inputs preserve gradients through the viscosity calculation. |
1.0
|
fourth_csp
|
Tensor | float
|
Dimensionless Lindeloff calibration factors. Tensor inputs preserve gradients through the viscosity calculation. |
1.0
|
initial_bubble_pressure
|
Tensor | float | None
|
Optional positive scalar pressure estimate in Pa reused at each temperature. Wilson initialization is used when omitted. |
None
|
tolerance
|
float
|
Dimensionless bubble-point and log-fugacity tolerance. |
1e-08
|
saturation_iterations
|
int
|
Maximum iterations for each bubble-point solve. |
50
|
substitution_iterations
|
int
|
Batched sub-bubble flash iteration limits. |
20
|
newton_iterations
|
int
|
Batched sub-bubble flash iteration limits. |
20
|
raise_on_failure
|
bool
|
Raise :class: |
True
|
Returns:
| Type | Description |
|---|---|
HeavyOilCSPProfile
|
Phase compositions, viscosities, and convergence diagnostics. |
Raises:
| Type | Description |
|---|---|
ValueError:
|
If shapes, component order, or numerical controls are invalid. |
InvalidStateError:
|
If state values or the feed are nonphysical. |
ConvergenceError:
|
If a bubble point or sub-bubble flash fails and
|
Notes
The viscosity formulation is Lindeloff et al., "The Corresponding States Viscosity Model Applied to Heavy Oil Systems" (2004), Paper 2003-150, through Pedersen, Christensen, and Shaikh (2024), section 10.1.2, doi:10.1201/9780429457418. Phase equilibrium is a separate cubic-EoS calculation; its model and characterization parameter set must therefore be reported with any result.
Source code in src/torch_flash/transport/heavy_oil.py
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 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 | |
fit_heavy_oil_csp_factors
¶
fit_heavy_oil_csp_factors(
temperature: Tensor,
pressure: Tensor,
liquid_composition: Tensor,
components: ComponentSet,
observed_viscosity: Tensor,
*,
initial_factors: tuple[float, float] = (1.0, 1.0),
factor_bounds: tuple[float, float] = (0.1, 5.0),
optimizer: OptimizerKind = "lbfgs",
learning_rate: float = 0.3,
max_iterations: int = 200,
tolerance: float = 1e-10,
no_improvement_patience: int = 30,
) -> HeavyOilCSPCalibrationResult
Fit both heavy-oil CSP factors to all supplied states simultaneously.
The full-batch objective is the mean squared logarithmic viscosity ratio, so every experimental point contributes in every optimizer step without a unit-dependent scale. Physical factors are smoothly bounded with a sigmoid transform. PyTorch supplies optimizer gradients and the final local sensitivity matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
State batches in K and Pa. |
required |
pressure
|
Tensor
|
State batches in K and Pa. |
required |
liquid_composition
|
Tensor
|
Feed or equilibrium liquid composition for every state, with components on the final axis. |
required |
components
|
ComponentSet
|
Critical properties and molar masses in matching order. |
required |
observed_viscosity
|
Tensor
|
Positive experimental dynamic viscosities in Pa s. |
required |
initial_factors
|
tuple[float, float]
|
Initial third and fourth CSP factors. |
(1.0, 1.0)
|
factor_bounds
|
tuple[float, float]
|
Shared positive lower and upper bounds for both factors. |
(0.1, 5.0)
|
optimizer
|
OptimizerKind
|
PyTorch optimizer identifier. Full-batch LBFGS with strong-Wolfe line search is the default for this two-parameter smooth problem. |
'lbfgs'
|
learning_rate
|
float
|
Optimizer learning rate. |
0.3
|
max_iterations
|
int
|
Maximum optimizer steps; the default is 200. |
200
|
tolerance
|
float
|
Relative successive-loss stopping tolerance. |
1e-10
|
no_improvement_patience
|
int
|
Early-stop patience; the default is 30 evaluated iterates. |
30
|
Returns:
| Type | Description |
|---|---|
HeavyOilCSPCalibrationResult
|
Selected factors, fitted predictions, history, and identifiability diagnostics. |
Raises:
| Type | Description |
|---|---|
ValueError:
|
If shapes, bounds, factors, or optimizer controls are invalid. |
InvalidStateError:
|
If observations are nonpositive or nonfinite. |
Notes
The fitted factors are the multipliers in Pedersen, Christensen, and Shaikh (2024), Eqs. 10.34-10.35, doi:10.1201/9780429457418. Lindeloff et al. (2004), Paper 2003-150, likewise fit both factors to all three Oil 5 temperature series simultaneously. This API does not refit the phase-equilibrium model.
Source code in src/torch_flash/transport/heavy_oil.py
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 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 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | |
brock_bird_surface_tension
¶
brock_bird_surface_tension(
temperature: Tensor,
critical_temperature: Tensor,
critical_pressure: Tensor,
normal_boiling_temperature: Tensor,
) -> Tensor
Evaluate Brock-Bird pure nonpolar-fluid surface tension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperatures in K. |
required |
critical_temperature
|
Tensor
|
Temperatures in K. |
required |
normal_boiling_temperature
|
Tensor
|
Temperatures in K. |
required |
critical_pressure
|
Tensor
|
Critical pressure in Pa. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Surface tension in N/m. |
Raises:
| Type | Description |
|---|---|
InvalidStateError
|
If the state is not below the critical temperature or the defining properties are nonphysical. |
Notes
Implements Brock and Bird, "Surface Tension and the Principle of Corresponding States," AIChE Journal 1 (1955), 174-177, through Pedersen et al. (2024), Eqs. 10.77-10.79. The published numerical equation yields dyn/cm from K and atm; the result is converted to N/m.
Source code in src/torch_flash/transport/interfacial_tension.py
lee_chien_interfacial_tension
¶
lee_chien_interfacial_tension(
liquid_molar_density: Tensor,
vapor_molar_density: Tensor,
liquid_composition: Tensor,
vapor_composition: Tensor,
components: ComponentSet,
riedel_parameters: Tensor,
b_parameters: Tensor,
) -> Tensor
Evaluate the Lee-Chien phase-parachor interfacial tension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
liquid_molar_density
|
Tensor
|
Coexisting molar densities in mol/m3. |
required |
vapor_molar_density
|
Tensor
|
Coexisting molar densities in mol/m3. |
required |
liquid_composition
|
Tensor
|
Phase mole fractions with components on the final axis. |
required |
vapor_composition
|
Tensor
|
Phase mole fractions with components on the final axis. |
required |
components
|
ComponentSet
|
Critical temperatures, pressures, and molar volumes. |
required |
riedel_parameters
|
Tensor
|
Dimensionless per-component Riedel parameters. |
required |
b_parameters
|
Tensor
|
Per-component Lee-Chien |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Interfacial tension in N/m. |
Notes
Implements Lee and Chien, SPE-12643-MS (1984), through Pedersen et al.
(2024), Eqs. 10.86-10.97. The bundled B table is deliberately limited
to the eight components reproduced in Pedersen Table 10.20; additional
components require explicit values. C7+ whole-fraction construction is a
characterization step and is not inferred silently.
Source code in src/torch_flash/transport/interfacial_tension.py
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 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | |
parachor_from_molar_mass
¶
Estimate a C7+ petroleum-fraction parachor from molar mass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
molar_mass
|
Tensor
|
Fraction molar mass in kg/mol. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Parachor in the Weinaug-Katz |
Notes
Implements Pedersen et al. (2024), Eq. 10.85. This is a petroleum pseudo-component correlation, not a replacement for published pure-component parachors.
Source code in src/torch_flash/transport/interfacial_tension.py
published_lee_chien_b
¶
Return Lee-Chien B values reproduced in Pedersen Table 10.20.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
Sequence[str]
|
Canonical component names in the desired output order. |
required |
like
|
Tensor
|
Tensor supplying output dtype and device. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
One dimensionless Lee-Chien |
Raises:
| Type | Description |
|---|---|
KeyError
|
If a component lies outside the eight-component published table. Explicit user-supplied values are required for additional compounds. |
Notes
The coefficients are reproduced from Pedersen, Christensen, and Shaikh, Phase Behavior of Petroleum Reservoir Fluids, 3rd ed. (2024), Table 10.20, doi:10.1201/9780429457418. The defining correlation is Lee and Chien, SPE-12643-MS (1984), doi:10.2118/12643-MS.
Source code in src/torch_flash/transport/interfacial_tension.py
published_parachors
¶
Return the Pedersen Table 10.19 parachors for supported components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
Sequence[str]
|
Canonical component names in the desired output order. |
required |
like
|
Tensor
|
Tensor supplying output dtype and device. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
One published component parachor per name, in conventional
|
Raises:
| Type | Description |
|---|---|
KeyError
|
If any component is outside the published table. Callers may instead
provide explicit parachors or use :func: |
Notes
Values are reproduced from Pedersen, Christensen, and Shaikh, Phase Behavior of Petroleum Reservoir Fluids, 3rd ed. (2024), Table 10.19, doi:10.1201/9780429457418.
Source code in src/torch_flash/transport/interfacial_tension.py
riedel_parameter
¶
riedel_parameter(
normal_boiling_temperature: Tensor,
critical_temperature: Tensor,
critical_pressure: Tensor,
) -> Tensor
Return the dimensionless Riedel parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
normal_boiling_temperature
|
Tensor
|
Normal boiling and critical temperatures in K. |
required |
critical_temperature
|
Tensor
|
Normal boiling and critical temperatures in K. |
required |
critical_pressure
|
Tensor
|
Critical pressure in Pa. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dimensionless Riedel parameter. |
Notes
Implements Pedersen et al. (2024), Eq. 10.79, from Riedel (1954). The numerical form uses critical pressure in atm internally.
Source code in src/torch_flash/transport/interfacial_tension.py
weinaug_katz_interfacial_tension
¶
weinaug_katz_interfacial_tension(
liquid_molar_density: Tensor,
vapor_molar_density: Tensor,
liquid_composition: Tensor,
vapor_composition: Tensor,
parachor: Tensor,
*,
liquid_mass_density: Tensor | None = None,
vapor_mass_density: Tensor | None = None,
danesh_exponent: bool = False,
) -> Tensor
Evaluate Weinaug-Katz gas-oil interfacial tension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
liquid_molar_density
|
Tensor
|
Coexisting phase molar densities in mol/m3. |
required |
vapor_molar_density
|
Tensor
|
Coexisting phase molar densities in mol/m3. |
required |
liquid_composition
|
Tensor
|
Phase mole fractions with components on the final axis. |
required |
vapor_composition
|
Tensor
|
Phase mole fractions with components on the final axis. |
required |
parachor
|
Tensor
|
Component parachors in the conventional
|
required |
liquid_mass_density
|
Tensor | None
|
Optional phase mass densities in kg/m3 required by the Danesh gas-condensate exponent. |
None
|
vapor_mass_density
|
Tensor | None
|
Optional phase mass densities in kg/m3 required by the Danesh gas-condensate exponent. |
None
|
danesh_exponent
|
bool
|
Use Pedersen Eq. 10.98 instead of the fixed one-quarter exponent. |
False
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Interfacial tension in N/m. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If component dimensions disagree or Danesh densities are absent. |
InvalidStateError
|
If phase densities are nonphysical. |
Notes
Implements the Macleod-Sugden/Weinaug-Katz relation as reproduced in Pedersen et al. (2024), Eqs. 10.83-10.85. The optional Danesh et al. modification follows Eq. 10.98. This operation requires an already solved pair of coexisting phases and does not identify or flash phases.
Source code in src/torch_flash/transport/interfacial_tension.py
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 | |
corresponding_states_thermal_conductivity
¶
corresponding_states_thermal_conductivity(
temperature: Tensor,
pressure: Tensor,
composition: Tensor,
components: ComponentSet,
ideal_gas: HeatCapacityModel,
methane_ideal_gas: HeatCapacityModel,
*,
phase: Literal["liquid", "vapor"] = "vapor",
) -> Tensor
Evaluate the Christensen-Fredenslund mixture thermal conductivity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Positive state variables in K and Pa. |
required |
pressure
|
Tensor
|
Positive state variables in K and Pa. |
required |
composition
|
Tensor
|
Mole fractions with components on the final axis. |
required |
components
|
ComponentSet
|
Critical properties and molar masses matching |
required |
ideal_gas
|
HeatCapacityModel
|
Component ideal-gas heat-capacity model for the mixture. |
required |
methane_ideal_gas
|
HeatCapacityModel
|
One-component methane ideal-gas heat-capacity model. |
required |
phase
|
Literal['liquid', 'vapor']
|
Methane BWR reference-density branch. |
'vapor'
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Mixture thermal conductivity in W/(m K). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If composition or heat-capacity component dimensions disagree. |
InvalidStateError
|
If the model produces a nonpositive result. |
Notes
Implements Christensen and Fredenslund, "A corresponding states model for the thermal conductivity of gases and liquids," Chemical Engineering Science 35 (1980), 871-875, and Pedersen et al. (2024), Eqs. 10.59-10.74. As specified for mixtures, the pure-fluid critical enhancement is omitted. The model requires homogeneous phase identity; it does not perform a flash.
Source code in src/torch_flash/transport/thermal_conductivity.py
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 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 | |
methane_critical_thermal_conductivity_enhancement
¶
methane_critical_thermal_conductivity_enhancement(
temperature: Tensor, density_mol_l: Tensor
) -> Tensor
Return the methane critical thermal-conductivity enhancement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Methane temperature in K. |
required |
density_mol_l
|
Tensor
|
Methane molar density in mol/L. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Critical enhancement in W/(m K). |
Raises:
| Type | Description |
|---|---|
InvalidStateError
|
If the supplied state is nonpositive or has nonpositive isothermal compressibility. |
Notes
Implements Hanley, McCarty, and Haynes, Cryogenics 15 (1975),
Appendix C, Eqs. 10-17, doi:10.1016/0011-2275(75)90010-7. The
Vicentini-Missoni scaling form replaces the BWR compressibility only
inside |T-Tc|/Tc <= 0.025 and |rho-rhoc|/rhoc <= 0.25. The
correlation is singular at the mathematical critical point.
Source code in src/torch_flash/transport/thermal_conductivity.py
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 | |
methane_thermal_conductivity
¶
methane_thermal_conductivity(
temperature: Tensor,
density_mol_l: Tensor,
*,
include_critical_enhancement: bool = True,
) -> Tensor
Evaluate the Hanley methane reference thermal conductivity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Methane temperature in K. |
required |
density_mol_l
|
Tensor
|
Methane molar density in mol/L. |
required |
include_critical_enhancement
|
bool
|
Include the pure-fluid critical anomaly from Hanley Appendix C. |
True
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Thermal conductivity in W/(m K). |
Notes
The background implements Pedersen et al. (2024), Eqs. 10.69-10.74,
doi:10.1201/9780429457418-10. GT(9)=5.311764e-2 follows the primary
Hanley table, doi:10.1016/0011-2275(75)90010-7. The critical term is a
pure-methane correction and is excluded from the mixture model as directed
by Pedersen section 10.2.
Source code in src/torch_flash/transport/thermal_conductivity.py
corresponding_states_viscosity
¶
corresponding_states_viscosity(
temperature: Tensor,
pressure: Tensor,
composition: Tensor,
components: ComponentSet,
*,
phase: Literal["liquid", "vapor"] = "vapor",
) -> Tensor
Evaluate the Pedersen corresponding-states mixture viscosity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Positive temperature in K with arbitrary leading batch dimensions. |
required |
pressure
|
Tensor
|
Positive pressure in Pa, broadcastable with the state/composition batch. |
required |
composition
|
Tensor
|
Mole fractions with components on the final axis. |
required |
components
|
ComponentSet
|
Ordered critical-property and molar-mass data matching |
required |
phase
|
Literal['liquid', 'vapor']
|
Methane-reference density root, |
'vapor'
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Mixture dynamic viscosity in Pa s with the broadcast batch shape. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the composition has no component axis or its component count
differs from |
InvalidStateError
|
If a required methane reference-state density cannot be solved. |
Notes
This is a homogeneous-phase correlation and does not perform phase equilibrium. Supply the composition and phase root returned by the relevant state or flash calculation.
Source code in src/torch_flash/transport/viscosity.py
friction_theory_viscosity
¶
friction_theory_viscosity(
temperature: Tensor,
pressure: Tensor,
composition: Tensor,
eos: CubicEOS,
*,
phase: PhaseKind = "stable",
critical_viscosity: Tensor | None = None,
critical_volume: Tensor | None = None,
) -> Tensor
Evaluate the one-parameter friction-theory cubic-EOS viscosity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Positive state variables in K and Pa. |
required |
pressure
|
Tensor
|
Positive state variables in K and Pa. |
required |
composition
|
Tensor
|
Nonpolar-fluid mole fractions with components on the final axis. |
required |
eos
|
CubicEOS
|
Native SRK or PR76 :class: |
required |
phase
|
PhaseKind
|
Cubic root selection for the supplied homogeneous state. |
'stable'
|
critical_viscosity
|
Tensor | None
|
Optional characteristic component viscosities in Pa s. When omitted, the n-alkane correlation of Eq. 21 is used. |
None
|
critical_volume
|
Tensor | None
|
Optional component critical volumes in m3/mol for the Chung dilute-gas term. Defaults to the component database. |
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Dynamic viscosity in Pa s for each broadcast state. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the EOS is not the published SRK or PR76 family, or component vectors have inconsistent shapes. |
InvalidStateError
|
If a required volume or state is nonphysical or the result is nonpositive. |
Notes
Implements Quiñones-Cisneros, Zéberg-Mikkelsen, and Stenby, "One parameter friction theory models for viscosity," Fluid Phase Equilibria 178 (2001), Eqs. 1-30 and Tables 1-2, doi:10.1016/S0378-3812(00)00474-X. The parameterization was developed for nonpolar fluids and n-alkane mixtures. PR78 and PRSV alpha functions are not silently identified with the paper's PR76 model.
Source code in src/torch_flash/transport/viscosity.py
906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 | |
heavy_oil_corresponding_states_viscosity
¶
heavy_oil_corresponding_states_viscosity(
temperature: Tensor,
pressure: Tensor,
composition: Tensor,
components: ComponentSet,
*,
phase: Literal["liquid", "vapor"] = "liquid",
third_csp: Tensor | float = 1.0,
fourth_csp: Tensor | float = 1.0,
) -> Tensor
Evaluate the blended corresponding-states heavy-oil viscosity model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Positive SI state variables in K and Pa. |
required |
pressure
|
Tensor
|
Positive SI state variables in K and Pa. |
required |
composition
|
Tensor
|
Mole fractions with components on the final axis. |
required |
components
|
ComponentSet
|
Critical properties and molar masses in the same order. |
required |
phase
|
Literal['liquid', 'vapor']
|
Methane-reference BWR density branch. |
'liquid'
|
third_csp
|
Tensor | float
|
Dimensionless Lindeloff tuning factors. |
1.0
|
fourth_csp
|
Tensor | float
|
Dimensionless Lindeloff tuning factors. |
1.0
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Dynamic viscosity in Pa s over the broadcast state/composition batch. |
Notes
Pedersen et al. (2024), section 10.1.2, retains the conventional corresponding-states result above a methane reference temperature of 75 K, uses the Lindeloff branch below 65 K, and linearly blends the two between 65 and 75 K. Calibration factors are explicit tensors so fitting preserves PyTorch gradients.
Source code in src/torch_flash/transport/viscosity.py
kinematic_viscosity
¶
Return kinematic viscosity from dynamic viscosity and mass density.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynamic_viscosity
|
Tensor
|
Dynamic viscosity in Pa s. |
required |
mass_density
|
Tensor
|
Homogeneous-phase mass density in kg/m3, broadcastable with
|
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Kinematic viscosity in m2/s with the broadcast input shape. |
Raises:
| Type | Description |
|---|---|
InvalidStateError
|
If viscosity is negative or either input is nonfinite or density is nonpositive. |
Notes
This is the SI definition in Pedersen et al. (2024), section 10.1, rather than an equilibrium or empirical transport model.
Source code in src/torch_flash/transport/viscosity.py
lbc_pseudocomponent_critical_volume
¶
lbc_pseudocomponent_critical_volume(
molar_mass: Tensor, standard_liquid_density: Tensor
) -> Tensor
Estimate a C7+ critical molar volume from Pedersen Eq. 10.41.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
molar_mass
|
Tensor
|
Pseudo-component molar mass in kg/mol. |
required |
standard_liquid_density
|
Tensor
|
Standard liquid mass density in kg/m3. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Estimated critical molar volume in m3/mol. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If either input is nonfinite or nonpositive. |
Notes
Parameters are SI: molar mass in kg/mol and liquid density in kg/m3. The returned critical molar volume is in m3/mol. The underlying empirical equation uses g/mol, g/cm3, and ft3/lbmol.
Source code in src/torch_flash/transport/viscosity.py
lbc_viscosity
¶
lbc_viscosity(
temperature: Tensor,
molar_density: Tensor,
composition: Tensor,
components: ComponentSet,
*,
critical_volume: Tensor | None = None,
coefficients: Tensor | None = None,
) -> Tensor
Return Lohrenz-Bray-Clark mixture viscosity in Pa s.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
molar_density
|
Tensor
|
Homogeneous-phase molar density in mol/m3, normally obtained from the same EoS used by the flash calculation. |
required |
composition
|
Tensor
|
Mole fractions with components on the final axis. |
required |
components
|
ComponentSet
|
Critical temperatures, pressures, molar masses, and volumes. |
required |
critical_volume
|
Tensor | None
|
Optional m3/mol values overriding the component data. This is the principal LBC tuning parameter for petroleum pseudocomponents. |
None
|
coefficients
|
Tensor | None
|
Optional trainable or fitted |
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Mixture dynamic viscosity in Pa s. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If component shapes, critical volumes, or coefficient tensors are inconsistent. |
InvalidStateError
|
If temperature/density or a required reducing property is outside its physical domain. |
Notes
The Stiel-Thodos reducing parameters use K, atm, and g/mol, as required by the published numerical constants. LBC is empirical and often needs pseudocomponent critical-volume or coefficient tuning for heavy oils.
Source code in src/torch_flash/transport/viscosity.py
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 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 | |
lee_gas_viscosity
¶
Evaluate the Lee-Gonzalez-Eakin natural-gas viscosity correlation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Gas temperature in K. |
required |
mass_density
|
Tensor
|
Gas mass density in kg/m3. |
required |
molar_mass
|
Tensor
|
Mixture molar mass in kg/mol. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dynamic viscosity in Pa s with the broadcast input shape. |
Raises:
| Type | Description |
|---|---|
InvalidStateError
|
If temperature or molar mass is nonpositive, density is negative, or any input or output is nonfinite. |
Notes
Implements Lee, Gonzalez, and Eakin, "The Viscosity of Natural Gases," J. Petroleum Technology 18 (1966), 997-1000, doi:10.2118/1340-PA, as reproduced in Pedersen et al. (2024), Eqs. 10.46-10.49. The published equation uses degrees Rankine, lb/ft3, g/mol, and cP; this API converts SI inputs and returns SI viscosity. It is a gas correlation and is not valid for a condensed liquid phase.
Source code in src/torch_flash/transport/viscosity.py
methane_viscosity
¶
Return methane dynamic viscosity in Pa s from Eq. 10.6.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
density_mol_l
|
Tensor
|
Methane molar density in mol/L. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Dynamic viscosity in Pa s. |
Notes
Although the 2024 textbook prose labels the correlation density as mol/L, the published Hanley coefficients require mass density in kg/L (numerically equal to g/cm3). Using molar density inside the fractional powers produces viscosities two orders of magnitude too large at reservoir pressures.
Source code in src/torch_flash/transport/viscosity.py
stabilized_heavy_oil_viscosity
¶
stabilized_heavy_oil_viscosity(
temperature: Tensor,
pressure: Tensor,
number_average_molar_mass: Tensor,
weight_average_molar_mass: Tensor,
*,
third_csp: Tensor | float = 1.0,
fourth_csp: Tensor | float = 1.0,
) -> Tensor
Evaluate the Lindeloff stabilized/live-heavy-oil viscosity branch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
Tensor
|
Temperature in K. |
required |
pressure
|
Tensor
|
Pressure in Pa. |
required |
number_average_molar_mass
|
Tensor
|
Mixture molecular-weight averages in kg/mol. |
required |
weight_average_molar_mass
|
Tensor
|
Mixture molecular-weight averages in kg/mol. |
required |
third_csp
|
Tensor | float
|
Dimensionless fitted factors in Pedersen et al. (2024), Eqs. 10.34-10.36. Defaults reproduce the published predictive branch. |
1.0
|
fourth_csp
|
Tensor | float
|
Dimensionless fitted factors in Pedersen et al. (2024), Eqs. 10.34-10.36. Defaults reproduce the published predictive branch. |
1.0
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Dynamic viscosity in Pa s. |
Raises:
| Type | Description |
|---|---|
InvalidStateError
|
If the state or molecular-weight averages are outside their physical domains, or the correlation returns a nonfinite result. |
Notes
Implements Lindeloff et al., "The corresponding states viscosity model
applied to heavy oil systems," J. Can. Petroleum Technology 43 (2004),
47-53, through Pedersen et al. (2024), Eqs. 10.33-10.37. This function is
the empirical heavy-oil branch only; use
:func:heavy_oil_corresponding_states_viscosity for the published
low-reference-temperature blending protocol.
Source code in src/torch_flash/transport/viscosity.py
663 664 665 666 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 748 749 750 751 752 753 754 755 756 757 758 759 | |