fugacio-thermo 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. fugacio_thermo-0.0.1/.gitignore +32 -0
  2. fugacio_thermo-0.0.1/PKG-INFO +130 -0
  3. fugacio_thermo-0.0.1/README.md +115 -0
  4. fugacio_thermo-0.0.1/pyproject.toml +33 -0
  5. fugacio_thermo-0.0.1/src/fugacio/thermo/__init__.py +615 -0
  6. fugacio_thermo-0.0.1/src/fugacio/thermo/_binary_params.py +461 -0
  7. fugacio_thermo-0.0.1/src/fugacio/thermo/_eos_params.py +169 -0
  8. fugacio_thermo-0.0.1/src/fugacio/thermo/_formation_data.py +115 -0
  9. fugacio_thermo-0.0.1/src/fugacio/thermo/_property_data.py +2812 -0
  10. fugacio_thermo-0.0.1/src/fugacio/thermo/activity/__init__.py +118 -0
  11. fugacio_thermo-0.0.1/src/fugacio/thermo/activity/margules.py +65 -0
  12. fugacio_thermo-0.0.1/src/fugacio/thermo/activity/models.py +335 -0
  13. fugacio_thermo-0.0.1/src/fugacio/thermo/activity/nrtl.py +76 -0
  14. fugacio_thermo-0.0.1/src/fugacio/thermo/activity/regular_solution.py +100 -0
  15. fugacio_thermo-0.0.1/src/fugacio/thermo/activity/uniquac.py +78 -0
  16. fugacio_thermo-0.0.1/src/fugacio/thermo/activity/vanlaar.py +44 -0
  17. fugacio_thermo-0.0.1/src/fugacio/thermo/activity/wilson.py +68 -0
  18. fugacio_thermo-0.0.1/src/fugacio/thermo/components.py +6465 -0
  19. fugacio_thermo-0.0.1/src/fugacio/thermo/consistency.py +94 -0
  20. fugacio_thermo-0.0.1/src/fugacio/thermo/constants.py +63 -0
  21. fugacio_thermo-0.0.1/src/fugacio/thermo/correlations.py +235 -0
  22. fugacio_thermo-0.0.1/src/fugacio/thermo/data.py +182 -0
  23. fugacio_thermo-0.0.1/src/fugacio/thermo/departure.py +200 -0
  24. fugacio_thermo-0.0.1/src/fugacio/thermo/diffcheck.py +55 -0
  25. fugacio_thermo-0.0.1/src/fugacio/thermo/energy.py +276 -0
  26. fugacio_thermo-0.0.1/src/fugacio/thermo/eos.py +348 -0
  27. fugacio_thermo-0.0.1/src/fugacio/thermo/equilibrium.py +385 -0
  28. fugacio_thermo-0.0.1/src/fugacio/thermo/gammaphi.py +481 -0
  29. fugacio_thermo-0.0.1/src/fugacio/thermo/groupcontrib/__init__.py +37 -0
  30. fugacio_thermo-0.0.1/src/fugacio/thermo/groupcontrib/_dortmund_data.py +1007 -0
  31. fugacio_thermo-0.0.1/src/fugacio/thermo/groupcontrib/_unifac_data.py +959 -0
  32. fugacio_thermo-0.0.1/src/fugacio/thermo/groupcontrib/dortmund.py +147 -0
  33. fugacio_thermo-0.0.1/src/fugacio/thermo/groupcontrib/joback.py +146 -0
  34. fugacio_thermo-0.0.1/src/fugacio/thermo/groupcontrib/unifac.py +152 -0
  35. fugacio_thermo-0.0.1/src/fugacio/thermo/helmholtz/__init__.py +140 -0
  36. fugacio_thermo-0.0.1/src/fugacio/thermo/helmholtz/_data.py +2595 -0
  37. fugacio_thermo-0.0.1/src/fugacio/thermo/helmholtz/density.py +121 -0
  38. fugacio_thermo-0.0.1/src/fugacio/thermo/helmholtz/fluids.py +334 -0
  39. fugacio_thermo-0.0.1/src/fugacio/thermo/helmholtz/iapws.py +219 -0
  40. fugacio_thermo-0.0.1/src/fugacio/thermo/helmholtz/props.py +229 -0
  41. fugacio_thermo-0.0.1/src/fugacio/thermo/helmholtz/saturation.py +245 -0
  42. fugacio_thermo-0.0.1/src/fugacio/thermo/helmholtz/states.py +334 -0
  43. fugacio_thermo-0.0.1/src/fugacio/thermo/helmholtz/surface.py +31 -0
  44. fugacio_thermo-0.0.1/src/fugacio/thermo/helmholtz/terms.py +220 -0
  45. fugacio_thermo-0.0.1/src/fugacio/thermo/ideal.py +188 -0
  46. fugacio_thermo-0.0.1/src/fugacio/thermo/implicit.py +317 -0
  47. fugacio_thermo-0.0.1/src/fugacio/thermo/kinetics.py +211 -0
  48. fugacio_thermo-0.0.1/src/fugacio/thermo/lle.py +178 -0
  49. fugacio_thermo-0.0.1/src/fugacio/thermo/oracles.py +582 -0
  50. fugacio_thermo-0.0.1/src/fugacio/thermo/parameter_bank.json +81 -0
  51. fugacio_thermo-0.0.1/src/fugacio/thermo/parameter_bank.py +271 -0
  52. fugacio_thermo-0.0.1/src/fugacio/thermo/phase.py +317 -0
  53. fugacio_thermo-0.0.1/src/fugacio/thermo/properties.py +189 -0
  54. fugacio_thermo-0.0.1/src/fugacio/thermo/py.typed +0 -0
  55. fugacio_thermo-0.0.1/src/fugacio/thermo/reaction_equilibrium.py +200 -0
  56. fugacio_thermo-0.0.1/src/fugacio/thermo/reactions.py +301 -0
  57. fugacio_thermo-0.0.1/src/fugacio/thermo/reference.py +139 -0
  58. fugacio_thermo-0.0.1/src/fugacio/thermo/regression.py +409 -0
  59. fugacio_thermo-0.0.1/src/fugacio/thermo/saft/__init__.py +90 -0
  60. fugacio_thermo-0.0.1/src/fugacio/thermo/saft/_data.py +154 -0
  61. fugacio_thermo-0.0.1/src/fugacio/thermo/saft/association.py +170 -0
  62. fugacio_thermo-0.0.1/src/fugacio/thermo/saft/equilibrium.py +256 -0
  63. fugacio_thermo-0.0.1/src/fugacio/thermo/saft/model.py +130 -0
  64. fugacio_thermo-0.0.1/src/fugacio/thermo/saft/parameters.py +239 -0
  65. fugacio_thermo-0.0.1/src/fugacio/thermo/saft/pcsaft.py +199 -0
  66. fugacio_thermo-0.0.1/src/fugacio/thermo/saft/properties.py +241 -0
  67. fugacio_thermo-0.0.1/src/fugacio/thermo/saft/regression.py +141 -0
  68. fugacio_thermo-0.0.1/src/fugacio/thermo/stability.py +140 -0
  69. fugacio_thermo-0.0.1/src/fugacio/thermo/thermoml.py +462 -0
  70. fugacio_thermo-0.0.1/src/fugacio/thermo/thermoml_samples/acetone_chloroform_vle_318K.xml +141 -0
  71. fugacio_thermo-0.0.1/src/fugacio/thermo/thermoml_samples/benzene_toluene_vle_363K.xml +141 -0
  72. fugacio_thermo-0.0.1/src/fugacio/thermo/thermoml_samples/ethanol_water_vle_323K.xml +138 -0
  73. fugacio_thermo-0.0.1/src/fugacio/thermo/thermoml_samples/isopropanol_water_vle_353K.xml +141 -0
  74. fugacio_thermo-0.0.1/src/fugacio/thermo/thermoml_samples/methanol_water_vle_338K.xml +141 -0
  75. fugacio_thermo-0.0.1/src/fugacio/thermo/thermoml_samples/water_vapor_pressure.xml +66 -0
  76. fugacio_thermo-0.0.1/src/fugacio/thermo/transport/__init__.py +70 -0
  77. fugacio_thermo-0.0.1/src/fugacio/thermo/transport/diffusivity.py +182 -0
  78. fugacio_thermo-0.0.1/src/fugacio/thermo/transport/surface_tension.py +100 -0
  79. fugacio_thermo-0.0.1/src/fugacio/thermo/transport/thermal_conductivity.py +200 -0
  80. fugacio_thermo-0.0.1/src/fugacio/thermo/transport/viscosity.py +227 -0
  81. fugacio_thermo-0.0.1/src/fugacio/thermo/vlle.py +270 -0
  82. fugacio_thermo-0.0.1/src/fugacio/thermo/volumetric.py +301 -0
  83. fugacio_thermo-0.0.1/tests/test_activity.py +35 -0
  84. fugacio_thermo-0.0.1/tests/test_activity_models.py +90 -0
  85. fugacio_thermo-0.0.1/tests/test_components.py +86 -0
  86. fugacio_thermo-0.0.1/tests/test_consistency.py +56 -0
  87. fugacio_thermo-0.0.1/tests/test_correlations.py +162 -0
  88. fugacio_thermo-0.0.1/tests/test_data.py +72 -0
  89. fugacio_thermo-0.0.1/tests/test_departure.py +73 -0
  90. fugacio_thermo-0.0.1/tests/test_dortmund.py +49 -0
  91. fugacio_thermo-0.0.1/tests/test_energy.py +88 -0
  92. fugacio_thermo-0.0.1/tests/test_eos.py +90 -0
  93. fugacio_thermo-0.0.1/tests/test_equilibrium.py +87 -0
  94. fugacio_thermo-0.0.1/tests/test_gammaphi.py +87 -0
  95. fugacio_thermo-0.0.1/tests/test_groupcontrib.py +63 -0
  96. fugacio_thermo-0.0.1/tests/test_helmholtz.py +404 -0
  97. fugacio_thermo-0.0.1/tests/test_helmholtz_consistency.py +185 -0
  98. fugacio_thermo-0.0.1/tests/test_helmholtz_oracles.py +275 -0
  99. fugacio_thermo-0.0.1/tests/test_ideal.py +51 -0
  100. fugacio_thermo-0.0.1/tests/test_kinetics.py +114 -0
  101. fugacio_thermo-0.0.1/tests/test_lle.py +30 -0
  102. fugacio_thermo-0.0.1/tests/test_oracles.py +163 -0
  103. fugacio_thermo-0.0.1/tests/test_parameter_bank.py +112 -0
  104. fugacio_thermo-0.0.1/tests/test_phase.py +58 -0
  105. fugacio_thermo-0.0.1/tests/test_properties.py +80 -0
  106. fugacio_thermo-0.0.1/tests/test_property_oracles.py +323 -0
  107. fugacio_thermo-0.0.1/tests/test_reaction_equilibrium.py +109 -0
  108. fugacio_thermo-0.0.1/tests/test_reaction_oracles.py +87 -0
  109. fugacio_thermo-0.0.1/tests/test_reactions.py +124 -0
  110. fugacio_thermo-0.0.1/tests/test_reference.py +61 -0
  111. fugacio_thermo-0.0.1/tests/test_regression.py +95 -0
  112. fugacio_thermo-0.0.1/tests/test_saft.py +312 -0
  113. fugacio_thermo-0.0.1/tests/test_saft_consistency.py +218 -0
  114. fugacio_thermo-0.0.1/tests/test_saft_oracles.py +83 -0
  115. fugacio_thermo-0.0.1/tests/test_saft_regression.py +76 -0
  116. fugacio_thermo-0.0.1/tests/test_stability.py +31 -0
  117. fugacio_thermo-0.0.1/tests/test_thermoml.py +112 -0
  118. fugacio_thermo-0.0.1/tests/test_transport.py +284 -0
  119. fugacio_thermo-0.0.1/tests/test_vlle.py +68 -0
  120. fugacio_thermo-0.0.1/tests/test_volumetric.py +165 -0
