ExoGibbs 0.2.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 (56) hide show
  1. exogibbs-0.2.1/.github/workflows/main.yml +58 -0
  2. exogibbs-0.2.1/.gitignore +174 -0
  3. exogibbs-0.2.1/CLAUDE.md +45 -0
  4. exogibbs-0.2.1/LICENSE +21 -0
  5. exogibbs-0.2.1/MANIFEST.in +6 -0
  6. exogibbs-0.2.1/PKG-INFO +34 -0
  7. exogibbs-0.2.1/README.md +9 -0
  8. exogibbs-0.2.1/documents/Makefile +20 -0
  9. exogibbs-0.2.1/documents/conf.py +79 -0
  10. exogibbs-0.2.1/documents/ipynb/chemical_potential.ipynb +401 -0
  11. exogibbs-0.2.1/documents/ipynb/tce_two_species.ipynb +327 -0
  12. exogibbs-0.2.1/examples/GALLERY_HEADER.rst +2 -0
  13. exogibbs-0.2.1/examples/comparisons/comparison_with_hcosystem.py +131 -0
  14. exogibbs-0.2.1/examples/comparisons/comparison_with_hsystem.py +434 -0
  15. exogibbs-0.2.1/examples/comparisons/comparison_with_ykcode.py +119 -0
  16. exogibbs-0.2.1/examples/comparisons/p10.txt +1 -0
  17. exogibbs-0.2.1/examples/comparisons/yk.list +1 -0
  18. exogibbs-0.2.1/examples/numpyro/example_nuts.py +138 -0
  19. exogibbs-0.2.1/pyproject.toml +50 -0
  20. exogibbs-0.2.1/results/README.md +1 -0
  21. exogibbs-0.2.1/setup.cfg +4 -0
  22. exogibbs-0.2.1/src/ExoGibbs.egg-info/PKG-INFO +34 -0
  23. exogibbs-0.2.1/src/ExoGibbs.egg-info/SOURCES.txt +54 -0
  24. exogibbs-0.2.1/src/ExoGibbs.egg-info/dependency_links.txt +1 -0
  25. exogibbs-0.2.1/src/ExoGibbs.egg-info/requires.txt +5 -0
  26. exogibbs-0.2.1/src/ExoGibbs.egg-info/top_level.txt +1 -0
  27. exogibbs-0.2.1/src/exogibbs/ExoGibbs_version.py +1 -0
  28. exogibbs-0.2.1/src/exogibbs/__init__.py +8 -0
  29. exogibbs-0.2.1/src/exogibbs/api/__init__.py +0 -0
  30. exogibbs-0.2.1/src/exogibbs/api/thermochem.py +38 -0
  31. exogibbs-0.2.1/src/exogibbs/data/gibbs_matrices.npz +0 -0
  32. exogibbs-0.2.1/src/exogibbs/data/janaf_raw_sample.txt +12 -0
  33. exogibbs-0.2.1/src/exogibbs/data/matrix_v3.dat +160 -0
  34. exogibbs-0.2.1/src/exogibbs/data/molname_v3.dat +160 -0
  35. exogibbs-0.2.1/src/exogibbs/data/number_of_species.sample.list +1 -0
  36. exogibbs-0.2.1/src/exogibbs/data/testdata.dat +1 -0
  37. exogibbs-0.2.1/src/exogibbs/equilibrium/__init__.py +0 -0
  38. exogibbs-0.2.1/src/exogibbs/equilibrium/gibbs.py +160 -0
  39. exogibbs-0.2.1/src/exogibbs/io/__init__.py +0 -0
  40. exogibbs-0.2.1/src/exogibbs/io/load_data.py +166 -0
  41. exogibbs-0.2.1/src/exogibbs/optimize/__init__.py +0 -0
  42. exogibbs-0.2.1/src/exogibbs/optimize/core.py +47 -0
  43. exogibbs-0.2.1/src/exogibbs/optimize/minimize.py +278 -0
  44. exogibbs-0.2.1/src/exogibbs/optimize/vjpgibbs.py +87 -0
  45. exogibbs-0.2.1/src/exogibbs/test/__init__.py +0 -0
  46. exogibbs-0.2.1/src/exogibbs/test/analytic_hcosystem.py +108 -0
  47. exogibbs-0.2.1/src/exogibbs/test/analytic_hsystem.py +246 -0
  48. exogibbs-0.2.1/src/exogibbs/test/generate_gibbs.py +13 -0
  49. exogibbs-0.2.1/src/exogibbs/utils/__init__.py +0 -0
  50. exogibbs-0.2.1/src/exogibbs/utils/constants.py +2 -0
  51. exogibbs-0.2.1/tests/unittests/equilibrium/gibbs_test.py +72 -0
  52. exogibbs-0.2.1/tests/unittests/io/load_data_test.py +41 -0
  53. exogibbs-0.2.1/tests/unittests/optimize/lagrange/hcosystem_test.py +93 -0
  54. exogibbs-0.2.1/tests/unittests/optimize/lagrange/lagrange_test.py +22 -0
  55. exogibbs-0.2.1/tests/unittests/optimize/lagrange/minimize_test.py +207 -0
  56. exogibbs-0.2.1/tests/unittests/optimize/lagrange/minimize_vmap_test.py +130 -0
