Skip to content

StackLattice implementation #2021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 71 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
d2bb247
initialize NonuniformStackLattice
yardasol Apr 1, 2022
67dca47
consistency changes in python api
yardasol Apr 1, 2022
228359a
initialize C++ stacklattice implementation
yardasol Apr 1, 2022
0eb4af5
wrote switch case for NonuniformStackLattice
yardasol Apr 1, 2022
3cf6fa7
implemented initialization funcs for NonuniformStackLattice
yardasol Apr 1, 2022
d558686
generalize NonuniformStackLattice to StackLattice in Python API
yardasol Apr 1, 2022
e3df97b
generalize what is implemnted so far on C++ side for StackLattice
yardasol Apr 1, 2022
67d253d
Added base_coordinate attribute
yardasol Apr 5, 2022
a20e4c9
ditto for C++ side
yardasol Apr 5, 2022
5b20824
advance C++ implementation
yardasol Apr 5, 2022
49d580d
remove cruft private functions
yardasol Apr 5, 2022
2a576a3
Add 1D lattice support in the Lattice clasS
yardasol Apr 5, 2022
19f9178
make behavior of pitch match the docstring
yardasol Apr 5, 2022
9d1da81
Added unit tests
yardasol Apr 5, 2022
751ba86
typo fix
yardasol Apr 5, 2022
c8f028e
add comments to mark functions that need work still
yardasol Apr 5, 2022
5afaef1
typo fixes
yardasol Apr 5, 2022
2355c00
syntax fixes
yardasol Apr 5, 2022
b1d322b
inital implementation of StackLattice::distance
yardasol Apr 5, 2022
d06814a
inital implementation of StackLattice::get_indices
yardasol Apr 5, 2022
bb0511a
remove cruft from StackLattice::distance
yardasol Apr 5, 2022
0d86333
fix implementation of StackLattice::find_element in lattice.py
yardasol Apr 5, 2022
9672384
fix implmenetation of StackLattice::get_indices in lattice.cpp
yardasol Apr 5, 2022
2607105
fix implementation of get_local_position, get_flat_index for StackLat…
yardasol Apr 5, 2022
5dedc60
implemented to_hdf5_inner, one of the offset funcs in StackLattice
yardasol Apr 5, 2022
63a639f
implement the 2nd offset func in StackLattice
yardasol Apr 5, 2022
cefd807
fixing compilation bugs 1
yardasol Apr 5, 2022
c0776ef
compile error fix 2
yardasol Apr 5, 2022
b3de134
added StackLattice to python api docs
yardasol Apr 5, 2022
209e2f7
Merge branch 'develop' into stack-lattice
yardasol Apr 5, 2022
c5d76c2
Added section on stack lattices to user guide
yardasol Apr 5, 2022
f6b992f
Merge branch 'stack-lattice' of github.com:yardasol/openmc into stack…
yardasol Apr 5, 2022
2497a9c
typo fixes in docstrings, docs, comments, and code
yardasol Apr 6, 2022
f4ed59b
change name of internal variable; levels->layers
yardasol Apr 7, 2022
be729cb
fix variable type
yardasol Apr 7, 2022
3697df9
fix typos and unit tests
yardasol Apr 7, 2022
43203dc
initial attempt at regression test for stacklattice
yardasol Apr 7, 2022
a4c0a2d
fix third case in determing layer index of particle
yardasol Apr 7, 2022
46df94e
hdf5 and xml related bug fixes
yardasol Apr 7, 2022
37b0d6f
clean up distance function
yardasol Apr 8, 2022
5c0a489
lattice_stack -> lattice_stack_uniform
yardasol Apr 8, 2022
2e6655f
remove some cruftfrom stacklattice implementation
yardasol Apr 8, 2022
2f2a3f5
don't divide distance by u_c
yardasol Apr 9, 2022
f16e8d3
Revert "don't divide distance by u_c"
yardasol Apr 9, 2022
c369b43
typo fix
yardasol Apr 9, 2022
8440068
fix initialization of layer_boundaries_
yardasol Apr 9, 2022
f3d4252
fix particles getting lost after crossing lattice; dataset->string fo…
yardasol Apr 10, 2022
3b81dac
finish regression test for uniform stack lattice
yardasol Apr 10, 2022
2f567ba
fix minor io bugs
yardasol Apr 10, 2022
c37b571
start regressiont test for nonuniform stack lattice
yardasol Apr 10, 2022
0af3476
add nonuniformity to the geometry
yardasol Apr 11, 2022
ead0fc7
add upper bound on pitch length
yardasol Apr 11, 2022
1a8122e
fix stacklattice printing formatting
yardasol Apr 11, 2022
4ddad83
typo fixes in test.py
yardasol Apr 11, 2022
85239b6
update the nonuniform test
yardasol Apr 11, 2022
ebb8a56
add in needed self keyword
yardasol Apr 11, 2022
d2245af
fix nonuniform lattice plotting on python side
yardasol Apr 18, 2022
2bff4cc
fix pitch type checking
yardasol Apr 18, 2022
35792ed
add notebooks for testing
yardasol Apr 18, 2022
6789365
fix python notebook lattice plotting; fix command line plotting and p…
yardasol Apr 20, 2022
5ad407d
fix hdf5 writing of boolean; update regression tests
yardasol Apr 21, 2022
68d0f56
remove cruft files
yardasol Apr 21, 2022
c606ecc
update stack lattice section in user guide
yardasol Apr 21, 2022
dcf8854
testing notebooks
yardasol Apr 21, 2022
e777294
fix inputs_true.dat for uniform regression test
yardasol Apr 21, 2022
bc1df00
fix stack lattice regression tests
yardasol Apr 21, 2022
4470d32
Added __init.py__ files to regression tests
yardasol Apr 21, 2022
0943849
formatting fixes
yardasol Apr 21, 2022
4809238
remove testing notebooks:
yardasol Apr 21, 2022
30553c2
Add section on stack lattice indexing to theory manual
yardasol Apr 21, 2022
c50b458
fix lattice unit tests
yardasol Apr 21, 2022
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
253 changes: 253 additions & 0 deletions docs/source/_images/stack_lat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions docs/source/methods/geometry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,45 @@ volumetric units of the lattice will be referred to as "tiles". Tiles are
identified by thier indices, and the process of discovering which tile contains
the particle is referred to as "indexing".

