-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
Hello @ZoeRichter! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2024-05-31 19:17:59 UTC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, a few minor changes to some wording, but everything looks good!
src/didymus/reader.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a more descriptive name for this file that would work better? reader_openmc? or just readers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @nsryan2's comment. I might offer mc_reader.py
standing for monte carlo reader
which could be OpenMC or Serpent.
@ZoeRichter if you plan to have more than one reader, you could consider borrowing some of @yardasol's code in Saltproc for reading data from Serpent/OpenMC (and others?) Maybe I'm misremembering the purpose of depcode
@yardasol.
Regardless, the pattern I'm suggesting is to have a generic reader object and have the openmc or serpent specific readers inherit from it and use the super().__init__()
function (see osier.Technology
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was on the fence about this specific implementation, actually. I initially started by creating it the way you suggested - by having a parent reader that's generic, and child classes for code-specific readers. But as I was making it, I realized the ones I knew enough about to be able to implement right now didn't actually have args in common, so I made the reader(s) distinct. I think going the other way (converting didymus to a given code format) will work best in that parent-child set up, however. Do you think it would still be best to organize them under an empty parent class?
src/didymus/reader.py
Outdated
Parameters | ||
---------- | ||
coord_array : array | ||
Array of center coordinates, in x, y, and z, from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array of center coordinates, in x, y, and z, from | |
Array of center coordinates, in x, y, and z from |
src/didymus/reader.py
Outdated
---------- | ||
peb_array : array of Pebble objects | ||
Array containing a unique Pebble object for each | ||
coordinate provided in coord_array. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a little unclear here, is it an object for each x, y, z set or each x coordinate, each y coordinate, and each z coordinate? The former, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, it's a pebble object for each set of (x,y,z) coordinates in coord_array (each set corresponds to a specific pebble's center). Do you think "...for each centroid coordinate provided..." would be a better descriptor (bouncing off of Sam's suggested change in a later comment)?
I wanna take a look before this merges, if that's okay! |
Co-authored-by: Nathan Ryan <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ZoeRichter thanks for this PR! It's a nice short PR. I left a lot of suggestions and I hope you're not feeling overwhelmed. Most of them are simply stylistic preferences. I want to highlight a few key items, though:
- Choosing variable names can be more of an art than a science. Here, it seems like you default to shortening words that are already pretty short. E.g., pebble --> peb. I think this is a bit "lossy" because it's not immediately obvious what a
peb
is to the casual reader. Now, if you had a LOT of info, for example,pebble_radius_cartesian_coordinates
then maybe it would be appropriate to shortenpeb
. I digress. - I think you're going to need an init.py file as well. Especially if you start adding sub modules.
- There isn't much functionality in this PR -- GREAT! What a perfect time to add a testing suite! I recommend adding tests now so that the suite is built up incrementally and you don't get overwhelmed later when you have a lot MORE functionality to test.
I'm excited to see where this goes! Also, @yardasol I'm curious if you agree with some/any of my comments.
src/didymus/reader.py
Outdated
peb_array = [] | ||
for i, coord, in enumerate(self.coord_array): | ||
peb_array.append( | ||
peb.Pebble( | ||
coord, | ||
peb_rad, | ||
mat_ids[i], | ||
uniq_ids[i])) | ||
|
||
return peb_array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
peb_array = [] | |
for i, coord, in enumerate(self.coord_array): | |
peb_array.append( | |
peb.Pebble( | |
coord, | |
peb_rad, | |
mat_ids[i], | |
uniq_ids[i])) | |
return peb_array | |
peb_array = [Pebble(coord, pebble_radius, mat_ids[i], pebble_ids[i]) for i, coord in enumerate(self.coord_array)] | |
return pebble_array |
List comprehensions are faster. Is every pebble going to be a unique material? Should mat_ids be part of the initialization of the OpenMCReader
? It seems cumbersome (and error prone) to have users generate id's for each pebble themselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each pebble will not necessarily be a unique material, I think it's more likely that you will have large numbers of the same pebble material (such as having a unique material description for each pass the pebbles have made through the core). I don't think having a default for the uniq_ids/pebble_ids is a bad thing, though.
src/didymus/reader.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @nsryan2's comment. I might offer mc_reader.py
standing for monte carlo reader
which could be OpenMC or Serpent.
@ZoeRichter if you plan to have more than one reader, you could consider borrowing some of @yardasol's code in Saltproc for reading data from Serpent/OpenMC (and others?) Maybe I'm misremembering the purpose of depcode
@yardasol.
Regardless, the pattern I'm suggesting is to have a generic reader object and have the openmc or serpent specific readers inherit from it and use the super().__init__()
function (see osier.Technology
).
Somewhere, this got lost in the shuffle of other things I was doing, and I thought I'd handled this (I haven't). I've read over the comments, and am going to go through either adding changes or responding to comments (I just wanted to make an update). Most of the ones re: longer form names I am up for changing, at the very least. Sorry this got away from me! |
Updates docstrings, variable names, and function names, to improve clarity/readability Co-authored-by: Sam Dotson <[email protected]>
I believe I have incorporated all recommended changes, with the exception of adding the reader parent class (which I'm not strictly opposed to, I mostly want to discuss it first). All changes wrt variable and files names (such as renaming reader to mc_reader) have been committed. I'm going to re-request reviews (thank you both!). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ZoeRichter, Sorry it has taken me so long to get around to this. Great work here, I have a couple suggestions.
src/didymus/mc_reader.py
Outdated
for the centroid of a sphere, obtained from the pack_spheres() | ||
function of OpenMC, where N is the number of spheres. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the centroid of a sphere, obtained from the pack_spheres() | |
function of OpenMC, where N is the number of spheres. | |
for the centroid of a sphere, obtained from the :function:`openmc.pack_spheres()` | |
function, where N is the number of spheres. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am okay with applying this change, but I'll have to do it manually and change where the line breaks are, because the first one is 81 characters, which (I believe) breaks PEP8 (and I don't want the bot to come yell at me).
src/didymus/pebble.py
Outdated
Class for a single pebble object. Contains information | ||
necessary to determine the pebble location within the core | ||
and track its material composition and unique id number. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Class for a single pebble object. Contains information | |
necessary to determine the pebble location within the core | |
and track its material composition and unique id number. | |
Class representing a TRISO fuel pebble. Contains information | |
necessary to determine the pebble location within the core | |
and track its material composition and unique id number. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely think representing is better than for here, but (at least tentatively) there's no reason this could be used with "dummy" graphite-only spheres, so I'm hesitant to specifically call them fuel pebbles. Maybe just "Class representing a pebble"?
Applies all suggested docstring changes from Olek's review, with the exception of two suggestions that either need further discussion or a slight change (see comments under suggestions). Co-authored-by: Olek <[email protected]>
Looks like these edits have covered the remaining recommendations from the reviewers . Merging! |
This is a relatively small commit, which mainly adds the basic Pebble and OpenmcReader classes.
For now, I'm leaving the recirc parameter in the Pebble object, and setting a default value. This is likely to change later.