@@ -0,0 +1,58 @@
1
+ name: Run pytest
2
+
3
+ on:
4
+ push:
5
+ branches: [ "develop", "main" ]
6
+ pull_request:
7
+ branches: [ "develop", "main" ]
8
+
9
+ permissions:
10
+ checks: write
11
+ contents: write
12
+ pull-requests: write
13
+
14
+ jobs:
15
+ pytest:
16
+ runs-on: ubuntu-latest
17
+
18
+ steps:
19
+ - name: Checkout (with full history & tags for setuptools-scm)
20
+ uses: actions/checkout@v4
21
+ with:
22
+ fetch-depth: 0
23
+
24
+ - name: Set up Python 3.11
25
+ uses: actions/setup-python@v5
26
+ with:
27
+ python-version: '3.11'
28
+
29
+ - name: Install package and test deps
30
+ run: |
31
+ python -m pip install --upgrade pip wheel
32
+ pip install -e .
33
+ pip install pytest
34
+ # if using extras: pip install -e .[test]
35
+
36
+ - name: Run tests and generate XML report
37
+ run: |
38
+ mkdir -p results
39
+ pytest tests/unittests --junit-xml results/pytest.xml
40
+ continue-on-error: true
41
+
42
+ - name: Upload Unit Test Results
43
+ if: ${{ always() }}
44
+ uses: actions/upload-artifact@v4
45
+ with:
46
+ name: Unit Test Results (Python 3.11)
47
+ path: results/*.xml
48
+
49
+ - name: Download Artifacts
50
+ if: success() || failure()
51
+ uses: actions/download-artifact@v4
52
+ with:
53
+ path: artifacts
54
+
55
+ - name: Publish Unit Test Results
56
+ uses: EnricoMi/publish-unit-test-result-action@v2
57
+ with:
58
+ files: artifacts/**/*.xml
@@ -0,0 +1,174 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+
110
+ # pdm
111
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
+ #pdm.lock
113
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
+ # in version control.
115
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
+ .pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
+ __pypackages__/
122
+
123
+ # Celery stuff
124
+ celerybeat-schedule
125
+ celerybeat.pid
126
+
127
+ # SageMath parsed files
128
+ *.sage.py
129
+
130
+ # Environments
131
+ .env
132
+ .venv
133
+ env/
134
+ venv/
135
+ ENV/
136
+ env.bak/
137
+ venv.bak/
138
+
139
+ # Spyder project settings
140
+ .spyderproject
141
+ .spyproject
142
+
143
+ # Rope project settings
144
+ .ropeproject
145
+
146
+ # mkdocs documentation
147
+ /site
148
+
149
+ # mypy
150
+ .mypy_cache/
151
+ .dmypy.json
152
+ dmypy.json
153
+
154
+ # Pyre type checker
155
+ .pyre/
156
+
157
+ # pytype static type analyzer
158
+ .pytype/
159
+
160
+ # Cython debug symbols
161
+ cython_debug/
162
+
163
+ # PyCharm
164
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
167
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
+ #.idea/
169
+
170
+ # Ruff stuff:
171
+ .ruff_cache/
172
+
173
+ # PyPI configuration file
174
+ .pypirc
@@ -0,0 +1,45 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ ExoGibbs is an auto-differentiable thermochemical equilibrium solver implemented in JAX. It computes chemical equilibrium states by minimizing Gibbs free energy, with applications in planetary atmosphere modeling and chemical process simulation.
8
+
9
+ ## Key Architecture
10
+
11
+ - **Core equilibrium calculations**: `src/exogibbs/equilibrium/gibbs.py` - Contains Gibbs energy computation and chemical potential interpolation
12
+ - **Optimization algorithms**: `src/exogibbs/optimize/` - Core optimization functions (`minimize.py`), KL mirror descent, projected gradient descent, and Lagrange multiplier methods for constrained optimization
13
+ - **Data handling**: `src/exogibbs/io/load_data.py` - Loads JANAF thermochemical data from `src/exogibbs/data/`
14
+ - **Stoichiometry**: `src/exogibbs/stoichiometry/analyze_formula_matrix.py` - Chemical formula matrix analysis for mass balance constraints
15
+ - **Test data generation**: `src/exogibbs/test/generate_gibbs.py` - Creates test cases for equilibrium calculations
16
+ - **Testing**: Uses pytest framework with tests in `tests/unittests/` organized by module structure
17
+
18
+ ## Development Commands
19
+
20
+ **Installation**:
21
+ ```bash
22
+ pip install -e .
23
+ ```
24
+
25
+ **Testing**:
26
+ ```bash
27
+ # Run all tests
28
+ python -m pytest tests/unittests/
29
+
30
+ # Run specific test file
31
+ python -m pytest tests/unittests/equilibrium/gibbs_test.py
32
+
33
+ # Run individual test function
34
+ python -m pytest tests/unittests/equilibrium/gibbs_test.py::test_total_gibbs_energy
35
+ ```
36
+
37
+ **Key Dependencies**: JAX/JAXlib for auto-differentiation, pandas for data handling, pytest for testing
38
+
39
+ ## Important Notes
40
+
41
+ - **JAX Compatibility**: The project uses JAX for auto-differentiation and JIT compilation - ensure JAX operations are used consistently. Be careful with JAX compatibility when adding new functions
42
+ - **Keep It Simple**: Stay simple, do not add complex tests and functions
43
+ - Chemical potential data is interpolated from JANAF tables stored in `src/exogibbs/data/`
44
+ - Optimization operates in log-space to handle numerical stability with exponential functions
45
+ - Formula matrices encode stoichiometric constraints for mass balance during equilibrium calculation
exogibbs-0.2.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Hajime Kawahara
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,6 @@
1
+ include src/exogibbs/data/janaf_raw_sample.txt
2
+ include src/exogibbs/data/testdata.dat
3
+ include src/exogibbs/data/matrix_v3.dat
4
+ include src/exogibbs/data/molname_v3.dat
5
+ include src/exogibbs/data/gibbs_matrices.npz
6
+ include src/exogibbs/data/number_of_species.sample.list
@@ -0,0 +1,34 @@
1
+ Metadata-Version: 2.4
2
+ Name: ExoGibbs
3
+ Version: 0.2.1
4
+ Summary: Differentiable Thermochemical Equilibrium Solver for Exoplanet Atmospheres
5
+ Author-email: Hajime Kawahara <divrot@gmail.com>
6
+ Maintainer-email: Hajime Kawahara <divrot@gmail.com>
7
+ License: MIT
8
+ Project-URL: Homepage, https://github.com/HajimeKawahara/exogibbs
9
+ Project-URL: Repository, https://github.com/HajimeKawahara/exogibbs
10
+ Project-URL: Issues, https://github.com/HajimeKawahara/exogibbs/issues
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Operating System :: OS Independent
16
+ Requires-Python: >=3.9
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: interpax
20
+ Requires-Dist: jax<0.7,>=0.4.30
21
+ Requires-Dist: tqdm
22
+ Requires-Dist: pandas
23
+ Requires-Dist: thermochem
24
+ Dynamic: license-file
25
+
26
+ # ExoGibbs
27
+
28
+ Differentiable Thermochemical Equilibrium, powered by JAX.
29
+
30
+ The optimization scheme is based on the Lagrange multiplier, similar to NASA/CEA algorithm.
31
+ The terminology follows Smith and Missen.
32
+
33
+ ExoGibbs is designed to plug into [ExoJAX](https://github.com/HajimeKawahara/exojax) and enable gradient-based equilibrium retrievals.
34
+ It is still in a very beta stage, so please use it at your own risk.
@@ -0,0 +1,9 @@
1
+ # ExoGibbs
2
+
3
+ Differentiable Thermochemical Equilibrium, powered by JAX.
4
+
5
+ The optimization scheme is based on the Lagrange multiplier, similar to NASA/CEA algorithm.
6
+ The terminology follows Smith and Missen.
7
+
8
+ ExoGibbs is designed to plug into [ExoJAX](https://github.com/HajimeKawahara/exojax) and enable gradient-based equilibrium retrievals.
9
+ It is still in a very beta stage, so please use it at your own risk.
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = .
9
+ BUILDDIR = _build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1,79 @@
1
+ # Configuration file for the Sphinx documentation builder.
2
+ #
3
+ # This file only contains a selection of the most common options. For a full
4
+ # list see the documentation:
5
+ # http://www.sphinx-doc.org/en/master/config
6
+
7
+ # -- Path setup --------------------------------------------------------------
8
+
9
+ # If extensions (or modules to document with autodoc) are in another directory,
10
+ # add these directories to sys.path here. If the directory is relative to the
11
+ # documentation root, use os.path.abspath to make it absolute, like shown here.
12
+ #
13
+ import sphinx_rtd_theme
14
+ import os
15
+ import sys
16
+
17
+ sys.path.insert(0, os.path.abspath("~/exogibbs"))
18
+
19
+
20
+ # -- Project information -----------------------------------------------------
21
+
22
+ project = "Exogibbs"
23
+ copyright = "2025, ExoGibbs contributors"
24
+ author = "Exogibbs contributors"
25
+
26
+ # The full version, including alpha/beta/rc tags
27
+ release = "2.0.0"
28
+
29
+
30
+ # -- General configuration ---------------------------------------------------
31
+
32
+ # Add any Sphinx extension module names here, as strings. They can be
33
+ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
34
+ # ones.
35
+ extensions = [
36
+ "sphinx.ext.autodoc",
37
+ "sphinx.ext.napoleon",
38
+ "sphinxemoji.sphinxemoji",
39
+ "sphinx_gallery.gen_gallery",
40
+ ]
41
+
42
+ # Add any paths that contain templates here, relative to this directory.
43
+ templates_path = ["_templates"]
44
+
45
+ # List of patterns, relative to source directory, that match files and
46
+ # directories to ignore when looking for source files.
47
+ # This pattern also affects html_static_path and html_extra_path.
48
+ exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
49
+
50
+
51
+ # -- Options for HTML output -------------------------------------------------
52
+
53
+ # The theme to use for HTML and HTML Help pages. See the documentation for
54
+ # a list of builtin themes.
55
+ #
56
+ html_theme = "sphinx_rtd_theme"
57
+ # Add any paths that contain custom static files (such as style sheets) here,
58
+ # relative to this directory. They are copied after the builtin static files,
59
+ # so a file named "default.css" will overwrite the builtin "default.css".
60
+ html_static_path = ["_static"]
61
+ html_logo = "_static/logo.png"
62
+
63
+ # html_theme_options = {
64
+ # 'style_nav_header_background': '#333',
65
+ # }
66
+ html_css_files = ["header.css"]
67
+
68
+ # Sphinx-Gallery
69
+ from sphinx_gallery.sorting import FileNameSortKey
70
+ sphinx_gallery_conf = {
71
+ "examples_dirs": ["../examples"],
72
+ "gallery_dirs": ["examples"],
73
+ "within_subsection_order": FileNameSortKey,
74
+ "filename_pattern": "/plot_",
75
+ "ignore_pattern": "/_",
76
+ "backreferences_dir": "backreferences",
77
+ "doc_module": ("exogibbs",),
78
+ "reference_url": {"exogibbs": None},
79
+ }