Skip to content

Commit

Permalink
Merge branch 'master' into higher_order_deriv
Browse files Browse the repository at this point in the history
  • Loading branch information
f0uriest authored Jul 28, 2023
2 parents 73e4c57 + 85c78c2 commit b021ef2
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
Changelog
=========

v0.9.2
------

[Github Commits](https://github.com/PlasmaControl/DESC/compare/v0.9.1...v0.9.2)

Improvements
- Improves robustness and speed of ``map_coordinates``.
- Adds axis parameters ``Ra_n`` and ``Za_n`` as optimizable DoF when using standard
constrained optimization methods (ie, not ``ProximalProjection``).
- Adds method to convert ``FourierRZCurve`` to ``FourierXYZCurve``.
- Makes DESC classes compatible with JAX pytrees.
- Adds Chebyshev polynomials as basis function (for future use).

Breaking changes
- Renames ``theta_sfl`` to ``theta_PEST`` in compute functions to avoid confusion with
other straight field line coordinate systems.
- Makes plotting kwargs a bit more uniform. ``zeta``, ``nzeta``, ``nphi`` have all been
superceded by ``phi`` which can be an integer for equally spaced angles or a float or
array of float to specify angles manually.

Bug fixes
- Avoids accidentally overwriting equilibria during automatic continuation method.

New Contributors

- \@rahulgaur104 made their first contribution in https://github.com/PlasmaControl/DESC/pull/576


v0.9.1
------

Expand Down
4 changes: 2 additions & 2 deletions desc/objectives/_qs.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ def __init__(
):
if target is None and bounds is None:
target = 0
assert len(helicity) == 2
assert (int(helicity[0]) == helicity[0]) and (int(helicity[1]) == helicity[1])
self._grid = grid
self.helicity = helicity
self.M_booz = M_booz
Expand Down Expand Up @@ -325,6 +323,7 @@ def build(self, eq=None, use_jit=True, verbose=1):
self._constants = {
"transforms": self._transforms,
"profiles": self._profiles,
"helicity": self.helicity,
}

timer.stop("Precomputing transforms")
Expand Down Expand Up @@ -369,6 +368,7 @@ def compute(self, *args, **kwargs):
params=params,
transforms=constants["transforms"],
profiles=constants["profiles"],
helicity=constants["helicity"],
)
return data["f_C"] * constants["transforms"]["grid"].weights

Expand Down
26 changes: 26 additions & 0 deletions tests/test_objective_funs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import pytest
from scipy.constants import mu_0

import desc.examples
from desc.backend import jnp
from desc.compute import get_transforms
from desc.equilibrium import Equilibrium
Expand Down Expand Up @@ -249,6 +250,31 @@ def test(eq):
test(Equilibrium(iota=PowerSeriesProfile(0)))
test(Equilibrium(current=PowerSeriesProfile(0)))

# also make sure helicity is set correctly
eq1 = desc.examples.get("precise_QA")
eq2 = desc.examples.get("precise_QH")

helicity_QA = (1, 0)
helicity_QH = (1, eq2.NFP)

# precise_QA should have lower QA than QH
obj = QuasisymmetryTwoTerm(eq=eq1, helicity=helicity_QA)
obj.build()
f1 = obj.compute_scalar(*obj.xs(eq1))
obj.helicity = helicity_QH
obj.build()
f2 = obj.compute_scalar(*obj.xs(eq1))
assert f1 < f2

# precise_QH should have lower QH than QA
obj = QuasisymmetryTwoTerm(eq=eq2, helicity=helicity_QH)
obj.build()
f1 = obj.compute_scalar(*obj.xs(eq2))
obj.helicity = helicity_QA
obj.build()
f2 = obj.compute_scalar(*obj.xs(eq2))
assert f1 < f2

@pytest.mark.unit
def test_qs_tripleproduct(self):
"""Test calculation of triple product QS metric."""
Expand Down

0 comments on commit b021ef2

Please sign in to comment.