Skip to content

Commit

Permalink
Merge branch 'dd/external' into terps
Browse files Browse the repository at this point in the history
  • Loading branch information
ddudt authored Aug 11, 2024
2 parents 782b232 + 7f1907b commit 2be9d53
Show file tree
Hide file tree
Showing 31 changed files with 1,895 additions and 732 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

New Features

- Add ``use_signed_distance`` flag to ``PlasmaVesselDistance`` which will use a signed distance as the target, which is positive when the plasma is inside of the vessel surface and negative if the plasma is outside of the vessel surface, to allow optimizer to distinguish if the equilbrium surface exits the vessel surface and guard against it by targeting a positive signed distance.

v0.12.1
-------

Expand Down
84 changes: 68 additions & 16 deletions desc/coils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,9 @@ def flatten_coils(coilset):
with open(coilsFilename, "w") as f:
f.writelines(lines)

def to_FourierPlanar(self, N=10, grid=None, basis="xyz", name=""):
def to_FourierPlanar(
self, N=10, grid=None, basis="xyz", name="", check_intersection=True
):
"""Convert all coils to FourierPlanarCoil.
Note that some types of coils may not be representable in this basis.
Expand All @@ -1614,6 +1616,8 @@ def to_FourierPlanar(self, N=10, grid=None, basis="xyz", name=""):
Coordinate system for center and normal vectors. Default = 'xyz'.
name : str
Name for this coilset.
check_intersection: bool
Whether or not to check the coils in the new coilset for intersections.
Returns
-------
Expand All @@ -1623,9 +1627,17 @@ def to_FourierPlanar(self, N=10, grid=None, basis="xyz", name=""):
"""
coils = [coil.to_FourierPlanar(N=N, grid=grid, basis=basis) for coil in self]
return self.__class__(*coils, NFP=self.NFP, sym=self.sym, name=name)
return self.__class__(
*coils,
NFP=self.NFP,
sym=self.sym,
name=name,
check_intersection=check_intersection,
)

def to_FourierRZ(self, N=10, grid=None, NFP=None, sym=False, name=""):
def to_FourierRZ(
self, N=10, grid=None, NFP=None, sym=False, name="", check_intersection=True
):
"""Convert all coils to FourierRZCoil representaion.
Note that some types of coils may not be representable in this basis.
Expand All @@ -1644,6 +1656,8 @@ def to_FourierRZ(self, N=10, grid=None, NFP=None, sym=False, name=""):
Whether the curve is stellarator-symmetric or not. Default is False.
name : str
Name for this coilset.
check_intersection: bool
Whether or not to check the coils in the new coiilset for intersections.
Returns
-------
Expand All @@ -1652,9 +1666,15 @@ def to_FourierRZ(self, N=10, grid=None, NFP=None, sym=False, name=""):
"""
coils = [coil.to_FourierRZ(N=N, grid=grid, NFP=NFP, sym=sym) for coil in self]
return self.__class__(*coils, NFP=self.NFP, sym=self.sym, name=name)
return self.__class__(
*coils,
NFP=self.NFP,
sym=self.sym,
name=name,
check_intersection=check_intersection,
)

def to_FourierXYZ(self, N=10, grid=None, s=None, name=""):
def to_FourierXYZ(self, N=10, grid=None, s=None, name="", check_intersection=True):
"""Convert all coils to FourierXYZCoil representation.
Parameters
Expand All @@ -1669,6 +1689,8 @@ def to_FourierXYZ(self, N=10, grid=None, s=None, name=""):
normalized arclength.
name : str
Name for the new CoilSet.
check_intersection: bool
Whether or not to check the coils in the new coiilset for intersections.
Returns
-------
Expand All @@ -1678,9 +1700,17 @@ def to_FourierXYZ(self, N=10, grid=None, s=None, name=""):
"""
coils = [coil.to_FourierXYZ(N, grid, s) for coil in self]
return self.__class__(*coils, NFP=self.NFP, sym=self.sym, name=name)
return self.__class__(
*coils,
NFP=self.NFP,
sym=self.sym,
name=name,
check_intersection=check_intersection,
)

def to_SplineXYZ(self, knots=None, grid=None, method="cubic", name=""):
def to_SplineXYZ(
self, knots=None, grid=None, method="cubic", name="", check_intersection=True
):
"""Convert all coils to SplineXYZCoil representation.
Parameters
Expand All @@ -1704,6 +1734,8 @@ def to_SplineXYZ(self, knots=None, grid=None, method="cubic", name=""):
- `'catmull-rom'`: C1 cubic centripetal "tension" splines
name : str
Name for the new CoilSet.
check_intersection: bool
Whether or not to check the coils in the new coiilset for intersections.
Returns
-------
Expand All @@ -1712,7 +1744,13 @@ def to_SplineXYZ(self, knots=None, grid=None, method="cubic", name=""):
"""
coils = [coil.to_SplineXYZ(knots, grid, method) for coil in self]
return self.__class__(*coils, NFP=self.NFP, sym=self.sym, name=name)
return self.__class__(
*coils,
NFP=self.NFP,
sym=self.sym,
name=name,
check_intersection=check_intersection,
)

