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
Merged

Conversation

ZoeRichter
Copy link
Collaborator

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.

@pep8speaks
Copy link

pep8speaks commented Feb 21, 2024

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

Copy link
Member

@nsryan2 nsryan2 left a 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!

Copy link
Member

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?

Copy link
Contributor

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).

Copy link
Collaborator Author

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?

Parameters
----------
coord_array : array
Array of center coordinates, in x, y, and z, from
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Array of center coordinates, in x, y, and z, from
Array of center coordinates, in x, y, and z from

----------
peb_array : array of Pebble objects
Array containing a unique Pebble object for each
coordinate provided in coord_array.
Copy link
Member

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?

Copy link
Collaborator Author

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)?

@samgdotson
Copy link
Contributor

I wanna take a look before this merges, if that's okay!

Co-authored-by: Nathan Ryan <[email protected]>
Copy link
Contributor

@samgdotson samgdotson left a 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:

  1. 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 shorten peb. I digress.
  2. I think you're going to need an init.py file as well. Especially if you start adding sub modules.
  3. 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.

Comment on lines 53 to 62
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Collaborator Author

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.

Copy link
Contributor

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).

@samgdotson samgdotson requested a review from nsryan2 February 21, 2024 21:25
@ZoeRichter
Copy link
Collaborator Author

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!

ZoeRichter and others added 3 commits May 6, 2024 13:13
Updates docstrings, variable names, and function names, to improve clarity/readability

Co-authored-by: Sam Dotson <[email protected]>
@ZoeRichter
Copy link
Collaborator Author

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!).

@ZoeRichter ZoeRichter requested a review from samgdotson May 13, 2024 18:57
Copy link
Contributor

@yardasol yardasol left a 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.

Comment on lines 22 to 23
for the centroid of a sphere, obtained from the pack_spheres()
function of OpenMC, where N is the number of spheres.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Collaborator Author

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).

Comment on lines 5 to 7
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Collaborator Author

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]>
@katyhuff katyhuff added Comp:Core This issue has to do with the main bulk of the code or document. (methods, main content) Priority:3-Desired This work is important, but not urgent. Status:5-In Review This issue has been handled, and the solution is being reviewed. (probably as a PR) Type:Feature New feature or feature request labels May 31, 2024
@katyhuff katyhuff added this to the Establish Code Structure milestone May 31, 2024
@katyhuff
Copy link
Member

katyhuff commented Jun 4, 2024

Looks like these edits have covered the remaining recommendations from the reviewers . Merging!

@katyhuff katyhuff merged commit 2f6adf3 into arfc:main Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Comp:Core This issue has to do with the main bulk of the code or document. (methods, main content) Priority:3-Desired This work is important, but not urgent. Status:5-In Review This issue has been handled, and the solution is being reviewed. (probably as a PR) Type:Feature New feature or feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants