ExoGibbs 0.2.2__tar.gz → 0.2.4__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.
- exogibbs-0.2.4/AGENTS.md +34 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/MANIFEST.in +1 -2
- {exogibbs-0.2.2/src/exogibbs.egg-info → exogibbs-0.2.4}/PKG-INFO +28 -3
- exogibbs-0.2.4/README.md +34 -0
- exogibbs-0.2.4/documents/_static/exogibbs_logo.png +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/documents/conf.py +1 -1
- exogibbs-0.2.4/documents/exogibbs/conf.py +36 -0
- exogibbs-0.2.4/documents/index.rst +47 -0
- exogibbs-0.2.4/documents/presets/ykb4.rst +196 -0
- exogibbs-0.2.4/examples/benchmark/clfac_yk.py +73 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/examples/comparisons/comparison_with_hcosystem.py +5 -5
- {exogibbs-0.2.2 → exogibbs-0.2.4}/examples/comparisons/comparison_with_hsystem.py +6 -6
- {exogibbs-0.2.2 → exogibbs-0.2.4}/examples/comparisons/comparison_with_ykcode.py +27 -8
- exogibbs-0.2.4/examples/layers/layer_ykb4.py +44 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/examples/numpyro/example_nuts.py +4 -4
- exogibbs-0.2.4/src/exogibbs/api/chemistry.py +124 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/api/equilibrium.py +63 -2
- exogibbs-0.2.4/src/exogibbs/exogibbs_version.py +1 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/optimize/minimize.py +67 -82
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/optimize/vjpgibbs.py +14 -14
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/presets/ykb4.py +23 -12
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/thermo/stoichiometry.py +2 -2
- {exogibbs-0.2.2 → exogibbs-0.2.4/src/exogibbs.egg-info}/PKG-INFO +28 -3
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs.egg-info/SOURCES.txt +8 -1
- exogibbs-0.2.4/tests/unittests/api/chemistry_bvector_test.py +46 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/tests/unittests/api/chemsetup_smoke_test.py +5 -10
- {exogibbs-0.2.2 → exogibbs-0.2.4}/tests/unittests/api/equilibrium_api_test.py +4 -4
- exogibbs-0.2.4/tests/unittests/api/equilibrium_jit_grad_test.py +42 -0
- exogibbs-0.2.4/tests/unittests/api/equilibrium_profile_test.py +61 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/tests/unittests/optimize/lagrange/hcosystem_test.py +3 -3
- {exogibbs-0.2.2 → exogibbs-0.2.4}/tests/unittests/optimize/lagrange/minimize_test.py +10 -10
- {exogibbs-0.2.2 → exogibbs-0.2.4}/tests/unittests/optimize/lagrange/minimize_vmap_test.py +4 -4
- exogibbs-0.2.2/AGENTS.md +0 -37
- exogibbs-0.2.2/README.md +0 -9
- exogibbs-0.2.2/examples/benchmark/clfac_yk.py +0 -61
- exogibbs-0.2.2/src/exogibbs/api/chemistry.py +0 -65
- exogibbs-0.2.2/src/exogibbs/data/number_of_species.sample.list +0 -1
- exogibbs-0.2.2/src/exogibbs/exogibbs_version.py +0 -1
- {exogibbs-0.2.2 → exogibbs-0.2.4}/.github/workflows/main.yml +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/.gitignore +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/CLAUDE.md +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/LICENSE +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/documents/Makefile +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/documents/ipynb/chemical_potential.ipynb +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/documents/ipynb/tce_two_species.ipynb +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/examples/GALLERY_HEADER.rst +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/examples/data/p10.txt +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/examples/data/yk.list +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/pyproject.toml +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/results/README.md +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/setup.cfg +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/ExoGibbs_version.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/__init__.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/api/__init__.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/data/gibbs_matrices.npz +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/data/janaf_raw_sample.txt +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/data/matrix_v3.dat +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/data/molecule_names.csv +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/data/testdata.dat +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/equilibrium/__init__.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/equilibrium/gibbs.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/io/__init__.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/io/load_data.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/optimize/__init__.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/optimize/core.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/presets/__init__.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/test/__init__.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/test/analytic_hcosystem.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/test/analytic_hsystem.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/test/generate_gibbs.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/test/reference_data.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/thermo/__init__.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/thermo/providers.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/utils/__init__.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs/utils/constants.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs.egg-info/dependency_links.txt +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs.egg-info/requires.txt +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/src/exogibbs.egg-info/top_level.txt +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/tests/unittests/equilibrium/gibbs_test.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/tests/unittests/io/formula_matrix_reference_vs_computed_test.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/tests/unittests/io/load_data_test.py +0 -0
- {exogibbs-0.2.2 → exogibbs-0.2.4}/tests/unittests/optimize/lagrange/lagrange_test.py +0 -0
exogibbs-0.2.4/AGENTS.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Repository Guidelines
|
|
2
|
+
|
|
3
|
+
## Project Structure & Module Organization
|
|
4
|
+
- Source: `src/exogibbs/` with subpackages `io/`, `equilibrium/`, `thermo/`, `optimize/`, `api/`, `presets/`, `utils/`; data files under `src/exogibbs/data/`.
|
|
5
|
+
- Tests: `tests/unittests/` organized by domain (e.g., `io/`, `equilibrium/`); files named `*_test.py`.
|
|
6
|
+
- Examples & docs: `examples/` and `documents/`.
|
|
7
|
+
|
|
8
|
+
## Build, Test, and Development Commands
|
|
9
|
+
- Install (editable): `python -m pip install -e .` (Python >= 3.9).
|
|
10
|
+
- Run tests: `pytest tests/unittests` (CI exports `results/pytest.xml`).
|
|
11
|
+
- Optional build: `python -m pip install build && python -m build` (ensure Git tags for correct versioning).
|
|
12
|
+
|
|
13
|
+
## Coding Style & Naming Conventions
|
|
14
|
+
- Language: Python with type hints where practical; 4-space indentation; keep functions short and focused.
|
|
15
|
+
- Naming: modules/functions/variables `snake_case`; classes `CapWords`; constants `UPPER_SNAKE_CASE`.
|
|
16
|
+
- Imports: standard lib, third-party, then local; avoid unused imports.
|
|
17
|
+
|
|
18
|
+
## Testing Guidelines
|
|
19
|
+
- Framework: `pytest`; keep tests deterministic (no network/GPU). Use small fixtures and cover edge cases (e.g., parsing, interpolation bounds).
|
|
20
|
+
- Location/pattern: place tests under `tests/unittests/<area>/`, name `*_test.py`.
|
|
21
|
+
- Run locally: `pytest tests/unittests`. Aim to maintain/raise coverage of changed code.
|
|
22
|
+
|
|
23
|
+
## Commit & Pull Request Guidelines
|
|
24
|
+
- Commits: concise, imperative (e.g., "thermo: fix electron parsing"); group related changes; reference issues (`#123`) when applicable.
|
|
25
|
+
- PRs: include a clear description, motivation, and testing notes; link issues; add/adjust tests; update data packaging (`MANIFEST.in`) when adding files under `src/exogibbs/data/`.
|
|
26
|
+
- CI: PRs to `develop`/`main` must pass the pytest workflow.
|
|
27
|
+
|
|
28
|
+
## Architecture Overview (Quick)
|
|
29
|
+
- `io.load_data`: loads molecule catalogs and JANAF-like tables.
|
|
30
|
+
- `thermo.stoichiometry`: builds formula matrices from species names.
|
|
31
|
+
- `equilibrium.gibbs`: pads tables and provides JAX-friendly interpolation of h-vectors.
|
|
32
|
+
- `optimize.*`: JAX-based core, VJP, and minimization routines.
|
|
33
|
+
- `api.chemistry` and `presets/`: typed containers and ready-to-use setups.
|
|
34
|
+
|
|
@@ -2,5 +2,4 @@ include src/exogibbs/data/janaf_raw_sample.txt
|
|
|
2
2
|
include src/exogibbs/data/testdata.dat
|
|
3
3
|
include src/exogibbs/data/matrix_v3.dat
|
|
4
4
|
include src/exogibbs/data/molecule_names.csv
|
|
5
|
-
include src/exogibbs/data/gibbs_matrices.npz
|
|
6
|
-
include src/exogibbs/data/number_of_species.sample.list
|
|
5
|
+
include src/exogibbs/data/gibbs_matrices.npz
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: exogibbs
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Differentiable Thermochemical Equilibrium Solver for Exoplanet Atmospheres
|
|
5
5
|
Author-email: Hajime Kawahara <divrot@gmail.com>
|
|
6
6
|
Maintainer-email: Hajime Kawahara <divrot@gmail.com>
|
|
@@ -24,11 +24,36 @@ Requires-Dist: thermochem
|
|
|
24
24
|
Dynamic: license-file
|
|
25
25
|
|
|
26
26
|
# ExoGibbs
|
|
27
|
+
[](https://deepwiki.com/HajimeKawahara/exogibbs)
|
|
27
28
|
|
|
28
29
|
Differentiable Thermochemical Equilibrium, powered by JAX.
|
|
29
30
|
|
|
30
|
-
The optimization scheme is based on the Lagrange multiplier, similar to NASA/CEA algorithm.
|
|
31
|
-
The terminology follows Smith and Missen.
|
|
31
|
+
The optimization scheme is based on the Lagrange multiplier, similar to [NASA/CEA algorithm](https://ntrs.nasa.gov/api/citations/19950013764/downloads/19950013764.pdf).
|
|
32
|
+
The terminology follows Smith and Missen, [Chemical Reaction Equilibrium Analysis](https://aiche.onlinelibrary.wiley.com/doi/10.1002/aic.690310127) (1983, Wiley-Interscience).
|
|
33
|
+
|
|
34
|
+
## Basic Use
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from exogibbs.presets.ykb4 import prepare_ykb4_setup
|
|
38
|
+
from exogibbs.api.equilibrium import equilibrium_profile, EquilibriumOptions
|
|
39
|
+
|
|
40
|
+
# chemical setup
|
|
41
|
+
chem = prepare_ykb4_setup()
|
|
42
|
+
|
|
43
|
+
# Thermodynamic conditions
|
|
44
|
+
Pref = 1.0 # bar, reference pressure
|
|
45
|
+
opts = EquilibriumOptions(epsilon_crit=1e-11, max_iter=1000)
|
|
46
|
+
|
|
47
|
+
res = equilibrium_profile(
|
|
48
|
+
chem,
|
|
49
|
+
temperature_profile,
|
|
50
|
+
pressure_profile,
|
|
51
|
+
chem.element_vector,
|
|
52
|
+
Pref=Pref,
|
|
53
|
+
options=opts,
|
|
54
|
+
)
|
|
55
|
+
nk_result = res.x #mixing ratio
|
|
56
|
+
```
|
|
32
57
|
|
|
33
58
|
ExoGibbs is designed to plug into [ExoJAX](https://github.com/HajimeKawahara/exojax) and enable gradient-based equilibrium retrievals.
|
|
34
59
|
It is still in a very beta stage, so please use it at your own risk.
|
exogibbs-0.2.4/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# ExoGibbs
|
|
2
|
+
[](https://deepwiki.com/HajimeKawahara/exogibbs)
|
|
3
|
+
|
|
4
|
+
Differentiable Thermochemical Equilibrium, powered by JAX.
|
|
5
|
+
|
|
6
|
+
The optimization scheme is based on the Lagrange multiplier, similar to [NASA/CEA algorithm](https://ntrs.nasa.gov/api/citations/19950013764/downloads/19950013764.pdf).
|
|
7
|
+
The terminology follows Smith and Missen, [Chemical Reaction Equilibrium Analysis](https://aiche.onlinelibrary.wiley.com/doi/10.1002/aic.690310127) (1983, Wiley-Interscience).
|
|
8
|
+
|
|
9
|
+
## Basic Use
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
from exogibbs.presets.ykb4 import prepare_ykb4_setup
|
|
13
|
+
from exogibbs.api.equilibrium import equilibrium_profile, EquilibriumOptions
|
|
14
|
+
|
|
15
|
+
# chemical setup
|
|
16
|
+
chem = prepare_ykb4_setup()
|
|
17
|
+
|
|
18
|
+
# Thermodynamic conditions
|
|
19
|
+
Pref = 1.0 # bar, reference pressure
|
|
20
|
+
opts = EquilibriumOptions(epsilon_crit=1e-11, max_iter=1000)
|
|
21
|
+
|
|
22
|
+
res = equilibrium_profile(
|
|
23
|
+
chem,
|
|
24
|
+
temperature_profile,
|
|
25
|
+
pressure_profile,
|
|
26
|
+
chem.element_vector,
|
|
27
|
+
Pref=Pref,
|
|
28
|
+
options=opts,
|
|
29
|
+
)
|
|
30
|
+
nk_result = res.x #mixing ratio
|
|
31
|
+
```
|
|
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.
|
|
Binary file
|
|
@@ -58,7 +58,7 @@ html_theme = "sphinx_rtd_theme"
|
|
|
58
58
|
# relative to this directory. They are copied after the builtin static files,
|
|
59
59
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
|
60
60
|
html_static_path = ["_static"]
|
|
61
|
-
html_logo = "_static/
|
|
61
|
+
html_logo = "_static/exogibbs_logo.png"
|
|
62
62
|
|
|
63
63
|
# html_theme_options = {
|
|
64
64
|
# 'style_nav_header_background': '#333',
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Configuration file for the Sphinx documentation builder.
|
|
2
|
+
#
|
|
3
|
+
# For the full list of built-in configuration values, see the documentation:
|
|
4
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
|
5
|
+
|
|
6
|
+
# -- Project information -----------------------------------------------------
|
|
7
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
|
8
|
+
|
|
9
|
+
project = 'exogibbs'
|
|
10
|
+
copyright = '2025, Author'
|
|
11
|
+
author = 'Author'
|
|
12
|
+
|
|
13
|
+
# -- General configuration ---------------------------------------------------
|
|
14
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
|
15
|
+
|
|
16
|
+
extensions = [
|
|
17
|
+
'sphinx.ext.autodoc',
|
|
18
|
+
'sphinx.ext.viewcode',
|
|
19
|
+
'sphinx.ext.todo',
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
templates_path = ['_templates']
|
|
23
|
+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
|
24
|
+
|
|
25
|
+
language = 'en'
|
|
26
|
+
|
|
27
|
+
# -- Options for HTML output -------------------------------------------------
|
|
28
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
|
29
|
+
|
|
30
|
+
html_theme = 'alabaster'
|
|
31
|
+
html_static_path = ['_static']
|
|
32
|
+
|
|
33
|
+
# -- Options for todo extension ----------------------------------------------
|
|
34
|
+
# https://www.sphinx-doc.org/en/master/usage/extensions/todo.html#configuration
|
|
35
|
+
|
|
36
|
+
todo_include_todos = True
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.. exojax documentation master file, created by
|
|
2
|
+
sphinx-quickstart on Mon Jan 11 14:38:51 2021.
|
|
3
|
+
You can adapt this file completely to your liking, but it should at least
|
|
4
|
+
contain the root `toctree` directive.
|
|
5
|
+
|
|
6
|
+
ExoGibbs
|
|
7
|
+
==================================
|
|
8
|
+
|
|
9
|
+
Version 0.2
|
|
10
|
+
|
|
11
|
+
|:frog:| `DeepWiki for ExoGibbs <https://deepwiki.com/HajimeKawahara/exogibbs>`_
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
`ExoGibbs <https://github.com/HajimeKawahara/exogibbs>`_ provides an auto-differentiable thermalchemical equilibrium solver
|
|
15
|
+
based on the Gibbs free energy minimization method, powered by `JAX <https://github.com/google/jax>`_.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
Contents
|
|
19
|
+
==================================
|
|
20
|
+
|
|
21
|
+
.. toctree::
|
|
22
|
+
:maxdepth: 2
|
|
23
|
+
:caption: PRESETS:
|
|
24
|
+
|
|
25
|
+
presets/ykb4.rst
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
.. toctree::
|
|
29
|
+
:maxdepth: 1
|
|
30
|
+
:caption: API:
|
|
31
|
+
|
|
32
|
+
exogibbs/exogibbs.rst
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
License & Attribution
|
|
38
|
+
---------------------
|
|
39
|
+
|
|
40
|
+
Copyright 2025-, Contributors
|
|
41
|
+
|
|
42
|
+
- `Hajime Kawahara <http://secondearths.sakura.ne.jp/en/index.html>`_ (@HajimeKawahara, maintainer)
|
|
43
|
+
- `Yui Kawashima <https://sites.google.com/view/yuikawashima/home>`_ (@ykawashima, the reference code author we inherit, the presets ykb4 originally comes from this code.)
|
|
44
|
+
-
|
|
45
|
+
|
|
46
|
+
ExoGibbs is free software made available under the MIT License.
|
|
47
|
+
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
YKB4 Preset
|
|
2
|
+
===========
|
|
3
|
+
|
|
4
|
+
Overview
|
|
5
|
+
--------
|
|
6
|
+
The ykb4 preset bundles a ready-to-use ChemicalSetup based on JANAF-like
|
|
7
|
+
Gibbs tables. It exposes a device-friendly stoichiometric matrix and a
|
|
8
|
+
JAX-differentiable h(T) interpolator for equilibrium calculations.
|
|
9
|
+
|
|
10
|
+
Quick Start
|
|
11
|
+
-----------
|
|
12
|
+
.. code-block:: python
|
|
13
|
+
|
|
14
|
+
from exogibbs.presets.ykb4 import prepare_ykb4_setup
|
|
15
|
+
from exogibbs.api.equilibrium import equilibrium
|
|
16
|
+
|
|
17
|
+
setup = prepare_ykb4_setup()
|
|
18
|
+
T, P = 1500.0, 1.0 # K, bar
|
|
19
|
+
b = setup.element_vector_reference # or your own jnp.array([...])
|
|
20
|
+
result = equilibrium(setup, T=T, P=P, b=b)
|
|
21
|
+
print(result.x) # mole fractions (K,)
|
|
22
|
+
|
|
23
|
+
Elements
|
|
24
|
+
--------
|
|
25
|
+
The following elements are included in this preset (including electrons as "e-"):
|
|
26
|
+
|
|
27
|
+
``C, H, He, K, N, Na, O, P, S, Ti, V, e-``
|
|
28
|
+
|
|
29
|
+
The reference elemental abundances (`element_vector_ref`) are taken from Asplund, Amarsi & Grevesse (2021).
|
|
30
|
+
|
|
31
|
+
Species (JANAF key)
|
|
32
|
+
-------------------
|
|
33
|
+
The species list corresponds to the ``JANAF`` column in ``molecule_names.csv``.
|
|
34
|
+
|
|
35
|
+
.. code-block:: text
|
|
36
|
+
|
|
37
|
+
000: C1
|
|
38
|
+
001: H2
|
|
39
|
+
002: He1
|
|
40
|
+
003: K1
|
|
41
|
+
004: N2
|
|
42
|
+
005: Na1
|
|
43
|
+
006: O2
|
|
44
|
+
007: Ti1
|
|
45
|
+
008: V1
|
|
46
|
+
009: P1
|
|
47
|
+
010: S1
|
|
48
|
+
011: e1-
|
|
49
|
+
012: C1H1
|
|
50
|
+
013: C1H1N1
|
|
51
|
+
014: C1H1N1O1
|
|
52
|
+
015: C1H1O1
|
|
53
|
+
016: C1H2
|
|
54
|
+
017: C1H2O1
|
|
55
|
+
018: C1H3
|
|
56
|
+
019: C1H4
|
|
57
|
+
020: C1K1N1
|
|
58
|
+
021: C1N1
|
|
59
|
+
022: C1N1Na1
|
|
60
|
+
023: C1N1O1
|
|
61
|
+
024: C1N2(CNN)
|
|
62
|
+
025: C1N2(NCN)
|
|
63
|
+
026: C1O1
|
|
64
|
+
027: C1O2
|
|
65
|
+
028: C2
|
|
66
|
+
029: C2H1
|
|
67
|
+
030: C2H2
|
|
68
|
+
031: C2H4
|
|
69
|
+
032: C2H4O1
|
|
70
|
+
033: C2K2N2
|
|
71
|
+
034: C2N1
|
|
72
|
+
035: C2N2
|
|
73
|
+
036: C2N2Na2
|
|
74
|
+
037: C2O1
|
|
75
|
+
038: C3
|
|
76
|
+
039: C3O2
|
|
77
|
+
040: C4
|
|
78
|
+
041: C4N2
|
|
79
|
+
042: C5
|
|
80
|
+
043: H1
|
|
81
|
+
044: H1K1
|
|
82
|
+
045: H1K1O1
|
|
83
|
+
046: H1N1
|
|
84
|
+
047: H1N1O1
|
|
85
|
+
048: H1N1O2(cis)
|
|
86
|
+
049: H1N1O2(trans)
|
|
87
|
+
050: H1N1O3
|
|
88
|
+
051: H1Na1
|
|
89
|
+
052: H1Na1O1
|
|
90
|
+
053: H1O1
|
|
91
|
+
054: H1O2
|
|
92
|
+
055: H2K2O2
|
|
93
|
+
056: H2N1
|
|
94
|
+
057: H2N2
|
|
95
|
+
058: H2Na2O2
|
|
96
|
+
059: H2O1
|
|
97
|
+
060: H2O2
|
|
98
|
+
061: H3N1
|
|
99
|
+
062: H4N2
|
|
100
|
+
063: K1O1
|
|
101
|
+
064: K2
|
|
102
|
+
065: N1
|
|
103
|
+
066: N1O1
|
|
104
|
+
067: N1O2
|
|
105
|
+
068: N1O3
|
|
106
|
+
069: N2O1
|
|
107
|
+
070: N2O3
|
|
108
|
+
071: N2O4
|
|
109
|
+
072: N2O5
|
|
110
|
+
073: N3
|
|
111
|
+
074: Na1O1
|
|
112
|
+
075: Na2
|
|
113
|
+
076: O1
|
|
114
|
+
077: O3
|
|
115
|
+
078: N1V1
|
|
116
|
+
079: O1Ti1
|
|
117
|
+
080: O1V1
|
|
118
|
+
081: O2Ti1
|
|
119
|
+
082: O2V1
|
|
120
|
+
083: C1H1P1
|
|
121
|
+
084: C1O1S1
|
|
122
|
+
085: C1P1
|
|
123
|
+
086: C1S1
|
|
124
|
+
087: C1S2
|
|
125
|
+
088: H1P1
|
|
126
|
+
089: H1S1
|
|
127
|
+
090: H2O4S1
|
|
128
|
+
091: H2P1
|
|
129
|
+
092: H2S1
|
|
130
|
+
093: H3P1
|
|
131
|
+
094: K2O4S1
|
|
132
|
+
095: N1P1
|
|
133
|
+
096: N1S1
|
|
134
|
+
097: Na2O4S1
|
|
135
|
+
098: O1P1
|
|
136
|
+
099: O1S1
|
|
137
|
+
100: O1S2
|
|
138
|
+
101: O2P1
|
|
139
|
+
102: O2S1
|
|
140
|
+
103: O3S1
|
|
141
|
+
104: O6P4
|
|
142
|
+
105: O10P4
|
|
143
|
+
106: P1S1
|
|
144
|
+
107: P2
|
|
145
|
+
108: P4
|
|
146
|
+
109: P4S3
|
|
147
|
+
110: S2
|
|
148
|
+
111: S3
|
|
149
|
+
112: S4
|
|
150
|
+
113: S5
|
|
151
|
+
114: S6
|
|
152
|
+
115: S7
|
|
153
|
+
116: S8
|
|
154
|
+
117: C1+
|
|
155
|
+
118: C1-
|
|
156
|
+
119: C1H1+
|
|
157
|
+
120: C1H1O1+
|
|
158
|
+
121: C1N1+
|
|
159
|
+
122: C1N1-
|
|
160
|
+
123: C1O2-
|
|
161
|
+
124: C2-
|
|
162
|
+
125: H1+
|
|
163
|
+
126: H1-
|
|
164
|
+
127: H1K1O1+
|
|
165
|
+
128: H1Na1O1+
|
|
166
|
+
129: H1O1+
|
|
167
|
+
130: H1O1-
|
|
168
|
+
131: H2+
|
|
169
|
+
132: H2-
|
|
170
|
+
133: H3O1+
|
|
171
|
+
134: He1+
|
|
172
|
+
135: K1+
|
|
173
|
+
136: K1-
|
|
174
|
+
137: K1O1-
|
|
175
|
+
138: N1+
|
|
176
|
+
139: N1-
|
|
177
|
+
140: N1O1+
|
|
178
|
+
141: N1O2-
|
|
179
|
+
142: N2+
|
|
180
|
+
143: N2-
|
|
181
|
+
144: N2O1+
|
|
182
|
+
145: Na1+
|
|
183
|
+
146: Na1-
|
|
184
|
+
147: Na1O1-
|
|
185
|
+
148: O1+
|
|
186
|
+
149: O1-
|
|
187
|
+
150: O2+
|
|
188
|
+
151: O2-
|
|
189
|
+
152: P1+
|
|
190
|
+
153: P1-
|
|
191
|
+
154: S1+
|
|
192
|
+
155: S1-
|
|
193
|
+
156: Ti1+
|
|
194
|
+
157: Ti1-
|
|
195
|
+
158: V1+
|
|
196
|
+
159: V1-
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Validation of Gibbs Minimization Against ykawashima's B4 code
|
|
3
|
+
============================================================
|
|
4
|
+
|
|
5
|
+
This example demonstrates and validates the ExoGibbs thermochemical equilibrium
|
|
6
|
+
solver against the code by ykawashima when she was at B4.
|
|
7
|
+
|
|
8
|
+
Updated to use the high-level API: exogibbs.api.equilibrium.equilibrium.
|
|
9
|
+
"""
|
|
10
|
+
from exogibbs.presets.ykb4 import prepare_ykb4_setup
|
|
11
|
+
import jax.numpy as jnp
|
|
12
|
+
from exogibbs.api.chemistry import ThermoState
|
|
13
|
+
from exogibbs.optimize.minimize import minimize_gibbs_core
|
|
14
|
+
|
|
15
|
+
from exogibbs.optimize.core import compute_ln_normalized_pressure
|
|
16
|
+
|
|
17
|
+
from jax import config
|
|
18
|
+
|
|
19
|
+
config.update("jax_enable_x64", True)
|
|
20
|
+
|
|
21
|
+
#chemical setup
|
|
22
|
+
chem = prepare_ykb4_setup()
|
|
23
|
+
|
|
24
|
+
# Thermodynamic conditions
|
|
25
|
+
temperature = 500.0 # K
|
|
26
|
+
P = 10.0 # bar
|
|
27
|
+
Pref = 1.0 # bar, reference pressure
|
|
28
|
+
ln_normalized_pressure = compute_ln_normalized_pressure(P, Pref)
|
|
29
|
+
|
|
30
|
+
# Initial guess for log number densities
|
|
31
|
+
ln_nk = jnp.zeros(chem.formula_matrix.shape[1]) # log(n_species)
|
|
32
|
+
ln_ntot = 0.0 # log(total number density)
|
|
33
|
+
|
|
34
|
+
# old reference elemental abundance b from yk's sample number densities
|
|
35
|
+
b_old_ref = jnp.array(
|
|
36
|
+
[
|
|
37
|
+
4.8774824e-04,
|
|
38
|
+
1.6749767e00,
|
|
39
|
+
1.6143440e-01,
|
|
40
|
+
2.5438149e-07,
|
|
41
|
+
1.3435642e-04,
|
|
42
|
+
3.9624806e-06,
|
|
43
|
+
9.7356725e-04,
|
|
44
|
+
5.7690579e-07,
|
|
45
|
+
3.0653933e-05,
|
|
46
|
+
1.6687756e-07,
|
|
47
|
+
1.9870969e-08,
|
|
48
|
+
0.0000000e00,
|
|
49
|
+
]
|
|
50
|
+
)
|
|
51
|
+
# ThermoState instance
|
|
52
|
+
thermo_state = ThermoState(
|
|
53
|
+
temperature=temperature,
|
|
54
|
+
ln_normalized_pressure=ln_normalized_pressure,
|
|
55
|
+
element_vector=b_old_ref,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# Convergence criteria
|
|
59
|
+
epsilon_crit = 1e-11
|
|
60
|
+
max_iter = 1000
|
|
61
|
+
|
|
62
|
+
ln_nk_result, _, icount = minimize_gibbs_core(
|
|
63
|
+
thermo_state,
|
|
64
|
+
ln_nk,
|
|
65
|
+
ln_ntot,
|
|
66
|
+
chem.formula_matrix,
|
|
67
|
+
chem.hvector_func,
|
|
68
|
+
epsilon_crit=epsilon_crit,
|
|
69
|
+
max_iter=max_iter,
|
|
70
|
+
)
|
|
71
|
+
nk_result = jnp.exp(ln_nk_result)
|
|
72
|
+
print("icount", icount)
|
|
73
|
+
#702 for clfac = 0.1, 347 for _cea_lambda
|
|
@@ -67,10 +67,10 @@ def hvector_func(temperature):
|
|
|
67
67
|
bH = 0.5
|
|
68
68
|
bC = 0.2
|
|
69
69
|
bO = 0.3
|
|
70
|
-
|
|
70
|
+
element_vector = jnp.array([bH, bC, bO]) # H, C, O
|
|
71
71
|
|
|
72
72
|
# ThermoState instance
|
|
73
|
-
thermo_state = ThermoState(temperature, ln_normalized_pressure,
|
|
73
|
+
thermo_state = ThermoState(temperature, ln_normalized_pressure, element_vector)
|
|
74
74
|
|
|
75
75
|
# Convergence criteria
|
|
76
76
|
epsilon_crit = 1e-11
|
|
@@ -110,8 +110,8 @@ assert jnp.abs(res) < epsilon_crit * 10.0
|
|
|
110
110
|
from exogibbs.test.analytic_hcosystem import derivative_dlnnCO_db
|
|
111
111
|
|
|
112
112
|
dlnn_db = jacrev(
|
|
113
|
-
lambda
|
|
114
|
-
ThermoState(temperature, ln_normalized_pressure,
|
|
113
|
+
lambda element_vector_in: minimize_gibbs(
|
|
114
|
+
ThermoState(temperature, ln_normalized_pressure, element_vector_in),
|
|
115
115
|
ln_nk,
|
|
116
116
|
ln_ntot,
|
|
117
117
|
formula_matrix,
|
|
@@ -119,7 +119,7 @@ dlnn_db = jacrev(
|
|
|
119
119
|
epsilon_crit=epsilon_crit,
|
|
120
120
|
max_iter=max_iter,
|
|
121
121
|
)
|
|
122
|
-
)(
|
|
122
|
+
)(element_vector) # (n_species, n_elements)
|
|
123
123
|
|
|
124
124
|
# analytical derivatives
|
|
125
125
|
gradf = derivative_dlnnCO_db(ln_nk_result[1], bC, bH, bO, k)
|
|
@@ -61,10 +61,10 @@ def hvector_func(temperature):
|
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
# Element abundance constraint: total H nuclei = 1.0
|
|
64
|
-
|
|
64
|
+
element_vector = jnp.array([1.0])
|
|
65
65
|
|
|
66
66
|
# ThermoState instance
|
|
67
|
-
thermo_state = ThermoState(temperature, ln_normalized_pressure,
|
|
67
|
+
thermo_state = ThermoState(temperature, ln_normalized_pressure, element_vector)
|
|
68
68
|
|
|
69
69
|
# Convergence criteria
|
|
70
70
|
epsilon_crit = 1e-11
|
|
@@ -116,7 +116,7 @@ dln_dT = jacrev(
|
|
|
116
116
|
ThermoState(
|
|
117
117
|
temperature_in,
|
|
118
118
|
ln_normalized_pressure,
|
|
119
|
-
|
|
119
|
+
element_vector,
|
|
120
120
|
),
|
|
121
121
|
ln_nk,
|
|
122
122
|
ln_ntot,
|
|
@@ -152,7 +152,7 @@ dln_dlogp = jacrev(
|
|
|
152
152
|
ThermoState(
|
|
153
153
|
temperature,
|
|
154
154
|
ln_normalized_pressure,
|
|
155
|
-
|
|
155
|
+
element_vector,
|
|
156
156
|
),
|
|
157
157
|
ln_nk,
|
|
158
158
|
ln_ntot,
|
|
@@ -193,7 +193,7 @@ ln_ntot_init = 0.0
|
|
|
193
193
|
# Vectorize minimize_gibbs over temperature axis
|
|
194
194
|
def func(T):
|
|
195
195
|
return minimize_gibbs(
|
|
196
|
-
ThermoState(T, ln_normalized_pressure,
|
|
196
|
+
ThermoState(T, ln_normalized_pressure, element_vector),
|
|
197
197
|
ln_nk_init,
|
|
198
198
|
ln_ntot_init,
|
|
199
199
|
formula_matrix,
|
|
@@ -327,7 +327,7 @@ print(f"Pressure range: {Parr[0]:.3f} to {Parr[-1]:.0f} bar ({len(Parr)} points)
|
|
|
327
327
|
# Vectorize minimize_gibbs over temperature axis
|
|
328
328
|
def funcp(logpin):
|
|
329
329
|
return minimize_gibbs(
|
|
330
|
-
ThermoState(temperature, logpin,
|
|
330
|
+
ThermoState(temperature, logpin, element_vector),
|
|
331
331
|
ln_nk_init,
|
|
332
332
|
ln_ntot_init,
|
|
333
333
|
formula_matrix,
|
|
@@ -11,7 +11,7 @@ Updated to use the high-level API: exogibbs.api.equilibrium.equilibrium.
|
|
|
11
11
|
from exogibbs.presets.ykb4 import prepare_ykb4_setup
|
|
12
12
|
from exogibbs.api.equilibrium import equilibrium, EquilibriumOptions
|
|
13
13
|
import numpy as np
|
|
14
|
-
|
|
14
|
+
import jax.numpy as jnp
|
|
15
15
|
from jax import config
|
|
16
16
|
|
|
17
17
|
config.update("jax_enable_x64", True)
|
|
@@ -22,9 +22,28 @@ temperature = 500.0 # K
|
|
|
22
22
|
P = 10.0 # bar
|
|
23
23
|
Pref = 1.0 # bar, reference pressure
|
|
24
24
|
|
|
25
|
-
#chemical setup
|
|
25
|
+
# chemical setup
|
|
26
26
|
chem = prepare_ykb4_setup()
|
|
27
27
|
|
|
28
|
+
# old reference elemental abundance b from yk's sample number densities
|
|
29
|
+
b_old_ref = jnp.array(
|
|
30
|
+
[
|
|
31
|
+
4.8774824e-04,
|
|
32
|
+
1.6749767e00,
|
|
33
|
+
1.6143440e-01,
|
|
34
|
+
2.5438149e-07,
|
|
35
|
+
1.3435642e-04,
|
|
36
|
+
3.9624806e-06,
|
|
37
|
+
9.7356725e-04,
|
|
38
|
+
5.7690579e-07,
|
|
39
|
+
3.0653933e-05,
|
|
40
|
+
1.6687756e-07,
|
|
41
|
+
1.9870969e-08,
|
|
42
|
+
0.0000000e00,
|
|
43
|
+
]
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
28
47
|
##############################################################################
|
|
29
48
|
# Solve equilibrium via high-level API
|
|
30
49
|
# ------------------------------------
|
|
@@ -33,7 +52,7 @@ res = equilibrium(
|
|
|
33
52
|
chem,
|
|
34
53
|
T=temperature,
|
|
35
54
|
P=P,
|
|
36
|
-
b=
|
|
55
|
+
b=b_old_ref,
|
|
37
56
|
Pref=Pref,
|
|
38
57
|
options=opts,
|
|
39
58
|
)
|
|
@@ -43,21 +62,22 @@ nk_result = res.n
|
|
|
43
62
|
|
|
44
63
|
# load yk's results for 10 bar
|
|
45
64
|
dat = np.loadtxt("../data/p10.txt", delimiter=",")
|
|
46
|
-
mask = dat > 1.
|
|
65
|
+
mask = dat > 1.0e-14
|
|
47
66
|
mask_nk_result = nk_result[mask]
|
|
48
67
|
mask_dat = dat[mask]
|
|
49
68
|
|
|
50
|
-
res = mask_nk_result/mask_dat - 1.0
|
|
51
|
-
print(res,"diff for n>1.e-14")
|
|
69
|
+
res = mask_nk_result / mask_dat - 1.0
|
|
70
|
+
print(res, "diff for n>1.e-14")
|
|
52
71
|
assert np.max(np.abs(res)) < 0.051
|
|
53
72
|
# 8/9/2025
|
|
54
|
-
#[-0.00163185 -0.00163185 0.02571018 -0.00203837 -0.05069541 -0.00163185
|
|
73
|
+
# [-0.00163185 -0.00163185 0.02571018 -0.00203837 -0.05069541 -0.00163185
|
|
55
74
|
# -0.00481986 -0.00420364 -0.00161074 -0.00163182 -0.00163185 -0.00163183
|
|
56
75
|
# -0.00163184 -0.00163178 -0.00163185 -0.00163184]
|
|
57
76
|
|
|
58
77
|
|
|
59
78
|
ind = np.arange(len(nk_result))
|
|
60
79
|
import matplotlib.pyplot as plt
|
|
80
|
+
|
|
61
81
|
plt.plot(ind, nk_result, "+", label="ExoGibbs")
|
|
62
82
|
plt.plot(ind, dat, ".", alpha=0.5, label="yk B4 code")
|
|
63
83
|
plt.xlabel("Species Index")
|
|
@@ -66,4 +86,3 @@ plt.yscale("log")
|
|
|
66
86
|
plt.legend()
|
|
67
87
|
plt.grid()
|
|
68
88
|
plt.show()
|
|
69
|
-
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Validation of Gibbs Minimization for Layered Systems
|
|
3
|
+
===================================================================================
|
|
4
|
+
|
|
5
|
+
This example demonstrates and validates the ExoGibbs thermochemical equilibrium for the layered system
|
|
6
|
+
|
|
7
|
+
Updated to use the high-level API: exogibbs.api.equilibrium.equilibrium.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from exogibbs.presets.ykb4 import prepare_ykb4_setup
|
|
11
|
+
from exogibbs.api.equilibrium import equilibrium_profile, EquilibriumOptions
|
|
12
|
+
import numpy as np
|
|
13
|
+
import jax.numpy as jnp
|
|
14
|
+
from jax import config
|
|
15
|
+
|
|
16
|
+
config.update("jax_enable_x64", True)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# Thermodynamic conditions
|
|
20
|
+
Pref = 1.0 # bar, reference pressure
|
|
21
|
+
Parr = jnp.logspace(-8, 2, 10)/Pref # bar
|
|
22
|
+
Tarr = 1500*Parr**0.1
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
#chemical setup
|
|
26
|
+
chem = prepare_ykb4_setup()
|
|
27
|
+
|
|
28
|
+
##############################################################################
|
|
29
|
+
# Solve equilibrium via high-level API
|
|
30
|
+
# ------------------------------------
|
|
31
|
+
opts = EquilibriumOptions(epsilon_crit=1e-11, max_iter=1000)
|
|
32
|
+
|
|
33
|
+
res = equilibrium_profile(
|
|
34
|
+
chem,
|
|
35
|
+
Tarr,
|
|
36
|
+
Parr,
|
|
37
|
+
chem.element_vector_reference,
|
|
38
|
+
Pref=Pref,
|
|
39
|
+
options=opts,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
##############################################################################
|
|
43
|
+
nk_result = res.n
|
|
44
|
+
print(nk_result)
|