Stack Lattice Indexing
----------------------

Indices are assigned to tiles in a stack lattice based on the tile's
position along the axis of orientation (the :math:`x`, :math:`y`, or
:math:`z` axis). Figure :num:`fig-stack-lat` maps the indices for a
stack lattice. The index, (1), maps to the bottom tile. (5) maps to
the top tile.


.. _fig-stack-lat:

.. figure:: ../_images/stack_lat.svg
:align: center
:figclass: align-center
:width: 400px

Stack lattice tile indices.

In general, a lattice tile is specified by the single index,
:math:`(i)`. If a particle's current coordinates are :math:`(x, y, z)`
and the lattice is oriented in the :math:`z` direction, then the index
of a tile in a uniform stack lattice can be determined from this formula:

.. math::
:label: stack_indexing

i = \left \lfloor \frac{z - z_0}{p} \right \rfloor

where :math:`(z_0)` is the coordinate to the base of the lattice, and
:math:`p` is the pitch along the :math:`z` axis. Similar equations govern
uniform stack lattices aligned with the :math:`x` and :math:`y` axes.


The index of a tile in a nonuniform stack lattice (i.e. a stack lattice where
tiles have differing dimensions) does not have a closed-form equation. It can
only be found numerically.


Rectilinear Lattice Indexing
----------------------------

Expand Down
1 change: 1 addition & 0 deletions docs/source/pythonapi/base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Building geometry
openmc.DAGMCUniverse
openmc.RectLattice
openmc.HexLattice
openmc.StackLattice
openmc.Geometry

Many of the above classes are derived from several abstract classes:
Expand Down
25 changes: 25 additions & 0 deletions docs/source/usersguide/geometry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ regular pattern such as a rectangular or hexagonal lattice. In such a case, it
would be cumbersome to have to define the boundaries of each of the cells to be
filled with a universe. OpenMC provides a means to define lattice structures
through the :class:`openmc.RectLattice` and :class:`openmc.HexLattice` classes.
Sometimes a model will have a repeated structure in only one dimension. OpenMC
provides a means to define such structures through the
:class:`openmc.StackLattice` class.

Rectangular Lattices
--------------------
Expand Down Expand Up @@ -412,6 +415,28 @@ code would work::
If you need to create a hexagonal boundary (composed of six planar surfaces) for
a hexagonal lattice, :func:`openmc.model.hexagonal_prism` can be used.

Stack Lattices
--------------
A stack lattice defines a one-dimensional array of universes that are filled into stacked layers (lattice elements). These layers can be of uniform or nonuniform thickness. Creating a stack lattice is similar to creating a rectangular lattice with a few differences:

The position of the central axis and coordinate of the base level of the stack
in must be specified (:attr:`StackLattice.central_axis` and
:attr:`StackLattice.base_coordinate`, respectively). Additionally,
:attr:`universes` must be set before :attr:`pitch`. For nonuniform lattices, the :attr:`is_uniform` attribute must be set to ``False`` before setting :attr:`pitch`.

For a uniform stack lattice, a single value for the pitch should be specified.
It should not be a list. For a nonuniform stack lattice, an iterable of values
should be given. The length of this iterable should match the length of
:attr:`StackLattice.universes`.

The lattice orientation is by default in the :math:`z`-direction, but this can
be changed using the :attr:`StackLattice.orientation` attribute to :attr:`x` or
:attr:`y`. :attr:`StackLattice.central_axis` assumes that the coordinates are
in the :math:`(x,y)`, :math:`(x,z)`, or :math:`(y,z)` basis for
:attr:`orientation` of :attr:`z`, :attr:`y`, or :attr:`x`, respectively.



.. _usersguide_geom_export:

--------------------------
Expand Down
3 changes: 3 additions & 0 deletions include/openmc/hdf5_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ inline hid_t create_group(hid_t parent_id, const std::stringstream& name)

hid_t file_open(const std::string& filename, char mode, bool parallel = false);
hid_t open_group(hid_t group_id, const std::string& name);
void write_bool(hid_t group_id, const char* name, bool b, bool indep);
void write_string(
hid_t group_id, const char* name, const std::string& buffer, bool indep);

Expand Down Expand Up @@ -109,6 +110,8 @@ void write_double(hid_t group_id, int ndim, const hsize_t* dims,
const char* name, const double* buffer, bool indep);
void write_int(hid_t group_id, int ndim, const hsize_t* dims, const char* name,
const int* buffer, bool indep);
void write_bool(hid_t group_id, int ndim, const hsize_t* dims, const char* name,
const hbool_t* buffer, bool indep);
void write_llong(hid_t group_id, int ndim, const hsize_t* dims,
const char* name, const long long* buffer, bool indep);
void write_string(hid_t group_id, int ndim, const hsize_t* dims, size_t slen,
Expand Down
Loading