Skip to content

feat(schema): new [nuclear] sub-table + py-mat[nuclear] extra (#157) - #195

Merged
gerchowl merged 4 commits into
mainfrom
feature/157-nuclear-subtable
May 6, 2026
Merged

gerchowl merged 4 commits into
mainfrom
feature/157-nuclear-subtable

Conversation

@gerchowl

@gerchowl gerchowl commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Per ADR-0003 §1 — semantic recategorization. radiation_length, interaction_length, moliere_radius were misfiled under [optical] but they're nuclear/radiation physics. Moved cleanly, no compat shim — the only known consumer (build123d) doesn't read these fields.

New NuclearProperties

Field Unit Notes
radiation_length cm moved from OpticalProperties
interaction_length cm moved from OpticalProperties
moliere_radius cm moved from OpticalProperties
Z_eff dimensionless new — effective Z
mean_excitation_energy_eV eV new — Geant4 SetMeanExcitationEnergy
intrinsic_activity_Bq_per_g Bq/g new — LYSO 176Lu ≈ 39

Plus mu_rho(energy_keV=...) lazy accessor.

Optional extra py-mat[nuclear]

pip install py-materials[nuclear]

Wires nucl-parquet (cross-section tables, decay chains, stopping powers). Lazy-imported in NuclearProperties.mu_rho() so the core install stays dependency-light. Without the extra installed, the call raises ImportError with a helpful hint.

Gated to Python 3.11+ (nucl-parquet's floor). On 3.10 the extra resolves to nothing; the scalar fields still work.

Migration

src/pymat/data/scintillators.toml — 6 entries migrated from [optical] to [nuclear]: LYSO, BGO, NaI, CsI, LaBr3, PWO. Values unchanged. Migration script in commit body.

Backwards-compat note

mat.properties.optical.radiation_length no longer exists. Per ADR-0003 §6 option (a), tagged as feat: not feat!: (minor bump). Justification: build123d-only consumer model — those fields aren't read in the documented integration path.

Test plan

  • pytest tests/test_nuclear_subtable.py — 9 tests pass
  • Migrated TOMLs load cleanly (test_lyso_radiation_length_after_migration)
  • Full suite: 579 passed, 11 skipped, zero regressions
  • ruff check clean
  • mu_rho() lazy import path tested without nucl-parquet installed

Closes #157
Phase 2 complete with this PR: #151 (merged) → #152 (merged) → #153 (merged) → #154 → #155 → #156 → #157.

gerchowl added 2 commits May 6, 2026 21:54
Per ADR-0003 §1 — semantic recategorization. radiation_length /
interaction_length / moliere_radius were misfiled under [optical] but
they're nuclear/radiation physics. Moved cleanly (no compat shim — only
known consumer is build123d, which doesn't read these fields).

New `NuclearProperties` dataclass with:
- radiation_length / interaction_length / moliere_radius (cm) — moved
  from OpticalProperties
- Z_eff (dimensionless)
- mean_excitation_energy_eV — Geant4 SetMeanExcitationEnergy
- intrinsic_activity_Bq_per_g — LYSO 176Lu ≈ 39

Plus `mu_rho(energy_keV=...)` lazy accessor that imports `nucl_parquet`
on first call. Without the extra installed, raises `ImportError` with a
helpful hint.

Optional extra in pyproject.toml:
  pip install py-materials[nuclear]
gated to Python 3.11+ (nucl-parquet's floor); on 3.10 the extra resolves
to nothing and `mu_rho()` is unavailable — scalar fields still work.

Wires:
- AllProperties.nuclear field
- Loader dispatch + child-skip whitelist
- test_toml_integrity._KNOWN_GROUPS
- pymat-mcp _ALL_DOMAINS
- src/pymat/data/scintillators.toml — 6 entries migrated from
  [optical] to [nuclear] (LYSO, BGO, NaI, CsI, LaBr3, PWO)

CONTRIBUTING.md: new "Nuclear data (optional extra)" section.

Note on backwards compat: `mat.properties.optical.radiation_length`
no longer exists. The user-clarified consumer model (build123d only,
which uses density+vis only) makes this a safe minor breakage. Tagged
as `feat:` (not `feat!:`) per ADR-0003 §6 option (a).

Tests: tests/test_nuclear_subtable.py (9 tests). Full suite: 579 passed.

Closes #157
Rust crate's OpticalProperties had radiation_length/interaction_length
that mirrored the now-removed Python fields. Mirror the schema move
to the new NuclearProperties dataclass + extract_nuclear() reader.

Updates the integration test to assert radiation_length under
.nuclear() instead of .optical().
@gerchowl
gerchowl force-pushed the feature/157-nuclear-subtable branch from ec36c2d to 67caacf Compare May 6, 2026 19:55
@gerchowl
gerchowl enabled auto-merge (squash) May 6, 2026 19:55
@gerchowl
gerchowl merged commit e37d404 into main May 6, 2026
20 checks passed
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.

Schema: new nuclear sub-table — scalar identity only (delegate tables to nucl-parquet)

1 participant