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

How to compute quantities along a fieldline #719

Closed
f0uriest opened this issue Oct 22, 2023 · 3 comments · Fixed by #1024
Closed

How to compute quantities along a fieldline #719

f0uriest opened this issue Oct 22, 2023 · 3 comments · Fixed by #1024
Assignees
Labels
hackathon Stuff to work on during hackathon

Comments

@f0uriest
Copy link
Member

There have been several applications recently that need data from the equilibrium evaluated along a fieldline (stability stuff from @rahulgaur104 , GX stuff from @pkim1818, gamma_c from @JaxCrocker)

Right now this isn't super easy to do so we have some hacky stuff for it, but it would be good to decide on a common API for this.

One possibility:

  • add an attribute to each Grid labelling what coordinates its using, rtz for regular DESC computational coordinates, raz for rho, alpha, zeta etc.
  • When calling desc.compute.compute we check the grid type and do any coordinate mapping to computational coordinates there.
  • quantities that use field aligned grids would need some logic in their individual compute functions to handle multiple fieldlines (ie multiple values of rho, alpha)

Issues:

  • the low level desc.compute.compute currently expects pre-built transforms and profiles. If we're doing grid mapping inside that function we would need to add an option to just pass in the grid and build transforms from that and the equilibrium
  • for grids based on alpha we would need to know iota to map it to computational coordinates which adds an extra layer of complication for fixed current equilibria

Any other thoughts? @ddudt @dpanici @unalmis

@dpanici
Copy link
Collaborator

dpanici commented Oct 25, 2023

Source grid, eval grid, single one for each computeable, by default are the same (so i.e call compute twice if want things on same src but different eval grids, one in normal coords other in SFL along field line)

@dpanici
Copy link
Collaborator

dpanici commented Oct 25, 2023

utilities covering common cases i.e. rtz -> raz and having routine to map back on field period etc.

@unalmis
Copy link
Collaborator

unalmis commented May 2, 2024

also related: #1006 (comment)

@unalmis unalmis removed their assignment May 2, 2024
@unalmis unalmis self-assigned this May 19, 2024
@unalmis unalmis added the hackathon Stuff to work on during hackathon label May 20, 2024
rahulgaur104 added a commit that referenced this issue Jul 20, 2024
Resolves #719, resolves #692, resolves #664, resolves #904, resolves
#1077. Needed to compute neoclassical stuff. Ready for review

Can look at the Gamma_c branch to see how these changes are used.

- According to jax, `jnp.take(x, idx, unique_indices=True)` is more
efficient than `x[idx]`, so this PR makes this change in the
`grid.compress()` method. (The `bounce` branch needs `jnp.take` for
different reasons, which is the actual motivation for adding `jnp.take`
and its numpy equivalent to `desc.backend`. )
- Adds an optional resolution requirement string to the register compute
function decorator to resolve 664.
- Adds stuff to use `eq.compute` method for things whose compute
functions assume the input data is evaluated along a field line.
- Changes some grid attributes (backwards-compatible) for the grids to
work better in different coordinate systems.
- Fixes a bug on `LinearGrid` with `grid.num_zeta = 1` and `grid.NFP!=1`
if used for a surface integral (surface averages or others such as
surface_integral(x) / surface_integral(y) were unaffected since the bug
would net a constant factor difference).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hackathon Stuff to work on during hackathon
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants