Skip to content

Add LabFrameParticleDiagnostic to picmi #4148

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

Merged
Merged
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
68 changes: 66 additions & 2 deletions Python/pywarpx/picmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2188,7 +2188,10 @@ def initialize_inputs(self):
class LabFrameFieldDiagnostic(picmistandard.PICMI_LabFrameFieldDiagnostic,
WarpXDiagnosticBase):
"""
See `Input Parameters <https://warpx.readthedocs.io/en/latest/usage/parameters.html>`_ for more information.
See `Input Parameters <https://warpx.readthedocs.io/en/latest/usage/parameters.html#backtransformed-diagnostics>`_
for more information.

This will by default write out both field and particle data. This can be changed by setting warpx_write_species.
Comment on lines +2192 to +2194
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for more information.
This will by default write out both field and particle data. This can be changed by setting warpx_write_species.
for more information.


Parameters
----------
Expand All @@ -2212,16 +2215,19 @@ class LabFrameFieldDiagnostic(picmistandard.PICMI_LabFrameFieldDiagnostic,

warpx_upper_bound: vector of floats, optional
Passed to <diagnostic name>.upper_bound

warpx_write_species: bool, optional, default=True
Copy link
Member

Choose a reason for hiding this comment

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

In PICMI, I think it makes more sense to turn them off by default...

Suggested change
warpx_write_species: bool, optional, default=True
warpx_write_species: bool, optional, default=False

Whether the species will also be written out.
"""
def init(self, kw):
# The user is using the new BTD
self.format = kw.pop('warpx_format', None)
self.openpmd_backend = kw.pop('warpx_openpmd_backend', None)
self.file_prefix = kw.pop('warpx_file_prefix', None)
self.file_min_digits = kw.pop('warpx_file_min_digits', None)
self.buffer_size = kw.pop('warpx_buffer_size', None)
self.lower_bound = kw.pop('warpx_lower_bound', None)
self.upper_bound = kw.pop('warpx_upper_bound', None)
self.write_species = kw.pop('warpx_write_species', None)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
self.write_species = kw.pop('warpx_write_species', None)
self.write_species = kw.pop('warpx_write_species', False)


def initialize_inputs(self):

Expand All @@ -2239,6 +2245,8 @@ def initialize_inputs(self):
self.diagnostic.dt_snapshots_lab = self.dt_snapshots
self.diagnostic.buffer_size = self.buffer_size

self.diagnostics.do_back_transformed_particles = self.write_species

# --- Use a set to ensure that fields don't get repeated.
fields_to_plot = set()

Expand Down Expand Up @@ -2279,6 +2287,62 @@ def initialize_inputs(self):

self.set_write_dir()


class LabFrameParticleDiagnostic(picmistandard.PICMI_LabFrameParticleDiagnostic,
WarpXDiagnosticBase):
"""
See `Input Parameters <https://warpx.readthedocs.io/en/latest/usage/parameters.html#backtransformed-diagnostics>`_
for more information.

This will by default write out both field and particle data. This can be changed by setting warpx_write_fields.
Comment on lines +2295 to +2297
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for more information.
This will by default write out both field and particle data. This can be changed by setting warpx_write_fields.
for more information.


Parameters
----------
warpx_format: string, optional
Passed to <diagnostic name>.format

warpx_openpmd_backend: string, optional
Passed to <diagnostic name>.openpmd_backend

warpx_file_prefix: string, optional
Passed to <diagnostic name>.file_prefix

warpx_file_min_digits: integer, optional
Passed to <diagnostic name>.file_min_digits

warpx_buffer_size: integer, optional
Passed to <diagnostic name>.buffer_size

warpx_write_fields: bool, optional, default=True
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
warpx_write_fields: bool, optional, default=True
warpx_write_fields: bool, optional, default=False

Whether the fields will also be written out.
"""
def init(self, kw):
self.format = kw.pop('warpx_format', None)
self.openpmd_backend = kw.pop('warpx_openpmd_backend', None)
self.file_prefix = kw.pop('warpx_file_prefix', None)
self.file_min_digits = kw.pop('warpx_file_min_digits', None)
self.buffer_size = kw.pop('warpx_buffer_size', None)
self.write_fields = kw.pop('warpx_write_fields', None)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
self.write_fields = kw.pop('warpx_write_fields', None)
self.write_fields = kw.pop('warpx_write_fields', False)


def initialize_inputs(self):

self.add_diagnostic()

self.diagnostic.diag_type = 'BackTransformed'
self.diagnostic.format = self.format
self.diagnostic.openpmd_backend = self.openpmd_backend
self.diagnostic.file_min_digits = self.file_min_digits

self.diagnostic.do_back_transformed_particles = 1
self.diagnostic.num_snapshots_lab = self.num_snapshots
self.diagnostic.dt_snapshots_lab = self.dt_snapshots
self.diagnostic.buffer_size = self.buffer_size

self.diagnostics.do_back_transformed_fields = self.write_fields

self.set_write_dir()


class ReducedDiagnostic(picmistandard.base._ClassWithInit, WarpXDiagnosticBase):
"""
Sets up a reduced diagnostic in the simulation.
Expand Down