@@ -0,0 +1,32 @@
1
+ # Byte-compiled / build artifacts
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .eggs/
6
+ build/
7
+ dist/
8
+
9
+ # Virtual environments
10
+ .venv/
11
+ venv/
12
+
13
+ # Tooling caches
14
+ .pytest_cache/
15
+ .mypy_cache/
16
+ .ruff_cache/
17
+ .import_linter_cache/
18
+ .jax_cache/
19
+ .coverage
20
+ coverage.xml
21
+ htmlcov/
22
+
23
+ # Docs build
24
+ site/
25
+ # Material social-cards plugin cache (downloaded fonts + generated card layers)
26
+ .cache/
27
+
28
+ # OS / editor
29
+ .DS_Store
30
+ *.swp
31
+ .idea/
32
+ .vscode/
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.4
2
+ Name: fugacio-thermo
3
+ Version: 0.0.1
4
+ Summary: Differentiable thermodynamics and physical-property engine for the Fugacio stack.
5
+ Author-email: Owen Carey <37121709+owenthcarey@users.noreply.github.com>
6
+ License-Expression: Apache-2.0
7
+ Keywords: activity-coefficients,chemical-engineering,jax,phase-equilibrium,thermodynamics
8
+ Classifier: Development Status :: 2 - Pre-Alpha
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
12
+ Requires-Python: >=3.11
13
+ Requires-Dist: jax>=0.4.34
14
+ Description-Content-Type: text/markdown
15
+
16
+ # fugacio-thermo
17
+
18
+ Differentiable thermodynamics and physical-property engine for the
19
+ [Fugacio](https://github.com/fugacio/fugacio) stack. Every model is written
20
+ in [JAX](https://github.com/jax-ml/jax), so any output (a fugacity coefficient,
21
+ a saturation pressure, a flash result) is differentiable with respect to
22
+ temperature, pressure, composition, *and* model parameters. The iterative solvers
23
+ (cubic-EOS root, flash, saturation, bubble/dew) carry hand-written
24
+ implicit-function-theorem rules, so gradients flow exactly through them rather
25
+ than through unrolled iterations.
26
+
27
+ ## What's inside
28
+
29
+ - **Curated open component database** (`DATABASE`, `get`, `component_arrays`):
30
+ critical constants, acentric factors, Antoine coefficients, and ideal-gas heat
31
+ capacities for common species.
32
+ - **Ideal-gas properties**: `cp_ig`, `enthalpy_ig`, `entropy_ig`, `gibbs_ig`
33
+ (plus mixture variants).
34
+ - **Cubic equations of state**: van der Waals, Redlich-Kwong, SRK, Peng-Robinson
35
+ (`VDW`, `RK`, `SRK`, `PR`), with mixing rules, a differentiable compressibility
36
+ solver, fugacity coefficients (`ln_phi_mixture`, `ln_phi_pure`), and molar
37
+ volume.
38
+ - **Real-fluid energy properties**: residual/departure functions
39
+ (`residual_enthalpy`, `residual_entropy`, `residual_gibbs`, `residual_cp`),
40
+ real-fluid molar properties (`molar_enthalpy`, `molar_entropy`, `molar_gibbs`,
41
+ `molar_cp`, `stable_phase`), two-phase `mixture_enthalpy` / `mixture_entropy`,
42
+ and energy-specified flashes `flash_ph` (isenthalpic) and `flash_ps`
43
+ (isentropic), the backbone of adiabatic units, valves, compressors, and
44
+ turbines.
45
+ - **Activity-coefficient models**: Margules, van Laar, Wilson, NRTL, UNIQUAC, and
46
+ predictive regular-solution / Flory-Huggins, available both as functions and
47
+ as differentiable `ActivityModel` objects (`nrtl`, `uniquac`, ...) whose
48
+ parameters are themselves gradient leaves.
49
+ - **Group contribution**: predictive `unifac_activity` and `joback_estimate`
50
+ (pure-component constants from a structure).
51
+ - **Molecular PC-SAFT**: the perturbed-chain SAFT equation of state
52
+ (`SaftParameters`, `saft_parameters_for`, `alpha_residual`, `SAFTModel`) with a
53
+ curated Gross-Sadowski parameter bank, Wertheim TPT1 association for
54
+ hydrogen-bonding fluids, fugacity / density / residual properties by autodiff,
55
+ the equilibrium routines `flash_pt_saft`, `bubble_pressure_saft`,
56
+ `dew_pressure_saft`, `psat_saft`, and `stability_saft`, and differentiable
57
+ parameter regression (`fit_saft_pure`, `fit_saft_kij`).
58
+ - **Reference state**: pure-liquid reference fugacity (`liquid_reference_fugacity`),
59
+ the `poynting_factor`, saturation fugacity coefficient, and `henry_constant`.
60
+ - **EOS phase equilibrium**: `rachford_rice`, `flash_pt`, `psat_eos`,
61
+ `bubble_pressure_eos`, `dew_pressure_eos`, and Michelsen `stability_analysis`.
62
+ - **Non-ideal (gamma-phi) VLE**: `flash_pt_gamma`, `bubble_pressure_gamma`,
63
+ `dew_pressure_gamma`, and the temperature duals, the route that captures
64
+ azeotropes and strongly polar mixtures.
65
+ - **Liquid-liquid & three-phase equilibria**: isoactivity `flash_lle` with
66
+ `tie_line` / `binodal_curve`, three-phase `flash_vlle`, the binary
67
+ `heterogeneous_azeotrope` solver, and a general tangent-plane stability test
68
+ (`stability_analysis_general`, `liquid_stability`).
69
+ - **Unified model interface**: `EOSModel`, `GammaPhiModel`, and `SAFTModel` expose
70
+ the same `flash_pt` / bubble / dew calls, so the rest of the stack switches
71
+ thermodynamic method (cubic, γ–φ, or molecular PC-SAFT) by swapping one
72
+ (differentiable) object.
73
+ - **Parameter regression & prediction**: a self-contained `levenberg_marquardt`
74
+ over arbitrary parameter pytrees with residual builders
75
+ (`bubble_pressure_residuals`, `activity_residuals`, `lle_residuals`), ready
76
+ fitters (`fit_nrtl_binary`, `fit_uniquac_binary`), and UNIFAC-to-binary
77
+ prediction (`predict_nrtl_from_unifac`, `predict_uniquac_from_unifac`) for
78
+ mixtures without fitted parameters.
79
+ - **Reactions, equilibrium & kinetics**: stoichiometry and standard-state
80
+ thermochemistry (`Reaction`, `reaction_properties`, `delta_g_rxn`,
81
+ `equilibrium_constant`), chemical-reaction `equilibrium` (single or simultaneous,
82
+ ideal-gas or EOS-`phi` basis), and differentiable rate laws (`PowerLaw`,
83
+ `MassActionReversible`, `LHHW`, `Arrhenius`).
84
+ - **Validation harness**: first-principles consistency checks (Gibbs-Duhem,
85
+ equifugacity, the `(d ln phi / dP)_T` identity), an AD-vs-finite-difference
86
+ checker, and optional differential-testing oracles: CoolProp / `chemicals`
87
+ (pure-fluid properties), `thermo` / Clapeyron.jl (activity coefficients and
88
+ PC-SAFT), and Cantera (reaction equilibrium and standard-state thermochemistry).
89
+
90
+ ## Example: a differentiable flash
91
+
92
+ ```python
93
+ import jax
94
+ import jax.numpy as jnp
95
+ from fugacio.thermo import PR, component_arrays, flash_pt
96
+
97
+ arr = component_arrays(["methane", "propane", "n-pentane"])
98
+ z = jnp.array([0.5, 0.3, 0.2])
99
+
100
+ result = flash_pt(PR, 320.0, 20e5, z, arr["tc"], arr["pc"], arr["omega"])
101
+ result.beta # vapour fraction (~0.75)
102
+ result.x, result.y # liquid / vapour compositions
103
+
104
+ # Gradient of the vapour fraction w.r.t. pressure, straight through the solver:
105
+ dbeta_dP = jax.grad(
106
+ lambda p: flash_pt(PR, 320.0, p, z, arr["tc"], arr["pc"], arr["omega"]).beta
107
+ )
108
+ dbeta_dP(20e5)
109
+ ```
110
+
111
+ ## Example: a non-ideal (gamma-phi) bubble point
112
+
113
+ ```python
114
+ import jax.numpy as jnp
115
+ from fugacio.thermo import bubble_pressure_gamma, component_arrays, nrtl
116
+
117
+ arr = component_arrays(["ethanol", "water"])
118
+ # NRTL with 1/T interaction coefficients (K); alpha = 0.3.
119
+ model = nrtl(
120
+ a=jnp.zeros((2, 2)),
121
+ b=jnp.array([[0.0, 670.0], [310.0, 0.0]]),
122
+ alpha=jnp.array([[0.0, 0.3], [0.3, 0.0]]),
123
+ )
124
+ P, y = bubble_pressure_gamma(model, 350.0, jnp.array([0.3, 0.7]),
125
+ arr["tc"], arr["pc"], arr["omega"])
126
+ # P, y are differentiable w.r.t. T, x, *and* the NRTL parameters.
127
+ ```
128
+
129
+ Part of the `fugacio` namespace; installs independently:
130
+ `pip install fugacio-thermo`.
@@ -0,0 +1,115 @@
1
+ # fugacio-thermo
2
+
3
+ Differentiable thermodynamics and physical-property engine for the
4
+ [Fugacio](https://github.com/fugacio/fugacio) stack. Every model is written
5
+ in [JAX](https://github.com/jax-ml/jax), so any output (a fugacity coefficient,
6
+ a saturation pressure, a flash result) is differentiable with respect to
7
+ temperature, pressure, composition, *and* model parameters. The iterative solvers
8
+ (cubic-EOS root, flash, saturation, bubble/dew) carry hand-written
9
+ implicit-function-theorem rules, so gradients flow exactly through them rather
10
+ than through unrolled iterations.
11
+
12
+ ## What's inside
13
+
14
+ - **Curated open component database** (`DATABASE`, `get`, `component_arrays`):
15
+ critical constants, acentric factors, Antoine coefficients, and ideal-gas heat
16
+ capacities for common species.
17
+ - **Ideal-gas properties**: `cp_ig`, `enthalpy_ig`, `entropy_ig`, `gibbs_ig`
18
+ (plus mixture variants).
19
+ - **Cubic equations of state**: van der Waals, Redlich-Kwong, SRK, Peng-Robinson
20
+ (`VDW`, `RK`, `SRK`, `PR`), with mixing rules, a differentiable compressibility
21
+ solver, fugacity coefficients (`ln_phi_mixture`, `ln_phi_pure`), and molar
22
+ volume.
23
+ - **Real-fluid energy properties**: residual/departure functions
24
+ (`residual_enthalpy`, `residual_entropy`, `residual_gibbs`, `residual_cp`),
25
+ real-fluid molar properties (`molar_enthalpy`, `molar_entropy`, `molar_gibbs`,
26
+ `molar_cp`, `stable_phase`), two-phase `mixture_enthalpy` / `mixture_entropy`,
27
+ and energy-specified flashes `flash_ph` (isenthalpic) and `flash_ps`
28
+ (isentropic), the backbone of adiabatic units, valves, compressors, and
29
+ turbines.
30
+ - **Activity-coefficient models**: Margules, van Laar, Wilson, NRTL, UNIQUAC, and
31
+ predictive regular-solution / Flory-Huggins, available both as functions and
32
+ as differentiable `ActivityModel` objects (`nrtl`, `uniquac`, ...) whose
33
+ parameters are themselves gradient leaves.
34
+ - **Group contribution**: predictive `unifac_activity` and `joback_estimate`
35
+ (pure-component constants from a structure).
36
+ - **Molecular PC-SAFT**: the perturbed-chain SAFT equation of state
37
+ (`SaftParameters`, `saft_parameters_for`, `alpha_residual`, `SAFTModel`) with a
38
+ curated Gross-Sadowski parameter bank, Wertheim TPT1 association for
39
+ hydrogen-bonding fluids, fugacity / density / residual properties by autodiff,
40
+ the equilibrium routines `flash_pt_saft`, `bubble_pressure_saft`,
41
+ `dew_pressure_saft`, `psat_saft`, and `stability_saft`, and differentiable
42
+ parameter regression (`fit_saft_pure`, `fit_saft_kij`).
43
+ - **Reference state**: pure-liquid reference fugacity (`liquid_reference_fugacity`),
44
+ the `poynting_factor`, saturation fugacity coefficient, and `henry_constant`.
45
+ - **EOS phase equilibrium**: `rachford_rice`, `flash_pt`, `psat_eos`,
46
+ `bubble_pressure_eos`, `dew_pressure_eos`, and Michelsen `stability_analysis`.
47
+ - **Non-ideal (gamma-phi) VLE**: `flash_pt_gamma`, `bubble_pressure_gamma`,
48
+ `dew_pressure_gamma`, and the temperature duals, the route that captures
49
+ azeotropes and strongly polar mixtures.
50
+ - **Liquid-liquid & three-phase equilibria**: isoactivity `flash_lle` with
51
+ `tie_line` / `binodal_curve`, three-phase `flash_vlle`, the binary
52
+ `heterogeneous_azeotrope` solver, and a general tangent-plane stability test
53
+ (`stability_analysis_general`, `liquid_stability`).
54
+ - **Unified model interface**: `EOSModel`, `GammaPhiModel`, and `SAFTModel` expose
55
+ the same `flash_pt` / bubble / dew calls, so the rest of the stack switches
56
+ thermodynamic method (cubic, γ–φ, or molecular PC-SAFT) by swapping one
57
+ (differentiable) object.
58
+ - **Parameter regression & prediction**: a self-contained `levenberg_marquardt`
59
+ over arbitrary parameter pytrees with residual builders
60
+ (`bubble_pressure_residuals`, `activity_residuals`, `lle_residuals`), ready
61
+ fitters (`fit_nrtl_binary`, `fit_uniquac_binary`), and UNIFAC-to-binary
62
+ prediction (`predict_nrtl_from_unifac`, `predict_uniquac_from_unifac`) for
63
+ mixtures without fitted parameters.
64
+ - **Reactions, equilibrium & kinetics**: stoichiometry and standard-state
65
+ thermochemistry (`Reaction`, `reaction_properties`, `delta_g_rxn`,
66
+ `equilibrium_constant`), chemical-reaction `equilibrium` (single or simultaneous,
67
+ ideal-gas or EOS-`phi` basis), and differentiable rate laws (`PowerLaw`,
68
+ `MassActionReversible`, `LHHW`, `Arrhenius`).
69
+ - **Validation harness**: first-principles consistency checks (Gibbs-Duhem,
70
+ equifugacity, the `(d ln phi / dP)_T` identity), an AD-vs-finite-difference
71
+ checker, and optional differential-testing oracles: CoolProp / `chemicals`
72
+ (pure-fluid properties), `thermo` / Clapeyron.jl (activity coefficients and
73
+ PC-SAFT), and Cantera (reaction equilibrium and standard-state thermochemistry).
74
+
75
+ ## Example: a differentiable flash
76
+
77
+ ```python
78
+ import jax
79
+ import jax.numpy as jnp
80
+ from fugacio.thermo import PR, component_arrays, flash_pt
81
+
82
+ arr = component_arrays(["methane", "propane", "n-pentane"])
83
+ z = jnp.array([0.5, 0.3, 0.2])
84
+
85
+ result = flash_pt(PR, 320.0, 20e5, z, arr["tc"], arr["pc"], arr["omega"])
86
+ result.beta # vapour fraction (~0.75)
87
+ result.x, result.y # liquid / vapour compositions
88
+
89
+ # Gradient of the vapour fraction w.r.t. pressure, straight through the solver:
90
+ dbeta_dP = jax.grad(
91
+ lambda p: flash_pt(PR, 320.0, p, z, arr["tc"], arr["pc"], arr["omega"]).beta
92
+ )
93
+ dbeta_dP(20e5)
94
+ ```
95
+
96
+ ## Example: a non-ideal (gamma-phi) bubble point
97
+
98
+ ```python
99
+ import jax.numpy as jnp
100
+ from fugacio.thermo import bubble_pressure_gamma, component_arrays, nrtl
101
+
102
+ arr = component_arrays(["ethanol", "water"])
103
+ # NRTL with 1/T interaction coefficients (K); alpha = 0.3.
104
+ model = nrtl(
105
+ a=jnp.zeros((2, 2)),
106
+ b=jnp.array([[0.0, 670.0], [310.0, 0.0]]),
107
+ alpha=jnp.array([[0.0, 0.3], [0.3, 0.0]]),
108
+ )
109
+ P, y = bubble_pressure_gamma(model, 350.0, jnp.array([0.3, 0.7]),
110
+ arr["tc"], arr["pc"], arr["omega"])
111
+ # P, y are differentiable w.r.t. T, x, *and* the NRTL parameters.
112
+ ```
113
+
114
+ Part of the `fugacio` namespace; installs independently:
115
+ `pip install fugacio-thermo`.
@@ -0,0 +1,33 @@
1
+ [project]
2
+ name = "fugacio-thermo"
3
+ version = "0.0.1"
4
+ description = "Differentiable thermodynamics and physical-property engine for the Fugacio stack."
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ license = "Apache-2.0"
8
+ authors = [
9
+ { name = "Owen Carey", email = "37121709+owenthcarey@users.noreply.github.com" },
10
+ ]
11
+ keywords = [
12
+ "thermodynamics",
13
+ "chemical-engineering",
14
+ "jax",
15
+ "phase-equilibrium",
16
+ "activity-coefficients",
17
+ ]
18
+ classifiers = [
19
+ "Development Status :: 2 - Pre-Alpha",
20
+ "Intended Audience :: Science/Research",
21
+ "Programming Language :: Python :: 3",
22
+ "Topic :: Scientific/Engineering :: Chemistry",
23
+ ]
24
+ dependencies = [
25
+ "jax>=0.4.34",
26
+ ]
27
+
28
+ [build-system]
29
+ requires = ["hatchling"]
30
+ build-backend = "hatchling.build"
31
+
32
+ [tool.hatch.build.targets.wheel]
33
+ packages = ["src/fugacio"]