ascot4fusion / ascot5

ASCOT5 is a high-performance orbit-following code for fusion plasma physics and engineering
https://ascot4fusion.github.io/ascot5/
GNU Lesser General Public License v3.0
29 stars 9 forks source link

Option to (re)instantiate the sanityChecks Group in HDF5 output #70

Closed rui-coelho closed 8 months ago

rui-coelho commented 8 months ago

I understand the concept of the "stupid code" being straightforward in it's output but, again, when trying to profit from the completeness of the HDF5 file output i find myself empty handed regarding some fundamental equilibrium data (not in the EQDSK) that is useful downstream: the toroidal magnetic field on axis ! This is useful since it is a common used normaliser e.g. omega_c for a given EP in case the Pphi comes in eV (i know...i know...not SI...). Of course i could get the R,Z of the axis (available in bfield group) and interpolate bphi (also available in bfield) on the magnetic axis.......but surely the result would depend on MY interpolator and not correspond on what internally the stupid code might actually have used.......

comments ?

rui-coelho commented 8 months ago

note that i don't want the HDF5 of ASCOT5 to revert back to the ASCOT4 format...on the contrary ! Example: the ASCOT4 did not have the BR,BZ (only available in the sanityChecks group) on the same grid as the BPHI. So.....i actually see that the HDF5 of A5 is better....but some quantities could still be added to avoid post-processing normalisation slight mismatches.

miekkasarki commented 8 months ago

The sanity checks from ASCOT4 are now in the output log. If you look closely you can find the Bphi value on the axis there:

Reading magnetic field input.
Active QID is 4261909647

2D magnetic field (B_2DS)
Grid: nR =  257 Rmin = 0.500 Rmax = 7.000
      nz =  513 zmin = -8.650 zmax = 8.650
Psi at magnetic axis (4.212 m, -0.000 m)
6.046 (evaluated)
6.046 (given)
Magnetic field on axis:
B_R = 0.000 B_phi = 2.648 B_z = 0.000
Estimated memory usage 16.1 MB
Magnetic field read and initialized.

However, what is printed on the log is just the bare minimum. ASCOT5 has more comprehensive (well still WIP) preflight checks shown either in the GUI, or called explicitly using any Ascot object routine that starts with preflight_*. For example, a5.preflight_plottopview would show the magnetic field & plasma current directions along with the wall outline and marker initial positions. Unlike sanity checks, these can be checked while you are still just preparing the inputs.

image

Printing Btor on axis and calculating total Ip (both using ASCOT's own interpolation routines) as part of the preflight checks will be included in the next release. Any ideas for other "sanity checks" that can be easily performed are very much welcome!

rui-coelho commented 8 months ago

well, i would have to think depending on the particular cases. Th most immediate one for me would be the Bmag. And note that i need it while in Fortran.....not in Python. This is why i always try to use the raw HDF5 output since that one is "universal". Again, nothing against the a5 code suite (on the contrary ! it is very very useful !).

miekkasarki commented 8 months ago

Well it is completely fine if you (assuming that you can use Python in between):

  1. First evaluate Bphi (or whatever) with a5py.
  2. Then write it in the same HDF5 in some group that does not interefere e.g. group named "meta".
  3. Read with Fortran.
rui-coelho commented 8 months ago

Also doable. Right now i either use it as an argument or linear interpolate (yeah...) the 3d Phi at known (R0,Z0)

rui-coelho commented 8 months ago

Also doable. Right now i either use it as an argument or linear interpolate (yeah...) the 3d Phi at known (R0,Z0). Thanks for the tips !