Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions openmc/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions src/lattice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ HexLattice::HexLattice(pugi::xml_node lat_node) : Lattice {lat_node}

//==============================================================================

void HexLattice::fill_lattice_x(const vector<std::string>& univ_words)
void HexLattice::fill_lattice_y(const vector<std::string>& univ_words)
{
int input_index = 0;
for (int m = 0; m < n_axial_; m++) {
Expand Down Expand Up @@ -597,7 +597,7 @@ void HexLattice::fill_lattice_x(const vector<std::string>& univ_words)

//==============================================================================

void HexLattice::fill_lattice_y(const vector<std::string>& univ_words)
void HexLattice::fill_lattice_x(const vector<std::string>& univ_words)
{
int input_index = 0;
for (int m = 0; m < n_axial_; m++) {
Expand Down Expand Up @@ -756,7 +756,7 @@ std::pair<double, array<int, 3>> 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;
Expand Down Expand Up @@ -785,7 +785,7 @@ std::pair<double, array<int, 3>> 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;
Expand All @@ -809,7 +809,7 @@ std::pair<double, array<int, 3>> 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;
Expand All @@ -836,7 +836,7 @@ std::pair<double, array<int, 3>> 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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -983,7 +983,7 @@ int HexLattice::get_flat_index(const array<int, 3>& i_xyz) const
Position HexLattice::get_local_position(
Position r, const array<int, 3>& 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];
Expand Down
2 changes: 1 addition & 1 deletion tests/regression_tests/filter_distribcell/case-4/model.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<cell id="101" material="1" name="cell 2" region="-5" universe="1" />
<cell id="102" material="2" name="cell 3" region="5" universe="1" />
<cell id="500" material="2" name="cell 4" universe="3" />
<hex_lattice id="5" n_rings="2">
<hex_lattice id="5" n_rings="2" orientation="x">
<pitch>1.0</pitch>
<outer>3</outer>
<center>0.0 0.0</center>
Expand Down
2 changes: 1 addition & 1 deletion tests/regression_tests/lattice_hex/geometry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

<!-- Lattice 101: Fuel assembly pins -->
<cell id="100" universe="100" material="1"/>
<hex_lattice id="101" outer="100" n_rings="11" n_axial="3"
<hex_lattice id="101" outer="100" n_rings="11" orientation="x" n_axial="3"
center="0.0 0.0 0.0" pitch="1.265 1.2">
<universes>
011
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<cell id="6" name="matrix coolant surround" material="2" region="6 2 -3" universe="2"/>
<cell id="7" material="2" universe="3"/>
<cell id="8" name="container cell" fill="4" region="-7 8 -9 -12 10 11 2 -3" universe="5"/>
<hex_lattice id="4" name="regular fuel assembly" n_rings="2">
<hex_lattice id="4" name="regular fuel assembly" n_rings="2" orientation="x">
<pitch>1.4</pitch>
<outer>3</outer>
<center>0.0 0.0</center>
Expand Down
1 change: 1 addition & 0 deletions tests/regression_tests/lattice_hex_coincident/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<cell id="11" material="2" region="8" universe="3"/>
<cell id="12" material="2" universe="4"/>
<cell id="13" name="container assembly cell" fill="6" region="-11 12 -13 -16 14 15 9 -10" universe="5"/>
<hex_lattice id="6" name="regular fuel assembly" n_rings="11" orientation="x" n_axial="2">
<hex_lattice id="6" name="regular fuel assembly" n_rings="11" n_axial="2">
<pitch>1.235 5.0</pitch>
<outer>4</outer>
<center>0.0 0.0 5.0</center>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion tests/regression_tests/lattice_rotated/inputs_true.dat
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<cell id="6" fill="4" region="-3" translation="-4.0 0.0 0.0" rotation="0.0 0.0 45.0" universe="5"/>
<cell id="7" fill="3" region="-4" translation="4.0 0.0 0.0" rotation="0.0 0.0 30.0" universe="5"/>
<cell id="8" material="3" region="-5 3 4" universe="5"/>
<hex_lattice id="3" n_rings="3">
<hex_lattice id="3" n_rings="3" orientation="x">
<pitch>1.25</pitch>
<outer>30</outer>
<center>0.0 0.0</center>
Expand Down
1 change: 1 addition & 0 deletions tests/regression_tests/lattice_rotated/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/cell_instances/test_hex_multilattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
11 changes: 7 additions & 4 deletions tests/unit_tests/test_lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand All @@ -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):
Expand Down
Loading