@@ -0,0 +1,2921 @@
+from desc.backend import jnp%0Afrom desc.geometry.core import Curve, xyz2rpz, xyz2rpz_vec, rpz2xyz, rpz2xyz_vec%0Afrom desc.magnetic_fields import MagneticField, biot_savart%0Afrom desc.grid import Grid%0A%0A%0Aclass Coil(Curve, MagneticField):%0A    %22%22%22Class representing a magnetic field coil, as a combination of a curve and current%0A%0A    Parameters%0A    ----------%0A    curve : Curve%0A        underlying geometric curve definining path of coil%0A    current : float%0A        current passing through the coil, in Amperes%0A    %22%22%22%0A%0A    def __init__(self, curve, current):%0A        assert isinstance(curve, Curve)%0A        self.curve = curve%0A        self.current = current%0A%0A    def compute_coordinates(self, *args, **kwargs):%0A        %22%22%22Compute real space coordinates on predefined grid.%22%22%22%0A        return self.curve.compute_coordinates(*args, **kwargs)%0A%0A    def compute_frenet_frame(self, *args, **kwargs):%0A        %22%22%22Compute Frenet frame on predefined grid.%22%22%22%0A        return self.curve.compute_frenet_frame(*args, **kwargs)%0A%0A    def compute_curvature(self, *args, **kwargs):%0A        %22%22%22Compute curvature on predefined grid.%22%22%22%0A        return self.curve.compute_curvature(*args, **kwargs)%0A%0A    def compute_torsion(self, *args, **kwargs):%0A        %22%22%22Compute torsion on predefined grid.%22%22%22%0A        return self.curve.compute_torsion(*args, **kwargs)%0A%0A    def compute_length(self, *args, **kwargs):%0A        %22%22%22Compute the length of the curve using specified nodes for quadrature.%22%22%22%0A        return self.curve.compute_length(*args, **kwargs)%0A%0A    def compute_magnetic_field(%0A        self, coords, curve_grid=None, dR=0, dp=0, dZ=0, params=%7B%7D%0A    ):%0A        %22%22%22Compute magnetic field at a set of points%0A%0A        Parameters%0A        ----------%0A        coords : array-like shape(N,3) or Grid%0A            cylindrical coordinates to evaluate field at %5BR,phi,Z%5D%0A        curve_grid : Grid, ndarray or int%0A            grid to use for evaluating curve geometry. If an integer, assumes that%0A            many equally spaced points in (0,2pi)%0A        dR, dp, dZ : int, optional%0A            order of derivative to take in R,phi,Z directions%0A        params : dict, optional%0A            parameters to pass to curve%0A%0A        Returns%0A        -------%0A        field : ndarray, shape(N,3)%0A            magnetic field at specified points, in cylindrical form %5BBR, Bphi,BZ%5D%0A%0A        %22%22%22%0A        if any(%5B(dR != 0), (dp != 0), (dZ != 0)%5D):%0A            raise NotImplementedError(%0A                %22Derivatives of coil fields have not been implemented%22%0A            )%0A        if isinstance(coords, Grid):%0A            coords = coords.nodes%0A        coords = jnp.atleast_2d(coords)%0A        coordsxyz = rpz2xyz(coords)%0A        current = params.pop(%22current%22, self.current)%0A        coil_coords = self.compute_coordinates(grid=curve_grid, **params, basis=%22xyz%22)%0A        B = biot_savart(coordsxyz, coil_coords, current)%0A        B = xyz2rpz_vec(B, phi=coords%5B..., 1%5D)%0A        return B%0A

Add base Coil class