diff options
author | 2020-03-17 16:39:51 -0700 | |
---|---|---|
committer | 2020-03-17 16:39:51 -0700 | |
commit | 85d2f945f41382c8ebfe6696d8093b47b46d8ea1 (patch) | |
tree | a2cb8ff29ad2644e9e7cb2b791c7e08841b5a97c | |
parent | 1a670a115eb3e7396ce922496319b943281c34a0 (diff) | |
download | WarpX-85d2f945f41382c8ebfe6696d8093b47b46d8ea1.tar.gz WarpX-85d2f945f41382c8ebfe6696d8093b47b46d8ea1.tar.zst WarpX-85d2f945f41382c8ebfe6696d8093b47b46d8ea1.zip |
Small fixes to Python to better handle particle weights (#807)
-rw-r--r-- | Python/pywarpx/PGroup.py | 13 | ||||
-rw-r--r-- | Python/pywarpx/WarpInterface.py | 2 |
2 files changed, 9 insertions, 6 deletions
diff --git a/Python/pywarpx/PGroup.py b/Python/pywarpx/PGroup.py index ae9e6800a..7383c88ef 100644 --- a/Python/pywarpx/PGroup.py +++ b/Python/pywarpx/PGroup.py @@ -28,7 +28,7 @@ class PGroup(object): self.sm = np.zeros(self.ns) # Species mass [kg] self.sq = np.zeros(self.ns) # Species charge [C] - self.sw = np.zeros(self.ns) # Species weight, (real particles per simulation particles) + self.sw = np.ones(self.ns) # Species weight, (real particles per simulation particles) self.sid = np.arange(self.ns, dtype=int) # Global species index for each species self.ndts = np.ones(self.ns, dtype=int) # Stride for time step advance for each species @@ -110,11 +110,12 @@ class PGroup(object): return _libwarpx.get_particle_uz(self.ispecie, self.level)[self.igroup] uzp = property(getuzp) - def getpid(self): - id = _libwarpx.get_particle_id(self.ispecie, self.level)[self.igroup] - pid = np.array([id]).T - return pid - pid = property(getpid) + def getw(self): + return _libwarpx.get_particle_weight(self.ispecie, self.level)[self.igroup] + + def getpid(self, id): + pid = _libwarpx.get_particle_arrays(self.ispecie, id, self.level)[self.igroup] + return np.array([pid]).T def getgaminv(self): uxp = self.getuxp() diff --git a/Python/pywarpx/WarpInterface.py b/Python/pywarpx/WarpInterface.py index 8a3823959..91217ef1e 100644 --- a/Python/pywarpx/WarpInterface.py +++ b/Python/pywarpx/WarpInterface.py @@ -8,6 +8,8 @@ import warp from . import fields from pywarpx import PGroup +# The particle weight is always the first pid +warp.top.wpid = 1 def warp_species(warp_type, picmi_species, level=0): """Returns a Warp species that has a reference to the WarpX particles. |