Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reviewer requested name change #1407

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions desc/compute/_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -1952,15 +1952,15 @@ def _g_sup_ra(params, transforms, profiles, data, **kwargs):
transforms={},
profiles=[],
coordinates="rtz",
data=["periodic(gbdrift)", "secular(gbdrift)"],
data=["gbdrift (periodic)", "gbdrift (secular)"],
)
def _gbdrift(params, transforms, profiles, data, **kwargs):
data["gbdrift"] = data["periodic(gbdrift)"] + data["secular(gbdrift)"]
data["gbdrift"] = data["gbdrift (periodic)"] + data["gbdrift (secular)"]
return data


@register_compute_fun(
name="periodic(gbdrift)",
name="gbdrift (periodic)",
label="\\mathrm{periodic}(\\nabla \\vert B \\vert)_{\\mathrm{drift}}",
units="1 / Wb",
units_long="Inverse webers",
Expand All @@ -1973,15 +1973,15 @@ def _gbdrift(params, transforms, profiles, data, **kwargs):
data=["|B|^2", "b", "periodic(grad(alpha))", "grad(|B|)"],
)
def _periodic_gbdrift(params, transforms, profiles, data, **kwargs):
data["periodic(gbdrift)"] = (
data["gbdrift (periodic)"] = (
dot(data["b"], cross(data["grad(|B|)"], data["periodic(grad(alpha))"]))
/ data["|B|^2"]
)
return data


@register_compute_fun(
name="secular(gbdrift)",
name="gbdrift (secular)",
label="\\mathrm{secular}(\\nabla \\vert B \\vert)_{\\mathrm{drift}}",
units="1 / Wb",
units_long="Inverse webers",
Expand All @@ -1994,15 +1994,15 @@ def _periodic_gbdrift(params, transforms, profiles, data, **kwargs):
data=["|B|^2", "b", "secular(grad(alpha))", "grad(|B|)"],
)
def _secular_gbdrift(params, transforms, profiles, data, **kwargs):
data["secular(gbdrift)"] = (
data["gbdrift (secular)"] = (
dot(data["b"], cross(data["grad(|B|)"], data["secular(grad(alpha))"]))
/ data["|B|^2"]
)
return data


@register_compute_fun(
name="secular(gbdrift)/phi",
name="gbdrift (secular)/phi",
label="\\mathrm{secular}(\\nabla \\vert B \\vert)_{\\mathrm{drift}} / \\phi",
units="1 / Wb",
units_long="Inverse webers",
Expand All @@ -2016,7 +2016,7 @@ def _secular_gbdrift(params, transforms, profiles, data, **kwargs):
data=["|B|^2", "b", "e^rho", "grad(|B|)", "iota_r"],
)
def _secular_gbdrift_over_phi(params, transforms, profiles, data, **kwargs):
data["secular(gbdrift)/phi"] = (
data["gbdrift (secular)/phi"] = (
dot(data["b"], cross(data["e^rho"], data["grad(|B|)"]))
* data["iota_r"]
/ data["|B|^2"]
Expand All @@ -2040,16 +2040,16 @@ def _secular_gbdrift_over_phi(params, transforms, profiles, data, **kwargs):
transforms={},
profiles=[],
coordinates="rtz",
data=["periodic(cvdrift)", "secular(gbdrift)"],
data=["cvdrift (periodic)", "gbdrift (secular)"],
)
def _cvdrift(params, transforms, profiles, data, **kwargs):
data["cvdrift"] = data["periodic(cvdrift)"] + data["secular(gbdrift)"]
data["cvdrift"] = data["cvdrift (periodic)"] + data["gbdrift (secular)"]
return data


@register_compute_fun(
name="periodic(cvdrift)",
label="\\mathrm{periodic(cvdrift)}",
name="cvdrift (periodic)",
label="\\mathrm{cvdrift (periodic)}",
units="1 / Wb",
units_long="Inverse webers",
description="Periodic, binormal, geometric part of the curvature drift.",
Expand All @@ -2058,11 +2058,11 @@ def _cvdrift(params, transforms, profiles, data, **kwargs):
transforms={},
profiles=[],
coordinates="rtz",
data=["p_r", "psi_r", "|B|^2", "periodic(gbdrift)"],
data=["p_r", "psi_r", "|B|^2", "gbdrift (periodic)"],
)
def _periodic_cvdrift(params, transforms, profiles, data, **kwargs):
data["periodic(cvdrift)"] = (
mu_0 * data["p_r"] / data["psi_r"] / data["|B|^2"] + data["periodic(gbdrift)"]
data["cvdrift (periodic)"] = (
mu_0 * data["p_r"] / data["psi_r"] / data["|B|^2"] + data["gbdrift (periodic)"]
)
return data

Expand Down
12 changes: 6 additions & 6 deletions desc/compute/_neoclassical.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def _cvdrift0(data, B, pitch):

def _gbdrift(data, B, pitch):
return safediv(
(data["periodic(gbdrift)"] + data["secular(gbdrift)/phi"] * data["zeta"])
(data["gbdrift (periodic)"] + data["gbdrift (secular)/phi"] * data["zeta"])
* (1 - 0.5 * pitch * B),
jnp.sqrt(jnp.abs(1 - pitch * B)),
)
Expand All @@ -528,8 +528,8 @@ def _gbdrift(data, B, pitch):
"min_tz |B|",
"max_tz |B|",
"cvdrift0",
"periodic(gbdrift)",
"secular(gbdrift)/phi",
"gbdrift (periodic)",
"gbdrift (secular)/phi",
]
+ Bounce2D.required_names,
resolution_requirement="tz",
Expand Down Expand Up @@ -595,7 +595,7 @@ def fun(pitch_inv):
[_v_tau, _cvdrift0, _gbdrift],
pitch_inv,
data,
["cvdrift0", "periodic(gbdrift)", "secular(gbdrift)/phi"],
["cvdrift0", "gbdrift (periodic)", "gbdrift (secular)/phi"],
bounce.points(pitch_inv, num_well=num_well),
is_fourier=True,
)
Expand All @@ -614,8 +614,8 @@ def fun(pitch_inv):
Gamma_c,
fun_data={
"cvdrift0": data["cvdrift0"],
"periodic(gbdrift)": data["periodic(gbdrift)"],
"secular(gbdrift)/phi": data["secular(gbdrift)/phi"],
"gbdrift (periodic)": data["gbdrift (periodic)"],
"gbdrift (secular)/phi": data["gbdrift (secular)/phi"],
},
data=data,
theta=theta,
Expand Down
Binary file modified tests/inputs/master_compute_data_rpz.pkl
Binary file not shown.
8 changes: 4 additions & 4 deletions tests/test_axis_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
"gbdrift",
"grad(alpha)",
"periodic(grad(alpha))",
"periodic(gbdrift)",
"periodic(cvdrift)",
"gbdrift (periodic)",
"cvdrift (periodic)",
"|e^helical|",
"|grad(theta)|",
"<J*B> Redl", # may not exist for all configurations
Expand Down Expand Up @@ -294,8 +294,8 @@ def test_limit_continuity(self):
"grad(B)": {"rtol": 1e-4},
"secular(alpha_r)": {"atol": 1e-4},
"secular(grad(alpha))": {"atol": 1e-4},
"secular(gbdrift)": {"atol": 1e-4},
"secular(gbdrift)/phi": {"atol": 1e-4},
"gbdrift (secular)": {"atol": 1e-4},
"gbdrift (secular)/phi": {"atol": 1e-4},
}
zero_map = dict.fromkeys(zero_limits, {"desired_at_axis": 0})
kwargs = weaker_tolerance | zero_map
Expand Down
6 changes: 3 additions & 3 deletions tests/test_compute_funs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1565,8 +1565,8 @@ def test(eq):
"grad(alpha)",
"grad(phi)",
"B_phi",
"secular(gbdrift)",
"secular(gbdrift)/phi",
"gbdrift (secular)",
"gbdrift (secular)/phi",
"phi",
],
)
Expand All @@ -1592,7 +1592,7 @@ def test(eq):
np.testing.assert_allclose(data["B^phi"], dot(data["B"], data["grad(phi)"]))
np.testing.assert_allclose(data["B_phi"], data["B"][:, 1])
np.testing.assert_allclose(
data["secular(gbdrift)"], data["secular(gbdrift)/phi"] * data["phi"]
data["gbdrift (secular)"], data["gbdrift (secular)/phi"] * data["phi"]
)

