Skip to content

Commit

Permalink
Merge branch 'master' into basis_vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
unalmis authored Aug 11, 2023
2 parents b8b53ba + cc10a94 commit 309c4ef
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 0 deletions.
99 changes: 99 additions & 0 deletions desc/coils.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,37 @@ class FourierRZCoil(Coil, FourierRZCurve):
whether to enforce stellarator symmetry
name : str
name for this coil
Examples
--------
.. code-block:: python
from desc.coils import FourierRZCoil
from desc.grid import LinearGrid
import numpy as np
I = 10
mu0 = 4 * np.pi * 1e-7
R_coil = 10
# circular coil given by R(phi) = 10
coil = FourierRZCoil(
current=I, R_n=R_coil, Z_n=0, modes_R=[0], grid=LinearGrid(N=100)
)
z0 = 10
field_evaluated = coil.compute_magnetic_field(
np.array([[0, 0, 0], [0, 0, z0]]), basis="rpz"
)
np.testing.assert_allclose(
field_evaluated[0, :], np.array([0, 0, mu0 * I / 2 / R_coil]), atol=1e-8
)
np.testing.assert_allclose(
field_evaluated[1, :],
np.array(
[0, 0, mu0 * I / 2 * R_coil**2 / (R_coil**2 + z0**2) ** (3 / 2)]
),
atol=1e-8,
)
"""

_io_attrs_ = Coil._io_attrs_ + FourierRZCurve._io_attrs_
Expand Down Expand Up @@ -150,6 +181,40 @@ class FourierXYZCoil(Coil, FourierXYZCurve):
name : str
name for this coil
Examples
--------
.. code-block:: python
from desc.coils import FourierXYZCoil
from desc.grid import LinearGrid
import numpy as np
I = 10
mu0 = 4 * np.pi * 1e-7
R_coil = 10
# circular coil given by X(phi) = 10*cos(phi), Y(phi) = 10*sin(phi)
coil = FourierXYZCoil(
current=I,
X_n=[0, R_coil, 0],
Y_n=[0, 0, R_coil],
Z_n=[0, 0, 0],
modes=[0, 1, -1],
grid=LinearGrid(N=100),
)
z0 = 10
field_evaluated = coil.compute_magnetic_field(
np.array([[0, 0, 0], [0, 0, z0]]), basis="rpz"
)
np.testing.assert_allclose(
field_evaluated[0, :], np.array([0, 0, mu0 * I / 2 / R_coil]), atol=1e-8
)
np.testing.assert_allclose(
field_evaluated[1, :],
np.array([0, 0, mu0 * I / 2 * R_coil**2 / (R_coil**2 + z0**2) ** (3 / 2)]),
atol=1e-8,
)
"""

_io_attrs_ = Coil._io_attrs_ + FourierXYZCurve._io_attrs_
Expand Down Expand Up @@ -188,6 +253,40 @@ class FourierPlanarCoil(Coil, FourierPlanarCurve):
name : str
name for this coil
Examples
--------
.. code-block:: python
from desc.coils import FourierPlanarCoil
from desc.grid import LinearGrid
import numpy as np
I = 10
mu0 = 4 * np.pi * 1e-7
R_coil = 10
# circular coil given by center at (0,0,0)
# and normal vector in Z direction (0,0,1) and radius 10
coil = FourierPlanarCoil(
current=I,
center=[0, 0, 0],
normal=[0, 0, 1],
r_n=R_coil,
modes=[0],
grid=LinearGrid(N=100),
)
z0 = 10
field_evaluated = coil.compute_magnetic_field(
np.array([[0, 0, 0], [0, 0, z0]]), basis="rpz"
)
np.testing.assert_allclose(
field_evaluated[0, :], np.array([0, 0, mu0 * I / 2 / R_coil]), atol=1e-8
)
np.testing.assert_allclose(
field_evaluated[1, :],
np.array([0, 0, mu0 * I / 2 * R_coil**2 / (R_coil**2 + z0**2) ** (3 / 2)]),
atol=1e-8,
)
"""

_io_attrs_ = Coil._io_attrs_ + FourierPlanarCurve._io_attrs_
Expand Down
28 changes: 28 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ Basis
desc.basis.ChebyshevDoubleFourierBasis
desc.basis.FourierZernikeBasis

Coils
*****

.. autosummary::
:toctree: _api/coils/
:recursive:
:template: class.rst

desc.coils.FourierRZCoil
desc.coils.FourierXYZCoil
desc.coils.FourierPlanarCoil
desc.coils.CoilSet

Continuation
************
Expand Down Expand Up @@ -104,6 +116,22 @@ IO
desc.io.InputReader
desc.io.load

Magnetic Fields
***************

.. autosummary::
:toctree: _api/magnetic_fields/
:recursive:

desc.magnetic_fields.ScaledMagneticField
desc.magnetic_fields.SumMagneticField
desc.magnetic_fields.ToroidalMagneticField
desc.magnetic_fields.VerticalMagneticField
desc.magnetic_fields.PoloidalMagneticField
desc.magnetic_fields.SplineMagneticField
desc.magnetic_fields.ScalarPotentialField
desc.magnetic_fields.field_line_integrate

Objective Functions
*******************

Expand Down

0 comments on commit 309c4ef

Please sign in to comment.