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
21 stars 6 forks source link

Option to provide dist5d in velocity rather than momentum space. #69

Closed rui-coelho closed 5 months ago

rui-coelho commented 5 months ago

Usually one wishes to present the distribution function in velocity space (Vpar,Vperp) and/or (R,Z) space. However, it is clear from the documentation that dist5d comes in (R, phi, z, ppar, pperp)...so in momentum rather than velocity space. Now, if when running ASCOT we use a SINGLE mass species in each one of the injectors used, there is no problem in converting to velocity space. If however i use 8 injectors, some with D and others with T beam ions, i have no way to map to velocity space since the dist5d knows nothing about the markers ! Incidentally, i note that dist5d "raw" is actually 8d, possibly (?,nR,nPhi,nZ,nPpa,nPpe,nTime,nCharge) but the first dimension (typically one) i have no clue what it is, nor i am sure if the nTime and nCharge are in the correct order....

Help.....?!

rui-coelho commented 5 months ago

Even when i defined a list of 5 "injectors" (all space/momentum grid is 60 points, charge and time 1) i see that:

In [170]: f = h5py.File('ascot5_200k.h5', 'r')
In [171]: f['results'].keys()
Out[171]: <KeysViewHDF5 ['bbnbi_1061274377', 'run_0684635874']>
In [172]: dist5d=f['results']['run_0684635874']['dist5d']
In [174]: np.shape(dist5d['ordinate'])
Out[174]: (1, 60, 1, 60, 60, 60, 1, 1)

Whereas "maybe" i would expect to see (5, 60, 1, 60, 60, 60, 1, 1).......so, can you please explain where/what the first dimension is ? And if it would be possible to output a dist5d in space-celocity space ?

miekkasarki commented 5 months ago

If you have multiple species (with different masses) the intended way is to run those separately (and use different options for different runs). Then, if you want, you can convert the momentum space to velocity space in postprocessing and combine them (easy to do if you first define vparallel-vperp grid and then for the simulations convert that to pparllel-pperp). I doubt that (vparallel,vperp) distribution is going to be implemented but (energy, pitch) might be.

The first dimension is just a placeholder/legacy from ASCOT4 and it is always 1 so you can just ignore it. It's "purpose" would have been to make it possible to store vector-valued functions (but so far we have only stored scalar distribution).

rui-coelho commented 5 months ago

Roger that. thank you for the clarification and suggestion which is the only solution i was figuring. However, strictly speaking this is only valid as long as the beam population is ridiculously small when compared to the plasma population since we are "technically" neglecting beam-beam collisions.....right ?

miekkasarki commented 5 months ago

If you have a single NBI input with 5 injectors, ASCOT is just going to sum everything in a single distribution and there is no way to separate markers from that. The only way to have them separate is to create 5 separate NBI inputs (each with a single injector) and run 5 separate simulations (and then you get 5 separate outputs).

miekkasarki commented 5 months ago

Yup, beam-beam collisions are neglected

rui-coelho commented 5 months ago

tkx !

rui-coelho commented 5 months ago

When using nbi units firing ions with different mass we should ALWAYS make separate ASCOT5 runs if we want to then plot dist5d in (R,Z,phi,Vpar,Vperp) instead of (R,Z,phi,Ppar,Pperp)