From 7afebb029b93d05f95d0dee5e31cc2a9ec24b4b0 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 3 Dec 2015 07:31:02 -0600 Subject: [PATCH] Address @wbinventor comments on #516 --- openmc/region.py | 24 +++++++++++------------ openmc/surface.py | 49 +++++++++++++++++++++++++---------------------- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/openmc/region.py b/openmc/region.py index 7b640a07f..b7cfbca7b 100644 --- a/openmc/region.py +++ b/openmc/region.py @@ -237,13 +237,13 @@ class Intersection(Region): @property def bounding_box(self): - ll = np.array([-np.inf, -np.inf, -np.inf]) - ur = np.array([np.inf, np.inf, np.inf]) + lower_left = np.array([-np.inf, -np.inf, -np.inf]) + upper_right = np.array([np.inf, np.inf, np.inf]) for n in self.nodes: - ll_n, ur_n = n.bounding_box - ll[:] = np.maximum(ll, ll_n) - ur[:] = np.minimum(ur, ur_n) - return ll, ur + lower_left_n, upper_right_n = n.bounding_box + lower_left[:] = np.maximum(lower_left, lower_left_n) + upper_right[:] = np.minimum(upper_right, upper_right_n) + return lower_left, upper_right @nodes.setter def nodes(self, nodes): @@ -288,13 +288,13 @@ class Union(Region): @property def bounding_box(self): - ll = np.array([np.inf, np.inf, np.inf]) - ur = np.array([-np.inf, -np.inf, -np.inf]) + lower_left = np.array([np.inf, np.inf, np.inf]) + upper_right = np.array([-np.inf, -np.inf, -np.inf]) for n in self.nodes: - ll_n, ur_n = n.bounding_box - ll[:] = np.minimum(ll, ll_n) - ur[:] = np.maximum(ur, ur_n) - return ll, ur + lower_left_n, upper_right_n = n.bounding_box + lower_left[:] = np.minimum(lower_left, lower_left_n) + upper_right[:] = np.maximum(upper_right, upper_right_n) + return lower_left, upper_right @nodes.setter def nodes(self, nodes): diff --git a/openmc/surface.py b/openmc/surface.py index 6bb05baef..8dc45209b 100644 --- a/openmc/surface.py +++ b/openmc/surface.py @@ -327,9 +327,9 @@ class XPlane(Plane): """Determine an axis-aligned bounding box. An axis-aligned bounding box for surface half-spaces is represented by - its lower-left and upper-right coordinates. If the half-space is - unbounded in a particular direction, numpy.inf is used to represent - infinity. + its lower-left and upper-right coordinates. For the x-plane surface, the + half-spaces are unbounded in their y- and z- directions. To represent + infinity, numpy.inf is used. Parameters ---------- @@ -405,9 +405,9 @@ class YPlane(Plane): """Determine an axis-aligned bounding box. An axis-aligned bounding box for surface half-spaces is represented by - its lower-left and upper-right coordinates. If the half-space is - unbounded in a particular direction, numpy.inf is used to represent - infinity. + its lower-left and upper-right coordinates. For the y-plane surface, the + half-spaces are unbounded in their x- and z- directions. To represent + infinity, numpy.inf is used. Parameters ---------- @@ -483,9 +483,9 @@ class ZPlane(Plane): """Determine an axis-aligned bounding box. An axis-aligned bounding box for surface half-spaces is represented by - its lower-left and upper-right coordinates. If the half-space is - unbounded in a particular direction, numpy.inf is used to represent - infinity. + its lower-left and upper-right coordinates. For the z-plane surface, the + half-spaces are unbounded in their x- and y- directions. To represent + infinity, numpy.inf is used. Parameters ---------- @@ -629,9 +629,10 @@ class XCylinder(Cylinder): """Determine an axis-aligned bounding box. An axis-aligned bounding box for surface half-spaces is represented by - its lower-left and upper-right coordinates. If the half-space is - unbounded in a particular direction, numpy.inf is used to represent - infinity. + its lower-left and upper-right coordinates. For the x-cylinder surface, + the negative half-space is unbounded in the x- direction and the + positive half-space is unbounded in all directions. To represent + infinity, numpy.inf is used. Parameters ---------- @@ -651,7 +652,7 @@ class XCylinder(Cylinder): if side == '-': return (np.array([-np.inf, self.y0 - self.r, self.z0 - self.r]), - np.array([np.inf, self.y0 + self.r, self.y0 + self.r])) + np.array([np.inf, self.y0 + self.r, self.z0 + self.r])) elif side == '+': return (np.array([-np.inf, -np.inf, -np.inf]), np.array([np.inf, np.inf, np.inf])) @@ -727,9 +728,10 @@ class YCylinder(Cylinder): """Determine an axis-aligned bounding box. An axis-aligned bounding box for surface half-spaces is represented by - its lower-left and upper-right coordinates. If the half-space is - unbounded in a particular direction, numpy.inf is used to represent - infinity. + its lower-left and upper-right coordinates. For the y-cylinder surface, + the negative half-space is unbounded in the y- direction and the + positive half-space is unbounded in all directions. To represent + infinity, numpy.inf is used. Parameters ---------- @@ -749,7 +751,7 @@ class YCylinder(Cylinder): if side == '-': return (np.array([self.x0 - self.r, -np.inf, self.z0 - self.r]), - np.array([self.x0 + self.r, np.inf, self.y0 + self.r])) + np.array([self.x0 + self.r, np.inf, self.z0 + self.r])) elif side == '+': return (np.array([-np.inf, -np.inf, -np.inf]), np.array([np.inf, np.inf, np.inf])) @@ -825,9 +827,10 @@ class ZCylinder(Cylinder): """Determine an axis-aligned bounding box. An axis-aligned bounding box for surface half-spaces is represented by - its lower-left and upper-right coordinates. If the half-space is - unbounded in a particular direction, numpy.inf is used to represent - infinity. + its lower-left and upper-right coordinates. For the z-cylinder surface, + the negative half-space is unbounded in the z- direction and the + positive half-space is unbounded in all directions. To represent + infinity, numpy.inf is used. Parameters ---------- @@ -953,9 +956,9 @@ class Sphere(Surface): """Determine an axis-aligned bounding box. An axis-aligned bounding box for surface half-spaces is represented by - its lower-left and upper-right coordinates. If the half-space is - unbounded in a particular direction, numpy.inf is used to represent - infinity. + its lower-left and upper-right coordinates. The positive half-space of a + sphere is unbounded in all directions. To represent infinity, numpy.inf + is used. Parameters ----------