Parameter scan and new examples - #35
Merged
Merged
Conversation
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
marked this pull request as ready for review
September 3, 2026 13:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.