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

Add Ability to Write Boozmn.nc style output files #680

Draft
wants to merge 100 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 88 commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
72da051
first commit, machinery working but need to figure out good way to fi…
dpanici Sep 19, 2023
efb9245
properly save nu_mn and zmns using sin bases when equilibrium is stel…
dpanici Sep 25, 2023
a15b3f3
fix Z_mn and nu_mn calculations by having them use the correct values…
dpanici Sep 25, 2023
64b9b29
rename sqrt(g)_B to jac_Boozer_DESC for clarity, add proper sqrt(g)_B…
dpanici Sep 25, 2023
d20de7a
Merge branch 'master' into dp/boozmn_style_output
dpanici Sep 25, 2023
a11e1ab
fix extra/lacking dependencies
dpanici Sep 26, 2023
279535b
add missing file.close(), change test to use get instead of solving H…
dpanici Sep 26, 2023
7aa6318
Merge branch 'master' into dp/boozmn_style_output
dpanici Nov 8, 2023
1600f49
correct signs of sin(theta) modes before conversion in boozmn output …
dpanici Nov 9, 2023
36749f6
add test against c++ version of booz_xform
dpanici Nov 9, 2023
84fd8f7
fix test half grid
dpanici Nov 9, 2023
2aed44e
Merge branch 'master' into dp/boozmn_style_output
dpanici Nov 9, 2023
8a1f5b8
fix boozmn test
dpanici Nov 9, 2023
4a0014f
reduce grid resolution for boozmn
dpanici Nov 9, 2023
31614d8
precompute quantities that don't need to use a single surface grid in…
dpanici Nov 9, 2023
46f1eda
add more precomputed quantities
dpanici Nov 9, 2023
5e69f19
Merge branch 'master' into dp/boozmn_style_output
dpanici Nov 9, 2023
40e24c8
precompute fitted quanttities (B_theta_mn and B_zeta_mn), add option …
dpanici Nov 10, 2023
b2d9ca4
fix error in logic in zernike to fourier util
dpanici Nov 10, 2023
b3b8e04
update master data pkl bc sqrt(g)_B changed definition
dpanici Nov 10, 2023
d3ec3eb
make computes in boozmn writing slighlty more efficient
dpanici Nov 10, 2023
4f78956
add test against most of the keys in the cpp version of boozmn
dpanici Nov 10, 2023
e1860ac
Merge branch 'master' into dp/boozmn_style_output
dpanici Nov 10, 2023
d827c78
update docstring
dpanici Nov 10, 2023
c05290f
Merge branch 'dp/boozmn_style_output' of github.com:PlasmaControl/DES…
dpanici Nov 10, 2023
0302761
update changelog
dpanici Nov 10, 2023
31ca5d1
add boozer transform prefactor to data index (the norm of the integra…
dpanici Nov 10, 2023
137c2eb
add basis evaluation to the prefactor computation, greatly speeds up …
dpanici Nov 10, 2023
8bd6497
refactor to use jit, sped up a bit (around 25% for the test)
dpanici Nov 12, 2023
eaa7d00
remove unneeded argument for comput_data_sin_sym
dpanici Nov 12, 2023
daf4e7a
update changelog, some comments, and reduce test resolution to avoid …
dpanici Nov 12, 2023
5d3585d
addres comments
dpanici Nov 12, 2023
691203f
reduce test tol
dpanici Nov 12, 2023
8b1930f
make changes to make asymmetric work, although still not completely c…
dpanici Nov 13, 2023
24166c2
add missing files for test
dpanici Nov 13, 2023
08b46f4
fixes for asymmetric boozmn output
dpanici Nov 13, 2023
3bb0683
add test against the simsopt version of C++ for asym
dpanici Nov 13, 2023
e86448e
Merge branch 'master' into dp/boozmn_style_output
dpanici Nov 13, 2023
5bc1c76
fix test paths
dpanici Nov 13, 2023
cded97b
Merge branch 'master' into dp/boozmn_style_output
dpanici Nov 14, 2023
1d14e72
rename prefactor to matrix
dpanici Nov 14, 2023
8938384
remove unneeded files, update test to use output from most recent boo…
dpanici Nov 14, 2023
537b7ec
remove unneeded files, update test to use output from most recent boo…
dpanici Nov 14, 2023
b9032b7
Merge branch 'dp/boozmn_style_output' of github.com:PlasmaControl/DES…
dpanici Nov 14, 2023
6d89589
reduce test tol for CI
dpanici Nov 15, 2023
d9646b3
Merge branch 'master' into dp/boozmn_style_output
dpanici Nov 16, 2023
f9e0619
fix units
dpanici Nov 16, 2023
4b0db03
Merge branch 'master' into dp/boozmn_style_output
dpanici Nov 16, 2023
96223bd
address comments
dpanici Nov 18, 2023
a972732
fix changed keyword
dpanici Nov 18, 2023
fa24b5a
fix compute quantity name in notebook
dpanici Nov 18, 2023
6701d38
Merge branch 'master' into dp/boozmn_style_output
dpanici Dec 2, 2023
111b8d9
remove Fourier-Zernike fitof B_theta and B_zeta as it was inaccurate,…
dpanici Dec 2, 2023
e08df50
update master pickle data
dpanici Dec 12, 2023
75b65ec
Merge branch 'master' into dp/boozmn_style_output
dpanici Dec 12, 2023
e0804a5
adjust test tol
dpanici Dec 12, 2023
fc68d35
change tests to rtol
dpanici Dec 12, 2023
4d48c7a
Merge branch 'master' into dp/boozmn_style_output
dpanici Feb 5, 2024
1fbf137
change test against cpp to test in real space, not in the Fourier coe…
dpanici Feb 5, 2024
8b220bc
remove redundant tests
dpanici Feb 5, 2024
5a4dd8b
add missing rho attribute to .h5 file
dpanici Feb 5, 2024
e0a9efb
update pkl, restore test to correct state, merge master
dpanici Feb 5, 2024
5597e24
add more description to test err msg
dpanici Feb 5, 2024
a147231
Revert "remove redundant tests"
dpanici Feb 5, 2024
230b32a
test against real space, adjust tols for the sym test
dpanici Feb 5, 2024
0db93d4
Merge branch 'master' into dp/boozmn_style_output
dpanici Mar 12, 2024
92bf4fc
Merge branch 'master' into dp/boozmn_style_output
dpanici Mar 12, 2024
3e664cf
update master data from cluster (not Mac as that causes some small di…
dpanici Mar 12, 2024
3d38ea7
resave eq with missing attributes
dpanici Mar 12, 2024
9b01ab0
add missing boozmn file
dpanici Mar 13, 2024
d47c658
loosen tol slightly
dpanici Mar 13, 2024
46d597f
Merge branch 'master' into dp/boozmn_style_output
dpanici Mar 20, 2024
86b8cc0
Merge branch 'master' into dp/boozmn_style_output
dpanici Apr 17, 2024
0a687f9
loosen rtol
dpanici Apr 17, 2024
c72360a
fix key for objective
dpanici Apr 17, 2024
3f056df
loosen asym test tol
dpanici Apr 17, 2024
aa06111
update master data by runnin on linux cluster
dpanici Apr 17, 2024
433d35c
add an atol to asym check against cpp
dpanici Apr 17, 2024
152b5f1
loosen tols
dpanici Apr 19, 2024
cc1e827
update pickle
dpanici May 8, 2024
bf97b5f
Merge branch 'master' into dp/boozmn_style_output
dpanici May 8, 2024
25d1864
change tol and grid
dpanici May 8, 2024
b1147d4
reduce tol
dpanici May 9, 2024
64e5bc6
Merge branch 'master' into dp/boozmn_style_output
dpanici May 9, 2024
ee7e016
rerun test on linux and update master data
dpanici May 9, 2024
e0035a0
Merge branch 'master' into dp/boozmn_style_output
dpanici Jun 19, 2024
bf41545
fix error in test
dpanici Jun 20, 2024
c0dc846
mark the asym comparison to cpp booz xform as xfail for now
dpanici Jun 20, 2024
c6de3fd
Merge branch 'master' into dp/boozmn_style_output
dpanici Aug 19, 2024
4a0da36
remove old kwarg
dpanici Aug 19, 2024
e53e29d
adjust tols
dpanici Aug 20, 2024
46efc0a
Merge branch 'master' into dp/boozmn_style_output
dpanici Aug 20, 2024
decbc52
Merge branch 'master' into dp/boozmn_style_output
dpanici Aug 20, 2024
f00189a
update master data in env with latest JAX version
dpanici Aug 20, 2024
4fed74d
address comments
dpanici Aug 21, 2024
1e05a2a
Merge branch 'dp/vmecio-asym' into dp/boozmn_style_output
dpanici Aug 29, 2024
6ab0cd4
Merge branch 'dp/vmecio-asym' into dp/boozmn_style_output
dpanici Aug 30, 2024
8a3e784
update boozmn
dpanici Sep 1, 2024
033e6ec
Merge branch 'master' into dp/boozmn_style_output
dpanici Sep 1, 2024
f7fb3c6
Merge branch 'master' into dp/boozmn_style_output
dpanici Sep 2, 2024
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ v0.10.3
use forward or reverse mode automatic differentiation.
- Adds ``desc.compat.rescale`` for rescaling equilibria to a specified size and field
strength.
- Adds ``desc.vmec_utils.make_boozmn_output `` for writing boozmn.nc style output files
for compatibility with other codes which expect such files from the Booz_Xform code.
- Renames compute quantity ``sqrt(g)_B`` to ``jac_Boozer_DESC`` to more accurately reflect what the quantiy is (the jacobian from (rho,theta_B,zeta_B) to (rho,theta,zeta)), and adds a new function to compute ``sqrt(g)_B`` which is the jacobian from (rho,theta_B,zeta_B) to (R,phi,Z)
dpanici marked this conversation as resolved.
Show resolved Hide resolved
- Adds new keyword ``surface_fixed`` to ``PlasmaVesselDistance`` objective which says
whether or not the surface comparing the distance from the plasma to is fixed or not.
If True, then the surface coordinates can be precomputed, saving on computation during
Expand Down
191 changes: 177 additions & 14 deletions desc/compute/_omnigenity.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,31 @@ def _nu(params, transforms, profiles, data, **kwargs):
return data


@register_compute_fun(
name="nu_mn",
label="\\nu_{mn} = (\\zeta_{B} - \\zeta)_{mn}",
units="rad",
units_long="radians",
description="Boozer harmonics of Boozer toroidal stream function",
dim=1,
params=[],
transforms={},
profiles=[],
coordinates="rtz",
data=[
"nu",
"sqrt(g)_Boozer_DESC",
"Boozer transform matrix",
],
)
def _nu_mn(params, transforms, profiles, data, **kwargs):
norm = data["Boozer transform matrix"]
data["nu_mn"] = (norm @ (data["sqrt(g)_Boozer_DESC"] * data["nu"])) / transforms[
"B"
].grid.num_nodes
return data


@register_compute_fun(
name="nu_t",
label="\\partial_{\\theta} \\nu",
Expand Down Expand Up @@ -254,27 +279,73 @@ def _zeta_B(params, transforms, profiles, data, **kwargs):


@register_compute_fun(
name="sqrt(g)_B",
label="\\sqrt{g}_{B}",
name="sqrt(g)_Boozer_DESC",
label="\\frac{\\partial(\\theta_B,\\zeta_B)}{\\theta_{DESC},\\zeta_{DESC}}",
units="~",
units_long="None",
description="Jacobian determinant of Boozer coordinates",
description="Jacobian determinant from Boozer coordinates (rho, theta_B, zeta_B)"
" to DESC coordinates (rho,theta,zeta).",
dim=1,
params=[],
transforms={},
profiles=[],
coordinates="rtz",
data=["lambda_t", "lambda_z", "nu_t", "nu_z", "iota"],
)
def _sqrtg_B(params, transforms, profiles, data, **kwargs):
data["sqrt(g)_B"] = (1 + data["lambda_t"]) * (1 + data["nu_z"]) + (
def _sqrt_g__Boozer_DESC(params, transforms, profiles, data, **kwargs):
dpanici marked this conversation as resolved.
Show resolved Hide resolved
data["sqrt(g)_Boozer_DESC"] = (1 + data["lambda_t"]) * (1 + data["nu_z"]) + (
data["iota"] - data["lambda_z"]
) * data["nu_t"]
return data


@register_compute_fun(
name="|B|_mn",
name="sqrt(g)_B",
label="\\sqrt{g}_B",
units="~",
units_long="None",
description="Jacobian determinant from (rho, theta_B, zeta_B)"
" Boozer coordinates to (R,phi,Z) lab frame.",
dim=1,
params=[],
transforms={},
profiles=[],
coordinates="rtz",
data=["sqrt(g)_Boozer_DESC", "sqrt(g)"],
)
def _sqrtg_B(params, transforms, profiles, data, **kwargs):
data["sqrt(g)_B"] = data["sqrt(g)"] / data["sqrt(g)_Boozer_DESC"]
return data


@register_compute_fun(
name="sqrt(g)_B_mn",
label="\\sqrt{g}_{B,mn}",
units="~",
units_long="None",
description="Boozer harmonics of Jacobian determinant from (rho, theta_B, zeta_B)"
" Boozer coordinates to (R,phi,Z) lab frame.",
dim=1,
params=[],
transforms={},
profiles=[],
coordinates="rtz",
data=[
"sqrt(g)_B",
"sqrt(g)_Boozer_DESC",
"Boozer transform matrix",
],
)
def _sqrtg_B_mn(params, transforms, profiles, data, **kwargs):
norm = data["Boozer transform matrix"]
data["sqrt(g)_B_mn"] = (
norm @ (data["sqrt(g)_Boozer_DESC"] * data["sqrt(g)_B"])
) / transforms["B"].grid.num_nodes
return data


@register_compute_fun(
name="|B|_mn_B",
dpanici marked this conversation as resolved.
Show resolved Hide resolved
label="B_{mn}^{\\mathrm{Boozer}}",
units="T",
units_long="Tesla",
Expand All @@ -284,18 +355,69 @@ def _sqrtg_B(params, transforms, profiles, data, **kwargs):
transforms={"B": [[0, 0, 0]]},
profiles=[],
coordinates="rtz",
data=["sqrt(g)_B", "|B|", "rho", "theta_B", "zeta_B"],
data=[
"sqrt(g)_Boozer_DESC",
"|B|",
"Boozer transform matrix",
],
M_booz="int: Maximum poloidal mode number for Boozer harmonics. Default 2*eq.M",
N_booz="int: Maximum toroidal mode number for Boozer harmonics. Default 2*eq.N",
)
def _B_mn(params, transforms, profiles, data, **kwargs):
nodes = jnp.array([data["rho"], data["theta_B"], data["zeta_B"]]).T
norm = 2 ** (3 - jnp.sum((transforms["B"].basis.modes == 0), axis=1))
data["|B|_mn"] = (
norm # 1 if m=n=0, 2 if m=0 or n=0, 4 if m!=0 and n!=0
* (transforms["B"].basis.evaluate(nodes).T @ (data["sqrt(g)_B"] * data["|B|"]))
/ transforms["B"].grid.num_nodes
)
norm = data["Boozer transform matrix"]
data["|B|_mn_B"] = (
norm @ (data["sqrt(g)_Boozer_DESC"] * data["|B|"])
) / transforms["B"].grid.num_nodes
return data


@register_compute_fun(
name="R_mn_B",
label="R_{mn}^{\\mathrm{Boozer}}",
units="m",
units_long="meters",
description="Boozer harmonics of radial toroidal coordinate of a flux surface",
dim=1,
params=[],
transforms={"B": [[0, 0, 0]]},
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rahulgaur104 if you want the zeta_B deriv of R you would do

transforms = {"B": [[0,0,1]]}

then have "R_mn" in your data

and in the compute, do dR_dzeta_B = transforms["B"].transforms(data["R_mn"], dz=1)

profiles=[],
coordinates="rtz",
data=[
"sqrt(g)_Boozer_DESC",
"R",
"Boozer transform matrix",
],
)
def _R_mn(params, transforms, profiles, data, **kwargs):
norm = data["Boozer transform matrix"]
data["R_mn_B"] = (norm @ (data["sqrt(g)_Boozer_DESC"] * data["R"])) / transforms[
"B"
].grid.num_nodes
return data


@register_compute_fun(
name="Z_mn_B",
label="Z_{mn}^{\\mathrm{Boozer}}",
units="m",
units_long="meters",
description="Boozer harmonics of vertical toroidal coordinate of a flux surface",
dim=1,
params=[],
transforms={"B": [[0, 0, 0]]},
profiles=[],
coordinates="rtz",
data=[
"sqrt(g)_Boozer_DESC",
"Z",
"Boozer transform matrix",
],
)
def _Z_mn(params, transforms, profiles, data, **kwargs):
norm = data["Boozer transform matrix"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure id call this a "norm"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed to transform_matrix

data["Z_mn_B"] = (norm @ (data["sqrt(g)_Boozer_DESC"] * data["Z"])) / transforms[
"B"
].grid.num_nodes
return data


Expand All @@ -319,6 +441,47 @@ def _B_modes(params, transforms, profiles, data, **kwargs):
return data


@register_compute_fun(
name="Boozer transform modes norm",
label="",
units="~",
units_long="None",
description="Inner product norm for boozer modes basis.",
dim=1,
params=[],
transforms={"B": [[0, 0, 0]]},
profiles=[],
coordinates="rtz",
data=[],
)
def _boozer_modes_norm(params, transforms, profiles, data, **kwargs):
# norm is 1 if m=n=0, 2 if m=0 or n=0, 4 if m!=0 and n!=0
norm = 2 ** (3 - jnp.sum((transforms["B"].basis.modes == 0), axis=1))
data["Boozer transform modes norm"] = norm
return data


@register_compute_fun(
name="Boozer transform matrix",
label="",
units="~",
units_long="None",
description="Matrix which performs boozer transformation.",
dim=1,
params=[],
transforms={"B": [[0, 0, 0]]},
profiles=[],
coordinates="rtz",
data=["rho", "theta_B", "zeta_B", "Boozer transform modes norm"],
)
def _boozer_transform_matrix(params, transforms, profiles, data, **kwargs):
nodes = jnp.array([data["rho"], data["theta_B"], data["zeta_B"]]).T
data["Boozer transform matrix"] = (
data["Boozer transform modes norm"] * transforms["B"].basis.evaluate(nodes)
dpanici marked this conversation as resolved.
Show resolved Hide resolved
).T
return data


@register_compute_fun(
name="f_C",
label="[(M \\iota - N) (\\mathbf{B} \\times \\nabla \\psi)"
Expand Down
15 changes: 9 additions & 6 deletions desc/compute/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,14 @@ def get_transforms(keys, obj, grid, jitable=False, **kwargs):
elif c == "B": # used for Boozer transform
transforms["B"] = Transform(
grid,
DoubleFourierSeries(
M=kwargs.get("M_booz", 2 * obj.M),
N=kwargs.get("N_booz", 2 * obj.N),
NFP=obj.NFP,
sym=obj.R_basis.sym,
kwargs.get(
"B_basis",
DoubleFourierSeries(
M=kwargs.get("M_booz", 2 * obj.M),
N=kwargs.get("N_booz", 2 * obj.N),
NFP=obj.NFP,
sym=kwargs.get("sym", obj.R_basis.sym),
),
),
derivs=derivs["B"],
build=False,
Expand All @@ -382,7 +385,7 @@ def get_transforms(keys, obj, grid, jitable=False, **kwargs):
M=kwargs.get("M_booz", 2 * obj.M),
N=kwargs.get("N_booz", 2 * obj.N),
NFP=obj.NFP,
sym=obj.Z_basis.sym,
sym=kwargs.get("sym", obj.Z_basis.sym),
),
derivs=derivs["w"],
build=False,
Expand Down
8 changes: 4 additions & 4 deletions desc/objectives/_omnigenity.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def build(self, use_jit=True, verbose=1):
"resolution for surface averages",
)

self._data_keys = ["|B|_mn"]
self._data_keys = ["|B|_mn_B"]

timer = Timer()
if verbose > 0:
Expand Down Expand Up @@ -210,7 +210,7 @@ def compute(self, params, constants=None):
transforms=constants["transforms"],
profiles=constants["profiles"],
)
B_mn = constants["matrix"] @ data["|B|_mn"]
B_mn = constants["matrix"] @ data["|B|_mn_B"]
return B_mn[constants["idx"]]

@property
Expand Down Expand Up @@ -753,7 +753,7 @@ def build(self, use_jit=True, verbose=1):
field_grid = self._field_grid

self._dim_f = field_grid.num_nodes
self._eq_data_keys = ["|B|_mn"]
self._eq_data_keys = ["|B|_mn_B"]
self._field_data_keys = ["|B|", "theta_B", "zeta_B"]

errorif(
Expand Down Expand Up @@ -925,7 +925,7 @@ def compute(self, params_1=None, params_2=None, constants=None):
)
).T
B_eta_alpha = jnp.matmul(
constants["eq_transforms"]["B"].basis.evaluate(nodes), eq_data["|B|_mn"]
constants["eq_transforms"]["B"].basis.evaluate(nodes), eq_data["|B|_mn_B"]
)
omnigenity_error = B_eta_alpha - field_data["|B|"]
weights = (self.eta_weight + 1) / 2 + (self.eta_weight - 1) / 2 * jnp.cos(
Expand Down
22 changes: 11 additions & 11 deletions desc/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -2425,7 +2425,7 @@ def plot_boozer_modes( # noqa: C901
ylabel_fontsize = kwargs.pop("ylabel_fontsize", None)

basis = get_transforms(
"|B|_mn", obj=eq, grid=Grid(np.array([])), M_booz=M_booz, N_booz=N_booz
"|B|_mn_B", obj=eq, grid=Grid(np.array([])), M_booz=M_booz, N_booz=N_booz
)["B"].basis
if helicity:
matrix, modes, symidx = ptolemy_linear_transform(
Expand All @@ -2437,12 +2437,12 @@ def plot_boozer_modes( # noqa: C901
for i, r in enumerate(rho):
grid = LinearGrid(M=2 * eq.M_grid, N=2 * eq.N_grid, NFP=eq.NFP, rho=np.array(r))
transforms = get_transforms(
"|B|_mn", obj=eq, grid=grid, M_booz=M_booz, N_booz=N_booz
"|B|_mn_B", obj=eq, grid=grid, M_booz=M_booz, N_booz=N_booz
)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
data = eq.compute("|B|_mn", grid=grid, transforms=transforms)
b_mn = np.atleast_2d(matrix @ data["|B|_mn"])
data = eq.compute("|B|_mn_B", grid=grid, transforms=transforms)
b_mn = np.atleast_2d(matrix @ data["|B|_mn_B"])
B_mn = np.vstack((B_mn, b_mn)) if B_mn.size else b_mn

zidx = np.where((modes[:, 1:] == np.array([[0, 0]])).all(axis=1))[0]
Expand Down Expand Up @@ -2493,7 +2493,7 @@ def plot_boozer_modes( # noqa: C901
)

plot_data = {
"|B|_mn": B_mn,
"|B|_mn_B": B_mn,
"B modes": modes,
"rho": rho,
}
Expand Down Expand Up @@ -2638,12 +2638,12 @@ def plot_boozer_surface(
with warnings.catch_warnings():
warnings.simplefilter("ignore")
data = thing.compute(
"|B|_mn", grid=grid_compute, M_booz=M_booz, N_booz=N_booz
"|B|_mn_B", grid=grid_compute, M_booz=M_booz, N_booz=N_booz
)
B_transform = get_transforms(
"|B|_mn", obj=thing, grid=grid_plot, M_booz=M_booz, N_booz=N_booz
"|B|_mn_B", obj=thing, grid=grid_plot, M_booz=M_booz, N_booz=N_booz
)["B"]
B = B_transform.transform(data["|B|_mn"]).reshape(
B = B_transform.transform(data["|B|_mn_B"]).reshape(
(grid_plot.num_theta, grid_plot.num_zeta), order="F"
)
theta_B = (
Expand Down Expand Up @@ -2845,7 +2845,7 @@ def plot_qs_error( # noqa: 16 fxn too complex
grid = LinearGrid(M=2 * eq.M_grid, N=2 * eq.N_grid, NFP=eq.NFP, rho=np.array(r))
if fB:
transforms = get_transforms(
"|B|_mn", obj=eq, grid=grid, M_booz=M_booz, N_booz=N_booz
"|B|_mn_B", obj=eq, grid=grid, M_booz=M_booz, N_booz=N_booz
)
if i == 0: # only need to do this once for the first rho surface
matrix, modes, idx = ptolemy_linear_transform(
Expand All @@ -2856,9 +2856,9 @@ def plot_qs_error( # noqa: 16 fxn too complex
with warnings.catch_warnings():
warnings.simplefilter("ignore")
data = eq.compute(
["|B|_mn", "B modes"], grid=grid, transforms=transforms
["|B|_mn_B", "B modes"], grid=grid, transforms=transforms
)
B_mn = matrix @ data["|B|_mn"]
B_mn = matrix @ data["|B|_mn_B"]
f_b = np.sqrt(np.sum(B_mn[idx] ** 2)) / np.sqrt(np.sum(B_mn**2))
f_B = np.append(f_B, f_b)
if fC:
Expand Down
Loading