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/WarpX.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Python/pywarpx/WarpX.py') diff --git a/Python/pywarpx/WarpX.py b/Python/pywarpx/WarpX.py index 5f7477e58..1b536a55c 100644 --- a/Python/pywarpx/WarpX.py +++ b/Python/pywarpx/WarpX.py @@ -48,6 +48,14 @@ class WarpX(Bucket): return argv + def add_field_to_plot(self, field): + try: + # Check if the field was already added to the string + if field not in self.fields_to_plot: + self.fields_to_plot.append(field) + except AttributeError: + self.fields_to_plot = [field] + def init(self): from . import wx argv = ['warpx'] + self.create_argv_list() -- 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/WarpX.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