Skip to content

[WIP] Extend API so as to extract the real momentum p #315

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,15 @@ def simplify_record(record_comps):
if 'momentum/x' in record_comps:
record_comps.remove('momentum/x')
record_comps.append('ux')
Copy link
Member

@ax3l ax3l Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One could even go so far to only add u(x|y|z) aliases if the ED-PIC extension is set in the data series.

But saying that, we have also users that use relativistic beams in openPMD without PIC, so maybe that's a bad idea.

But saying that, we could add u(x|y|z) only if we also have a mass in record_comps :)

record_comps.append('px')
if 'momentum/y' in record_comps:
record_comps.remove('momentum/y')
record_comps.append('uy')
record_comps.append('py')
if 'momentum/z' in record_comps:
record_comps.remove('momentum/z')
record_comps.append('uz')
record_comps.append('pz')

# Replace the name for 'weights'
if 'weighting' in record_comps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def read_species_data(filename, iteration, species, record_comp, extensions):
'ux': 'momentum/x',
'uy': 'momentum/y',
'uz': 'momentum/z',
'px': 'momentum/x',
'py': 'momentum/y',
'pz': 'momentum/z',
'w': 'weighting'}
if record_comp in dict_record_comp:
opmd_record_comp = dict_record_comp[record_comp]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,15 @@ def simplify_record(record_comps):
if 'momentum/x' in record_comps:
record_comps.remove('momentum/x')
record_comps.append('ux')
record_comps.append('px')
if 'momentum/y' in record_comps:
record_comps.remove('momentum/y')
record_comps.append('uy')
record_comps.append('py')
if 'momentum/z' in record_comps:
record_comps.remove('momentum/z')
record_comps.append('uz')
record_comps.append('pz')

# Replace the name for 'weights'
if 'weighting' in record_comps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ def read_species_data(series, iteration, species_name, component_name,
'ux': ['momentum', 'x'],
'uy': ['momentum', 'y'],
'uz': ['momentum', 'z'],
'px': ['momentum', 'x'],
'py': ['momentum', 'y'],
'pz': ['momentum', 'z'],
'w': ['weighting', None]}

if component_name in dict_record_comp:
ompd_record_name, ompd_record_comp_name = \
dict_record_comp[component_name]
Expand Down
9 changes: 4 additions & 5 deletions openpmd_viewer/openpmd_timeseries/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,14 @@ def get_particle(self, var_list=None, species=None, t=None, iteration=None,
If two quantities are requested by the user, this plots
a 2d histogram of these quantities.

In the case of momenta, the result is returned as:
- unitless momentum (i.e. gamma*beta) for particles with non-zero mass
- in kg.m.s^-1 for particles with zero mass

Parameters
----------
var_list : list of string, optional
A list of the particle variables to extract. If var_list is not
provided, the available particle quantities are printed
provided, the available particle quantities are printed.
Note that `px`, `py`, `pz` represent the momentum in kg.m.s^-1,
while `ux`, `uy`, `uz` represent the unitless momentum
(i.e. gamma*beta).

species: string
A string indicating the name of the species
Expand Down