diff --git a/openmc/lattice.py b/openmc/lattice.py index f0e8b40b0d2..33b0d1c738f 100644 --- a/openmc/lattice.py +++ b/openmc/lattice.py @@ -1301,7 +1301,7 @@ def find_element(self, point): else: z = point[2] - self.center[2] iz = floor(z/self.pitch[1] + 0.5*self.num_axial) - if self._orientation == 'x': + if self._orientation == 'y': alpha = y - x*sqrt(3.) i1 = floor(-alpha/(sqrt(3.0) * self.pitch[0])) i2 = floor(y/(sqrt(0.75) * self.pitch[0])) @@ -1343,7 +1343,7 @@ def get_local_coordinates(self, point, idx): system """ - if self._orientation == 'x': + if self._orientation == 'y': x = point[0] - (self.center[0] + (idx[0] + 0.5*idx[1])*self.pitch[0]) y = point[1] - (self.center[1] + sqrt(0.75)*self.pitch[0]*idx[1]) else: @@ -1395,7 +1395,7 @@ def get_universe_index(self, idx): else: i_within = 5*g - z - if self._orientation == 'x' and g > 0: + if self._orientation == 'y' and g > 0: i_within = (i_within + 5*g) % (6*g) if self.num_axial is None: @@ -1556,7 +1556,7 @@ def from_xml_element(cls, elem, get_universe): # Get list for a single axial level axial_level = univs[z] if n_axial > 1 else univs - if lat.orientation == 'y': + if lat.orientation == 'x': # Start iterating from top x, alpha = 0, n_rings - 1 while True: @@ -1615,7 +1615,7 @@ def _repr_axial_slice(self, universes): each sub-list represents a single ring. The first list should be the outer ring. """ - if self._orientation == 'x': + if self._orientation == 'y': return self._repr_axial_slice_x(universes) else: return self._repr_axial_slice_y(universes) @@ -2051,7 +2051,7 @@ def show_indices(num_rings, orientation="y"): """ - if orientation == 'x': + if orientation == 'y': return HexLattice._show_indices_x(num_rings) else: return HexLattice._show_indices_y(num_rings) @@ -2095,7 +2095,7 @@ def from_hdf5(cls, group, universes): # If the Universe specified outer the Lattice is not void if outer >= 0: lattice.outer = universes[outer] - if orientation == "y": + if orientation == "x": # Build array of Universe pointers for the Lattice. Note that # we need to convert between the HDF5's square array of # (x, alpha, z) to the Python API's format of a ragged nested diff --git a/src/lattice.cpp b/src/lattice.cpp index efbfcb2163a..c0068d13fab 100644 --- a/src/lattice.cpp +++ b/src/lattice.cpp @@ -545,7 +545,7 @@ HexLattice::HexLattice(pugi::xml_node lat_node) : Lattice {lat_node} //============================================================================== -void HexLattice::fill_lattice_x(const vector& univ_words) +void HexLattice::fill_lattice_y(const vector& univ_words) { int input_index = 0; for (int m = 0; m < n_axial_; m++) { @@ -597,7 +597,7 @@ void HexLattice::fill_lattice_x(const vector& univ_words) //============================================================================== -void HexLattice::fill_lattice_y(const vector& univ_words) +void HexLattice::fill_lattice_x(const vector& univ_words) { int input_index = 0; for (int m = 0; m < n_axial_; m++) { @@ -756,7 +756,7 @@ std::pair> HexLattice::distance( double beta_dir; double gamma_dir; double delta_dir; - if (orientation_ == Orientation::y) { + if (orientation_ == Orientation::x) { beta_dir = u.x * std::sqrt(3.0) / 2.0 + u.y / 2.0; gamma_dir = u.x * std::sqrt(3.0) / 2.0 - u.y / 2.0; delta_dir = u.y; @@ -785,7 +785,7 @@ std::pair> HexLattice::distance( r_t = get_local_position(r, i_xyz_t); } double beta; - if (orientation_ == Orientation::y) { + if (orientation_ == Orientation::x) { beta = r_t.x * std::sqrt(3.0) / 2.0 + r_t.y / 2.0; } else { beta = r_t.x; @@ -809,7 +809,7 @@ std::pair> HexLattice::distance( r_t = get_local_position(r, i_xyz_t); } double gamma; - if (orientation_ == Orientation::y) { + if (orientation_ == Orientation::x) { gamma = r_t.x * std::sqrt(3.0) / 2.0 - r_t.y / 2.0; } else { gamma = r_t.x / 2.0 - r_t.y * std::sqrt(3.0) / 2.0; @@ -836,7 +836,7 @@ std::pair> HexLattice::distance( r_t = get_local_position(r, i_xyz_t); } double delta; - if (orientation_ == Orientation::y) { + if (orientation_ == Orientation::x) { delta = r_t.y; } else { delta = r_t.x / 2.0 + r_t.y * std::sqrt(3.0) / 2.0; @@ -897,7 +897,7 @@ void HexLattice::get_indices( } } - if (orientation_ == Orientation::y) { + if (orientation_ == Orientation::x) { // Convert coordinates into skewed bases. The (x, alpha) basis is used to // find the index of the global coordinates to within 4 cells. double alpha = r_o.y - r_o.x / std::sqrt(3.0); @@ -983,7 +983,7 @@ int HexLattice::get_flat_index(const array& i_xyz) const Position HexLattice::get_local_position( Position r, const array& i_xyz) const { - if (orientation_ == Orientation::y) { + if (orientation_ == Orientation::x) { // x_l = x_g - (center + pitch_x*cos(30)*index_x) r.x -= center_.x + std::sqrt(3.0) / 2.0 * (i_xyz[0] - n_rings_ + 1) * pitch_[0]; diff --git a/tests/regression_tests/filter_distribcell/case-4/model.xml b/tests/regression_tests/filter_distribcell/case-4/model.xml index 8694219194b..aa5740f2f63 100644 --- a/tests/regression_tests/filter_distribcell/case-4/model.xml +++ b/tests/regression_tests/filter_distribcell/case-4/model.xml @@ -21,7 +21,7 @@ - + 1.0 3
0.0 0.0
diff --git a/tests/regression_tests/lattice_hex/geometry.xml b/tests/regression_tests/lattice_hex/geometry.xml index fa6a18ee16b..08666760bb4 100644 --- a/tests/regression_tests/lattice_hex/geometry.xml +++ b/tests/regression_tests/lattice_hex/geometry.xml @@ -43,7 +43,7 @@ - 011 diff --git a/tests/regression_tests/lattice_hex_coincident/inputs_true.dat b/tests/regression_tests/lattice_hex_coincident/inputs_true.dat index fafc03da1ed..a17f124b328 100644 --- a/tests/regression_tests/lattice_hex_coincident/inputs_true.dat +++ b/tests/regression_tests/lattice_hex_coincident/inputs_true.dat @@ -39,7 +39,7 @@ - + 1.4 3
0.0 0.0
diff --git a/tests/regression_tests/lattice_hex_coincident/test.py b/tests/regression_tests/lattice_hex_coincident/test.py index f971098c06a..b1c2ab02d4d 100644 --- a/tests/regression_tests/lattice_hex_coincident/test.py +++ b/tests/regression_tests/lattice_hex_coincident/test.py @@ -113,6 +113,7 @@ def __init__(self, *args, **kwargs): pincell_only_lattice.center = (0., 0.) pincell_only_lattice.pitch = (assembly_pitch,) pincell_only_lattice.outer = inf_mat_univ + pincell_only_lattice.orientation = "x" # setup hex rings ring0 = [fuel_ch_univ] diff --git a/tests/regression_tests/lattice_hex_x/__init__.py b/tests/regression_tests/lattice_hex_y/__init__.py similarity index 100% rename from tests/regression_tests/lattice_hex_x/__init__.py rename to tests/regression_tests/lattice_hex_y/__init__.py diff --git a/tests/regression_tests/lattice_hex_x/inputs_true.dat b/tests/regression_tests/lattice_hex_y/inputs_true.dat similarity index 99% rename from tests/regression_tests/lattice_hex_x/inputs_true.dat rename to tests/regression_tests/lattice_hex_y/inputs_true.dat index b6536c6a8b3..708f97bde9a 100644 --- a/tests/regression_tests/lattice_hex_x/inputs_true.dat +++ b/tests/regression_tests/lattice_hex_y/inputs_true.dat @@ -43,7 +43,7 @@ - + 1.235 5.0 4
0.0 0.0 5.0
diff --git a/tests/regression_tests/lattice_hex_x/results_true.dat b/tests/regression_tests/lattice_hex_y/results_true.dat similarity index 100% rename from tests/regression_tests/lattice_hex_x/results_true.dat rename to tests/regression_tests/lattice_hex_y/results_true.dat diff --git a/tests/regression_tests/lattice_hex_x/test.py b/tests/regression_tests/lattice_hex_y/test.py similarity index 99% rename from tests/regression_tests/lattice_hex_x/test.py rename to tests/regression_tests/lattice_hex_y/test.py index dd5c53d0c02..51813b5ad23 100644 --- a/tests/regression_tests/lattice_hex_x/test.py +++ b/tests/regression_tests/lattice_hex_y/test.py @@ -166,7 +166,7 @@ def __init__(self, *args, **kwargs): for i, j in channels: universes[i][j] = abs_ch_univ lattice = openmc.HexLattice(lattice_id=6, name="regular fuel assembly") - lattice.orientation = "x" + lattice.orientation = "y" lattice.center = (0., 0., length/2.0) lattice.pitch = (assembly_pitch, length/2.0) lattice.universes = 2*[universes] diff --git a/tests/regression_tests/lattice_rotated/inputs_true.dat b/tests/regression_tests/lattice_rotated/inputs_true.dat index e53b93f9324..1c91e98dcfb 100644 --- a/tests/regression_tests/lattice_rotated/inputs_true.dat +++ b/tests/regression_tests/lattice_rotated/inputs_true.dat @@ -25,7 +25,7 @@ - + 1.25 30
0.0 0.0
diff --git a/tests/regression_tests/lattice_rotated/test.py b/tests/regression_tests/lattice_rotated/test.py index 63641fb84a7..c2e0b505e8b 100644 --- a/tests/regression_tests/lattice_rotated/test.py +++ b/tests/regression_tests/lattice_rotated/test.py @@ -37,6 +37,7 @@ def rotated_lattice_model(): pitch = 1.25 hexlat = openmc.HexLattice() hexlat.center = (0., 0.) + hexlat.orientation = "x" hexlat.pitch = [pitch] hexlat.outer = outer_universe outer_ring = [big_pin_universe] + [pin_universe]*11 diff --git a/tests/unit_tests/cell_instances/test_hex_multilattice.py b/tests/unit_tests/cell_instances/test_hex_multilattice.py index 3f503fe9b84..fa7452cbac3 100644 --- a/tests/unit_tests/cell_instances/test_hex_multilattice.py +++ b/tests/unit_tests/cell_instances/test_hex_multilattice.py @@ -41,7 +41,7 @@ def double_hex_lattice_model(): # create a hexagonal lattice of compacts hex_lattice = openmc.HexLattice() - hex_lattice.orientation = 'y' + hex_lattice.orientation = 'x' hex_lattice.pitch = (pin_lattice_pitch,) hex_lattice.center = (0., 0.) center = [univ] diff --git a/tests/unit_tests/test_lattice.py b/tests/unit_tests/test_lattice.py index d72d9c5c3e6..707a0196425 100644 --- a/tests/unit_tests/test_lattice.py +++ b/tests/unit_tests/test_lattice.py @@ -104,6 +104,7 @@ def hlat2(pincell1, pincell2, uo2, water, zr): pitch = 1.2 u1, u2 = pincell1, pincell2 lattice = openmc.HexLattice() + lattice.orientation = "x" lattice.center = (0., 0.) lattice.pitch = (pitch,) lattice.outer = openmc.Universe(cells=[all_zr]) @@ -135,6 +136,7 @@ def hlat3(pincell1, pincell2, uo2, water, zr): pitch = 1.2 u1, u2 = pincell1, pincell2 lattice = openmc.HexLattice() + lattice.orientation = "x" lattice.center = (0., 0., 0.) lattice.pitch = (pitch, 10.0) lattice.outer = openmc.Universe(cells=[all_zr]) @@ -202,12 +204,12 @@ 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' + hlat2.orientation = 'y' 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' + hlat2.orientation = 'x' u1, u2, u3, outer = hlat3.univs assert hlat3.get_universe((0, 0, 0)) == u2 @@ -357,9 +359,9 @@ def test_xml_hex(hlat2, hlat3): def test_show_indices(): for i in range(1, 11): - lines = openmc.HexLattice.show_indices(i).split('\n') + lines = openmc.HexLattice.show_indices(i, 'x').split('\n') assert len(lines) == 4*i - 3 - lines_x = openmc.HexLattice.show_indices(i, 'x').split('\n') + lines_x = openmc.HexLattice.show_indices(i, 'y').split('\n') assert len(lines_x) == 4*i - 3 @@ -373,6 +375,7 @@ def test_unset_universes(): lattice.create_xml_subelement(elem) hex_lattice = openmc.HexLattice() + hex_lattice.orientation = "x" hex_lattice.center = (0., 0.) hex_lattice.pitch = (1.,) with pytest.raises(ValueError):