Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement FourierRZCurveWindingSurface Class #844

Draft
wants to merge 47 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c767a3e
initial commit, working but need to finish implementing position vect…
dpanici Jan 30, 2024
60eb84b
finish adding x_ss
dpanici Jan 30, 2024
e75fa9e
implement x_sss compute function
dpanici Jan 30, 2024
dbd8587
add missing theta_sss and zeta_sss
dpanici Jan 30, 2024
bc16e0b
Merge branch 'master' into dp/curve-winding-surface
dpanici Jan 31, 2024
d07d5c5
Merge branch 'master' into dp/curve-winding-surface
dpanici Feb 1, 2024
c8d6766
Merge branch 'master' into dp/curve-winding-surface
dpanici Feb 1, 2024
bc100b5
add coil class
dpanici Feb 1, 2024
b4ca09f
fix secular terms in curve class
dpanici Feb 1, 2024
3d15a30
add inheritance to FourierRZWindingSurfaceCoil to data index
dpanici Feb 1, 2024
8b2ef75
Merge branch 'master' into dp/curve-winding-surface
dpanici Feb 1, 2024
0a3f882
remove extra params
dpanici Feb 1, 2024
8be000e
Merge branch 'dp/curve-winding-surface' of github.com:PlasmaControl/D…
dpanici Feb 1, 2024
c2b22d7
Merge branch 'master' into dp/curve-winding-surface
dpanici Feb 2, 2024
9739987
correct typos in compute function
dpanici Feb 2, 2024
4fbf0ba
Merge branch 'master' into dp/curve-winding-surface
dpanici Feb 6, 2024
3a73214
fix compute quantities, add tests for the new curve class
dpanici Feb 7, 2024
9fed838
fix bug where did not return data, need to still figure out correct w…
dpanici Feb 7, 2024
24d6daf
fix error in io attrs
dpanici Feb 9, 2024
1027ea6
Merge branch 'master' into dp/curve-winding-surface
dpanici Feb 22, 2024
1584648
Merge branch 'master' into dp/curve-winding-surface
dpanici Mar 4, 2024
c0279c5
fix compute bug, fix setting res bug
dpanici Mar 4, 2024
4f9f8f0
Merge branch 'master' into dp/curve-winding-surface
dpanici Mar 6, 2024
f8aebe9
Merge branch 'dp/surface-RZ-derivs' into dp/curve-winding-surface
dpanici Mar 6, 2024
f326f34
fix torsion computation for winding surface curve
dpanici Mar 6, 2024
ecf4de6
Merge branch 'master' into dp/curve-winding-surface
dpanici Mar 6, 2024
d8be6e7
Merge branch 'master' into dp/curve-winding-surface
dpanici Mar 6, 2024
5410cee
Merge branch 'dp/surface-RZ-derivs' into dp/curve-winding-surface
dpanici Mar 7, 2024
1c337bc
Merge branch 'dp/surface-RZ-derivs' into dp/curve-winding-surface
dpanici Mar 8, 2024
8cf8971
merge, add from_values method
dpanici Mar 23, 2024
0d3cbcc
Merge branch 'master' into dp/curve-winding-surface
dpanici Mar 30, 2024
6f30531
Merge branch 'dp/plot-3d-hide-things' into dp/curve-winding-surface
dpanici Mar 30, 2024
61ee7cb
Merge branch 'dp/plot-3d-hide-things' into dp/curve-winding-surface
dpanici Mar 30, 2024
4e1c056
Merge branch 'master' into dp/curve-winding-surface
dpanici Apr 9, 2024
786c718
update master data (ran on linux now, not on mac)
dpanici Apr 9, 2024
79e0279
merge, need to re-run test compute everything on linux though
dpanici Jul 15, 2024
dc23cf4
Merge branch 'master' into dp/curve-winding-surface
dpanici Jul 16, 2024
6f10972
Merge branch 'master' into dp/curve-winding-surface
dpanici Jul 22, 2024
bd4f186
fix error in coord transform for winding surface curve computes
dpanici Jul 22, 2024
8886b99
add R_lmn Z_lmn params to winding surface curve and modify compute fx…
dpanici Jul 22, 2024
c2e42fd
fix test
dpanici Jul 22, 2024
ffe5f48
remove unused params, add some attrs to CoilSet for the winding surfa…
dpanici Jul 22, 2024
e2aad22
remove extra dependencies
dpanici Jul 23, 2024
ea9184c
add missing dependency
dpanici Aug 5, 2024
2359ac3
Merge branch 'master' into dp/curve-winding-surface
dpanici Aug 6, 2024
c389360
Merge branch 'master' into dp/curve-winding-surface
dpanici Sep 5, 2024
982cedd
Merge branch 'master' into dp/curve-winding-surface
dpanici Sep 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions desc/coils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from desc.geometry import (
FourierPlanarCurve,
FourierRZCurve,
FourierRZWindingSurfaceCurve,
FourierXYZCurve,
SplineXYZCurve,
)
Expand Down Expand Up @@ -699,6 +700,64 @@ def from_values(cls, current, coords, N=10, NFP=1, basis="rpz", sym=False, name=
)


