From de27a944f5cad8e1e84de092ae23d33af1d9faba Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Sat, 14 Nov 2015 17:05:32 -0500 Subject: [PATCH 1/6] Fixed bug in OpenCG compatibility module with Lattice outside attribute --- openmc/opencg_compatible.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openmc/opencg_compatible.py b/openmc/opencg_compatible.py index 019d2aabcf..c0f6c943cb 100644 --- a/openmc/opencg_compatible.py +++ b/openmc/opencg_compatible.py @@ -877,6 +877,7 @@ def get_opencg_lattice(openmc_lattice): pitch = openmc_lattice.pitch lower_left = openmc_lattice.lower_left universes = openmc_lattice.universes + outside = openmc_lattice.outside if len(pitch) == 2: new_pitch = np.ones(3, dtype=np.float64) @@ -909,6 +910,8 @@ def get_opencg_lattice(openmc_lattice): opencg_lattice.dimension = dimension opencg_lattice.width = pitch opencg_lattice.universes = universe_array + if outside: + opencg_lattice.outside = outside offset = np.array(lower_left, dtype=np.float64) - \ ((np.array(pitch, dtype=np.float64) * @@ -955,6 +958,7 @@ def get_openmc_lattice(opencg_lattice): width = opencg_lattice.width offset = opencg_lattice.offset universes = opencg_lattice.universes + outside = opencg_lattice.outside # Initialize an empty array for the OpenMC nested Universes in this Lattice universe_array = np.ndarray(tuple(np.array(dimension)), @@ -985,6 +989,8 @@ def get_openmc_lattice(opencg_lattice): openmc_lattice.pitch = width openmc_lattice.universes = universe_array openmc_lattice.lower_left = lower_left + if outside: + openmc_lattice.outside = outside # Add the OpenMC Lattice to the global collection of all OpenMC Lattices OPENMC_LATTICES[lattice_id] = openmc_lattice From 36d1b17e13f52ee5dfb59d22cfabeb36c35f7563 Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Sat, 14 Nov 2015 17:12:30 -0500 Subject: [PATCH 2/6] OpenCG compatibility module now converts lattice outer/outside OpenMC/OpenCG appropriate version --- openmc/opencg_compatible.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openmc/opencg_compatible.py b/openmc/opencg_compatible.py index c0f6c943cb..6da21fa055 100644 --- a/openmc/opencg_compatible.py +++ b/openmc/opencg_compatible.py @@ -910,8 +910,8 @@ def get_opencg_lattice(openmc_lattice): opencg_lattice.dimension = dimension opencg_lattice.width = pitch opencg_lattice.universes = universe_array - if outside: - opencg_lattice.outside = outside + if outside != None: + opencg_lattice.outside = get_opencg_universe(outside) offset = np.array(lower_left, dtype=np.float64) - \ ((np.array(pitch, dtype=np.float64) * @@ -958,7 +958,7 @@ def get_openmc_lattice(opencg_lattice): width = opencg_lattice.width offset = opencg_lattice.offset universes = opencg_lattice.universes - outside = opencg_lattice.outside + outer = opencg_lattice.outside # Initialize an empty array for the OpenMC nested Universes in this Lattice universe_array = np.ndarray(tuple(np.array(dimension)), @@ -989,8 +989,8 @@ def get_openmc_lattice(opencg_lattice): openmc_lattice.pitch = width openmc_lattice.universes = universe_array openmc_lattice.lower_left = lower_left - if outside: - openmc_lattice.outside = outside + if outer != None: + openmc_lattice.outer = get_openmc_universe(outer) # Add the OpenMC Lattice to the global collection of all OpenMC Lattices OPENMC_LATTICES[lattice_id] = openmc_lattice From 179b32ca39e16486c5e3b1e07bd5591381b10e23 Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Sat, 14 Nov 2015 22:01:53 -0500 Subject: [PATCH 3/6] Corrected outside to outer for OpenCG lattices --- openmc/opencg_compatible.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openmc/opencg_compatible.py b/openmc/opencg_compatible.py index 6da21fa055..3164c97885 100644 --- a/openmc/opencg_compatible.py +++ b/openmc/opencg_compatible.py @@ -877,7 +877,7 @@ def get_opencg_lattice(openmc_lattice): pitch = openmc_lattice.pitch lower_left = openmc_lattice.lower_left universes = openmc_lattice.universes - outside = openmc_lattice.outside + outer = openmc_lattice.outer if len(pitch) == 2: new_pitch = np.ones(3, dtype=np.float64) @@ -910,8 +910,8 @@ def get_opencg_lattice(openmc_lattice): opencg_lattice.dimension = dimension opencg_lattice.width = pitch opencg_lattice.universes = universe_array - if outside != None: - opencg_lattice.outside = get_opencg_universe(outside) + if outer != None: + opencg_lattice.outside = get_opencg_universe(outer) offset = np.array(lower_left, dtype=np.float64) - \ ((np.array(pitch, dtype=np.float64) * From c8111b1e21f14b9519b9d78a0ec673dfa15eebef Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Sat, 14 Nov 2015 22:40:36 -0500 Subject: [PATCH 4/6] Fixed get_opencg_cell routine for cells without any surfaces --- openmc/opencg_compatible.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/openmc/opencg_compatible.py b/openmc/opencg_compatible.py index 3164c97885..2b5c76459d 100644 --- a/openmc/opencg_compatible.py +++ b/openmc/opencg_compatible.py @@ -486,20 +486,22 @@ def get_opencg_cell(openmc_cell): # works if the region is a single half-space or an intersection of # half-spaces, i.e., no complex cells. region = openmc_cell.region - if isinstance(region, Halfspace): - surface = region.surface - halfspace = -1 if region.side == '-' else 1 - opencg_cell.add_surface(get_opencg_surface(surface), halfspace) - elif isinstance(region, Intersection): - for node in region.nodes: - if not isinstance(node, Halfspace): - raise NotImplementedError("Complex cells not yet supported " - "in OpenCG.") - surface = node.surface - halfspace = -1 if node.side == '-' else 1 + if region != None: + if isinstance(region, Halfspace): + surface = region.surface + halfspace = -1 if region.side == '-' else 1 opencg_cell.add_surface(get_opencg_surface(surface), halfspace) - else: - raise NotImplementedError("Complex cells not yet supported in OpenCG.") + elif isinstance(region, Intersection): + for node in region.nodes: + if not isinstance(node, Halfspace): + raise NotImplementedError("Complex cells not yet " + "supported in OpenCG.") + surface = node.surface + halfspace = -1 if node.side == '-' else 1 + opencg_cell.add_surface(get_opencg_surface(surface), halfspace) + else: + raise NotImplementedError("Complex cells not yet supported " + "in OpenCG.") # Add the OpenMC Cell to the global collection of all OpenMC Cells OPENMC_CELLS[cell_id] = openmc_cell From 2c19aaae74c84d7ffe5c77946d3b854404459cb0 Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Mon, 16 Nov 2015 08:03:52 -0500 Subject: [PATCH 5/6] Changed conditionals for lattice outer to be more Pythonic per comments by @paulromano --- openmc/opencg_compatible.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openmc/opencg_compatible.py b/openmc/opencg_compatible.py index 2b5c76459d..8fc48bcf4c 100644 --- a/openmc/opencg_compatible.py +++ b/openmc/opencg_compatible.py @@ -912,7 +912,7 @@ def get_opencg_lattice(openmc_lattice): opencg_lattice.dimension = dimension opencg_lattice.width = pitch opencg_lattice.universes = universe_array - if outer != None: + if outer is not None: opencg_lattice.outside = get_opencg_universe(outer) offset = np.array(lower_left, dtype=np.float64) - \ @@ -991,7 +991,7 @@ def get_openmc_lattice(opencg_lattice): openmc_lattice.pitch = width openmc_lattice.universes = universe_array openmc_lattice.lower_left = lower_left - if outer != None: + if outer is not None: openmc_lattice.outer = get_openmc_universe(outer) # Add the OpenMC Lattice to the global collection of all OpenMC Lattices From c38fcdc073fd8c14d4fe96f49377ced65c28b41d Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Mon, 16 Nov 2015 08:06:43 -0500 Subject: [PATCH 6/6] Changed conditionals for cell region to be more Pythonic per comments by @paulromano --- openmc/opencg_compatible.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc/opencg_compatible.py b/openmc/opencg_compatible.py index 8fc48bcf4c..93c0e5fae7 100644 --- a/openmc/opencg_compatible.py +++ b/openmc/opencg_compatible.py @@ -486,7 +486,7 @@ def get_opencg_cell(openmc_cell): # works if the region is a single half-space or an intersection of # half-spaces, i.e., no complex cells. region = openmc_cell.region - if region != None: + if region is not None: if isinstance(region, Halfspace): surface = region.surface halfspace = -1 if region.side == '-' else 1