pyrast 0.1.0__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.
- pyrast-0.1.0/LICENSE.md +19 -0
- pyrast-0.1.0/PKG-INFO +106 -0
- pyrast-0.1.0/README.rst +82 -0
- pyrast-0.1.0/pyproject.toml +71 -0
- pyrast-0.1.0/setup.cfg +4 -0
- pyrast-0.1.0/src/pyrast/__init__.py +0 -0
- pyrast-0.1.0/src/pyrast/activity_coefficients/__init__.py +8 -0
- pyrast-0.1.0/src/pyrast/activity_coefficients/a_margules.py +75 -0
- pyrast-0.1.0/src/pyrast/activity_coefficients/a_nrtl.py +86 -0
- pyrast-0.1.0/src/pyrast/activity_coefficients/activity_coefficient.py +525 -0
- pyrast-0.1.0/src/pyrast/activity_coefficients/s_margules.py +67 -0
- pyrast-0.1.0/src/pyrast/activity_coefficients/s_nrtl.py +86 -0
- pyrast-0.1.0/src/pyrast/activity_coefficients/van_laar.py +75 -0
- pyrast-0.1.0/src/pyrast/activity_coefficients/wilson.py +80 -0
- pyrast-0.1.0/src/pyrast/calculations/__init__.py +0 -0
- pyrast-0.1.0/src/pyrast/calculations/iast.py +337 -0
- pyrast-0.1.0/src/pyrast/calculations/rast.py +387 -0
- pyrast-0.1.0/src/pyrast/isotherms/__init__.py +20 -0
- pyrast-0.1.0/src/pyrast/isotherms/anrtlvst.py +144 -0
- pyrast-0.1.0/src/pyrast/isotherms/bet.py +65 -0
- pyrast-0.1.0/src/pyrast/isotherms/dslangmuir.py +68 -0
- pyrast-0.1.0/src/pyrast/isotherms/fhvst.py +128 -0
- pyrast-0.1.0/src/pyrast/isotherms/henry.py +77 -0
- pyrast-0.1.0/src/pyrast/isotherms/interpolator_isotherm.py +593 -0
- pyrast-0.1.0/src/pyrast/isotherms/langmuir.py +90 -0
- pyrast-0.1.0/src/pyrast/isotherms/model_isotherm.py +377 -0
- pyrast-0.1.0/src/pyrast/isotherms/quadratic.py +64 -0
- pyrast-0.1.0/src/pyrast/isotherms/snrtlvst.py +144 -0
- pyrast-0.1.0/src/pyrast/isotherms/temkinapprox.py +67 -0
- pyrast-0.1.0/src/pyrast/isotherms/wvst.py +137 -0
- pyrast-0.1.0/src/pyrast/utilities/__init__.py +0 -0
- pyrast-0.1.0/src/pyrast/utilities/plotting.py +222 -0
- pyrast-0.1.0/src/pyrast.egg-info/PKG-INFO +106 -0
- pyrast-0.1.0/src/pyrast.egg-info/SOURCES.txt +35 -0
- pyrast-0.1.0/src/pyrast.egg-info/dependency_links.txt +1 -0
- pyrast-0.1.0/src/pyrast.egg-info/requires.txt +18 -0
- pyrast-0.1.0/src/pyrast.egg-info/top_level.txt +1 -0
pyrast-0.1.0/LICENSE.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2026 Jonah Finkelstein
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
pyrast-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyrast
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Author-email: Jonah Finkelstein <jonahfinkelstein2030@u.northwestern.edu>
|
|
5
|
+
Keywords: adsorption,thermodynamics,isotherm
|
|
6
|
+
Requires-Python: >=3.6
|
|
7
|
+
Description-Content-Type: text/x-rst
|
|
8
|
+
License-File: LICENSE.md
|
|
9
|
+
Requires-Dist: numpy
|
|
10
|
+
Requires-Dist: scipy
|
|
11
|
+
Requires-Dist: pandas
|
|
12
|
+
Requires-Dist: matplotlib
|
|
13
|
+
Provides-Extra: all
|
|
14
|
+
Requires-Dist: pyrast[dev,docs,test]; extra == "all"
|
|
15
|
+
Provides-Extra: dev
|
|
16
|
+
Requires-Dist: pyrast[docs,test]; extra == "dev"
|
|
17
|
+
Requires-Dist: ruff; extra == "dev"
|
|
18
|
+
Requires-Dist: ipykernel; extra == "dev"
|
|
19
|
+
Provides-Extra: docs
|
|
20
|
+
Requires-Dist: sphinx; extra == "docs"
|
|
21
|
+
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
22
|
+
Provides-Extra: test
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
.. image:: https://raw.githubusercontent.com/snurr-group/pyRAST/refs/heads/main/docs/source/_static/pyrast_logo_200x200.png
|
|
26
|
+
:alt: pyRAST logo
|
|
27
|
+
:align: center
|
|
28
|
+
:width: 200px
|
|
29
|
+
|
|
30
|
+
========
|
|
31
|
+
Overview
|
|
32
|
+
========
|
|
33
|
+
|
|
34
|
+
Python Real Adsorbed Solution Theory (pyRAST) is a package for modeling adsorption
|
|
35
|
+
using ideal and real adsorbed solution theories. pyRAST was designed to be user-friendly
|
|
36
|
+
and flexible, allowing users to easily control the fitting and calculation process.
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
.. badges
|
|
40
|
+
|
|
41
|
+
|status| |docs| |license|
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
.. |status| image:: https://www.repostatus.org/badges/latest/active.svg
|
|
45
|
+
:alt: Project Status: Active - The project has reached a stable, usable state and is being actively developed.
|
|
46
|
+
:target: https://www.repostatus.org/#active
|
|
47
|
+
|
|
48
|
+
.. |docs| image:: https://readthedocs.org/projects/pyrast/badge/?style=flat
|
|
49
|
+
:target: https://readthedocs.org/projects/pyrast
|
|
50
|
+
:alt: Documentation Status
|
|
51
|
+
|
|
52
|
+
.. |license| image:: https://img.shields.io/badge/License-MIT-yellow.svg
|
|
53
|
+
:target: https://opensource.org/licenses/MIT
|
|
54
|
+
:alt: Project License
|
|
55
|
+
|
|
56
|
+
Features
|
|
57
|
+
--------
|
|
58
|
+
- Analytical single component isotherm fitting
|
|
59
|
+
- Vacancy solution theory (VST) isotherm fitting
|
|
60
|
+
- Single component interpolator isotherms
|
|
61
|
+
- Activity coefficient fitting for binary adsorbed mixtures (component loading or total loading)
|
|
62
|
+
- Multicomponent forward and reverse IAST calculations
|
|
63
|
+
- Binary forward and reverse RAST calculations
|
|
64
|
+
|
|
65
|
+
Usage
|
|
66
|
+
-----
|
|
67
|
+
Please see the `tutorial <https://pyrast.readthedocs.io/en/latest/tutorial/index.html>`__ for a detailed overview
|
|
68
|
+
of pyRAST's functionality and usage. If you are looking for detailed documentation, please see the
|
|
69
|
+
`reference <https://pyrast.readthedocs.io/en/latest/reference/index.html>`__ section. For a detailed
|
|
70
|
+
description of the underlying theory, please see the manuscript (link to be added).
|
|
71
|
+
|
|
72
|
+
Installation
|
|
73
|
+
============
|
|
74
|
+
pyRAST is available on pyPI and can be installed using pip: ::
|
|
75
|
+
|
|
76
|
+
pip install pyrast
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
Citation
|
|
80
|
+
========
|
|
81
|
+
If you used pyRAST in your research, please cite the following paper: ::
|
|
82
|
+
|
|
83
|
+
To be added
|
|
84
|
+
|
|
85
|
+
pyRAST was built on the foundation of `pyIAST <https://github.com/CorySimon/pyIAST>`__ by Cory Simon
|
|
86
|
+
and pulled ideas from `pyGAPS <https://github.com/pauliacomi/pyGAPS>`__ by Paul Iacomi. Please
|
|
87
|
+
check out the work of these developers, too!
|
|
88
|
+
|
|
89
|
+
Acknowledgements
|
|
90
|
+
================
|
|
91
|
+
pyRAST was developed by Jonah Finkelstein in the Snurr Research Group at Northwestern University.
|
|
92
|
+
The development of pyRAST was supported by: TBD
|
|
93
|
+
|
|
94
|
+
Development
|
|
95
|
+
===========
|
|
96
|
+
If you wish to install pyRAST in development mode, clone the repository and run the following command in the root directory: ::
|
|
97
|
+
|
|
98
|
+
pip install -e .[dev]
|
|
99
|
+
|
|
100
|
+
If you wish to contribute to the development of pyRAST, please submit a `pull request <https://github.com/snurr-group/pyRAST/pulls>`__
|
|
101
|
+
on the GitHub Repository or contact Jonah Finkelstein.
|
|
102
|
+
|
|
103
|
+
Questions?
|
|
104
|
+
==========
|
|
105
|
+
If you have any questions, please contact Jonah Finkelstein at jonahfinkelstein2030@u.northwestern.edu.
|
|
106
|
+
Alternatively, you can open an `issue <https://github.com/snurr-group/pyRAST/issues>`__ on the GitHub repository.
|
pyrast-0.1.0/README.rst
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
.. image:: https://raw.githubusercontent.com/snurr-group/pyRAST/refs/heads/main/docs/source/_static/pyrast_logo_200x200.png
|
|
2
|
+
:alt: pyRAST logo
|
|
3
|
+
:align: center
|
|
4
|
+
:width: 200px
|
|
5
|
+
|
|
6
|
+
========
|
|
7
|
+
Overview
|
|
8
|
+
========
|
|
9
|
+
|
|
10
|
+
Python Real Adsorbed Solution Theory (pyRAST) is a package for modeling adsorption
|
|
11
|
+
using ideal and real adsorbed solution theories. pyRAST was designed to be user-friendly
|
|
12
|
+
and flexible, allowing users to easily control the fitting and calculation process.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
.. badges
|
|
16
|
+
|
|
17
|
+
|status| |docs| |license|
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
.. |status| image:: https://www.repostatus.org/badges/latest/active.svg
|
|
21
|
+
:alt: Project Status: Active - The project has reached a stable, usable state and is being actively developed.
|
|
22
|
+
:target: https://www.repostatus.org/#active
|
|
23
|
+
|
|
24
|
+
.. |docs| image:: https://readthedocs.org/projects/pyrast/badge/?style=flat
|
|
25
|
+
:target: https://readthedocs.org/projects/pyrast
|
|
26
|
+
:alt: Documentation Status
|
|
27
|
+
|
|
28
|
+
.. |license| image:: https://img.shields.io/badge/License-MIT-yellow.svg
|
|
29
|
+
:target: https://opensource.org/licenses/MIT
|
|
30
|
+
:alt: Project License
|
|
31
|
+
|
|
32
|
+
Features
|
|
33
|
+
--------
|
|
34
|
+
- Analytical single component isotherm fitting
|
|
35
|
+
- Vacancy solution theory (VST) isotherm fitting
|
|
36
|
+
- Single component interpolator isotherms
|
|
37
|
+
- Activity coefficient fitting for binary adsorbed mixtures (component loading or total loading)
|
|
38
|
+
- Multicomponent forward and reverse IAST calculations
|
|
39
|
+
- Binary forward and reverse RAST calculations
|
|
40
|
+
|
|
41
|
+
Usage
|
|
42
|
+
-----
|
|
43
|
+
Please see the `tutorial <https://pyrast.readthedocs.io/en/latest/tutorial/index.html>`__ for a detailed overview
|
|
44
|
+
of pyRAST's functionality and usage. If you are looking for detailed documentation, please see the
|
|
45
|
+
`reference <https://pyrast.readthedocs.io/en/latest/reference/index.html>`__ section. For a detailed
|
|
46
|
+
description of the underlying theory, please see the manuscript (link to be added).
|
|
47
|
+
|
|
48
|
+
Installation
|
|
49
|
+
============
|
|
50
|
+
pyRAST is available on pyPI and can be installed using pip: ::
|
|
51
|
+
|
|
52
|
+
pip install pyrast
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
Citation
|
|
56
|
+
========
|
|
57
|
+
If you used pyRAST in your research, please cite the following paper: ::
|
|
58
|
+
|
|
59
|
+
To be added
|
|
60
|
+
|
|
61
|
+
pyRAST was built on the foundation of `pyIAST <https://github.com/CorySimon/pyIAST>`__ by Cory Simon
|
|
62
|
+
and pulled ideas from `pyGAPS <https://github.com/pauliacomi/pyGAPS>`__ by Paul Iacomi. Please
|
|
63
|
+
check out the work of these developers, too!
|
|
64
|
+
|
|
65
|
+
Acknowledgements
|
|
66
|
+
================
|
|
67
|
+
pyRAST was developed by Jonah Finkelstein in the Snurr Research Group at Northwestern University.
|
|
68
|
+
The development of pyRAST was supported by: TBD
|
|
69
|
+
|
|
70
|
+
Development
|
|
71
|
+
===========
|
|
72
|
+
If you wish to install pyRAST in development mode, clone the repository and run the following command in the root directory: ::
|
|
73
|
+
|
|
74
|
+
pip install -e .[dev]
|
|
75
|
+
|
|
76
|
+
If you wish to contribute to the development of pyRAST, please submit a `pull request <https://github.com/snurr-group/pyRAST/pulls>`__
|
|
77
|
+
on the GitHub Repository or contact Jonah Finkelstein.
|
|
78
|
+
|
|
79
|
+
Questions?
|
|
80
|
+
==========
|
|
81
|
+
If you have any questions, please contact Jonah Finkelstein at jonahfinkelstein2030@u.northwestern.edu.
|
|
82
|
+
Alternatively, you can open an `issue <https://github.com/snurr-group/pyRAST/issues>`__ on the GitHub repository.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pyrast"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
readme = "README.rst"
|
|
5
|
+
keywords = ["adsorption", "thermodynamics", "isotherm"]
|
|
6
|
+
requires-python = ">=3.6"
|
|
7
|
+
license = {file = "LICENSE"}
|
|
8
|
+
authors = [
|
|
9
|
+
{name = "Jonah Finkelstein", email = "jonahfinkelstein2030@u.northwestern.edu"}
|
|
10
|
+
]
|
|
11
|
+
dependencies = [
|
|
12
|
+
"numpy",
|
|
13
|
+
"scipy",
|
|
14
|
+
"pandas",
|
|
15
|
+
"matplotlib",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.optional-dependencies]
|
|
19
|
+
all = ["pyrast[dev,docs,test]"]
|
|
20
|
+
dev = [
|
|
21
|
+
"pyrast[test,docs]",
|
|
22
|
+
"ruff",
|
|
23
|
+
"ipykernel",
|
|
24
|
+
]
|
|
25
|
+
docs = [
|
|
26
|
+
"sphinx",
|
|
27
|
+
"sphinx-rtd-theme",
|
|
28
|
+
]
|
|
29
|
+
test = [
|
|
30
|
+
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
[tool.ruff]
|
|
35
|
+
target-version = "py314"
|
|
36
|
+
line-length = 88
|
|
37
|
+
|
|
38
|
+
[tool.ruff.lint]
|
|
39
|
+
extend-select = [
|
|
40
|
+
"F", # Pyflakes rules
|
|
41
|
+
"W", # PyCodeStyle warnings
|
|
42
|
+
"E", # PyCodeStyle errors
|
|
43
|
+
"I", # Sort imports properly
|
|
44
|
+
"UP", # Warn if certain things can changed due to newer Python versions
|
|
45
|
+
"C4", # Catch incorrect use of comprehensions, dict, list, etc
|
|
46
|
+
"FA", # Enforce from __future__ import annotations
|
|
47
|
+
"ISC", # Good use of string concatenation
|
|
48
|
+
"ICN", # Use common import conventions
|
|
49
|
+
"RET", # Good return practices
|
|
50
|
+
"SIM", # Common simplification rules
|
|
51
|
+
"TID", # Some good import practices
|
|
52
|
+
"TC", # Enforce importing certain types in a TYPE_CHECKING block
|
|
53
|
+
"PTH", # Use pathlib instead of os.path
|
|
54
|
+
"TD", # Be diligent with TODO comments
|
|
55
|
+
"NPY", # Some numpy-specific things
|
|
56
|
+
"COM", # enforce trailing comma rules
|
|
57
|
+
"DTZ", # require strict timezone manipulation with datetime
|
|
58
|
+
"FBT", # detect boolean traps
|
|
59
|
+
"N", # enforce naming conventions, e.g. ClassName vs function_name
|
|
60
|
+
"A", # detect shadowed builtins
|
|
61
|
+
"BLE", # disallow catch-all exceptions
|
|
62
|
+
"S", # disallow things like "exec"
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
[tool.ruff.format]
|
|
66
|
+
quote-style = "single"
|
|
67
|
+
indent-style = "space"
|
|
68
|
+
|
|
69
|
+
[build-system]
|
|
70
|
+
requires=["setuptools"]
|
|
71
|
+
build-backend = "setuptools.build_meta"
|
pyrast-0.1.0/setup.cfg
ADDED
|
File without changes
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""Implementation of Asymmetric Margules Model"""
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
from pyrast.activity_coefficients.activity_coefficient import ActivityCoefficient
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class AMargules(ActivityCoefficient, model_name='aMargules'):
|
|
9
|
+
r"""
|
|
10
|
+
The Asymmetric Margules model is an extension of the traditional Margules model that
|
|
11
|
+
allows for asymmetry in the activity coefficients of the components in a
|
|
12
|
+
binary mixture. It is best suited for mixtures where adsorbates differ slightly in
|
|
13
|
+
size, shape, or polarity. It is more flexible than the symmetric Margules model, but
|
|
14
|
+
is not great for highly non-ideal mixtures.
|
|
15
|
+
|
|
16
|
+
The excess Gibbs free energy in the Asymmetric Margules model is given by:
|
|
17
|
+
|
|
18
|
+
.. math:: \frac{g^E}{RT} = x_1 x_2 (A_{12} x_2 + A_{21} x_1) (1 - e^{-C \phi})
|
|
19
|
+
|
|
20
|
+
Source: Krishna, R. & van Baten, J. M. How reliable is the Real Adsorbed Solution
|
|
21
|
+
Theory (RAST) for estimating ternary mixture equilibrium in microporous host
|
|
22
|
+
materials? Fluid Phase Equilibria 589, 114260 (2025).
|
|
23
|
+
"""
|
|
24
|
+
# Class variables for every instance
|
|
25
|
+
name = 'aMargules'
|
|
26
|
+
param_names = ('A12', 'A21', 'C')
|
|
27
|
+
param_default_bounds = ((-np.inf, np.inf), (-np.inf, np.inf), (0.0, np.inf))
|
|
28
|
+
param_ideal_values = (0.0, 0.0)
|
|
29
|
+
|
|
30
|
+
def ln_gamma(self, x, phi):
|
|
31
|
+
r"""Calculates the natural log of the activity coefficients for each component.
|
|
32
|
+
|
|
33
|
+
In the Asymmetric Margules model, the activity coefficients are calculated as:
|
|
34
|
+
|
|
35
|
+
.. math::
|
|
36
|
+
\ln \gamma_1 = x_2^2 (A_{12} + 2(A_{21} - A_{12}) x_1) (1 - e^{-C \phi})
|
|
37
|
+
|
|
38
|
+
\ln \gamma_2 = x_1^2 (A_{21} + 2(A_{12} - A_{21}) x_2) (1 - e^{-C \phi})
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
x (array-like): Mole fractions of the components in the mixture.
|
|
42
|
+
phi (float): Spreading pressure for the mixture.
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
np.ndarray: Natural log of the activity coefficients for each component.
|
|
46
|
+
"""
|
|
47
|
+
a12 = self.model_parameters['A12']
|
|
48
|
+
a21 = self.model_parameters['A21']
|
|
49
|
+
c = self.model_parameters['C']
|
|
50
|
+
f = 1.0 - np.exp(-c * phi)
|
|
51
|
+
ln_gamma0 = x[1]**2 * f * (a12 + 2*(a21 - a12)*x[0])
|
|
52
|
+
ln_gamma1 = x[0]**2 * f * (a21 + 2*(a12 - a21)*x[1])
|
|
53
|
+
return np.array([ln_gamma0, ln_gamma1])
|
|
54
|
+
|
|
55
|
+
def inverse_excess_loading(self, x, phi):
|
|
56
|
+
r"""Calculates the inverse of the excess loading given composition and phi.
|
|
57
|
+
|
|
58
|
+
The excess loading in the Asymmetric Margules model is calculated as:
|
|
59
|
+
|
|
60
|
+
.. math::
|
|
61
|
+
\left(\frac{1}{q}\right)^E = C x_1 x_2 (A_{12} x_2 + A_{21} x_1)
|
|
62
|
+
e^{-C \phi}
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
x (array-like): Mole fractions of the components in the mixture.
|
|
66
|
+
phi (float): Spreading pressure for the mixture.
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
float: Inverse of the excess loading for the mixture.
|
|
70
|
+
"""
|
|
71
|
+
a12 = self.model_parameters['A12']
|
|
72
|
+
a21 = self.model_parameters['A21']
|
|
73
|
+
c = self.model_parameters['C']
|
|
74
|
+
|
|
75
|
+
return c * x[0] * x[1] * np.exp(-c * phi) * (a12*x[1] + a21*x[0])
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"""Implementation of Asymmetric NRTL Model"""
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
from pyrast.activity_coefficients.activity_coefficient import ActivityCoefficient
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ANRTL(ActivityCoefficient, model_name='aNRTL'):
|
|
9
|
+
r"""
|
|
10
|
+
The Asymmetric NRTL model is analagous to the Asymmetric NRTL model for vapor liquid
|
|
11
|
+
equlibria. The Asymmetric NRTL model is best suited for: UPDATE
|
|
12
|
+
|
|
13
|
+
The excess Gibbs free energy in the Asymmetric NRTL model is given by:
|
|
14
|
+
|
|
15
|
+
.. math::
|
|
16
|
+
\frac{g^E}{RT} = \frac{x_1 x_2 \tau_{12} (G_{12} - 1)}
|
|
17
|
+
{x_1 G_{12} + x_2} (1 - e^{-C \phi})
|
|
18
|
+
|
|
19
|
+
G_{12} = \exp(-\alpha \tau_{12}), \ \tau_{12} = -\tau_{21}, \ \alpha = 0.3
|
|
20
|
+
|
|
21
|
+
Sources: Kaur, H., Tun, H., Sees, M. & Chen, C.-C. Local composition activity
|
|
22
|
+
coefficient model for mixed-gas adsorption equilibria. Adsorption 25, 951-964
|
|
23
|
+
(2019).
|
|
24
|
+
|
|
25
|
+
Kopatsis, A., Salinger, A. & Myers, A. L. Thermodynamics of solutions with solvent
|
|
26
|
+
and solute in different pure states. AIChE Journal 34, 1275-1286 (1988).
|
|
27
|
+
"""
|
|
28
|
+
# Class variables for every instance
|
|
29
|
+
name = 'aNRTL'
|
|
30
|
+
param_names = ('t12', 'C')
|
|
31
|
+
param_default_bounds = ((-np.inf, np.inf), (0.0, np.inf))
|
|
32
|
+
param_ideal_values = (1.0,)
|
|
33
|
+
alpha = 0.3
|
|
34
|
+
|
|
35
|
+
def ln_gamma(self, x, phi):
|
|
36
|
+
r"""Calculates the natural log of the activity coefficients for each component.
|
|
37
|
+
|
|
38
|
+
In the Asymmetric NRTL model, the activity coefficients are calculated as:
|
|
39
|
+
|
|
40
|
+
.. math::
|
|
41
|
+
\ln \gamma_1 = \frac{x_2^2 \tau_{12} (G_{12} - 1)}{(x_1 G_{12} + x_2)^2}
|
|
42
|
+
(1 - e^{-C \phi})
|
|
43
|
+
|
|
44
|
+
\ln \gamma_2 = \frac{x_1^2 \tau_{21} (G_{21} - 1)}{(x_2 G_{21} + x_1)^2}
|
|
45
|
+
(1 - e^{-C \phi})
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
x (array-like): Mole fractions of the components in the mixture.
|
|
49
|
+
phi (float): Spreading pressure for the mixture.
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
np.ndarray: Natural log of the activity coefficients for each component.
|
|
53
|
+
"""
|
|
54
|
+
t12 = self.model_parameters['t12']
|
|
55
|
+
t21 = -t12
|
|
56
|
+
c = self.model_parameters['C']
|
|
57
|
+
f = 1.0 - np.exp(-c * phi)
|
|
58
|
+
alpha = self.alpha
|
|
59
|
+
g12 = np.exp(-alpha*t12)
|
|
60
|
+
g21 = np.exp(-alpha*t21)
|
|
61
|
+
|
|
62
|
+
ln_gamma0 = x[1]**2 * f * t12 * (g12 - 1.0) / (x[0] * g12 + x[1])**2
|
|
63
|
+
ln_gamma1 = x[0]**2 * f * t21 * (g21 - 1.0) / (x[1] * g21 + x[0])**2
|
|
64
|
+
return np.array([ln_gamma0, ln_gamma1])
|
|
65
|
+
|
|
66
|
+
def inverse_excess_loading(self, x, phi):
|
|
67
|
+
r"""Calculates the inverse of the excess loading given composition and phi.
|
|
68
|
+
|
|
69
|
+
The excess loading in the Asymmetric NRTL model is calculated as:
|
|
70
|
+
|
|
71
|
+
.. math:: \left(\frac{1}{q}\right)^E = \frac{x_1 x_2 \tau_{12} (G_{12} - 1)}
|
|
72
|
+
{x_1 G_{12} + x_2} C e^{-C \phi}
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
x (array-like): Mole fractions of the components in the mixture.
|
|
76
|
+
phi (float): Spreading pressure for the mixture.
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
float: Inverse of the excess loading for the mixture.
|
|
80
|
+
"""
|
|
81
|
+
t12 = self.model_parameters['t12']
|
|
82
|
+
g12 = np.exp(-self.alpha*t12)
|
|
83
|
+
c = self.model_parameters['C']
|
|
84
|
+
|
|
85
|
+
return c * x[0] * x[1] * t12 * (g12 - 1.0) * np.exp(-c * phi) / \
|
|
86
|
+
(x[0]*g12 + x[1])
|