class FourierRZWindingSurfaceCoil(_Coil, FourierRZWindingSurfaceCurve):
"""Coil parameterized by Fourier series for theta,zeta in terms of parameter s.

This curve will lie on the given winding surface, parameterized by a
Fourier series given by Rb_mn and Zb_mn.

Parameters
----------
current : float
current through coil, in Amperes
surface : FourierRZToroidalSurface
Winding surface that the coil will lie on.
theta_n, zeta_n: array-like
Fourier coefficients for theta, zeta in terms of curve parameter s.
modes_theta : array-like, optional
Mode numbers associated with theta_n. If not given defaults to [-n:n].
modes_zeta : array-like, optional
Mode numbers associated with zeta_n, If not given defaults to [-n:n]].
sym_theta : {"cos", "sin", False}, optional
Whether to enforce symmetry for the theta(t) Fourier series. Defaults to "sin"
sym_zeta : {"cos", "sin", False}, optional
Whether to enforce symmetry for the zeta(t) Fourier series. Defaults to "sin"
name : str
Name for this coil.

"""

_io_attrs_ = _Coil._io_attrs_ + FourierRZWindingSurfaceCurve._io_attrs_

def __init__(
self,
current=1,
surface=None,
theta_n=1,
zeta_n=1,
secular_theta=1.0,
secular_zeta=1.0,
modes_theta=None,
modes_zeta=None,
sym_theta="sin",
sym_zeta="sin",
name="",
):
super().__init__(
current,
surface,
theta_n,
zeta_n,
secular_theta,
secular_zeta,
modes_theta,
modes_zeta,
sym_theta,
sym_zeta,
name,
)


