google-deepmind / torax

TORAX: Tokamak transport simulation in JAX
https://torax.readthedocs.io
Other
345 stars 31 forks source link

`TimeInterpolatedArray` is only on face grid #222

Closed theo-brown closed 3 months ago

theo-brown commented 3 months ago

Some variables that need to be time-interpolated are on the face grid, and some are on the cell grid. However, the time interpolation only interpolates onto face_centers at the moment (interpolate_var_2d, line 164).

theo-brown commented 3 months ago

I believe this claim is correct, but happy to be corrected: core profiles are interpolated on the face grid, but sources must be interpolated on the cell grid. This is currently blocking adding time-interpolate prescribed source profiles.

jcitrin commented 3 months ago

Indeed, the radial profiles from interpolate_var_2d are interpolated onto the face grid. However, that is not their "final destination". Currently they're only used for Te, Ti, ne. After interpolation, the DynamicRuntimeParamsSlice['profile_conditions'] have face profiles. These then go through further processing before finally making it into a Te, Ti, ne CellVariable. See here for Te. There is a geometry_face_to_cell call before the CellVariable is constructed. You can do something similar for the sources.

The reason the interpolation in the precursor phase is done on the face grid, is that it facilitates more accurate integrations for updating the density, for example when constraining nbar.

theo-brown commented 3 months ago

Ah, I see. Sorry, I should've read the code more closely! Thanks for the explanation. Happy to close this issue and have any further discussions in the PR.