Add Julia/C++ bindings for MUSICA#794
Add Julia/C++ bindings for MUSICA#794sjsprecious wants to merge 12 commits intojulia-binary-distributionfrom
Conversation
|
📄 Documentation for this branch is available at: https://ncar.github.io/musica/branch/add_julia_cxx_bindings/ |
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive Julia bindings for the MUSICA chemical kinetics library (MICM). It wraps the existing C++ API using CxxWrap, following the patterns established by the Python and JavaScript bindings.
Changes:
- Added C++/CxxWrap binding layer (
musica_julia.cpp) exposing MICM solver creation, state management, conditions, solver parameters, and solve functionality to Julia - Added Julia-side wrapper types and functions (
Musica.jl+micm/*.jl) providing a high-level Julia API with proper types, enums, and idiomatic Julia conventions - Fixed a CMake bug where
POSITION_INDEPENDENT_CODEwas set on the wrong target (musica→musica_julia), and restructuredMusica_jllas an optional dependency
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| julia/CMakeLists.txt | Bugfix: set PIC on musica_julia instead of musica |
| julia/Project.toml | Move Musica_jll from deps to extras; remove compat entry |
| julia/bindings/musica_julia.cpp | C++ binding layer exposing MICM types and functions via CxxWrap |
| julia/src/Musica.jl | Main module: library loading, includes, and exports |
| julia/src/micm/constants.jl | Physical constants (Avogadro, Boltzmann, gas constant) |
| julia/src/micm/solver.jl | SolverType enum |
| julia/src/micm/solver_result.jl | SolverState enum, SolverStats, SolverResult types |
| julia/src/micm/conditions.jl | Conditions struct with ideal gas law computation |
| julia/src/micm/solver_parameters.jl | Rosenbrock and BackwardEuler parameter types with C++ conversion |
| julia/src/micm/utils.jl | flat_index helper for vector-ordered memory layout |
| julia/src/micm/state.jl | State type with concentration/condition/rate parameter management |
| julia/src/micm/micm.jl | MICM wrapper with create_state, solve!, parameter management |
| julia/test/runtests.jl | Comprehensive tests covering all new functionality |
Comments suppressed due to low confidence (1)
julia/Project.toml:14
Musica_jllwas moved from[deps]to[extras], but it's not listed in the[targets] testlist either. This means it won't be available as a dependency in any context — neither at runtime nor during tests. The@eval using Musica_jllinMusica.jlwill always fail (caught by try/catch), so the package will only work whenMUSICA_JULIA_LIBis set.
If this is intentional (e.g., the JLL hasn't been updated yet), consider adding a code comment explaining why. Otherwise, either keep Musica_jll in [deps] or add it to the test targets: test = ["Test", "Musica_jll"].
[extras]
Musica_jll = "f5e5459d-1a87-5129-97d9-bab22ca84fbb"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[targets]
test = ["Test"]
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## julia-binary-distribution #794 +/- ##
============================================================
Coverage ? 71.46%
============================================================
Files ? 109
Lines ? 8676
Branches ? 0
============================================================
Hits ? 6200
Misses ? 2476
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive Julia bindings for the MUSICA chemical kinetics library (MICM solver), following the patterns established in the existing Python and JavaScript wrappers. It provides a full Julia API including solver creation, state management, condition setting, and solving, all backed by CxxWrap-based C++ bindings.
Changes:
- Added C++ binding layer (
musica_julia.cpp) exposing MICM solver, state, conditions, and solver parameters to Julia via CxxWrap - Added Julia module files implementing high-level wrappers for MICM including
MICM,State,Conditions, solver parameter types, enums, and utility functions - Updated build infrastructure (CMakeLists, Dockerfile, CI workflow, Project.toml) to support the new bindings with proper library discovery and linking
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| julia/bindings/musica_julia.cpp | C++ binding layer exposing MICM types and functions to Julia via CxxWrap |
| julia/src/Musica.jl | Main module restructured to load CxxWrap bindings and export new types/functions |
| julia/src/micm/micm.jl | High-level MICM solver wrapper struct and methods |
| julia/src/micm/state.jl | State management including concentrations, conditions, and rate parameters |
| julia/src/micm/solver.jl | SolverType enum definition |
| julia/src/micm/solver_result.jl | SolverState enum, SolverStats, and SolverResult types |
| julia/src/micm/solver_parameters.jl | Rosenbrock and BackwardEuler solver parameter types with C++ conversion |
| julia/src/micm/conditions.jl | Conditions struct with ideal gas law auto-calculation |
| julia/src/micm/constants.jl | Physical constants (Avogadro, Boltzmann, gas constant) |
| julia/src/micm/utils.jl | Vector-ordering index calculation utility |
| julia/test/runtests.jl | Comprehensive tests covering all new functionality |
| julia/CMakeLists.txt | Fixed PIC target name and added STL library link |
| julia/Project.toml | Moved Musica_jll to extras, removed compat entry |
| docker/Dockerfile.julia | Updated build to discover CxxWrap prefix and set library path |
| .github/workflows/julia.yml | Added CxxWrap prefix discovery, library path setup, and PIC flag |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
This PR is purely done by Claude, which follows the wrapper code under the
pythonandjavascriptfolders to add the Julia and C++ bindings for necessary MUSICA code.I tested it with
Julia/1.11and all the tests passed.