Skip to content

Commit

Permalink
Fix failing axis limit test
Browse files Browse the repository at this point in the history
  • Loading branch information
unalmis committed Oct 17, 2024
1 parent 9ca889d commit aedb90f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion desc/compute/_basis_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3262,7 +3262,7 @@ def _periodic_grad_alpha(params, transforms, profiles, data, **kwargs):
units_long="Inverse meters",
description=(
"Gradient of field line label, which is perpendicular to the field line, "
"periodic component"
"secular component"
),
dim=3,
params=[],
Expand Down
13 changes: 9 additions & 4 deletions desc/integrals/basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,15 @@ class FourierChebyshevSeries(IOAble):
Examples
--------
Let the magnetic field be B = ∇ρ × ∇α, x = α, and y = ζ. This basis can
will then parameterize maps in Clebsch coordinates. Passing in a sequence
of α values tracking the field line (see ``get_alpha``) to the
``compute_cheb`` method will generate f along field lines.
Let the magnetic field be B = ∇ρ × ∇x. This basis will then parameterize
maps in Clebsch coordinates. Passing in a sequence of x values tracking
the field line (see ``get_alpha``) to the ``compute_cheb`` method will
generate a 1D parameterization of f along the field line.
This is useful to interpolate f ≝ θ and use the map x, ζ ↦ θ(x, ζ) to
compute quantities along field lines via evaluating Fourier series
parameterized in DESC computational coordinates θ, ζ, where the Fourier
transform is more condensed when NFP > 1.
Notes
-----
Expand Down
15 changes: 10 additions & 5 deletions tests/test_axis_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from desc.grid import LinearGrid
from desc.integrals import surface_integrals_map
from desc.objectives import GenericObjective, ObjectiveFunction
from desc.utils import dot
from desc.utils import dot, errorif

# Unless mentioned in the source code of the compute function, the assumptions
# made to compute the magnetic axis limit can be reduced to assuming that these
Expand All @@ -44,6 +44,7 @@
"curvature_k1_zeta",
"curvature_k2_rho",
"curvature_k2_zeta",
"cvdrift",
"e^helical",
"e^theta",
"e^theta_r",
Expand All @@ -63,10 +64,11 @@
"g^tz_z",
"g^aa",
"g^ra",
"gbdrift",
"grad(alpha)",
"periodic(grad(alpha))",
"gbdrift",
"cvdrift",
"periodic(gbdrift)",
"periodic(cvdrift)",
"|e^helical|",
"|grad(theta)|",
"<J*B> Redl", # may not exist for all configurations
Expand Down Expand Up @@ -216,10 +218,10 @@ def assert_is_continuous(
if name in not_continuous_limits:
continue
elif name in not_finite_limits:
assert (np.isfinite(data[name]).T != axis).all(), name
errorif(np.any(np.isfinite(data[name]).T == axis), AssertionError, msg=name)
continue
else:
assert np.isfinite(data[name]).all(), name
errorif(not np.isfinite(data[name]).all(), AssertionError, msg=name)

if (
data_index[p][name]["coordinates"] == ""
Expand Down Expand Up @@ -289,6 +291,9 @@ def test_limit_continuity(self):
"iota_r": {"atol": 1e-6},
"iota_num_rr": {"atol": 5e-5},
"grad(B)": {"rtol": 1e-4},
"secular(alpha_r)": {"atol": 1e-4},
"secular(grad(alpha))": {"atol": 1e-4},
"secular(gbdrift)": {"atol": 1e-4},
}
zero_map = dict.fromkeys(zero_limits, {"desired_at_axis": 0})
kwargs = weaker_tolerance | zero_map
Expand Down

0 comments on commit aedb90f

Please sign in to comment.