Simsopt macromag: GPMOmr#587
Conversation
…d to vetorized A construction for speedup
… coil scaling to test out stronger coils
…st no coupling solutions
…acking with non 0 backtracking threshold
… of Macromag GPMO. Added corresponding tests. Still trying to quantify error better
…s stuff since couldnt find evidence of actually needing that
…ot the case and also updated nfp since grid is predefined. Prof K. should take a look at this
…rror plot with multiple kmm values for same GPMOmr run....etc
…iour in cpp code. Pushing to see if ci/cd is fixed
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #587 +/- ##
==========================================
+ Coverage 90.14% 90.20% +0.05%
==========================================
Files 84 85 +1
Lines 17880 19757 +1877
==========================================
+ Hits 16118 17821 +1703
- Misses 1762 1936 +174
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…e the voxel picture. Update unit tests and improve coverage.
… file for finitemu optimization with MUSE. Refactor how arguments are passed to the GPMO functions.
…ples. Added unit test that checks convergance with Nadjacent. Added unit test that validates matrix_Free=True against matrix_free=False.
|
Made some improvements and refactoring changes. Sorry everyone but some significant PM refactoring got appended here, since it really helps and is past time. Most significantly:
Sorry this ballooned but I think its running much faster, has much more documentation, and removed lots of duplicate code. Let me know what you think and please check if I managed to destroy things. The finitemu analysis and optimizations in the example files looks about the same as before, with few percent differences, but I haven't taken the time to verify the Paraview plots and so on still look good. I have also not checked the updated docs -- please verify all the new docstrings (and their mathematical formulas) are building/visualizing well. |
|
@akaptano Thanks! Will take a loook. |
…d skipping the timing test if running the CI.
| theta_dipole = np.arctan2(oz, np.sqrt(ox ** 2 + oy ** 2) - R0) | ||
| mmx_temp = mmx * np.cos(phi_dipole) * np.cos(theta_dipole) - mmy * np.sin(phi_dipole) - mmz * np.cos(phi_dipole) * np.sin(theta_dipole) | ||
| mmy_temp = mmx * np.sin(phi_dipole) * np.cos(theta_dipole) + mmy * np.cos(phi_dipole) - mmz * np.sin(phi_dipole) * np.sin(theta_dipole) | ||
| mmx_temp = ( |
There was a problem hiding this comment.
@armulrich Was there a reason to change _dipole_fields_from_symmetries logic here? I can't tell if this function actually changed at all
There was a problem hiding this comment.
@akaptano I think if I remember correctly the only real change here was replacing the old self.dipole_grid = dipole_grid with self.dipole_grid_unique = np.ascontiguousarray(dipole_grid), since self.dipole_grid gets overwritten later by the symmetry-expanded full grid anyway; we needed to keep the original half-period grid around for the _toVTK(..., dx, dy, dz) / _geometry_unique path. ALso needed to use ascontiguousarray here for the VTK export code. Other than that, I don’t think the symmetry logic changed here, and the long toroidal lines were just me reformatting them for readability.... Let me know if I should change that
Summary
This PR adds and documents the GPMOmr workflow (GPMO with macromagnetic refinement) and significantly improves reproducibility and post-processing for the permanent-magnet MUSE study. The changes align the codebase with the methodology and results presented in:
Key Improvements
Macromagnetic refinement in the greedy loop
Adds a device-scale MacroMag refinement path that accounts for finite-permeability and demagnetization effects. This includes a Python implementation of GPMO together with a Numba-accelerated implementation of the demagnetization tensors. Refinement is applied in a winner-only fashion via
mm_refine_every, preserving the efficiency of the greedy loop while incorporating realistic magnetic coupling.Standardized run artifacts
Introduces a consistent artifact format across GPMO and GPMOmr:
run_<id>.yamlfor configuration and metadatarunhistory_<id>.csvfor optimization historiesThis replaces legacy
*.txthistories and enables uniform plotting and comparison across runs.Overall, this PR makes the GPMO/GPMOmr workflows more realistic, reproducible, and directly traceable to the results reported in arXiv:2512.14997.