Open
Conversation
…rting between IMAS and DIIID ECH launcher angle coordinates.
…erages. Also figured out how to import the b_field_tor using the derive_equilibrium_profiles_2d_quantity function. Still only partway through updating add_volume_profle to compute accurate flux surface averages. Committing now in order to merge changes from the main branch into this one in order to merge in an update to the b_field_tor definition (there was an error that has been recently fixed).
… function in omas_physics.py.
…_surface_averages.
…omas into feature/flux_surface_integrals
Collaborator
|
Thanks for your contribution @rossmfusion. @torrinba and I will work on creating a test for this. |
… omas_physics instead of "add_voluem_profile" now that that function name has been change. This appears to fix the failed test encountered in the original PR for this branch.
…s requireed explicit definition of trapz function.
…d on suggestion from Severin.
AreWeDreaming
requested changes
Jan 29, 2026
Collaborator
AreWeDreaming
left a comment
There was a problem hiding this comment.
This could be slightly more numerically efficient if we interpolate the total magnetic field instead of the individual compoonents.
Comment on lines
+653
to
+656
| try: | ||
| trapz = np.trapezoid # modern NumPy >=1.20 | ||
| except AttributeError: | ||
| trapz = np.trapz # older NumPy |
Collaborator
There was a problem hiding this comment.
Suggested change
| try: | |
| trapz = np.trapezoid # modern NumPy >=1.20 | |
| except AttributeError: | |
| trapz = np.trapz # older NumPy |
Please look at the top of this file. trapz has already been imported
Comment on lines
683
to
698
| @@ -671,15 +691,34 @@ def add_volume_profile(ods, grid_index=0): | |||
| eq_slice[f'profiles_2d.{grid_index}.grid.dim2'], | |||
| eq_slice[f'profiles_2d.{grid_index}.b_field_z']) | |||
|
|
|||
| b_field_tor_spline = RectBivariateSpline( | |||
| eq_slice[f'profiles_2d.{grid_index}.grid.dim1'], | |||
| eq_slice[f'profiles_2d.{grid_index}.grid.dim2'], | |||
| eq_slice[f'profiles_2d.{grid_index}.b_field_tor']) | |||
|
|
|||
Collaborator
There was a problem hiding this comment.
Suggested change
| b_field_tot_spline = RectBivariateSpline( | |
| eq_slice[f'profiles_2d.{grid_index}.grid.dim1'], | |
| eq_slice[f'profiles_2d.{grid_index}.grid.dim2'], | |
| np.sqrt(eq_slice[f'profiles_2d.{grid_index}.b_field_tor']**2 | |
| + eq_slice[f'profiles_2d.{grid_index}.b_field_r']**2 | |
| + eq_slice[f'profiles_2d.{grid_index}.b_field_r']**2 )) |
This saves 2/3 of the operations
| if k == 0: | ||
| RMAXIS = ods['equilibrium.time_slice.'+str(time_index)+'.global_quantities.magnetic_axis.r'] | ||
| ZMAXIS = ods['equilibrium.time_slice.'+str(time_index)+'.global_quantities.magnetic_axis.z'] | ||
| Btot = numpy.sqrt(b_field_r_spline(RMAXIS, ZMAXIS, grid=False)**2 + b_field_z_spline(RMAXIS, ZMAXIS, grid=False)**2 + b_field_tor_spline(RMAXIS, ZMAXIS, grid=False)**2) |
Collaborator
There was a problem hiding this comment.
Suggested change
| Btot = numpy.sqrt(b_field_r_spline(RMAXIS, ZMAXIS, grid=False)**2 + b_field_z_spline(RMAXIS, ZMAXIS, grid=False)**2 + b_field_tor_spline(RMAXIS, ZMAXIS, grid=False)**2) | |
| Btot = b_field_tot_spline(RMAXIS, ZMAXIS, grid=False) |
| * (2.0 * numpy.pi) ** (1.0 - cocos['exp_Bp'])) | ||
|
|
||
| # determine flux-surface-averaged quantities | ||
| Btot = numpy.sqrt(b_field_r_spline(r, z, grid=False)**2 + b_field_z_spline(r, z, grid=False)**2 + b_field_tor_spline(r, z, grid=False)**2) |
Collaborator
There was a problem hiding this comment.
Suggested change
| Btot = numpy.sqrt(b_field_r_spline(r, z, grid=False)**2 + b_field_z_spline(r, z, grid=False)**2 + b_field_tor_spline(r, z, grid=False)**2) | |
| Btot = b_field_tot_spline(r, z, grid=False) |
Collaborator
There was a problem hiding this comment.
Actually now I see that B_tor is needed for hf so I recommend to instead create a B_pol^2 = b_field_r2 + b_field_z2 spline and evaluating B_t and adding it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR includes updates to the flux surface averaging of quantities relevant to TORAY runs in ECpy. It puts the "hf" helical flux function in gm10 in the IMAS data scheme. It also updates EC launcher angle conversion functions.