def is_self_intersecting(self, grid=None, tol=None):
"""Check if any coils in the CoilSet intersect.
Expand Down Expand Up @@ -2001,7 +2039,9 @@ def compute_magnetic_field(

return B

def to_FourierPlanar(self, N=10, grid=None, basis="xyz", name=""):
def to_FourierPlanar(
self, N=10, grid=None, basis="xyz", name="", check_intersection=False
):
"""Convert all coils to FourierPlanarCoil representation.
Note that some types of coils may not be representable in this basis.
Expand All @@ -2019,6 +2059,8 @@ def to_FourierPlanar(self, N=10, grid=None, basis="xyz", name=""):
Coordinate system for center and normal vectors. Default = 'xyz'.
name : str
Name for the new MixedCoilSet.
check_intersection: bool
Whether or not to check the coils in the new coiilset for intersections.
Returns
-------
Expand All @@ -2028,9 +2070,11 @@ def to_FourierPlanar(self, N=10, grid=None, basis="xyz", name=""):
"""
coils = [coil.to_FourierPlanar(N=N, grid=grid, basis=basis) for coil in self]
return self.__class__(*coils, name=name)
return self.__class__(*coils, name=name, check_intersection=check_intersection)

def to_FourierRZ(self, N=10, grid=None, NFP=None, sym=False, name=""):
def to_FourierRZ(
self, N=10, grid=None, NFP=None, sym=False, name="", check_intersection=True
):
"""Convert all coils to FourierRZCoil representation.
Note that some types of coils may not be representable in this basis.
Expand All @@ -2049,6 +2093,8 @@ def to_FourierRZ(self, N=10, grid=None, NFP=None, sym=False, name=""):
Whether the curve is stellarator-symmetric or not. Default is False.
name : str
Name for the new MixedCoilSet.
check_intersection: bool
Whether or not to check the coils in the new coiilset for intersections.
Returns
-------
Expand All @@ -2057,9 +2103,9 @@ def to_FourierRZ(self, N=10, grid=None, NFP=None, sym=False, name=""):
"""
coils = [coil.to_FourierRZ(N=N, grid=grid, NFP=NFP, sym=sym) for coil in self]
return self.__class__(*coils, name=name)
return self.__class__(*coils, name=name, check_intersection=check_intersection)

def to_FourierXYZ(self, N=10, grid=None, s=None, name=""):
def to_FourierXYZ(self, N=10, grid=None, s=None, name="", check_intersection=True):
"""Convert all coils to FourierXYZCoil representation.
Parameters
Expand All @@ -2074,6 +2120,8 @@ def to_FourierXYZ(self, N=10, grid=None, s=None, name=""):
normalized arclength.
name : str
Name for the new MixedCoilSet.
check_intersection: bool
Whether or not to check the coils in the new coiilset for intersections.
Returns
-------
Expand All @@ -2083,9 +2131,11 @@ def to_FourierXYZ(self, N=10, grid=None, s=None, name=""):
"""
coils = [coil.to_FourierXYZ(N, grid, s) for coil in self]
return self.__class__(*coils, name=name)
return self.__class__(*coils, name=name, check_intersection=check_intersection)

def to_SplineXYZ(self, knots=None, grid=None, method="cubic", name=""):
def to_SplineXYZ(
self, knots=None, grid=None, method="cubic", name="", check_intersection=True
):
"""Convert all coils to SplineXYZCoil representation.
Parameters
Expand All @@ -2109,6 +2159,8 @@ def to_SplineXYZ(self, knots=None, grid=None, method="cubic", name=""):
- `'catmull-rom'`: C1 cubic centripetal "tension" splines
name : str
Name for the new MixedCoilSet.
check_intersection: bool
Whether or not to check the coils in the new coiilset for intersections.
Returns
-------
Expand All @@ -2117,7 +2169,7 @@ def to_SplineXYZ(self, knots=None, grid=None, method="cubic", name=""):
"""
coils = [coil.to_SplineXYZ(knots, grid, method) for coil in self]
return self.__class__(*coils, name=name)
return self.__class__(*coils, name=name, check_intersection=check_intersection)

def __add__(self, other):
if isinstance(other, (CoilSet, MixedCoilSet)):
Expand Down
Loading

0 comments on commit 2be9d53

Please sign in to comment.