Repository navigation
Physical coefficients in simsopt/DiscretizedCoils conversions; array PerturbationSample - #139
Merged
Merged
Conversation
…ns; accept array PerturbationSample
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.
Curves.dofs(andCoils.dofs_curves) are the optimizer-facing coefficients,_dofs * scaling; the geometry is built from the unscaled_dofs. Three conversions used the scaled values as physical Fourier coefficients, so any coil set with non-defaultscaling_factor/scale_fixedwas exported or converted with the wrong shape:Curves.to_simsoptandCoils.to_simsoptnow use_dofs(the coil export also takesdofs_currents_rawdirectly instead ofdofs_currents * currents_scale).DiscretizedCoils.from_Coilsnow builds the base gamma fromcoils.curves._dofs. On main, for a radius-2 circle withscaling_factor=0.3, scale_fixed=7, the converted gamma differs fromcoils.gammaby up to 16.9 m.Also
PerturbationSample.__init__usedif sample:on a JAX array, which raises for any multi-element sample; it is nowif sample is not None:.Tests (fail on main, pass here;
JAX_ENABLE_X64=1 pytest -n 2 tests/test_coils.py tests/test_coil_perturbation.py):test_scaled_curves_convert_with_physical_coefficientsuses a stubsimsoptmodule so it runs in CI without simsopt, and checks both exports andfrom_Coilsagainst the physical coefficients and gamma.test_perturbation_sample_accepts_array_sampleOn main: 2 failed. With this branch: 37 passed.
Overlap: #132 fixes the related
DiscretizedCoils.copy/perturb_curvesuse of the scaleddofs_gammaand does not touch these lines. This PR does not duplicate it and merges cleanly with #132, #119 and #133.