Skip to content
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

Adding OpenmcReader and Pebble Classes #1

Merged
merged 12 commits into from
Jun 4, 2024
3 changes: 3 additions & 0 deletions src/didymus/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@


__version__ = "0.1.0"
64 changes: 64 additions & 0 deletions src/didymus/mc_reader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# import here
import numpy as np
from didymus.pebble import Pebble


# defining code-specific readers here:
class OpenmcReader():
"""
Class for reading OpenMC pebble coordinates from the
:function:`openmc.pack_spheres()` function into an array of
distinct :class:`didymus.Pebble` objects.
"""

def __init__(self, coord_array):
'''
Initializes the OpenmcReader.

Parameters
----------
coord_array : numpy.ndarray
A 2-D numpy array with shape (N, 3) of cartesian coordinates
for the centroid of a sphere, obtained from
:function:`openmc.pack_spheres()`, where N is the number
of spheres.

'''
self.coord_array = coord_array

def generate_pebbles(self, pebble_radius, mat_ids, pebble_ids):
'''
Creates an array of :class:`didymus.Pebble` objects, using
the central coordinates in coord_array.

Parameters
----------
pebble_radius : float
Radius of a single pebble, with units matching those
used to create center coordinates. Assumes all
pebbles are the same size.
mat_ids : array of int or str
Array containing the mat_ids associated with each pebble
center. While multiple pebbles can share the same mat_id,
the length of the mat_ids array should match coord_array.
pebble_ids : array of int
Array containing the uniq_ids associated with each pebble
center. Each pebble should have a distinct pebble_id.

Returns
-------
pebble_array : list of :class:`didymus.Pebble` objects
A list of unique :class:`didymus.Pebble` objects for each
set of centroid coordinates provided in coord_array.

'''
peb_array = []
for i, coord, in enumerate(self.coord_array):
peb_array.append(
Pebble(
coord,
peb_rad,
mat_ids[i],
uniq_ids[i]))

return peb_array
35 changes: 35 additions & 0 deletions src/didymus/pebble.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# imports

class Pebble:
'''
Class representing a single pebble. Contains information
necessary to determine the pebble location within the core
and track its material composition and unique id number.
'''

def __init__(self, coords, radius, mat_id, pebble_id, recirc=False):
'''
Initializes a single instance of a Pebble object.

Parameters
----------
coords : array
Array containing the x, y, and z coordinates of the pebble.
radius : float
Radius of the pebble, with the same units as core measurements.
mat_id : int or str
User-defined integer or string for the material in the pebble,
which multiple pebble objects can share.
pebble_id : int
User-defined integer for identifying a specific pebble.
Each pebble_id should be distinct.
recirc : bool
Boolean for determining if a given pebble should recirculate,
for use in multi-pass cycles. Defaults to False.

'''
self.coords = coords
self.radius = radius
self.mat_id = mat_id
self.pebble_id = pebble_id
self.recirc = recirc