Repository navigation
ErrorFields - FEATURE - Add tolerance sampling distributions - #450
Conversation
Stack summary — OMFIT → Julia error-field tolerance migration (updated 2026-09-17)Nothing in this set merges without a third-party human review, the three small bugfix PRs included. Full page with the diagram, per-PR table, review order and links to every review package (a private claude.ai artifact until the author shares it; DIII-D-like and synthetic data only): https://claude.ai/code/artifact/408ddd36-e52c-42d8-8f5c-52f680f41da9
Benchmark, qualitatively. The original OMFIT project's case, rebuilt from that project's own run inputs, is reproduced once #458, #457 and #460 are in: dominant-mode singular values agree to 1e-4, singular-coupling rows match Fortran GPEC at 1.0000 correlation and within 0.5 % in norm, and every coil set's dominant-mode overlap agrees within 1 % once both codes use the same converged toroidal coil grid. The DIII-D-like example agrees with Fortran to 1e-4 throughout. Any comparison shown on these PRs uses the DIII-D-like examples only. Design issue for what comes after the stack: #461 (momentum-balance module fed by tabulated torque surfaces; stationary solvers only). |
Random draws of coil misalignment within a tolerance, the primitives a tolerance Monte Carlo recombines with the coil sensitivities: the RadialDistribution shapes (Flat = uniform in radius, UniformArea, Hollow, Ring, PowerLaw) with radial_distribution for the tolerance-file names; disk_radius / sample_disk (Δx + iΔy) / sample_uncertainty (signed normal amplitude with a uniform direction); and the two tolerance models — sample_additive (independent shift and tilt disks) and sample_cylinder (axis endpoints drawn in the top and bottom disks of a cylinder, the coil placed at the midplane crossing and tilted by the lean, as the (θx, θy) rotation angles apply_transforms uses). Every sampler takes the caller's rng, scalar exponents, and optional fixed directions so coherent groups can share a direction. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BzKDmtKYDotJWrcxWf1oJu
5b182e9 to
6e69220
Compare
Fifth PR of the OMFIT → Julia error-field tolerance migration, stacked on #449. It adds the random-draw primitives a tolerance Monte Carlo recombines with the coil sensitivities: the radial sampling shapes, the disk draw, the Gaussian placement uncertainty, and the two tolerance models (additive shift + tilt, and the cylinder axis-line model). No dependency added (
Randomonly); no driver or output change.What it does (
src/ErrorFields/Sampling.jl)RadialDistributionwithFlat(p = 1, uniform in radius — OMFIT'sflat, kept exactly),UniformArea(p = 1/2, new),Hollow(p = 1/3, OMFIT default),Ring(p = 0),PowerLaw(p);randpow, andradial_distribution(name)for the TOML strings PR4 validates.rngand aFloat64exponent so PR6's hot loop resolves dispatch outside the loop:disk_radius,sample_disk(→Δx + iΔy),sample_uncertainty(OMFIT's signed-normal-times-uniform-phase construction, documented as half-normal rather than Rayleigh).phase,phase_top/phase_bot) so coherent groups sharing aphase_grouppass one direction and draw their own radii — the OMFITphasing_indexsemantics settled in PR4.sample_additive→ independent shift (m) and tilt (deg) draws.sample_cylinder(rng, R, z_top, p)→ the axis endpoints drawn in the top and bottom disks, the coil placed at the midplane crossing and tilted by the lean:shift = (p_top + p_bot)/2,α = atan(|p_top − p_bot|, 2 z_top), tilt expressed as the(θx, θy)rotation anglesapply_transformsuses so the lean direction and the shift direction are physically correlated.Verification (
test/runtests_sampling.jl, 55 tests)|shift| ≤ R,|tilt| ≤ atan(R/z_top), ⟨|shift|²⟩ = R²/6 for Flat (mean of two draws), tall cylinder → zero tilt, zero radius → zero everything, endpoint swap flips the lean; closed-form check against hand-computed endpoints.(θx, θy)for an axis leaning toward +x (and +y) raises the hoop on the −x (−y) side, as it must.Two OMFIT points, for the record (documented in the
sample_cylinderdocstring):tilt_tol · atan(|d|/R, 2 z_top)rather than the physicalatan(|d|, 2 z_top). This sampler works in physical units from(R, z_top)alone; the paper's cylinder rows were run with pre-derived tilt tolerances, so PR6's benchmark against OMFIT is exact for the additive model and in-kind for the cylinder model.phase_unique_botis computed and never used). Endpoints are independent here; a reproduction toggle is yours to call for.cc @matt-pharr
Release note
ErrorFieldsgains the misalignment samplers a tolerance Monte Carlo needs: the radial sampling shapes (Flat,UniformArea,Hollow,Ring,PowerLaw), disk and uncertainty draws, and the additive and cylinder axis-line tolerance models, all seedable and with injectable shared directions for coherent groups.Regression report
Harness, re-run at this branch head
5b182e9a9compared againstdevelop(9578c9b86), casediiid_n1:Every tracked quantity is bit-identical; only wall-clock
Runtimediffers, which theharness does not track. The branch carries a merge of the current
develop.