Add phase equilibrium#100
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new fixed-temperature / fixed-pressure multiphase chemical equilibrium capability (EquilibriumTP) with both C++ and CUDA backends, plus Python bindings and a NASA-9-based Python-side log(K) model (Nasa9LogK). It extends the library’s thermochemistry tooling with molar-mass utilities and documents a full YAML-driven equilibrium workflow.
Changes:
- Add
EquilibriumTPsolver core (CPU + CUDA dispatch) and YAML-drivenEquilibriumOptions. - Add molar-mass utilities (C++ + Python bindings) and a Python
Nasa9LogKlog(K) model. - Add end-to-end examples, README documentation, and new C++/Python tests for equilibrium.
Reviewed changes
Copilot reviewed 28 out of 29 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_equilibrium.py | Adds Python tests covering bindings, molar-mass helpers, and NASA-9 equilibrium case. |
| tests/test_equilibrium.cpp | Adds C++/device tests for equilibrium solver and YAML parsing/validation. |
| tests/CMakeLists.txt | Registers the new equilibrium test target. |
| src/utils/molar_mass.hpp | Declares atomic/compound molar-mass utilities and YAML extraction helper. |
| src/utils/molar_mass.cpp | Implements molar-mass utilities and YAML-based molar-mass extraction. |
| src/species.hpp | Adjusts declarations and exposes nasa9_gibbs_rt API. |
| src/species.cpp | Integrates molar-mass utility, NASA-9 access, and provides nasa9_gibbs_rt implementation. |
| src/math/leastsq_kkt.h | Makes hash_set inline for header safety/ODR. |
| src/loops.cuh | Adds a global-memory CUDA workspace kernel helper used by equilibrium. |
| src/equilibrium/phase_equilibrate_tp.h | Adds the core multiphase TP equilibrium solver routine. |
| src/equilibrium/equilibrium.hpp | Adds public C++ module API for options + TP solver. |
| src/equilibrium/equilibrium.cpp | Implements option validation, stoichiometry setup, and tensor iterator integration. |
| src/equilibrium/equilibrium_options.cpp | Implements YAML parsing for equilibrium options and reaction balance validation. |
| src/equilibrium/equilibrium_dispatch.hpp | Defines the CPU/CUDA dispatch stub interface for equilibrium. |
| src/equilibrium/equilibrium_dispatch.cu | Implements CUDA dispatch using per-cell global-memory workspace. |
| src/equilibrium/equilibrium_dispatch.cpp | Implements CPU dispatch via TensorIterator for_each. |
| src/CMakeLists.txt | Adds equilibrium sources to CPU and CUDA library builds. |
| README.md | Documents multiphase equilibrium workflow and NASA-9 example usage. |
| python/kintera.pyi | Adds type stubs for equilibrium APIs, molar-mass utilities, and NASA-9 Gibbs helper. |
| python/equilibrium/nasa9.py | Adds Nasa9LogK Python model for log(K) using bundled NASA-9 data. |
| python/equilibrium/init.py | Exposes equilibrium Python submodule exports. |
| python/csrc/pyequilibrium.cpp | Adds pybind bindings for equilibrium options + module. |
| python/csrc/kintera.cpp | Exposes molar-mass helpers and NASA-9 Gibbs helper; registers equilibrium bindings. |
| python/init.py | Re-exports equilibrium Python package. |
| pyproject.toml | Adds kintera.equilibrium package and includes equilibrium YAMLs in package data. |
| examples/equilibrium_nasa9.yaml | Adds a YAML-defined NASA-9 equilibrium example configuration. |
| examples/equilibrium_nasa9.py | Adds runnable example script demonstrating equilibrium + NASA-9 log(K). |
| .gitignore | Ignores PDF files. |
| .github/workflows/release.yml | Updates macOS runner label for wheel builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+58
to
+61
| static std::unordered_map<std::string, Nasa9Entry> &get_nasa9_db() { | ||
| static std::unordered_map<std::string, Nasa9Entry> db; | ||
| if (!db.empty()) return db; | ||
| if (!db.empty()) | ||
| return db; |
Comment on lines
+130
to
+139
| auto tensor_options = temp.options(); | ||
| auto low_tensor = | ||
| torch::empty({static_cast<int64_t>(species.size()), 9}, tensor_options); | ||
| auto high_tensor = torch::empty_like(low_tensor); | ||
| for (size_t i = 0; i < species.size(); ++i) { | ||
| for (int j = 0; j < 9; ++j) { | ||
| low_tensor.index_put_({static_cast<int64_t>(i), j}, low[i][j]); | ||
| high_tensor.index_put_({static_cast<int64_t>(i), j}, high[i][j]); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.