Skip to content

Commit

Permalink
Add resolution requirement to <|grad(rho)|> to match ripple branch
Browse files Browse the repository at this point in the history
  • Loading branch information
unalmis committed Jul 21, 2024
1 parent 7ae8ad1 commit fae2c2f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions desc/compute/_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,7 @@ def _gradrho(params, transforms, profiles, data, **kwargs):
coordinates="r",
data=["|grad(rho)|", "sqrt(g)"],
axis_limit_data=["sqrt(g)_r"],
resolution_requirement="tz",
)
def _gradrho_norm_fsa(params, transforms, profiles, data, **kwargs):
data["<|grad(rho)|>"] = surface_averages(

Check warning on line 1816 in desc/compute/_metric.py

View check run for this annotation

Codecov / codecov/patch

desc/compute/_metric.py#L1816

Added line #L1816 was not covered by tests
Expand Down
6 changes: 5 additions & 1 deletion desc/compute/data_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ def register_compute_fun( # noqa: C901
or `'desc.equilibrium.Equilibrium'`.
resolution_requirement : str
Resolution requirements in coordinates. I.e. "r" expects radial resolution
in the grid, "rtz" expects a grid with radial, poloidal, and toroidal resolution.
in the grid. Likewise, "rtz" is shorthand for "rho, theta, zeta" and indicates
the computation expects a grid with radial, poloidal, and toroidal resolution.
If the computation simply performs pointwise operations, instead of a
reduction (such as integration) over a coordinate, then an empty string may
be used to indicate no requirements.
source_grid_requirement : dict
Attributes of the source grid that the compute function requires.
Also assumes dependencies were computed on such a grid.
Expand Down
7 changes: 7 additions & 0 deletions docs/adding_compute_funs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The full code is below:
coordinates="rtz",
data=["sqrt(g)", "B_zeta_t", "B_theta_z"],
axis_limit_data=["sqrt(g)_r", "B_zeta_rt", "B_theta_rz"],
resolution_requirement="",
parameterization="desc.equilibrium.equilibrium.Equilibrium",
)
def _J_sup_rho(params, transforms, profiles, data, **kwargs):
Expand Down Expand Up @@ -96,6 +97,12 @@ metadata about the quantity. The necessary fields are detailed below:
the quantities mentioned above to evaluate the magnetic axis limit. These dependencies
are specified in ``axis_limit_data``. The dependencies specified in this list are
marked to be computed only when there is a node at the magnetic axis.
* ``resolution_requirement``: Resolution requirements in coordinates.
I.e. "r" expects radial resolution in the grid. Likewise, "rtz" is shorthand for
"rho, theta, zeta" and indicates the computation expects a grid with radial,
poloidal, and toroidal resolution. If the computation simply performs
pointwise operations, instead of a reduction (such as integration) over a
coordinate, then an empty string may be used to indicate no requirements.
* ``parameterization``: what sorts of DESC objects is this function for. Most functions
will just be for ``Equilibrium``, but some methods may also be for ``desc.geometry.core.Curve``,
or specific types eg ``desc.geometry.curve.FourierRZCurve``. If a quantity is computed differently
Expand Down
Binary file modified tests/inputs/master_compute_data_rpz.pkl
Binary file not shown.
Binary file modified tests/inputs/master_compute_data_xyz.pkl
Binary file not shown.

0 comments on commit fae2c2f

Please sign in to comment.