Skip to content

Commit

Permalink
Merge branch 'master' into fix-plotting-subplots
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulgaur104 authored Oct 1, 2024
2 parents 930939b + 056fcc4 commit 3e1bd18
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion desc/objectives/linear_objectives.py
Original file line number Diff line number Diff line change
Expand Up @@ -3065,7 +3065,7 @@ def build(self, use_jit=True, verbose=1):
np.logical_and((basis.modes[:, 1] % 2 == 0), basis.modes[:, 1] > 0),
)
)[0]
mm = basis.modes[idx_m, 2]
mm = basis.modes[idx_m, 1]
self._A[i, idx_0] = 1
self._A[i, idx_m] = (mm % 2 - 1) * (mm % 4 - 1)

Expand Down
21 changes: 21 additions & 0 deletions tests/test_linear_objectives.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
FixNearAxisLambda,
FixNearAxisR,
FixNearAxisZ,
FixOmniBmax,
FixOmniMap,
FixOmniWell,
FixParameters,
Expand Down Expand Up @@ -915,6 +916,26 @@ def test_fix_omni_indices():
assert constraint.dim_f == indices.size


@pytest.mark.unit
def test_fix_omni_Bmax():
"""Test that omnigenity parameters are constrained for B_max to be a straight line.
Test for GH issue #1266.
"""

def _test(M_x, N_x, NFP, sum):
field = OmnigenousField(L_x=2, M_x=M_x, N_x=N_x, NFP=NFP, helicity=(1, NFP))
constraint = FixOmniBmax(field=field)
constraint.build()
assert constraint.dim_f == (2 * field.N_x + 1) * (field.L_x + 1)
# 0 - 2 + 4 - 6 + 8 ...
np.testing.assert_allclose(constraint._A @ field.x_basis.modes[:, 1], sum)

_test(M_x=6, N_x=3, NFP=1, sum=-4)
_test(M_x=9, N_x=4, NFP=2, sum=4)
_test(M_x=12, N_x=5, NFP=3, sum=6)


@pytest.mark.unit
def test_fix_parameters_input_order(DummyStellarator):
"""Test that FixParameters preserves the input indices and target ordering."""
Expand Down

0 comments on commit 3e1bd18

Please sign in to comment.