aboutsummaryrefslogtreecommitdiff
path: root/Python/pywarpx
diff options
context:
space:
mode:
authorGravatar Dave Grote <grote1@llnl.gov> 2018-07-25 14:38:15 -0700
committerGravatar Dave Grote <grote1@llnl.gov> 2018-07-25 14:38:15 -0700
commit9c9ab769bba7b6d92170bce2651a294c500c1260 (patch)
tree4589f4b39a979def3569168d8ace544f7d3f5295 /Python/pywarpx
parent4e379e6c6e69fe499cd91be7c6019448f392ec14 (diff)
downloadWarpX-9c9ab769bba7b6d92170bce2651a294c500c1260.tar.gz
WarpX-9c9ab769bba7b6d92170bce2651a294c500c1260.tar.zst
WarpX-9c9ab769bba7b6d92170bce2651a294c500c1260.zip
Cleaned up handling of new species
Diffstat (limited to 'Python/pywarpx')
-rw-r--r--Python/pywarpx/Particles.py5
-rw-r--r--Python/pywarpx/WarpX.py8
-rw-r--r--Python/pywarpx/__init__.py2
3 files changed, 10 insertions, 5 deletions
diff --git a/Python/pywarpx/Particles.py b/Python/pywarpx/Particles.py
index 395a888d7..757a49d00 100644
--- a/Python/pywarpx/Particles.py
+++ b/Python/pywarpx/Particles.py
@@ -22,3 +22,8 @@ particle_dict = {'electrons':electrons,
'positrons':positrons,
'protons':protons
}
+
+def newspecies(name):
+ result = Bucket(name)
+ particles_list.append(result)
+ return result
diff --git a/Python/pywarpx/WarpX.py b/Python/pywarpx/WarpX.py
index 7a05c40fb..d7a37a6fa 100644
--- a/Python/pywarpx/WarpX.py
+++ b/Python/pywarpx/WarpX.py
@@ -29,10 +29,10 @@ class WarpX(Bucket):
argv += particles.attrlist()
argv += laser.attrlist()
- if not particles_list:
- # --- This is needed in case only species_names has been set,
- # --- assuming that only the built in particle types are being used.
- for pstring in particles.species_names.split(' '):
+ # --- Search through species_names and add any predefined particle objects in the list.
+ # --- assuming that only the built in particle types are being used.
+ for pstring in particles.species_names.split(' '):
+ if hasattr(Particles, pstring):
particles_list.append(getattr(Particles, pstring))
for particle in particles_list:
diff --git a/Python/pywarpx/__init__.py b/Python/pywarpx/__init__.py
index 14d028a45..c3f824e8f 100644
--- a/Python/pywarpx/__init__.py
+++ b/Python/pywarpx/__init__.py
@@ -5,7 +5,7 @@ from .Geometry import geometry
from .Algo import algo
from .Langmuirwave import langmuirwave
from .Interpolation import interpolation
-from .Particles import particles, electrons, positrons, protons
+from .Particles import particles, electrons, positrons, protons, newspecies
from .Laser import laser
#from .timestepper import TimeStepper