Skip to content

Add Julia/C++ bindings for MUSICA#794

Open
sjsprecious wants to merge 12 commits intojulia-binary-distributionfrom
add_julia_cxx_bindings
Open

Add Julia/C++ bindings for MUSICA#794
sjsprecious wants to merge 12 commits intojulia-binary-distributionfrom
add_julia_cxx_bindings

Conversation

@sjsprecious
Copy link
Contributor

This PR is purely done by Claude, which follows the wrapper code under the python and javascript folders to add the Julia and C++ bindings for necessary MUSICA code.

I tested it with Julia/1.11 and all the tests passed.

@github-actions
Copy link
Contributor

📄 Documentation for this branch is available at: https://ncar.github.io/musica/branch/add_julia_cxx_bindings/

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_CODE was set on the wrong target (musicamusica_julia), and restructured Musica_jll as 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_jll was moved from [deps] to [extras], but it's not listed in the [targets] test list either. This means it won't be available as a dependency in any context — neither at runtime nor during tests. The @eval using Musica_jll in Musica.jl will always fail (caught by try/catch), so the package will only work when MUSICA_JULIA_LIB is 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-commenter
Copy link

codecov-commenter commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (julia-binary-distribution@03ff14a). Learn more about missing BASE report.

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           
Flag Coverage Δ
cpp_fortran 65.81% <ø> (?)
python 79.63% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants