From 95057442914b2d36d87809dd23e55c724cd44fc6 Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Sat, 9 Jan 2016 23:44:26 -0500 Subject: [PATCH] Fix void distribmats --- openmc/universe.py | 13 +++++++++---- src/summary.F90 | 14 +++++++++++--- tests/test_distribmat/inputs_true.dat | 2 +- tests/test_distribmat/results_true.dat | 4 ++-- tests/test_distribmat/test_distribmat.py | 5 +---- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/openmc/universe.py b/openmc/universe.py index 2fa535265c..048b6a0e9f 100644 --- a/openmc/universe.py +++ b/openmc/universe.py @@ -113,8 +113,11 @@ class Cell(object): string += '{0: <16}{1}{2}\n'.format('\tMaterial', '=\t', self._fill._id) elif isinstance(self._fill, Iterable): - string += ('{0: <16}{1}'.format('\tMaterial', '=\t') - + '[' + ', '.join([str(m.id) for m in self.fill]) + ']\n') + string += '{0: <16}{1}'.format('\tMaterial', '=\t') + string += '[' + string += ', '.join(['void' if m == 'void' else str(m.id) + for m in self.fill]) + string += ']\n' elif isinstance(self._fill, (Universe, Lattice)): string += '{0: <16}{1}{2}\n'.format('\tFill', '=\t', self._fill._id) @@ -209,7 +212,8 @@ class Cell(object): self._type = 'normal' elif isinstance(fill, Iterable): - cv.check_type('cell.fill', fill, Iterable, openmc.Material) + cv.check_type('cell.fill', fill, Iterable, + (openmc.Material, basestring)) self._type = 'normal' elif isinstance(fill, Universe): @@ -402,7 +406,8 @@ class Cell(object): element.set("material", str(self._fill._id)) elif isinstance(self._fill, Iterable): - element.set("material", ' '.join([str(m.id) for m in self.fill])) + element.set("material", ' '.join([m if m == 'void' else str(m.id) + for m in self.fill])) elif isinstance(self._fill, (Universe, Lattice)): element.set("fill", str(self._fill._id)) diff --git a/src/summary.F90 b/src/summary.F90 index deccaddf59..c06d2549c2 100644 --- a/src/summary.F90 +++ b/src/summary.F90 @@ -152,12 +152,20 @@ contains case (CELL_NORMAL) call write_dataset(cell_group, "fill_type", "normal") if (size(c % material) == 1) then - call write_dataset(cell_group, "material", & - materials(c % material(1)) % id) + if (c % material(1) == MATERIAL_VOID) then + call write_dataset(cell_group, "material", MATERIAL_VOID) + else + call write_dataset(cell_group, "material", & + materials(c % material(1)) % id) + end if else allocate(cell_materials(size(c % material))) do j = 1, size(c % material) - cell_materials(j) = materials(c % material(j)) % id + if (c % material(j) == MATERIAL_VOID) then + cell_materials(j) = MATERIAL_VOID + else + cell_materials(j) = materials(c % material(j)) % id + end if end do call write_dataset(cell_group, "material", cell_materials) deallocate(cell_materials) diff --git a/tests/test_distribmat/inputs_true.dat b/tests/test_distribmat/inputs_true.dat index 48044e2872..0fb8cc8bf8 100644 --- a/tests/test_distribmat/inputs_true.dat +++ b/tests/test_distribmat/inputs_true.dat @@ -1 +1 @@ -24a3537446feafcf79fc84d268b43130e9521ad7cccfcf733ba35ca50bf3c644e0b8e91bfdef7bdb4073783197cfdd730d1e459fc622aa3ce6dcf3143c805a1f \ No newline at end of file +bdc2acd3a4f5078c61d7cb83ff30e07b76c89b21d8131c1b0ce86a43156da7bd0b9ebb5d6acc0b98a7d8128667f99403ef12a6d76ed2ec6cb187810222e4f6b3 \ No newline at end of file diff --git a/tests/test_distribmat/results_true.dat b/tests/test_distribmat/results_true.dat index 5e93e4e473..70464fbc6c 100644 --- a/tests/test_distribmat/results_true.dat +++ b/tests/test_distribmat/results_true.dat @@ -1,9 +1,9 @@ k-combined: -1.433669E+00 7.069157E-03 +1.309285E+00 1.263629E-02 Cell ID = 11 Name = - Material = [2, 3, 2, 2] + Material = [2, 3, void, 2] Region = -10000 Rotation = None Translation = None diff --git a/tests/test_distribmat/test_distribmat.py b/tests/test_distribmat/test_distribmat.py index 61e40e64c6..f0d09e963a 100644 --- a/tests/test_distribmat/test_distribmat.py +++ b/tests/test_distribmat/test_distribmat.py @@ -44,7 +44,7 @@ class DistribmatTestHarness(PyAPITestHarness): r0 = openmc.ZCylinder(R=0.3) c11 = openmc.Cell(cell_id=11) c11.region = -r0 - c11.fill = [dense_fuel, light_fuel] + [dense_fuel]*2 + c11.fill = [dense_fuel, light_fuel, 'void', dense_fuel] c12 = openmc.Cell(cell_id=12) c12.region = +r0 c12.fill = moderator @@ -122,9 +122,6 @@ class DistribmatTestHarness(PyAPITestHarness): outstr += str(su.get_cell_by_id(11)) return outstr -# def _cleanup(self): -# return None - if __name__ == '__main__': harness = DistribmatTestHarness('statepoint.5.*')