Skip to content

Commit

Permalink
Merge branch 'master' into yge/numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
dpanici authored Aug 20, 2024
2 parents 6425388 + dd3f472 commit 73c18ca
Show file tree
Hide file tree
Showing 42 changed files with 2,116 additions and 1,132 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
27 changes: 27 additions & 0 deletions desc/compute/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,30 @@ def _build_data_index():


_build_data_index()


def set_tier(name, p):
"""Determine how deep in the dependency tree a given name is.
tier of 0 means no dependencies on other data,
tier of 1 means it depends on only tier 0 stuff,
tier of 2 means it depends on tier 0 and tier 1, etc etc.
Designed such that if you compute things in the order determined by tiers,
all dependencies will always be computed in the correct order.
"""
if "tier" in data_index[p][name]:
return
if len(data_index[p][name]["full_with_axis_dependencies"]["data"]) == 0:
data_index[p][name]["tier"] = 0
else:
thistier = 0
for name1 in data_index[p][name]["full_with_axis_dependencies"]["data"]:
set_tier(name1, p)
thistier = max(thistier, data_index[p][name1]["tier"])
data_index[p][name]["tier"] = thistier + 1


for par in data_index.keys():
for name in data_index[par]:
set_tier(name, par)
Loading

0 comments on commit 73c18ca

Please sign in to comment.