From 1da6d9ae4ec9abbf2f1bed3ea0b4ef78a6902ee8 Mon Sep 17 00:00:00 2001 From: Christopher Mayes <31023527+ChristopherMayes@users.noreply.github.com> Date: Wed, 28 Jun 2023 11:34:21 -0700 Subject: [PATCH] Fix bug where z=0 or t=0 drift was actually setting to the mean. --- pmd_beamphysics/particles.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pmd_beamphysics/particles.py b/pmd_beamphysics/particles.py index 5e95acb..dae4ac5 100644 --- a/pmd_beamphysics/particles.py +++ b/pmd_beamphysics/particles.py @@ -738,7 +738,7 @@ def drift(self, delta_t): def drift_to_z(self, z=None): - if not z: + if z is None: z = self.avg('z') dt = (z - self.z) / (self.beta_z * c_light) self.drift(dt) @@ -752,7 +752,7 @@ def drift_to_t(self, t=None): If no z is given, particles will be drifted to the average t """ - if not t: + if t is None: t = self.avg('t') dt = t - self.t self.drift(dt)