From e7f3e34088496b2c43d9e7bbb0f3da81d1644e3c Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 10 Jun 2019 13:13:52 -0500 Subject: [PATCH] Fix from_hdf5 for hex lattice with x orientation. Assorted other fixes. --- docs/source/io_formats/geometry.rst | 4 +- include/openmc/lattice.h | 4 +- openmc/lattice.py | 49 ++++++++++--------- src/initialize.cpp | 4 +- src/relaxng/geometry.rnc | 2 +- src/relaxng/geometry.rng | 14 ++++-- .../lattice_hex_x/inputs_true.dat | 3 -- tests/regression_tests/lattice_hex_x/test.py | 3 -- tests/unit_tests/test_lattice.py | 9 ++++ 9 files changed, 50 insertions(+), 42 deletions(-) diff --git a/docs/source/io_formats/geometry.rst b/docs/source/io_formats/geometry.rst index a89bfb1e34..617ac6e870 100644 --- a/docs/source/io_formats/geometry.rst +++ b/docs/source/io_formats/geometry.rst @@ -320,8 +320,8 @@ the following attributes or sub-elements: :orientation: The orientation of the hexagonal lattice. The string "x" indicates that two - sides of the lattice are perpendicular to the x-axis, whereas the string "y" - indicates that two sides are perpendicular to the y-axis. + sides of the lattice are parallel to the x-axis, whereas the string "y" + indicates that two sides are parallel to the y-axis. *Default*: "y" diff --git a/include/openmc/lattice.h b/include/openmc/lattice.h index 8f2b6c4a1e..cd73b96408 100644 --- a/include/openmc/lattice.h +++ b/include/openmc/lattice.h @@ -267,8 +267,8 @@ public: private: enum class Orientation { - y, //!< Flat side perpendicular to y-axis - x //!< Flat side perpendicular to x-axis + y, //!< Flat side of lattice parallel to y-axis + x //!< Flat side of lattice parallel to x-axis }; //! Fill universes_ vector for 'y' orientation diff --git a/openmc/lattice.py b/openmc/lattice.py index 0ac47b9065..663d051e3c 100644 --- a/openmc/lattice.py +++ b/openmc/lattice.py @@ -228,38 +228,38 @@ class Lattice(IDManagerMixin, metaclass=ABCMeta): # Add a list for this ring. uarray[-1].append([]) - # Climb up the top-left. - for i in range(r): - uarray[-1][-1].append(universe_ids[z, y, a]) - a -= 1 - y += 1 - - # Climb the left. - for i in range(r): - uarray[-1][-1].append(universe_ids[z, y, a]) - a -= 1 - - # Climb down the bottom-left. - for i in range(r): - uarray[-1][-1].append(universe_ids[z, y, a]) - y -= 1 - # Climb down the bottom-right. for i in range(r): uarray[-1][-1].append(universe_ids[z, y, a]) - a += 1 y -= 1 - # Climb up the right. + # Climb across the bottom. for i in range(r): uarray[-1][-1].append(universe_ids[z, y, a]) - a += 1 + a -= 1 - # Climb up the top-right. + # Climb up the bottom-left. + for i in range(r): + uarray[-1][-1].append(universe_ids[z, y, a]) + a -= 1 + y +=1 + + # Climb up the top-left. for i in range(r): uarray[-1][-1].append(universe_ids[z, y, a]) y += 1 + # Climb across the top. + for i in range(r): + uarray[-1][-1].append(universe_ids[z, y, a]) + a += 1 + + # Climb down the top-right. + for i in range(r): + uarray[-1][-1].append(universe_ids[z, y, a]) + a += 1 + y -= 1 + # Move down to the next ring. a -= 1 @@ -405,9 +405,11 @@ class Lattice(IDManagerMixin, metaclass=ABCMeta): ---------- idx : Iterable of int Lattice element indices. For a rectangular lattice, the indices are - given in the :math:`(x,y)` or :math:`(x,y,z)` coordinate system.For + given in the :math:`(x,y)` or :math:`(x,y,z)` coordinate system. For hexagonal lattices, they are given in the :math:`x,\alpha` or - :math:`x,\alpha,z` coordinate systems. + :math:`x,\alpha,z` coordinate systems for "y" orientations and + :math:`\alpha,y` or :math:`\alpha,y,z` coordinate systems for "x" + orientations. Returns ------- @@ -947,8 +949,7 @@ class HexLattice(Lattice): string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id) string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name) string += '{0: <16}{1}{2}\n'.format('\tOrientation', '=\t', - "x" if (self._orientation == 'x') - else "y") + self._orientation) string += '{0: <16}{1}{2}\n'.format('\t# Rings', '=\t', self._num_rings) string += '{0: <16}{1}{2}\n'.format('\t# Axial', '=\t', self._num_axial) string += '{0: <16}{1}{2}\n'.format('\tCenter', '=\t', diff --git a/src/initialize.cpp b/src/initialize.cpp index 061025745f..f8a4f4a39a 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -36,9 +36,7 @@ int openmc_init(int argc, char* argv[], const void* intracomm) { using namespace openmc; - - char cCurrentPath[256]; - + #ifdef OPENMC_MPI // Check if intracomm was passed MPI_Comm comm; diff --git a/src/relaxng/geometry.rnc b/src/relaxng/geometry.rnc index 30fdf2c8ad..c349340717 100644 --- a/src/relaxng/geometry.rnc +++ b/src/relaxng/geometry.rnc @@ -36,7 +36,7 @@ element geometry { attribute dimension { list { xsd:positiveInteger+ } }) & (element lower_left { list { xsd:double+ } } | attribute lower_left { list { xsd:double+ } }) & (element pitch { list { xsd:double+ } } | attribute pitch { list { xsd:double+ } }) & - (element orient { ( "OX" ) } | attribute orient { ( "OX" ) })? & + (element orientation { ( "x" | "y" ) } | attribute orientation { ( "x" | "y" ) })? & (element universes { list { xsd:int+ } } | attribute universes { list { xsd:int+ } }) & (element outer { xsd:int } | attribute outer { xsd:int })? }* diff --git a/src/relaxng/geometry.rng b/src/relaxng/geometry.rng index e6c5f6ca16..52b9825be8 100644 --- a/src/relaxng/geometry.rng +++ b/src/relaxng/geometry.rng @@ -296,11 +296,17 @@ - - OX + + + x + y + - - OX + + + x + y + diff --git a/tests/regression_tests/lattice_hex_x/inputs_true.dat b/tests/regression_tests/lattice_hex_x/inputs_true.dat index 9c0b102a93..b528a97b7c 100644 --- a/tests/regression_tests/lattice_hex_x/inputs_true.dat +++ b/tests/regression_tests/lattice_hex_x/inputs_true.dat @@ -119,8 +119,5 @@ -13.62546635287517 -13.62546635287517 0.0 13.62546635287517 13.62546635287517 10.0 - - false - 22 diff --git a/tests/regression_tests/lattice_hex_x/test.py b/tests/regression_tests/lattice_hex_x/test.py index 405e9d1e9c..538f790dac 100644 --- a/tests/regression_tests/lattice_hex_x/test.py +++ b/tests/regression_tests/lattice_hex_x/test.py @@ -6,7 +6,6 @@ import numpy as np class HexLatticeOXTestHarness(PyAPITestHarness): def _build_inputs(self): - materials = openmc.Materials() fuel_mat = openmc.Material(material_id=1, name="UO2") @@ -195,7 +194,6 @@ class HexLatticeOXTestHarness(PyAPITestHarness): source.space = openmc.stats.Box(ll, ur) source.strength = 1.0 settings.source = source - settings.output = {'summary': False} settings.batches = 10 settings.inactive = 5 settings.particles = 1000 @@ -204,6 +202,5 @@ class HexLatticeOXTestHarness(PyAPITestHarness): def test_lattice_hex_ox_surf(): - harness = HexLatticeOXTestHarness('statepoint.10.h5') harness.main() diff --git a/tests/unit_tests/test_lattice.py b/tests/unit_tests/test_lattice.py index fe86e2a784..c4a3517769 100644 --- a/tests/unit_tests/test_lattice.py +++ b/tests/unit_tests/test_lattice.py @@ -202,6 +202,13 @@ def test_get_universe(rlat2, rlat3, hlat2, hlat3): assert hlat2.get_universe((1, 0)) == u1 assert hlat2.get_universe((-2, 2)) == u1 + hlat2.orientation = 'x' + assert hlat2.get_universe((2, 0)) == u2 + assert hlat2.get_universe((1, 0)) == u2 + assert hlat2.get_universe((1, 1)) == u1 + assert hlat2.get_universe((-1, 1)) == u1 + hlat2.orientation = 'y' + u1, u2, u3, outer = hlat3.univs assert hlat3.get_universe((0, 0, 0)) == u2 assert hlat3.get_universe((0, 0, 1)) == u3 @@ -342,3 +349,5 @@ def test_show_indices(): for i in range(1, 11): lines = openmc.HexLattice.show_indices(i).split('\n') assert len(lines) == 4*i - 3 + lines_x = openmc.HexLattice.show_indices(i, 'x').split('\n') + assert len(lines) == 4*i - 3