Adding QUADCOIL integration to DESC as an objective - #2110
Conversation
…also coming soon.
… optimizable_io.py and objective_funs.py to avoid error for static, empty tuple attributes and _objectives with self.coordinates == \'\'
…nversion, but it's not working because quadcoilproxy does not directly store the input dictionary, and desc static dict cannot contain strings (?)
…: Colorbar layout of new layout engine not compatible with old engine, and a colorbar has been created. Engine not changed.
…for merging into main
…for merging into main
YigitElma
left a comment
There was a problem hiding this comment.
Thanks fore adding this!
I will review rest of the code later, but it would be nice if you can resolve the problem with CI tests first. It looks like CI and pip in general cannot install quadcoil, I couldn't install it locally either.
| "_use_jit", | ||
| ] | ||
| _static_attrs = [ | ||
| "_static_attrs", # A bug as of Oct 10 2025 |
There was a problem hiding this comment.
_static_attrs is already included couple lines below. You probably had to add it before we added in master.
| def _unmake_hashable(x): | ||
| # turn tuple of ints and shape to ndarray | ||
| if isinstance(x, tuple) and x[0] == "ndarray": | ||
| if isinstance(x, tuple) and len(x) and x[0] == "ndarray": |
There was a problem hiding this comment.
I don't think it hurts to have it, but why did you need this change?
There was a problem hiding this comment.
The default values for some QUADCOIL arguments are empty list/tuples (I had to do it because the adjoint derivative is wrapped in a vjp rule before handed to DESC and this way some flows are simpler). Without this check it breaks DESC Optimizable.
| metric_name, | ||
| value_only, | ||
| verbose, | ||
| plasma_M_theta : int, optional, default=eq.M_grid |
There was a problem hiding this comment.
We usually give defaults at the end of the description
| bs_chunk_size : int, optional, default=None | ||
| Size to split Biot-Savart computation into chunks of evaluation points. | ||
|
|
||
| Attributes |
There was a problem hiding this comment.
These don't seem necessary
| # we set them here. This is necessary because we are calling quadcoil | ||
| # through quadcoil.io.quadcoil_for_diff, which cannot see their default | ||
| # values in quadcoil.quadcoil. | ||
| if "net_toroidal_current_amperes" in quadcoil_kwargs.keys(): |
There was a problem hiding this comment.
You can replace all if/else statements by something = dict.pop("something", default)
| self._quadcoil_for_diff = jit(_quadcoil_for_diff) | ||
| self._quadcoil_values = jit(_quadcoil_values) | ||
| # ----- Setting and registering keyword arguments ----- | ||
| self._static_attrs = _Objective._static_attrs + [ |
There was a problem hiding this comment.
You can move this to line 165, right after docs. We usually define it there
Co-authored-by: Yigit Gunsur Elmacioglu <102380275+YigitElma@users.noreply.github.com>
…maControl/DESC into ffu/quadcoil-qss-pre-commit
…dict popping with defaults using pop(default=**) to improve readability
|
@lankef https://github.com/PlasmaControl/DESC/actions/runs/25258105132/job/74060745121?pr=2110 this error happens if you commit a notebook from cluster or after running notebook in Jupyter Lab session (tbh it is very annoying and we have a long standing issue about this #1215, but it is actually not our problem but |
Merging main changes to branch --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Yigit Gunsur Elmacioglu <102380275+YigitElma@users.noreply.github.com> Co-authored-by: Kaya Unalmis <kayaunalmis@proton.me> Co-authored-by: Matthew Feickert <matthew.feickert@cern.ch> Co-authored-by: Dario Panici <37969854+dpanici@users.noreply.github.com> Co-authored-by: YigitElma <yigitelmacioglu@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Dario Panici <dpanici@princeton.edu> Co-authored-by: Rory Conlin <mail@fouriest.net> Co-authored-by: Daniel Dudt <33005725+ddudt@users.noreply.github.com> Co-authored-by: daniel-dudt <daniel.dudt@princetonstellarators.energy> Co-authored-by: Jonathan Brodrick <jonathan.brodrick@simulation.science> Co-authored-by: Wenyin Wei <wenyin.wei.ww@gmail.com> Co-authored-by: Jaydeep Singh <jaydeepsingh15@gmail.com> Co-authored-by: Jonathan Brodrick <jonathanbrodrick@gmail.com> Co-authored-by: Daniel Dudt <135651230+daniel-dudt@users.noreply.github.com> Co-authored-by: issraali <issra.ali@mail.utoronto.ca> Co-authored-by: T.Thun <timothun@web.de>
Co-authored-by: Yigit Gunsur Elmacioglu <102380275+YigitElma@users.noreply.github.com>
2. Changing import to use desc.backend 3. Fixing notebook issue
…maControl/DESC into ffu/quadcoil-qss-pre-commit
…maControl/DESC into ffu/quadcoil-qss-pre-commit
…maControl/DESC into ffu/quadcoil-qss-pre-commit
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2110 +/- ##
==========================================
+ Coverage 84.50% 93.94% +9.44%
==========================================
Files 101 103 +2
Lines 28953 29386 +433
==========================================
+ Hits 24466 27607 +3141
+ Misses 4487 1779 -2708
🚀 New features to boost your workflow:
|
|
I made some small changes to fix the failing test and fixed a couple of bugs (for example, One additional question for other devs: do we want this in the |
This pull request adds two files under /objective,
_quadcoil.pyand_quadcoil_utils.py. These allows one to call QUADCOIL using a DESC equilibrium and filament coil set as input, and perform quasi-single-stage optimization on the equilibrium and/or the coilset. There are some additions in coils and curves for conversion from simsopt objects. (since quadcoil is written in the simsopt convention). Winding surface can be either fixed or auto-generated, but optimizing the geometry of the winding surface is not yet implemented. The unit test compares quadcoil to desc's built-in REGCOIL.