Add SIMSOPT MHD-energy Optimizable#60
Open
krystophny wants to merge 32 commits into
Open
Conversation
1cf0fa8 to
154b811
Compare
154b811 to
acdd31a
Compare
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.
Wraps GVEC as a SIMSOPT
Optimizablefor the fixed-boundary MHD energy.GvecEnergyProblemre-solves the interior equilibrium for a boundary vector with a target-preserving scipyhybrroot solve and caches the solved state per boundary vector.GvecEnergy.J()returns the MHD energy at the solved equilibrium;dJ()returns the analytic reverse boundary adjoint gradient throughadjoint_boundary_gradient, exact when the build provides Enzyme derivatives and FD otherwise.make_simsopt_optimizable(state)raises a typed ImportError without SIMSOPT; the problem class itself works without SIMSOPT.Closes #24.
Verification
Test fails on main
Test passes after fix
Enzyme-off isolated build (FD path):
Enzyme-on isolated build (exact path, fixed RZ, LLVM/Flang 22.1.6):
test_simsopt_wrapper_reuses_cached_equilibriumasserts one equilibrium solve for repeateddJ()and a new solve after a boundary change.test_simsopt_gradient_matches_fd_resolvechecks sampled boundary DOFs against(J(x+δ)-J(x-δ))/2δwith full interior re-solves.