Skip to content

Commit

Permalink
Implemented class method to initialize OrientedCurveXYZFourier from C…
Browse files Browse the repository at this point in the history
…urveXYZFourier
  • Loading branch information
abaillod committed Jul 24, 2024
1 parent 6924121 commit f9593e9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/simsopt/geo/curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions src/simsopt/geo/orientedcurve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f9593e9

Please sign in to comment.