Skip to content

Commit 34bbd72

Browse files
authored
Merge branch 'master' into dependabot/pip/interpax-fft-gte-0.0.6-and-lte-0.1.0
2 parents 16c4f41 + 24aa7b9 commit 34bbd72

3 files changed

Lines changed: 28 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Performance Improvements
88
Bug Fixes
99

1010
- Fixes bug that was always setting NFP=1 in ``to_FourierRZ`` methods.
11+
- Fixes ``VMECIO.save`` metadata for current-density variables and corrects the
12+
asymmetric ``currvmns`` magnetic-axis extrapolation.
1113

1214

1315
v0.17.2

desc/vmec.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ def load(
5353
boundary is loaded and the DESC Equilibrium R,Z are constrained to
5454
match the given VMEC boundary.
5555
56-
NOTE: This is only a fit, so the DESC Equilibrium returned is not
57-
expected to be in force balance. It is recommended to solve the
58-
Equilibrium once loaded before using the Equilibrium for any
59-
analysis.
56+
NOTE: This is only a fit of the VMEC R, Z and lambda, so the DESC
57+
Equilibrium returned is not expected to be in force balance. It is
58+
recommended to solve the Equilibrium once loaded before using the
59+
Equilibrium for any analysis or computing any derived quantities in
60+
DESC (e.g. anything that is not just R, Z or lambda).
6061
6162
Parameters
6263
----------
@@ -734,7 +735,7 @@ def save( # noqa: C901
734735
jcuru[0] = 0
735736

736737
jcurv = file.createVariable("jcurv", np.float64, ("radius",))
737-
jcuru.long_name = "flux surface average of sqrt(g)*J^zeta, on full mesh"
738+
jcurv.long_name = "flux surface average of sqrt(g)*J^zeta, on full mesh"
738739
jcurv.units = "A/m^3"
739740
jcurv[:] = surface_averages(
740741
grid_full,
@@ -1331,7 +1332,7 @@ def fullfit(x):
13311332
# TODO (#1379): evaluate current at rho=0 nodes instead of extrapolation
13321333
if not eq.sym:
13331334
currvmns[:, :] = -s
1334-
currumns[0, :] = -(
1335+
currvmns[0, :] = -(
13351336
s[1, :] - (s[2, :] - s[1, :]) / (s_full[2] - s_full[1]) * s_full[1]
13361337
)
13371338
timer.stop("J^zeta*sqrt(g)")

tests/test_vmec.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,25 @@ def test_vmec_save_asym(VMEC_save_asym):
10271027
np.testing.assert_allclose(
10281028
vmec.variables["jcurv"][20:100], desc.variables["jcurv"][20:100], rtol=2
10291029
)
1030+
assert desc.variables["jcuru"].long_name == (
1031+
"flux surface average of sqrt(g)*J^theta, on full mesh"
1032+
)
1033+
assert desc.variables["jcurv"].long_name == (
1034+
"flux surface average of sqrt(g)*J^zeta, on full mesh"
1035+
)
1036+
s_full = np.linspace(0, 1, desc.dimensions["radius"].size)
1037+
expected_currumns_axis = desc.variables["currumns"][1, :] - (
1038+
(desc.variables["currumns"][2, :] - desc.variables["currumns"][1, :])
1039+
/ (s_full[2] - s_full[1])
1040+
* s_full[1]
1041+
)
1042+
expected_currvmns_axis = desc.variables["currvmns"][1, :] - (
1043+
(desc.variables["currvmns"][2, :] - desc.variables["currvmns"][1, :])
1044+
/ (s_full[2] - s_full[1])
1045+
* s_full[1]
1046+
)
1047+
np.testing.assert_allclose(desc.variables["currumns"][0, :], expected_currumns_axis)
1048+
np.testing.assert_allclose(desc.variables["currvmns"][0, :], expected_currvmns_axis)
10301049
np.testing.assert_allclose(
10311050
vmec.variables["DShear"][20:100], desc.variables["DShear"][20:100], rtol=6e-2
10321051
)

0 commit comments

Comments
 (0)