diff options
author | 2023-08-31 17:35:55 -0700 | |
---|---|---|
committer | 2023-08-31 17:35:55 -0700 | |
commit | 8e3d9400c4a1c8f5cf440bcc5c53e56c9de0eaef (patch) | |
tree | 633189f4695f53c258c67624d4c15bdb0b221301 | |
parent | cf32cabd23e264d8cf99aca1f11a0888c035ec59 (diff) | |
download | WarpX-8e3d9400c4a1c8f5cf440bcc5c53e56c9de0eaef.tar.gz WarpX-8e3d9400c4a1c8f5cf440bcc5c53e56c9de0eaef.tar.zst WarpX-8e3d9400c4a1c8f5cf440bcc5c53e56c9de0eaef.zip |
PICMI: LabFrameParticleDiagnostic w/ Species (#4254)
Support the `species=...` argument in `PICMI_LabFrameParticleDiagnostic`.
-rw-r--r-- | Python/pywarpx/picmi.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index d5d00fb30..0417a260f 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -2161,6 +2161,7 @@ class ParticleDiagnostic(picmistandard.PICMI_ParticleDiagnostic, WarpXDiagnostic variables = list(variables) variables.sort() + # species list if np.iterable(self.species): species_list = self.species else: @@ -2342,6 +2343,46 @@ class LabFrameParticleDiagnostic(picmistandard.PICMI_LabFrameParticleDiagnostic, self.set_write_dir() + # --- Use a set to ensure that fields don't get repeated. + variables = set() + + if self.data_list is not None: + for dataname in self.data_list: + if dataname == 'position': + # --- The positions are alway written out anyway + pass + elif dataname == 'momentum': + variables.add('ux') + variables.add('uy') + variables.add('uz') + elif dataname == 'weighting': + variables.add('w') + elif dataname == 'fields': + variables.add('Ex') + variables.add('Ey') + variables.add('Ez') + variables.add('Bx') + variables.add('By') + variables.add('Bz') + elif dataname in ['ux', 'uy', 'uz', 'Ex', 'Ey', 'Ez', 'Bx', 'By', 'Bz', 'Er', 'Et', 'Br', 'Bt']: + variables.add(dataname) + + # --- Convert the set to a sorted list so that the order + # --- is the same on all processors. + variables = list(variables) + variables.sort() + + # species list + if np.iterable(self.species): + species_list = self.species + else: + species_list = [self.species] + + for specie in species_list: + diag = pywarpx.Bucket.Bucket(self.name + '.' + specie.name, + variables = variables) + self.diagnostic._species_dict[specie.name] = diag + class ReducedDiagnostic(picmistandard.base._ClassWithInit, WarpXDiagnosticBase): """ |