ErrorFields - FEATURE - Add the correction requirement against the NTV-limited current allowance - #488
Open
logan-nc wants to merge 4 commits into
Conversation
…V-limited current allowance The NTV limits say how much correction current an array may carry; nothing said how much it needs, or on which rational surfaces a correction falls short. correction_requirement takes an error-field source and a set of correction arrays as CoilOverlaps and returns, in a CorrectionRequirement, the dominant-mode factor of each array alone, the joint least-squares factors on all arrays that minimize the resonant field on every rational surface, the resonant field left on each surface before and after each correction, and each array's cosine similarity to the source. Factors are complex multiples of each array's current as given, so any geometry can be a source or an array. needed_current_distribution re-expresses the Monte Carlo's |δ| histogram as the factor an array needs per sample, and uncorrectable_probability is the fraction of the histogram beyond max_correctable_overlap's NTV-limited with_ntv limit, naming the model: the explicit-correction counterpart of the corrected locking probability's efc_factor model. plot_correction_requirement draws the per-surface fields and the factors; plot_needed_current the distribution with the as-designed factor and the allowance. Tests on the Solovev two-hoop fixture: an array identical to the source needs exactly -1 and the least squares leaves nothing; a second hoop alone cancels the dominant mode and leaves no more than the least squares; both arrays find (-1, 0); file form equals memory form; the distribution integrates to one; the exceedance is the histogram's mass beyond the limit. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BzKDmtKYDotJWrcxWf1oJu
…fields-correction-requirement
…ere-turns A factor on an array's current as given is not comparable between arrays whose patterns were given at different currents (the example's C-coil at 20 A, its I-coils at 1 kA). CoilOverlap now carries the array's ampere-turns as given, |winding multiplier| × max|I| / 1000, the normalization the EFC couplings use; the correction requirement reports each needed current both as that factor and in kilo-ampere-turns; the minimum-current member of the dominant-mode family and the rank-deficient least squares minimize total ampere-turns squared rather than factor norm; the needed-current distribution and both plots use the same kilo-ampere-turn axis as the NTV-limited allowance. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BzKDmtKYDotJWrcxWf1oJu
…eck energizes the correction array Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BzKDmtKYDotJWrcxWf1oJu
This branch has not been deployed
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.
Stacked on #487 (base
feature/errorfields-linearity-check), itself on #486 and #485; the last of the three feature PRs planned after the ErrorFields stack merged. Closes #475.The question it answers. The NTV limits (#455, #462) say how much correction current an array may carry before its own torque lowers the threshold. Nothing said how much it needs, or on which rational surfaces a correction falls short. For one array and the dominant mode the answer is the ratio
−δ_source/δ_arrayand is not worth a PR. The question worth one is the joint one: given an error-field instance and a set of arrays, what complex currents on all of them minimize the resonant field on every rational surface, what is left on each surface after that, and how often does the sampled machine's overlap exceed what the NTV-limited array can correct at all?What it adds (
src/ErrorFields/Correction.jl, two plots inAnalysis.ErrorFields)correction_requirement(ctx, source::CoilOverlap, arrays)and its file form, returning aCorrectionRequirement: per array the dominant-mode factor−δ_source/δ_arrayfor the array alone and, for several arrays, the member of the dominant-mode family (one complex equation innarrayunknowns, so any two arrays can cancel each other) with the least total ampere-turns squared; the joint least-squares factorsargmin ‖C·(b̃_source + Σ_k f_k b̃_k)‖over every rational surface (\on thensurface × narraycomplex system, with its rank reported, unique when the rank isnarray); the resonant field on each surface before, after each array's dominant-mode correction alone, and after the joint correction; and each array's cosine similarity to the source's spectrum. Every current comes twice: as a complex factor on the array's current as given, and in kilo-ampere-turns through a newCoilOverlap.ampere_turns_kat(|winding multiplier| × max|I| / 1000, the normalization the EFC couplings use), because factors on arrays whose patterns were given at different currents are not comparable (the example's C-coil pattern is 0.08 kAt, its I-coil patterns 1 kAt) while kilo-ampere-turns are, and sit on the same axis as the NTV-limited current. AnyCoilOverlapcan be a source or an array, so an as-built assembly fromcombine_overlapscan be corrected with arrays that were never part of the run.needed_current_distribution(mc, array): the Monte Carlo's|δ|histogram as the current on the array that cancels each sampled overlap's dominant mode, as a factor on its current as given and in kilo-ampere-turns.uncorrectable_probability(mc, c::EFCCoupling; delta_threshold, torque_budget, model, …): the fraction of the Monte Carlo's overlap beyondmax_correctable_overlap'swith_ntvlimit for that array, naming the model it used. This is the explicit-correction counterpart of the corrected locking probability'sefc_factormodel: not "does the field divided by a factor still lock" but "can the array, spending its own torque, reach the field at all".plot_correction_requirement(resonant field per surface before and after, as stems on a log axis; then one polar panel per array with its needed currents as phasors in kilo-ampere-turns, radius the magnitude and angle the toroidal phase) andplot_needed_current(the distribution in kilo-ampere-turns with the as-designed current and the NTV-limited allowance marked on the same axis).Verification
(−1, 0)at rank 2, and the least-ampere-turn member of the dominant-mode family cancels the mode exactly with less current than(−1, 0); the overlap's ampere-turns normalize exactly as the coupling's per-kAt overlap, so the needed current and the allowance share one axis; the file form equals the memory form; the needed-current distribution integrates to one in both units and is the histogram rescaled; the exceedance equals the histogram's mass beyond the limit and is zero for a limit beyond the grid; unknown names, empty array lists and a coupling without its threshold throw.uncorrectable_probability: it integrates the binned|δ|histogram beyond the limit, and the Monte Carlo folds every sample pastdelta_maxinto the last bin, so a limit that lands in or beyond that bin with a nonzeroclamped_fractionunderstates the probability; the remedy is a widerdelta_maxon the Monte Carlo, and the result should be read together withclamped_fraction.test.yamlworkflow triggers only for pull requests intodevelopormain, so this stacked PR gets the conventions and documentation checks but not the Julia test suites; the test files above were run locally on the pushed head.Review package (DIII-D-like example variant only): https://claude.ai/artifact/M95zYnDC7HtPJTNdsZJc1t (private until shared).
cc @matt-pharr
Release note
0ebab04a5adds a docs-only note, no source change) —diiid_n153 unchanged anddiiid_error_field8 unchanged against the basecorrection_requirementgives the joint least-squares currents a set of correction arrays needs to cancel an error field on every rational surface and what each correction leaves per surface;uncorrectable_probabilityis the fraction of the tolerance Monte Carlo beyond what an NTV-limited array can correct; two plots draw them.Regression report
🤖 Generated with Claude Code
https://claude.ai/code/session_01BzKDmtKYDotJWrcxWf1oJu