From 2475186d79fae93edc8851c3adc38b0edec228f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kn=C3=BCttel?= Date: Fri, 12 Jul 2019 22:28:39 +0200 Subject: [PATCH] fixed assymetry in momentum-overflow handling --- py/brown/brown.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/py/brown/brown.py b/py/brown/brown.py index 320b128..f2bec87 100644 --- a/py/brown/brown.py +++ b/py/brown/brown.py @@ -38,8 +38,10 @@ class BrownIterator(object): return self.x, self.y self.px, self.py = self._interaction(self.x, self.y, self.px, self.py) - self.px[np.isnan(self.px)] = self.speed_of_light - self.py[np.isnan(self.py)] = self.speed_of_light + # XXX: We need the (-1)**i to make the problem + # symmetric. + self.px[np.isnan(self.px)] = self.speed_of_light * (-1)**self._i + self.py[np.isnan(self.py)] = self.speed_of_light * (-1)**self._i self._reflect_at_borders() self.x += self.dt * self.px