Skip to content

Fix remaining v0->v1 conversion gaps (third body, gas phase, surface prefix) - #310

Merged
K20shores merged 2 commits into
mainfrom
fix-v0-to-v1-conversion
Jul 24, 2026
Merged

Fix remaining v0->v1 conversion gaps (third body, gas phase, surface prefix)#310
K20shores merged 2 commits into
mainfrom
fix-v0-to-v1-conversion

Conversation

@K20shores

Copy link
Copy Markdown
Collaborator

Follow-up to #309. That PR fixed the diffusion coefficient, but three more v0-parser issues block converting a real v0 (CAMP) config to a loadable v1 mechanism. (#309 was squash-merged with only its first commit, so the third-body and gas-phase fixes below — briefly part of that PR — are not actually in main; they are re-included here.)

Fixes

  1. THIRD_BODY tracer dropped. A CHEM_SPEC with tracer type: THIRD_BODY recorded only the tracer-type string, which the unified type does not carry into v1 serialization (v1 uses is third body). Set is_third_body so the designation survives conversion — otherwise species like M silently lose their third-body role.

  2. Empty reaction gas phase. v0 reactions left gas_phase empty, but the v1 parser requires every reaction to name a non-empty gas phase, so a converted mechanism failed to re-parse with Unknown phase ''. Place all v0 reactions in the gas phase, mirroring how all v0 species are placed there.

  3. Doubled SURF. prefix. The v0 surface parser stored the name as "SURF." + MUSICA name — the only v0 reaction parser that prefixes the name (photolysis, emission, loss, user-defined all store the bare name and let the MICM conversion add the label prefix). Since that conversion also prepends SURF., surface labels became SURF.SURF.<name>, breaking consumers that build per-reaction columns from the name (e.g. music_box's SURF.<name>.<property>.<unit>). Store the bare name so the single downstream prefix yields SURF.<name>.

Tests

Extends the v0 species, arrhenius, and surface unit tests. All 12 v0 tests pass.

Together with NCAR/musica#983 (stamp v1 version on --convert), this lets musica-cli --convert produce a v1 mechanism that loads directly.

🤖 Generated with Claude Code

K20shores and others added 2 commits July 24, 2026 10:46
Two more v0-parser gaps that broke round-tripping a v0 config to v1:

- A CHEM_SPEC with `tracer type: THIRD_BODY` recorded only the tracer-type
  string, which the unified type does not carry into v1 serialization
  (v1 represents a third body via `is third body`). Set is_third_body so
  the designation survives conversion; without it species like M silently
  lose their third-body role.
- v0 reactions left `gas_phase` empty. The v1 parser requires every
  reaction to name a (non-empty) gas phase, so a converted mechanism failed
  to re-parse with "Unknown phase ''". Place all v0 reactions in the gas
  phase, mirroring how all v0 species are placed there.

Extends the v0 species and arrhenius tests to cover both.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The v0 surface parser stored the reaction name as "SURF." + MUSICA name,
but it is the only v0 reaction parser that prefixes the name — photolysis,
emission, first-order-loss and user-defined all store the bare MUSICA name
and rely on the downstream MICM conversion to add the label prefix. Since
that conversion also prepends "SURF.", surface labels became
"SURF.SURF.<name>", which breaks consumers that build per-reaction columns
from the name (e.g. music_box's "SURF.<name>.<property>.<unit>" parsing).

Store the bare MUSICA name so the single downstream prefix yields the
correct "SURF.<name>" label. Updates the v0 surface test expectations.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@K20shores
K20shores merged commit 2fb2312 into main Jul 24, 2026
26 of 28 checks passed
@K20shores
K20shores deleted the fix-v0-to-v1-conversion branch July 24, 2026 19:58
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.

2 participants