Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
441cb57
rename _Grid to AbstractGrid
daniel-dudt Aug 14, 2025
6ef6c6f
remove functionality from AbstractGrid
daniel-dudt Aug 15, 2025
43ab00e
merge with master
daniel-dudt Jan 2, 2026
c2f0011
reorganize grid file to subdirectory
daniel-dudt Jan 5, 2026
6587ee1
update flux grids
daniel-dudt Jan 5, 2026
ebf39af
test_grid is passing
daniel-dudt Jan 6, 2026
bace610
fix references in surface_integrals
daniel-dudt Jan 6, 2026
8ac82d2
edit Changelog
daniel-dudt Jan 6, 2026
afaa319
fix LinearGrid resolution getters
daniel-dudt Jan 7, 2026
1d17f22
set default surface_label='rho'
daniel-dudt Jan 7, 2026
6b410dc
fix typo in previous commit
daniel-dudt Jan 7, 2026
a6a816d
add source_grid back
daniel-dudt Jan 7, 2026
4102387
revert removal of source_grid test
daniel-dudt Jan 7, 2026
1fb537f
repairing tests
daniel-dudt Jan 7, 2026
4bbe81d
Merge branch 'master' into dd/grids
ddudt Jan 7, 2026
545c063
rename AbstractRTZGrid to AbstractGridFlux
daniel-dudt Jan 7, 2026
87d3a3b
check for flux grids in objectives
daniel-dudt Jan 7, 2026
d75f05e
update Basis coordinate references
daniel-dudt Jan 7, 2026
61c020c
Merge branch 'master' into dd/grids
ddudt Jan 8, 2026
f5c3e2f
Merge branch 'master' into dd/grids
ddudt Jan 8, 2026
9eb5d51
start adding curve grids
daniel-dudt Jan 12, 2026
686b986
Merge branch 'master' into dd/grids
ddudt Jan 13, 2026
7792e44
Merge branch 'master' into dd/grids
ddudt Jan 14, 2026
8336b1d
enforcing coils to use curve grids
daniel-dudt Jan 14, 2026
829ca0d
update curve/coil tests
daniel-dudt Jan 15, 2026
8a14706
Merge branch 'master' into dd/grids
ddudt Jan 15, 2026
99562c8
Merge branch 'master' into dd/grids
ddudt Jan 20, 2026
f761a58
fix broken test, zeta -> x2
daniel-dudt Jan 21, 2026
6aa931e
Merge branch 'master' into dd/grids
ddudt Jan 22, 2026
e463d18
update defaults for surface_label args
daniel-dudt Jan 26, 2026
958e6fc
update docstring types
daniel-dudt Jan 26, 2026
e596c94
other changes requested by Yigit and Rory
daniel-dudt Jan 26, 2026
bbb0241
super set up
daniel-dudt Jan 26, 2026
1a1a43c
changes requested by Yigit part 2
daniel-dudt Jan 27, 2026
c3e2fdf
CustomGridCurve and repairing tests
daniel-dudt Jan 27, 2026
cda41a1
Merge branch 'master' into dd/grids
ddudt Jan 27, 2026
af0af2e
fixing tests and correcting previous commits
daniel-dudt Jan 27, 2026
58bb052
scale weights to volume, even when not 3D coordinates
daniel-dudt Jan 27, 2026
426ddbc
special logic for alpha bounds/period
daniel-dudt Jan 27, 2026
9f98a11
fix particle test
daniel-dudt Jan 27, 2026
f082e0c
use CustomGridCurve in curve tests
daniel-dudt Jan 28, 2026
52c4070
remove period from create_meshgrid
daniel-dudt Jan 28, 2026
6919768
replace more tests with curve grids
daniel-dudt Jan 28, 2026
8cfc526
repairing more tests
daniel-dudt Jan 28, 2026
00a37cf
fix plotting grids
daniel-dudt Jan 29, 2026
6c97da4
curve grid in makegrid test
daniel-dudt Jan 29, 2026
640dab5
curve grid in coilset_geometry_optimization test
daniel-dudt Jan 29, 2026
af37ae2
update flux bounds and period
daniel-dudt Jan 29, 2026
4200563
generalize grid get_label() output
daniel-dudt Jan 29, 2026
99de6a1
generalize and remove checks from _get_grid_surface
daniel-dudt Jan 29, 2026
fd77c69
update line_label reference in line_integrals
daniel-dudt Jan 30, 2026
1c00411
initial commit of surface grids
daniel-dudt Jan 30, 2026
bf587ca
rename flux grids
daniel-dudt Jan 30, 2026
5eeccb6
revert some name changes in docs
daniel-dudt Jan 30, 2026
5574788
fix docs
daniel-dudt Jan 30, 2026
d4b5ee4
revert changes to html files
daniel-dudt Jan 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ or if multiple things are being optimized, `x_scale` can be a list of dict, one
- Adds new option `x_scale='ess'` to use exponential spectral scaling from (Jang 2025) which has been shown to improve performance and robustness as an
alternative to fourier continuation methods.
- Adds ``"scipy-l-bfgs-b"`` optimizer option as a wrapper to scipy's ``"l-bfgs-b"`` method.
- Restructures the grid classes to allow for new grids in other coordinate systems besides flux coordinates. No change to the public API, except that ``Curves`` now expect to use a ``LinearGridCurve`` type grid.
- Adds ``check_intersection`` flag to ``desc.magnetic_fields.FourierCurrentPotentialField.to_Coilset``, to allow the choice of checking the resulting coilset for intersections or not.
- Changes the import paths for ``desc.external`` to require reference to the sub-modules.

