Skip to content

(refac): Accept abstract IMAS.DD in fusion power signatures#302

Open
mgyoo86 wants to merge 2 commits into
masterfrom
ife_dd
Open

(refac): Accept abstract IMAS.DD in fusion power signatures#302
mgyoo86 wants to merge 2 commits into
masterfrom
ife_dd

Conversation

@mgyoo86
Copy link
Copy Markdown
Member

@mgyoo86 mgyoo86 commented May 19, 2026

Summary

Relax three fusion-power physics functions to accept any IMAS.DD subtype, so packages built on top of IMAS (e.g. IFE-related workflows or other FUSE-based applications that define their own DD subtype) can call them on their own top-level container without re-implementing the body.

Changes (1 file, 6 lines)

In src/physics/nuclear.jl, dd::IMAS.dddd::IMAS.DD for:

  • fusion_power(dd; …)
  • fusion_energy(dd; …)
  • fusion_neutron_power(dd)

Each body only accesses dd.core_profiles.profiles_1d[…], which is available on any DD subtype that embeds core_profiles.

Compatibility

Pure widening. IMAS.dd <: IMAS.DD, so every existing call site dispatches to the same method as before. No behavioral change, no performance change (Julia still specializes on the concrete type at compile time).

Scope

Minimally invasive on purpose: only these three functions are touched, and only because their bodies are already trivially generic over the container. In principle most dd::IMAS.dd annotations on functions that touch only shared IDS could receive the same treatment, but this PR keeps the change small and easy to verify — broader relaxation can follow in separate PRs as concrete need emerges.

mgyoo86 added 2 commits May 13, 2026 10:17
Change `dd::IMAS.dd` → `dd::IMAS.DD` (or `IMAS.DD{T}` where T is needed
in the body) for:
- fusion_power
- fusion_energy
- fusion_neutron_power

Backward-compatible: IMAS.dd <: IMAS.DD so existing call sites are
unaffected. Allows satellite packages whose top-level container is a
sibling DD subtype (e.g. IFEdd.dd_ife) to call these functions when
their container embeds core_profiles.
Copy link
Copy Markdown

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 widens the dispatch signatures of selected fusion-power helper functions so they accept any IMAS.DD subtype (not just the concrete IMAS.dd container), enabling downstream packages with custom top-level DD containers to reuse these physics utilities without re-implementing them.

Changes:

  • Widened fusion_power to accept dd::IMAS.DD (and updated its docstring signature/description accordingly).
  • Widened fusion_energy to accept dd::IMAS.DD{T}.
  • Widened fusion_neutron_power to accept dd::IMAS.DD (and expanded its docstring description).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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