diff --git a/src/simsopt/geo/curve.py b/src/simsopt/geo/curve.py index ba28ce3fa..2d07d7499 100644 --- a/src/simsopt/geo/curve.py +++ b/src/simsopt/geo/curve.py @@ -635,6 +635,12 @@ def __init__(self, curve, phi, flip): [0, 0, -1]]) self.rotmatT = self.rotmat.T.copy() + def change_curve(self, new_curve): + if isinstance(self.curve, RotatedCurve): + self.curve.change_curve(new_curve) + else: + self.curve = new_curve + def get_dofs(self): """ RotatedCurve does not have any dofs of its own. diff --git a/src/simsopt/geo/orientedcurve.py b/src/simsopt/geo/orientedcurve.py index 60b70196e..3b85add54 100644 --- a/src/simsopt/geo/orientedcurve.py +++ b/src/simsopt/geo/orientedcurve.py @@ -142,4 +142,19 @@ def _make_names(self): for j in range(0, self.order): dofs_name += [f'{c}s({j+1})', f'{c}c({j+1})'] return xyc_name + ypr_name + dofs_name + + @classmethod + def from_curvexyzfourier(cls, xyzcurve): + oriented_curve = cls(xyzcurve.quadpoints, xyzcurve.order) + + for dname in xyzcurve.local_full_dof_names: + if dname in ['xc(0)', 'yc(0)', 'zc(0)']: + continue + oriented_curve.set(dname, xyzcurve.get(dname)) + + oriented_curve.set('x0', xyzcurve.get('xc(0)')) + oriented_curve.set('y0', xyzcurve.get('yc(0)')) + oriented_curve.set('z0', xyzcurve.get('zc(0)')) + + return oriented_curve