ECP-WarpX / WarpX

WarpX is an advanced electromagnetic & electrostatic Particle-In-Cell code.
https://ecp-warpx.github.io
Other
292 stars 186 forks source link

Particle metadata is missing with BackTransformed openPMD diagnostics #3301

Open RemiLehe opened 2 years ago

RemiLehe commented 2 years ago

I had previously tested the particle openPMD output of the new BTD diagnostics, but it turns out that I did not do a complete check. Some of the metadata (e.g. particle mass, position offset) is not being written to the file.

Here is a simple reproducing script: inputs_3d.txt

RemiLehe commented 2 years ago

My impression is that the function SetConstParticleRecordsEDPIC is not being called.

RemiLehe commented 2 years ago

The openPMD files can be tested with the following Python code (after doing pip install openpmd-viewer)

from openpmd_viewer import OpenPMDTimeSeries
ts = OpenPMDTimeSeries('./diags/back_3d/')
ts.get_particle(['ux'])

It currently raises an exception: IndexError: Key 'mass' does not exist (read-only).

RemiLehe commented 2 years ago

It seems that the problem disappears when prob_hi is 0 in z inputs_3d_zmax0.txt

RemiLehe commented 2 years ago

It seems that the version of WarpX that I was using was not up to date. Sorry about this! I will close this issue for now.

RevathiJambunathan commented 2 years ago

thank you for checking @RemiLehe

RTSandberg commented 2 years ago

I observe this issue some times, working on the latest WarpX branch.

When loading in openPMD-viewer:

>>> ts = OpenPMDTimeSeries('diags/diag_lab')
Warning: File 9 has different openPMD parameters than the rest of the time series.
...
Warning: File 18 has different openPMD parameters than the rest of the time series.
>>> ts_l.get_particle(species='beam', var_list = ['charge','w', 'ux', 'uy', 'uz'], iteration=8);
>>> ts_l.get_particle(species='beam', var_list = ['charge','w', 'ux', 'uy', 'uz'], iteration=9);
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/tmp/ipykernel_86/3022048230.py in <module>
      1 ii = 9
----> 2 pdata = ts_l.get_particle(species='beam', var_list = ['charge','w', 'ux', 'uy', 'uz'], iteration=ii)
...
KeyError: "Unable to open object (object 'charge' doesn't exist)"

Here is a reproducing input file inputs.txt