class FourierXYZCoil(_Coil, FourierXYZCurve):
"""Coil parameterized by fourier series for X,Y,Z in terms of arbitrary angle s.

Expand Down Expand Up @@ -1184,6 +1243,8 @@ def _check_type(coil0, coil):
FourierXYZCoil: ["X_basis", "Y_basis", "Z_basis"],
FourierPlanarCoil: ["r_basis"],
SplineXYZCoil: ["method", "N", "knots"],
# TODO: probably add a surf_R_basis or R_basis and Z_basis to this
FourierRZWindingSurfaceCoil: ["N", "theta_basis", "zeta_basis", "surface"],
}

for attr in attrs[coil0.__class__]:
Expand Down
71 changes: 71 additions & 0 deletions desc/compute/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2758,6 +2758,10 @@ def _phi_r(params, transforms, profiles, data, **kwargs):
profiles=[],
coordinates="rtz",
data=["omega_rr"],
parameterization=[
"desc.equilibrium.equilibrium.Equilibrium",
"desc.geometry.core.Surface",
],
)
def _phi_rr(params, transforms, profiles, data, **kwargs):
data["phi_rr"] = data["omega_rr"]
Expand All @@ -2777,6 +2781,10 @@ def _phi_rr(params, transforms, profiles, data, **kwargs):
profiles=[],
coordinates="rtz",
data=["omega_rrz"],
parameterization=[
"desc.equilibrium.equilibrium.Equilibrium",
"desc.geometry.core.Surface",
],
)
def _phi_rrz(params, transforms, profiles, data, **kwargs):
data["phi_rrz"] = data["omega_rrz"]
Expand All @@ -2796,6 +2804,10 @@ def _phi_rrz(params, transforms, profiles, data, **kwargs):
profiles=[],
coordinates="rtz",
data=["omega_rt"],
parameterization=[
"desc.equilibrium.equilibrium.Equilibrium",
"desc.geometry.core.Surface",
],
)
def _phi_rt(params, transforms, profiles, data, **kwargs):
data["phi_rt"] = data["omega_rt"]
Expand All @@ -2815,6 +2827,10 @@ def _phi_rt(params, transforms, profiles, data, **kwargs):
profiles=[],
coordinates="rtz",
data=["omega_rtz"],
parameterization=[
"desc.equilibrium.equilibrium.Equilibrium",
"desc.geometry.core.Surface",
],
)
def _phi_rtz(params, transforms, profiles, data, **kwargs):
data["phi_rtz"] = data["omega_rtz"]
Expand All @@ -2834,6 +2850,10 @@ def _phi_rtz(params, transforms, profiles, data, **kwargs):
profiles=[],
coordinates="rtz",
data=["omega_rz"],
parameterization=[
"desc.equilibrium.equilibrium.Equilibrium",
"desc.geometry.core.Surface",
],
)
def _phi_rz(params, transforms, profiles, data, **kwargs):
data["phi_rz"] = data["omega_rz"]
Expand All @@ -2853,6 +2873,10 @@ def _phi_rz(params, transforms, profiles, data, **kwargs):
profiles=[],
coordinates="rtz",
data=["omega_rzz"],
parameterization=[
"desc.equilibrium.equilibrium.Equilibrium",
"desc.geometry.core.Surface",
],
)
def _phi_rzz(params, transforms, profiles, data, **kwargs):
data["phi_rzz"] = data["omega_rzz"]
Expand Down Expand Up @@ -2894,12 +2918,39 @@ def _phi_t(params, transforms, profiles, data, **kwargs):
profiles=[],
coordinates="rtz",
data=["omega_tt"],
parameterization=[
"desc.equilibrium.equilibrium.Equilibrium",
"desc.geometry.core.Surface",
],
)
def _phi_tt(params, transforms, profiles, data, **kwargs):
data["phi_tt"] = data["omega_tt"]
return data


@register_compute_fun(
name="phi_ttt",
label="\\partial_{\\theta \\theta \\theta} \\phi",
units="rad",
units_long="radians",
description="Toroidal angle in lab frame, third derivative wrt poloidal "
"coordinate",
dim=1,
params=[],
transforms={},
profiles=[],
coordinates="rtz",
data=["omega_ttt"],
parameterization=[
"desc.equilibrium.equilibrium.Equilibrium",
"desc.geometry.core.Surface",
],
)
def _phi_ttt(params, transforms, profiles, data, **kwargs):
data["phi_ttt"] = data["omega_ttt"]
return data


@register_compute_fun(
name="phi_ttz",
label="\\partial_{\\theta \\theta \\zeta} \\phi",
Expand All @@ -2913,6 +2964,10 @@ def _phi_tt(params, transforms, profiles, data, **kwargs):
profiles=[],
coordinates="rtz",
data=["omega_ttz"],
parameterization=[
"desc.equilibrium.equilibrium.Equilibrium",
"desc.geometry.core.Surface",
],
)
def _phi_ttz(params, transforms, profiles, data, **kwargs):
data["phi_ttz"] = data["omega_ttz"]
Expand All @@ -2932,6 +2987,10 @@ def _phi_ttz(params, transforms, profiles, data, **kwargs):
profiles=[],
coordinates="rtz",
data=["omega_tz"],
parameterization=[
"desc.equilibrium.equilibrium.Equilibrium",
"desc.geometry.core.Surface",
],
)
def _phi_tz(params, transforms, profiles, data, **kwargs):
data["phi_tz"] = data["omega_tz"]
Expand All @@ -2951,6 +3010,10 @@ def _phi_tz(params, transforms, profiles, data, **kwargs):
profiles=[],
coordinates="rtz",
data=["omega_tzz"],
parameterization=[
"desc.equilibrium.equilibrium.Equilibrium",
"desc.geometry.core.Surface",
],
)
def _phi_tzz(params, transforms, profiles, data, **kwargs):
data["phi_tzz"] = data["omega_tzz"]
Expand Down Expand Up @@ -2992,6 +3055,10 @@ def _phi_z(params, transforms, profiles, data, **kwargs):
profiles=[],
coordinates="rtz",
data=["omega_zz"],
parameterization=[
"desc.equilibrium.equilibrium.Equilibrium",
"desc.geometry.core.Surface",
],
)
def _phi_zz(params, transforms, profiles, data, **kwargs):
data["phi_zz"] = data["omega_zz"]
Expand All @@ -3011,6 +3078,10 @@ def _phi_zz(params, transforms, profiles, data, **kwargs):
profiles=[],
coordinates="rtz",
data=["omega_zzz"],
parameterization=[
"desc.equilibrium.equilibrium.Equilibrium",
"desc.geometry.core.Surface",
],
)
def _phi_zzz(params, transforms, profiles, data, **kwargs):
data["phi_zzz"] = data["omega_zzz"]
Expand Down
Loading
Loading