Expand Down
127 changes: 64 additions & 63 deletions desc/basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np

from desc.backend import custom_jvp, fori_loop, jit, jnp, sign
from desc.grid import Grid, _Grid
from desc.grid import AbstractGrid, CustomGridFlux
from desc.io import IOAble
from desc.utils import check_nonnegint, check_posint, flatten_list

Expand Down Expand Up @@ -192,10 +192,10 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):

Parameters
----------
grid : Grid or ndarray of float, size(num_nodes,3)
Node coordinates, in (rho,theta,zeta).
grid : AbstractGrid or ndarray of float, size(num_nodes,3)
Node coordinates, in (x0,x1,x2).
derivatives : ndarray of int, shape(3,)
order of derivatives to compute in (rho,theta,zeta)
order of derivatives to compute in (x0,x1,x2)
modes : ndarray of in, shape(num_modes,3), optional
basis modes to evaluate (if None, full basis is used)

Expand Down Expand Up @@ -399,10 +399,10 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):

Parameters
----------
grid : Grid or ndarray of float, size(num_nodes,3)
Node coordinates, in (rho,theta,zeta).
grid : AbstractGrid or ndarray of float, size(num_nodes,3)
Node coordinates, in (x0,x1,x2).
derivatives : ndarray of int, shape(num_derivatives,3)
Order of derivatives to compute in (rho,theta,zeta).
Order of derivatives to compute in (x0,x1,x2).
modes : ndarray of in, shape(num_modes,3), optional
Basis modes to evaluate (if None, full basis is used)

Expand All @@ -412,8 +412,8 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):
basis functions evaluated at nodes

"""
if not isinstance(grid, _Grid):
grid = Grid(grid, sort=False, jitable=True)
if not isinstance(grid, AbstractGrid):
grid = CustomGridFlux(grid, sort=False, jitable=True)
if modes is None:
modes = self.modes
lidx = self.unique_L_idx
Expand All @@ -426,8 +426,8 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):
return np.array([]).reshape((grid.num_nodes, 0))

try:
ridx = grid.unique_rho_idx
routidx = grid.inverse_rho_idx
ridx = grid.unique_x0_idx
routidx = grid.inverse_x0_idx
except AttributeError:
ridx = routidx = np.arange(grid.num_nodes)

Expand Down Expand Up @@ -512,10 +512,10 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):

Parameters
----------
grid : Grid or ndarray of float, size(num_nodes,3)
Node coordinates, in (rho,theta,zeta).
grid : AbstractGrid or ndarray of float, size(num_nodes,3)
Node coordinates, in (x0,x1,x2).
derivatives : ndarray of int, shape(num_derivatives,3)
Order of derivatives to compute in (rho,theta,zeta).
Order of derivatives to compute in (x0,x1,x2).
modes : ndarray of in, shape(num_modes,3), optional
Basis modes to evaluate (if None, full basis is used).

Expand All @@ -528,8 +528,8 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):
[sin(N𝛇), ..., sin(𝛇), 1, cos(𝛇), ..., cos(N𝛇)].

"""
if not isinstance(grid, _Grid):
grid = Grid(grid, sort=False, jitable=True)
if not isinstance(grid, AbstractGrid):
grid = CustomGridFlux(grid, sort=False, jitable=True)
if modes is None:
modes = self.modes
nidx = self.unique_N_idx
Expand All @@ -542,8 +542,8 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):
return np.array([]).reshape((grid.num_nodes, 0))