test(get("W7-X"))
Expand Down
6 changes: 3 additions & 3 deletions tests/test_integrals.py
Original file line number Diff line number Diff line change
Expand Up @@ -1619,10 +1619,10 @@ def drift_num_integrand(data, B, pitch):
"""Integrand of numerator of bounce averaged binormal drift."""
g = jnp.sqrt(jnp.abs(1 - pitch * B))
cvdrift = (
data["periodic(cvdrift)"] + data["secular(gbdrift)/phi"] * data["zeta"]
data["cvdrift (periodic)"] + data["gbdrift (secular)/phi"] * data["zeta"]
)
gbdrift = (
data["periodic(gbdrift)"] + data["secular(gbdrift)/phi"] * data["zeta"]
data["gbdrift (periodic)"] + data["gbdrift (secular)/phi"] * data["zeta"]
)
return (cvdrift * g) - (0.5 * g * gbdrift) + (0.5 * gbdrift / g)

Expand All @@ -1637,7 +1637,7 @@ def test_binormal_drift_bounce2d(self):
grid = LinearGrid(
rho=data["rho"], M=eq.M_grid, N=max(1, eq.N_grid), NFP=eq.NFP, sym=False
)
names = ["periodic(cvdrift)", "periodic(gbdrift)", "secular(gbdrift)/phi"]
names = ["cvdrift (periodic)", "gbdrift (periodic)", "gbdrift (secular)/phi"]
grid_data = eq.compute(names=Bounce2D.required_names + names, grid=grid)
for name in names:
grid_data[name] = grid_data[name] * data["normalization"]
Expand Down