Skip to content

Parameter scan and new examples - #35

Merged
ebursch merged 2 commits into
hansec:mainfrom
ebursch:Parameter-Scan
Sep 3, 2026
Merged

Parameter scan and new examples#35
ebursch merged 2 commits into
hansec:mainfrom
ebursch:Parameter-Scan

Conversation

@ebursch

@ebursch ebursch commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Adds ITER and CENTAUR to examples. Also adds parameter scans to the examples. Beta_n for examples now matches design points due to a fix from PR #34.

ebursch and others added 2 commits August 4, 2026 16:51
Three things from the POPCON project thread, for the Fusion Reactor Design
course.

POPCON_scan: runs a full POPCON at every combination of two machine
parameters and tiles them into one figure, plus a summary heatmap of one
number per cell. Fills in the placeholder class that was already exported.
Specified either by a `scan:` block in the settings file or by a scan=
argument.

Cells are built by re-running the whole settings derivation from the raw
file contents rather than by patching solved fields. This matters: read()
prefers I_P over qstar and B_0 over B_coil, so overriding a shadowed key
would have been silently ignored and produced N identical POPCONs that
looked like a working scan. _apply_overrides drops the shadowing key, and
scanning R on a qstar-based file now correctly re-derives Ip.

Scanning R, a, kappa, delta or I_P against a gEQDSK is refused rather than
warned about. __get_geometry overrides those past a 10% deviation and takes
the ohmic current from the equilibrium unconditionally, so a narrow scan
would be partially clobbered, which is worse than fully.

Plot axes: one PLOT_AXES registry replaces the xax/yax if/elif chain that
was duplicated three times (plot data, plot labels, custom_plot). Either
axis now takes either family, so a density can go on x; that case needs the
2-D arrays transposed, since they are stored (n_index, T_index). Adding an
axis is now one dict entry.

CENTAUR and ITER examples, with notebooks. Both use parabolic profiles
rather than a gEQDSK so their geometry stays scannable. Each carries a note
on where the 0-D result tracks the published design point and where it does
not: ITER reaches 481 MW against a nominal 500 but reports a higher Q,
because the Q=10 point carries 50 MW for burn control rather than being the
minimum; CENTAUR reaches the published 40 MW and beta_N, but cannot match Q
and tau_E at once, since the published scalars are not mutually consistent
under a plain 0-D balance and H_NT23's -0.89 exponent makes P_heat
extremely stiff.

Fixes found along the way:
- __version__ was stale at 2.0.0 while pyproject said 2.1.0, and was being
  stamped into every saved output. Now read from package metadata.
- plot() called plt.savefig, which writes the current figure rather than
  the one being drawn into. Only observable once ax= existed.
- gEQDSK geometry is memoized on (path, mtime, nr), returning copies. It
  is identical for every cell of a scan and was the dominant per-cell cost.

Tests go from 32 to 103. The golden regression is untouched and passes, so
none of this moves the physics.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ebursch
ebursch marked this pull request as ready for review September 3, 2026 13:46
@ebursch
ebursch merged commit b1ad3ec into hansec:main Sep 3, 2026
0 of 2 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.

1 participant