Skip to content

Tutorial Ch 4: Multiple mechanisms in the same host application#867

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-solvers-for-multiple-mechanisms
Draft

Tutorial Ch 4: Multiple mechanisms in the same host application#867
Copilot wants to merge 3 commits intomainfrom
copilot/add-solvers-for-multiple-mechanisms

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 5, 2026

Adds Tutorial Chapter 4 covering how to create and run independent MICM solver instances for different chemical mechanisms within a single host application — a common pattern in multi-domain atmospheric models.

Python tutorial (tutorials/4. multiple_mechanisms.ipynb)

  • Defines two mechanisms in-code: A→B→C (Arrhenius) and a reversible D⇌E+F system
  • Creates separate MICM solver + state per mechanism; advances both in the same time loop
  • Side-by-side matplotlib visualization of both systems
solver_1 = musica.MICM(mechanism=mechanism_1, solver_type=musica.SolverType.rosenbrock_standard_order)
solver_2 = musica.MICM(mechanism=mechanism_2, solver_type=musica.SolverType.rosenbrock_standard_order)
state_1, state_2 = solver_1.create_state(), solver_2.create_state()

while curr_time < sim_length:
    solver_1.solve(state_1, time_step)   # 3-species A→B→C
    solver_2.solve(state_2, time_step)   # 3-species D⇌E+F
    curr_time += time_step

Fortran tutorial (fortran/test/tutorial/test_multiple_mechanisms.F90)

  • Solver 1: configs/v0/analytical (6-species with Arrhenius + user-defined rates)
  • Solver 2: configs/v1/analytical/config.json (3-species pure Arrhenius)
  • Registered as tutorial_multiple_mechanisms in fortran/test/integration/CMakeLists.txt

Fortran docs (docs/source/user_guide/fortran/chapter4.rst)

  • New chapter explaining independent solver instances, separate states, simultaneous time-stepping, and memory management
  • Added to Fortran tutorial toctree

Tutorial renumbering

Existing tutorials 4–11 shifted to 5–12 to place the new chapter in its logical position (after user-defined reactions, before parallelization). Updated all cross-references and doc index links accordingly.

Copilot AI and others added 2 commits May 5, 2026 14:05
- Add Python notebook: tutorials/4. multiple_mechanisms.ipynb
- Rename existing tutorials 4-11 to 5-12 to accommodate new Ch 4
- Update cross-reference in 6. hpc_parallelization.ipynb (4 → 5)
- Add Fortran test: fortran/test/tutorial/test_multiple_mechanisms.F90
- Register Fortran test in fortran/test/integration/CMakeLists.txt
- Add Fortran docs: docs/source/user_guide/fortran/chapter4.rst
- Update docs/source/user_guide/fortran/index.rst to include chapter4
- Update docs/source/user_guide/python/notebooks/index.rst with new/renumbered entries
- Fix binder link for HPC parallelization doc (5 → 6)

Agent-Logs-Url: https://github.com/NCAR/musica/sessions/0952954f-4e6c-4610-bc3e-e272310b586b

Co-authored-by: K20shores <13836216+K20shores@users.noreply.github.com>
Copilot AI changed the title [WIP] Add solvers for multiple mechanisms in the same host application Tutorial Ch 4: Multiple mechanisms in the same host application May 5, 2026
Copilot AI requested a review from K20shores May 5, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tutorial Ch 4: Create solvers for multiple mechanisms that run in the same host application

2 participants