Skip to content

Commit 24b5030

Browse files
committed
helicity_n now optional in j_dot_B_Redl. In Quasisymmetry, renamed m and n to helicity_m and helicity_n for consistency with QuasisymmetryRatioResidual and j_dot_B_Redl
1 parent 4f9bd37 commit 24b5030

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

src/simsopt/mhd/bootstrap.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def integrand(lambd):
165165
return Bmin, Bmax, epsilon, fsa_B2, fsa_1overB, f_t
166166

167167

168-
def j_dot_B_Redl(ne, Te, Ti, Zeff, helicity_n, s=None, G=None, R=None, iota=None,
168+
def j_dot_B_Redl(ne, Te, Ti, Zeff, helicity_n=None, s=None, G=None, R=None, iota=None,
169169
epsilon=None, f_t=None, psi_edge=None, nfp=None,
170170
geom=None, plot=False):
171171
r"""
@@ -199,6 +199,10 @@ def j_dot_B_Redl(ne, Te, Ti, Zeff, helicity_n, s=None, G=None, R=None, iota=None
199199
:math:`\left<\vec{J}\cdot\vec{B}\right>` will be computed on this
200200
same set of flux surfaces.
201201
202+
If you provide a :obj:`RedlGeomBoozer` object for ``geom``, then
203+
it is not necessary to specify the argument ``helicity_n`` here,
204+
in which case ``helicity_n`` will be taken from ``geom``.
205+
202206
Args:
203207
ne: A :obj:`~simsopt.mhd.profiles.Profile` object with the electron density profile.
204208
Te: A :obj:`~simsopt.mhd.profiles.Profile` object with the electron temperature profile.
@@ -247,6 +251,9 @@ def j_dot_B_Redl(ne, Te, Ti, Zeff, helicity_n, s=None, G=None, R=None, iota=None
247251
f_t = geom_data.f_t
248252
nfp = geom_data.nfp
249253

254+
if helicity_n is None:
255+
helicity_n = geom.helicity_n
256+
250257
helicity_N = nfp * helicity_n
251258
if Zeff is None:
252259
Zeff = ProfilePolynomial(1.0)

src/simsopt/mhd/boozer.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,10 @@ class Quasisymmetry(Optimizable):
243243
Args:
244244
boozer: A Boozer object on which the calculation will be based.
245245
s: The normalized toroidal magnetic flux for the flux surface to analyze. Should be in the range [0, 1].
246-
m: The poloidal mode number of the symmetry you want to achive.
247-
The departure from symmetry B(m * theta - nfp * n * zeta) will be reported.
248-
n: The toroidal mode number of the symmetry you want to achieve.
249-
The departure from symmetry B(m * theta - nfp * n * zeta) will be reported.
246+
helicity_m: The poloidal mode number of the symmetry you want to achive.
247+
The departure from symmetry ``B(helicity_m * theta - nfp * helicity_n * zeta)`` will be reported.
248+
helicity_n: The toroidal mode number of the symmetry you want to achieve.
249+
The departure from symmetry ``B(helicity_m * theta - nfp * helicity_n * zeta)`` will be reported.
250250
normalization: A uniform normalization applied to all bmnc harmonics.
251251
If ``"B00"``, the symmetry-breaking modes will be divided by the m=n=0 mode amplitude
252252
on the same surface. If ``"symmetric"``, the symmetry-breaking modes will be
@@ -258,17 +258,17 @@ class Quasisymmetry(Optimizable):
258258
def __init__(self,
259259
boozer: Boozer,
260260
s: Union[float, Iterable[float]],
261-
m: int,
262-
n: int,
261+
helicity_m: int,
262+
helicity_n: int,
263263
normalization: str = "B00",
264264
weight: str = "even") -> None:
265265
"""
266266
Constructor
267267
268268
"""
269269
self.boozer = boozer
270-
self.m = m
271-
self.n = n
270+
self.helicity_m = helicity_m
271+
self.helicity_n = helicity_n
272272
self.normalization = normalization
273273
self.weight = weight
274274

@@ -308,23 +308,23 @@ def J(self) -> np.ndarray:
308308
xm = self.boozer.bx.xm_b
309309
xn = self.boozer.bx.xn_b / self.boozer.bx.nfp
310310

311-
if self.m != 0 and self.m != 1:
311+
if self.helicity_m != 0 and self.helicity_m != 1:
312312
raise ValueError("m for quasisymmetry should be 0 or 1.")
313313

314314
# Find the indices of the symmetric modes:
315-
if self.n == 0:
315+
if self.helicity_n == 0:
316316
# Quasi-axisymmetry
317317
symmetric = (xn == 0)
318318

319-
elif self.m == 0:
319+
elif self.helicity_m == 0:
320320
# Quasi-poloidal symmetry
321321
symmetric = (xm == 0)
322322

323323
else:
324324
# Quasi-helical symmetry
325-
symmetric = (xm * self.n + xn * self.m == 0)
326-
# Stellopt takes the "and" of this with mod(xm, self.m),
327-
# which does not seem necessary since self.m must be 1 to
325+
symmetric = (xm * self.helicity_n + xn * self.helicity_m == 0)
326+
# Stellopt takes the "and" of this with mod(xm, self.helicity_m),
327+
# which does not seem necessary since self.helicity_m must be 1 to
328328
# get here.
329329
nonsymmetric = np.logical_not(symmetric)
330330

tests/mhd/test_bootstrap.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,10 +636,11 @@ def test_Redl_sfincs_tokamak_benchmark(self):
636636
for geom_method in range(2):
637637
if geom_method == 0:
638638
geom = RedlGeomVmec(vmec, surfaces)
639+
jdotB, details = j_dot_B_Redl(ne, Te, Ti, Zeff, helicity_n, geom=geom, plot=False)
639640
else:
640641
geom = RedlGeomBoozer(boozer, surfaces, helicity_n)
642+
jdotB, details = j_dot_B_Redl(ne, Te, Ti, Zeff, geom=geom, plot=False)
641643

642-
jdotB, details = j_dot_B_Redl(ne, Te, Ti, Zeff, helicity_n, geom=geom, plot=False)
643644
jdotB_history.append(jdotB)
644645

645646
# The relative error is a bit larger at s \approx 1, where the

0 commit comments

Comments
 (0)