-
Notifications
You must be signed in to change notification settings - Fork 217
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
Jumps in output data of plugins (in moving window simulations) #2703
Comments
@steindev I checked the phase space plugin and it looks like sliding window is not supported from the plugin. |
Afair, the plugin dumps the whole box but also adds the meta information to slice out the window accordingly. Our Python plugin should do this reliably, so users don't need to fiddle with the HDF5 attributes and the cutting: https://picongpu.readthedocs.io/en/0.4.0-rc2/usage/plugins/phaseSpace.html#analysis |
offline discussion with @psychocoderHPC: The effect seen is thus a aliasing effect due to the low sampling rate of the field energy plugin compared to the sliding rate. A visualization of this effect is shown below. The result is a rapid increase and a slow decrease as seen by @steindev: |
The effect can be resolved if the field energy plugin output occurs more frequently (at least every ~200 time steps (~512/2 = Nyquist sampling rate)) or can be avoided if the plugin only works on the moving window. |
Yep, many plugins need that filter still: #89 and it is now easy to implement with our filters: #2131 #2582 (note: not as a user option; I mean default-filtered) Nevertheless, the phase space plugin has this implemented in simple post-processing. @steindev Can you please show the Python snippet used for PS visualization? I want to see if there is a bug hidden or if this is just not processing the data correctly. |
@steindev or for comparison a "forward (green) and backward (orange) in time propagating" aliasing: |
@ax3l: I used my own script for visualization of the phase space data: tstep = 130000
ps = "ypy"
## Read data
f = h5py.File(path + "phaseSpace/PhaseSpace_e_all_%s_%i.h5"%(ps,tstep), "r")
# Unit data
Dr_SI = f["/data/%i/%s"%(tstep,ps)].attrs['dr_unit'] # position unit
Dp_SI = f["/data/%i/%s"%(tstep,ps)].attrs['p_unit'] / m_e / cspeed # momentum unit in gamma*beta
# Grid data
p_min = f["/data/%i/%s"%(tstep,ps)].attrs['p_min'] * Dp_SI
p_max = f["/data/%i/%s"%(tstep,ps)].attrs['p_max'] * Dp_SI
N_r, N_p = f["/data/%i/%s"%(tstep,ps)].shape
# Data
rp = f["/data/%i/%s"%(tstep,ps)][...]
f.close()
## Plot data
figure(figsize=(8,6))
imshow(abs(rp).T, cmap = mpl.cm.cubehelix_r#, vmax = 2, vmin = 0
, origin='lower', interpolation='none', aspect='auto'
, extent=(0, N_r, p_min, p_max)
, norm = matplotlib.colors.LogNorm())
# Plot setup
colorbar()
grid()
xticks(arange(0,N_r,200))
xlabel(r"position [cells]")
ylabel(r"momentum [$\gamma\beta_{komp}$]")
title(r"%s space @ %ikDt"%(ps,tstep*1.e-3))
show() That is, I plot the complete data set stored in the phase space hdf5 file as is shown in the phaseSpace plugin docs. If there is a script for analysis provided by picongpu, I would wish there is a link or comment about it on this page. Further, the documentation page could list under known limitations the observed behavior and/or link to #89. |
Ah, that's the reason it jumps. Older versions ( But you should not do this anymore. Use the new python lib that you can add to your
No, it now documents how to read the data. That's not a limitation for users: you are currently hacking the recommended workflow ;-) I don't recommend to anyone to parse HDF5 files by hand, it's verbose and error-prune. |
If you are in the mood to be extra-lazy (tm), which I can only recommend to be, then you could also replace the documented from picongpu.plugins.phase_space import PhaseSpace with an even lazier from picongpu.plugins.plot_mpl.phase_space_visualizer import Visualizer That object has the same arguments as the data reader API, but generates you immediately an MPL plot :D picongpu/lib/python/picongpu/plugins/plot_mpl/phase_space_visualizer.py Lines 161 to 164 in 2f265eb
I am recommending you the undocumented feature, since you seem to skip the recommended, documented ones ;-p |
My apologies. I remember seeing the script which loads the python lib. I simply did not know where to find it... :-( |
Nothing to be sorry for, we just moved all the plugin docs from the wiki to the mainline docs during the last year. They were hard to find. Everything is more shiny now! ✨ But really, switch to the new Python imports. It's just one line in your |
(Feel free to comment further if I missed something. The other issue is a duplicate of the energy plugin not yet implementing a moving window filter, cross-linked above.) |
I recognized in two different kind of simulations with two different plugins jumps in output data of longitudinal (y) quantities. I suspect these are related to calculations of output data within the moving window.
The two cases are:
Resetting of electron bunch longitudinal position in phase space output of LWFA sims
The electron position in y-direction (laser propagation and moving window direction) is repeatedly reset at a period of about twice the simulation box size in y-direction. Here, electron position resets take place every 3k to 4k (mostly) time steps. The simulation box is 2304 cells in y direction, with 8 gpus along this direction. The ratio of y cell size to time step is
DY / ( cspeed * DT ) = 1.5275
. That is, it seems like a reset occurs when the moving window moved once over the simulation box, i.e. everyn_reset = 2304 * DY / ( cspeed * DT ) = 2304 * 1.5275 = 3519
time steps. This value fits to the observed reset period.Increase in longitudinal E- and B-field energy in field energy plugin
The longitudinal field energy jumps with a period of 20kDT. This time the simulation volume is 8192 cells in y-direction distributed over 16 gpus. The ratio of y cell size to time step is
DY / ( cspeed * DT ) = 0.99976
.Zoom in to Ey data. Note that the sampling rate is high compared to period length of jumps.
As this second appearance of jumps does not really match the first one I will start a primitive bunch acceleration with piconpu-0.4.0 and see how the fields develop and if this behavior is reproduced.
Still it is funny that these jumps appear at a time the window needs to pass about twice the simbox.
The text was updated successfully, but these errors were encountered: