From 4d4ec41f5637e9ee26014d4db9536bd740a1c666 Mon Sep 17 00:00:00 2001 From: Dave Grote Date: Fri, 3 Jan 2020 14:54:19 -0800 Subject: Updated handling of fields_to_plot in picmi interface --- Python/pywarpx/picmi.py | 55 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 19 deletions(-) (limited to 'Python/pywarpx/picmi.py') diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index 224a53737..a65312bb7 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -612,22 +612,33 @@ class FieldDiagnostic(picmistandard.PICMI_FieldDiagnostic): pywarpx.amr.check_consistency('plot_int', self.period, 'The period must be the same for all simulation frame diagnostics') pywarpx.amr.plot_int = self.period - if 'rho' in self.data_list: - pywarpx.warpx.plot_rho = 1 - if 'dive' in self.data_list: - pywarpx.warpx.plot_dive = 1 - if 'divb' in self.data_list: - pywarpx.warpx.plot_divb = 1 - if 'F' in self.data_list: - pywarpx.warpx.plot_F = 1 - if 'proc_number' in self.data_list: - pywarpx.warpx.plot_proc_number = 1 + for dataname in self.data_list: + if dataname == 'E': + pywarpx.warpx.add_field_to_plot('Ex') + pywarpx.warpx.add_field_to_plot('Ey') + pywarpx.warpx.add_field_to_plot('Ez') + elif dataname == 'B': + pywarpx.warpx.add_field_to_plot('Bx') + pywarpx.warpx.add_field_to_plot('By') + pywarpx.warpx.add_field_to_plot('Bz') + elif dataname == 'J': + pywarpx.warpx.add_field_to_plot('jx') + pywarpx.warpx.add_field_to_plot('jy') + pywarpx.warpx.add_field_to_plot('jz') + elif dataname in ['Ex', 'Ey', 'Ez', 'Bx', 'By', 'Bz', 'rho', 'F', 'proc_number']: + pywarpx.warpx.add_field_to_plot(dataname) + elif dataname in ['Jx', 'Jy', 'Jz']: + pywarpx.warpx.add_field_to_plot(dataname.lower()) + elif dataname == 'dive': + pywarpx.warpx.add_field_to_plot('divE') + elif dataname == 'divb': + pywarpx.warpx.add_field_to_plot('divB') pywarpx.warpx.plot_raw_fields = self.plot_raw_fields pywarpx.warpx.plot_raw_fields_guards = self.plot_raw_fields_guards - pywarpx.amr.check_consistency('plot_finepatch', self.plot_finepatch, 'The fine patch flag must be the same for all simulation frame field diagnostics') - pywarpx.amr.check_consistency('plot_crsepatch', self.plot_crsepatch, 'The coarse patch flag must be the same for all simulation frame field diagnostics') + pywarpx.warpx.check_consistency('plot_finepatch', self.plot_finepatch, 'The fine patch flag must be the same for all simulation frame field diagnostics') + pywarpx.warpx.check_consistency('plot_crsepatch', self.plot_crsepatch, 'The coarse patch flag must be the same for all simulation frame field diagnostics') pywarpx.warpx.plot_finepatch = self.plot_finepatch pywarpx.warpx.plot_crsepatch = self.plot_crsepatch @@ -654,12 +665,9 @@ class ParticleDiagnostic(picmistandard.PICMI_ParticleDiagnostic): pywarpx.amr.check_consistency('plot_int', self.period, 'The period must be the same for all simulation frame diagnostics') pywarpx.amr.plot_int = self.period - if 'part_per_cell' in self.data_list: - pywarpx.warpx.plot_part_per_cell = 1 - if 'part_per_grid' in self.data_list: - pywarpx.warpx.plot_part_per_grid = 1 - if 'part_per_proc' in self.data_list: - pywarpx.warpx.plot_part_per_proc = 1 + for dataname in self.data_list: + if dataname in ['part_per_cell', 'part_per_grid', 'part_per_proc']: + pywarpx.warpx.add_field_to_plot(dataname) if self.write_dir is not None: plot_file = self.write_dir + '/plotfiles/plt' @@ -694,7 +702,16 @@ class LabFrameParticleDiagnostic(picmistandard.PICMI_LabFrameParticleDiagnostic) pywarpx.warpx.check_consistency('lab_data_directory', self.write_dir, 'The write directory must be the same in all lab frame diagnostics') pywarpx.warpx.do_back_transformed_diagnostics = 1 + + if isinstance(self.species, Species): + self.species.do_back_transformed_diagnostics = 1 + else: + try: + for specie in self.species: + specie.do_back_transformed_diagnostics = 1 + except TypeError: + pass + pywarpx.warpx.num_snapshots_lab = self.num_snapshots pywarpx.warpx.dt_snapshots_lab = self.dt_snapshots - pywarpx.warpx.do_back_transformed_particles = 1 pywarpx.warpx.lab_data_directory = self.write_dir -- cgit v1.2.3 From d20a7b866fc2c65519da587b305ff20b3d235ca4 Mon Sep 17 00:00:00 2001 From: Dave Grote Date: Fri, 3 Jan 2020 15:06:39 -0800 Subject: In picmi diagnostics, added plot_finepatch etc to list --- Python/pywarpx/picmi.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Python/pywarpx/picmi.py') diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index a65312bb7..c05bce211 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -633,6 +633,16 @@ class FieldDiagnostic(picmistandard.PICMI_FieldDiagnostic): pywarpx.warpx.add_field_to_plot('divE') elif dataname == 'divb': pywarpx.warpx.add_field_to_plot('divB') + elif dataname == 'costs': + pywarpx.warpx.plot_costs = 1 + elif dataname == 'raw_fields': + self.plot_raw_fields = 1 + elif dataname == 'raw_fields_guards': + self.plot_raw_fields_guards = 1 + elif dataname == 'finepatch': + self.plot_finepatch = 1 + elif dataname == 'crsepatch': + self.plot_crsepatch = 1 pywarpx.warpx.plot_raw_fields = self.plot_raw_fields pywarpx.warpx.plot_raw_fields_guards = self.plot_raw_fields_guards -- cgit v1.2.3 From e93fd4ee732826df82f6fd942b27b81daa7dbff4 Mon Sep 17 00:00:00 2001 From: Dave Grote Date: Thu, 9 Jan 2020 15:40:11 -0800 Subject: For picmi, added plot_vars for species --- Python/pywarpx/picmi.py | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'Python/pywarpx/picmi.py') diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index c05bce211..28dde05e6 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -68,8 +68,12 @@ class Species(picmistandard.PICMI_Species): else: pywarpx.particles.species_names += ' ' + self.name - self.species = pywarpx.Bucket.Bucket(self.name, mass=self.mass, charge=self.charge, - injection_style = 'python', initialize_self_fields=int(initialize_self_fields)) + self.species = pywarpx.Bucket.Bucket(self.name, + mass = self.mass, + charge = self.charge, + injection_style = 'python', + initialize_self_fields = int(initialize_self_fields), + plot_vars = set()) pywarpx.Particles.particles_list.append(self.species) if self.initial_distribution is not None: @@ -675,10 +679,37 @@ class ParticleDiagnostic(picmistandard.PICMI_ParticleDiagnostic): pywarpx.amr.check_consistency('plot_int', self.period, 'The period must be the same for all simulation frame diagnostics') pywarpx.amr.plot_int = self.period + plot_vars = set() for dataname in self.data_list: - if dataname in ['part_per_cell', 'part_per_grid', 'part_per_proc']: + if dataname == 'position': + # --- The positions are alway written out anyway + pass + elif dataname == 'momentum': + plot_vars.add('ux') + plot_vars.add('uy') + plot_vars.add('uz') + elif dataname == 'weighting': + plot_vars.add('w') + elif dataname == 'fields': + plot_vars.add('Ex') + plot_vars.add('Ey') + plot_vars.add('Ez') + plot_vars.add('Bx') + plot_vars.add('By') + plot_vars.add('Bz') + elif dataname in ['ux', 'uy', 'uz', 'Ex', 'Ey', 'Ez', 'Bx', 'By', 'Bz']: + plot_vars.add(dataname) + elif dataname in ['part_per_cell', 'part_per_grid', 'part_per_proc']: pywarpx.warpx.add_field_to_plot(dataname) + if plot_vars: + species = self.species + if not np.iterable(species): + species = [species] + for specie in species: + for var in plot_vars: + specie.species.plot_vars.add(var) + if self.write_dir is not None: plot_file = self.write_dir + '/plotfiles/plt' pywarpx.amr.check_consistency('plot_file', plot_file, 'The plot directory must be the same for all simulation frame diagnostics') -- cgit v1.2.3 From 0c593f22cd3c5571ff89ddc32a6b7b205815ead2 Mon Sep 17 00:00:00 2001 From: Dave Grote Date: Thu, 9 Jan 2020 16:56:10 -0800 Subject: For picmi, minor clean up --- Python/pywarpx/Lasers.py | 7 ++----- Python/pywarpx/Particles.py | 2 +- Python/pywarpx/WarpX.py | 2 +- Python/pywarpx/picmi.py | 5 +---- 4 files changed, 5 insertions(+), 11 deletions(-) (limited to 'Python/pywarpx/picmi.py') diff --git a/Python/pywarpx/Lasers.py b/Python/pywarpx/Lasers.py index ba7303d35..b54156ba1 100644 --- a/Python/pywarpx/Lasers.py +++ b/Python/pywarpx/Lasers.py @@ -1,14 +1,11 @@ from .Bucket import Bucket -lasers = Bucket('lasers', nlasers=0, names=None) +lasers = Bucket('lasers', nlasers=0, names=[]) lasers_list = [] def newlaser(name): result = Bucket(name) lasers_list.append(result) lasers.nlasers += 1 - if lasers.names is None: - lasers.names = name - else: - lasers.names += ' ' + name + lasers.names.append(name) return result diff --git a/Python/pywarpx/Particles.py b/Python/pywarpx/Particles.py index 757a49d00..582e623b7 100644 --- a/Python/pywarpx/Particles.py +++ b/Python/pywarpx/Particles.py @@ -1,6 +1,6 @@ from .Bucket import Bucket -particles = Bucket('particles', nspecies=0, species_names=None) +particles = Bucket('particles', nspecies=0, species_names=[]) particles_list = [] electrons = Bucket('electrons') diff --git a/Python/pywarpx/WarpX.py b/Python/pywarpx/WarpX.py index 1b536a55c..2ef3d99c1 100644 --- a/Python/pywarpx/WarpX.py +++ b/Python/pywarpx/WarpX.py @@ -29,7 +29,7 @@ class WarpX(Bucket): # --- Search through species_names and add any predefined particle objects in the list. particles_list_names = [p.instancename for p in particles_list] - for pstring in particles.species_names.split(' '): + for pstring in particles.species_names: if pstring in particles_list_names: # --- The species is already included in particles_list continue diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index 28dde05e6..70f356475 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -63,10 +63,7 @@ class Species(picmistandard.PICMI_Species): if self.name is None: self.name = 'species{}'.format(self.species_number) - if pywarpx.particles.species_names is None: - pywarpx.particles.species_names = self.name - else: - pywarpx.particles.species_names += ' ' + self.name + pywarpx.particles.species_names.append(self.name) self.species = pywarpx.Bucket.Bucket(self.name, mass = self.mass, -- cgit v1.2.3