try:
zidx = grid.unique_zeta_idx
zoutidx = grid.inverse_zeta_idx
zidx = grid.unique_x2_idx
zoutidx = grid.inverse_x2_idx
except AttributeError:
zidx = zoutidx = np.arange(grid.num_nodes)

Expand Down Expand Up @@ -640,10 +640,10 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):

Parameters
----------
grid : Grid or ndarray of float, size(num_nodes,3)
Node coordinates, in (rho,theta,zeta).
grid : AbstractGrid or ndarray of float, size(num_nodes,3)
Node coordinates, in (x0,x1,x2).
derivatives : ndarray of int, shape(num_derivatives,3)
Order of derivatives to compute in (rho,theta,zeta).
Order of derivatives to compute in (x0,x1,x2).
modes : ndarray of in, shape(num_modes,3), optional
Basis modes to evaluate (if None, full basis is used).

Expand All @@ -658,8 +658,8 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):
⊗ [sin(N𝛇), ..., sin(𝛇), 1, cos(𝛇), ..., cos(N𝛇)].

"""
if not isinstance(grid, _Grid):
grid = Grid(grid, sort=False, jitable=True)
if not isinstance(grid, AbstractGrid):
grid = CustomGridFlux(grid, sort=False, jitable=True)
if modes is None:
modes = self.modes
midx = self.unique_M_idx
Expand All @@ -675,8 +675,8 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):
return np.array([]).reshape((grid.num_nodes, 0))

try:
zidx = grid.unique_zeta_idx
zoutidx = grid.inverse_zeta_idx
zidx = grid.unique_x2_idx
zoutidx = grid.inverse_x2_idx
except AttributeError:
zidx = zoutidx = np.arange(grid.num_nodes)
try:
Expand Down Expand Up @@ -856,10 +856,10 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):

Parameters
----------
grid : Grid or ndarray of float, size(num_nodes,3)
Node coordinates, in (rho,theta,zeta).
grid : AbstractGrid or ndarray of float, size(num_nodes,3)
Node coordinates, in (x0,x1,x2).
derivatives : ndarray of int, shape(num_derivatives,3)
Order of derivatives to compute in (rho,theta,zeta).
Order of derivatives to compute in (x0,x1,x2).
modes : ndarray of int, shape(num_modes,3), optional
Basis modes to evaluate (if None, full basis is used).

Expand All @@ -869,8 +869,9 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):
Basis functions evaluated at nodes.

"""
if not isinstance(grid, _Grid):
grid = Grid(grid, sort=False, jitable=True)
if not isinstance(grid, AbstractGrid):
grid = CustomGridFlux(grid, sort=False, jitable=True)

if modes is None:
modes = self.modes
lmidx = self.unique_LM_idx
Expand All @@ -890,13 +891,13 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):
m = modes[:, 1]

try:
ridx = grid.unique_rho_idx
routidx = grid.inverse_rho_idx
ridx = grid.unique_x0_idx
routidx = grid.inverse_x0_idx
except AttributeError:
ridx = routidx = np.arange(grid.num_nodes)
try:
tidx = grid.unique_theta_idx
toutidx = grid.inverse_theta_idx
tidx = grid.unique_x1_idx
toutidx = grid.inverse_x1_idx
except AttributeError:
tidx = toutidx = np.arange(grid.num_nodes)

Expand Down Expand Up @@ -1009,10 +1010,10 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):

Parameters
----------
grid : Grid or ndarray of float, size(num_nodes,3)
Node coordinates, in (rho,theta,zeta).
grid : AbstractGrid or ndarray of float, size(num_nodes,3)
Node coordinates, in (x0,x1,x2).
derivatives : ndarray of int, shape(num_derivatives,3)
Order of derivatives to compute in (rho,theta,zeta).
Order of derivatives to compute in (x0,x1,x2).
modes : ndarray of in, shape(num_modes,3), optional
Basis modes to evaluate (if None, full basis is used).

Expand All @@ -1028,8 +1029,8 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):
⊗ [sin(N𝛇), ..., sin(𝛇), 1, cos(𝛇), ..., cos(N𝛇)].

"""
if not isinstance(grid, _Grid):
grid = Grid(grid, sort=False, jitable=True)
if not isinstance(grid, AbstractGrid):
grid = CustomGridFlux(grid, sort=False, jitable=True)
if modes is None:
modes = self.modes
lidx = self.unique_L_idx
Expand All @@ -1049,18 +1050,18 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):
l, m, n = modes.T

try:
ridx = grid.unique_rho_idx
routidx = grid.inverse_rho_idx
ridx = grid.unique_x0_idx
routidx = grid.inverse_x0_idx
except AttributeError:
ridx = routidx = np.arange(grid.num_nodes)
try:
tidx = grid.unique_theta_idx
toutidx = grid.inverse_theta_idx
tidx = grid.unique_x1_idx
toutidx = grid.inverse_x1_idx
except AttributeError:
tidx = toutidx = np.arange(grid.num_nodes)
try:
zidx = grid.unique_zeta_idx
zoutidx = grid.inverse_zeta_idx
zidx = grid.unique_x2_idx
zoutidx = grid.inverse_x2_idx
except AttributeError:
zidx = zoutidx = np.arange(grid.num_nodes)

Expand Down Expand Up @@ -1257,10 +1258,10 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):

Parameters
----------
grid : Grid or ndarray of float, size(num_nodes,3)
Node coordinates, in (rho,theta,zeta).
grid : AbstractGrid or ndarray of float, size(num_nodes,3)
Node coordinates, in (x0,x1,x2).
derivatives : ndarray of int, shape(num_derivatives,3)
Order of derivatives to compute in (rho,theta,zeta).
Order of derivatives to compute in (x0,x1,x2).
modes : ndarray of int, shape(num_modes,3), optional
Basis modes to evaluate (if None, full basis is used).

Expand All @@ -1270,8 +1271,8 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):
Basis functions evaluated at nodes.

"""
if not isinstance(grid, _Grid):
grid = Grid(grid, sort=False, jitable=True)
if not isinstance(grid, AbstractGrid):
grid = CustomGridFlux(grid, sort=False, jitable=True)
if modes is None:
modes = self.modes
lmidx = self.unique_LM_idx
Expand All @@ -1292,18 +1293,18 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):
lm = modes[:, :2]

try:
ridx = grid.unique_rho_idx
routidx = grid.inverse_rho_idx
ridx = grid.unique_x0_idx
routidx = grid.inverse_x0_idx
except AttributeError:
ridx = routidx = np.arange(grid.num_nodes)
try:
tidx = grid.unique_theta_idx
toutidx = grid.inverse_theta_idx
tidx = grid.unique_x1_idx
toutidx = grid.inverse_x1_idx
except AttributeError:
tidx = toutidx = np.arange(grid.num_nodes)
try:
zidx = grid.unique_zeta_idx
zoutidx = grid.inverse_zeta_idx
zidx = grid.unique_x2_idx
zoutidx = grid.inverse_x2_idx
except AttributeError:
zidx = zoutidx = np.arange(grid.num_nodes)

Expand Down Expand Up @@ -1412,10 +1413,10 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):

Parameters
----------
grid : Grid or ndarray of float, size(num_nodes,3)
Node coordinates, in (rho,theta,zeta).
grid : AbstractGrid or ndarray of float, size(num_nodes,3)
Node coordinates, in (x0,x1,x2).
derivatives : ndarray of int, shape(num_derivatives,3)
Order of derivatives to compute in (rho,theta,zeta).
Order of derivatives to compute in (x0,x1,x2).
modes : ndarray of in, shape(num_modes,3), optional
Basis modes to evaluate (if None, full basis is used)
unique : bool, optional
Expand All @@ -1428,8 +1429,8 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):
basis functions evaluated at nodes

"""
if not isinstance(grid, _Grid):
grid = Grid(grid, sort=False, jitable=True)
if not isinstance(grid, AbstractGrid):
grid = CustomGridFlux(grid, sort=False, jitable=True)
if modes is None:
modes = self.modes
lidx = self.unique_L_idx
Expand All @@ -1445,8 +1446,8 @@ def evaluate(self, grid, derivatives=np.array([0, 0, 0]), modes=None):
l = modes[:, 0]

try:
ridx = grid.unique_rho_idx
routidx = grid.inverse_rho_idx
ridx = grid.unique_x0_idx
routidx = grid.inverse_x0_idx
except AttributeError:
ridx = routidx = np.arange(grid.num_nodes)

Expand Down
Loading
Loading