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

Use a more robust method for determining number of pins in HexBlock._rotatePins() #1859

Merged
merged 19 commits into from
Oct 4, 2024

Conversation

mgjarrett
Copy link
Contributor

@mgjarrett mgjarrett commented Sep 6, 2024

What is the change?

Use block.getNumPins() instead of counting Flags.CLAD components. Round this number up to a number of pins that fits exactly into a regular hex lattice.

Why is the change being made?

  1. Using block.getNumPins(): because counting the multiplicity of Flags.CLAD components on a block will not always be equal to the number of pins (e.g., a solid steel reflector slug)
  2. Rounding up the number of pins: If a block is missing pin locations from a full hex lattice, we should round up the number of pins. The math for mapping the indices only works if the number of pins fits exactly into a regular hex lattice (19, 37, 61, 91, etc.)

Checklist

  • The release notes have been updated if necessary.
  • The documentation is still up-to-date in the doc folder.
  • The dependencies are still up-to-date in pyproject.toml.

@mgjarrett
Copy link
Contributor Author

Note that I just realized #1846 will make rotatePins private, so if that is merged first then I would have to update the release notes, which currently mark this as being an API change.

@drewj-tp
Copy link
Contributor

drewj-tp commented Sep 6, 2024

The justCompute=True behavior is something that I think could be moved off of HexBlock.rotatePins. The place it's used in ARMI at least is just to find post-rotation location of pins to minimize burnup

indexLookup = maxBuBlock.rotatePins(possibleRotation, justCompute=True)

Which feels like overkill to emulate rotating every single pin in a block just to see where one pin would end up. So I put some of the code in armi.utils.hexagon in afd4528.

If there are other needs for justCompute=True, let me know and I can try to fold them in to #1846 or we can put them in a new ticket

@mgjarrett
Copy link
Contributor Author

Marking this as draft until #1846 is merged; this PR will be updated after that

@john-science john-science self-requested a review September 9, 2024 15:34
@john-science john-science added the feature request Smaller user request label Sep 9, 2024
@mgjarrett mgjarrett marked this pull request as draft September 9, 2024 18:43
@mgjarrett
Copy link
Contributor Author

after #1846 made _rotatePins private, it no longer makes sense to add the optional numPins argument to this function, because users won't be calling this function directly anyway.

However, I think it could still be worthwhile to make the determination of the number of pins more robust. Block has a getNumPins method that is more robust than the one-liner used.

armi/armi/reactor/blocks.py

Lines 1047 to 1079 in abd1db4

def getNumPins(self):
"""Return the number of pins in this block.
.. impl:: Get the number of pins in a block.
:id: I_ARMI_BLOCK_NPINS
:implements: R_ARMI_BLOCK_NPINS
Uses some simple criteria to infer the number of pins in the block.
For every flag in the module list :py:data:`~armi.reactor.blocks.PIN_COMPONENTS`,
loop over all components of that type in the block. If the component
is an instance of :py:class:`~armi.reactor.components.basicShapes.Circle`,
add its multiplicity to a list, and sum that list over all components
with each given flag.
After looping over all possibilities, return the maximum value returned
from the process above, or if no compatible components were found,
return zero.
"""
nPins = [
sum(
[
(
int(c.getDimension("mult"))
if isinstance(c, basicShapes.Circle)
else 0
)
for c in self.iterComponents(compType)
]
)
for compType in PIN_COMPONENTS
]
return 0 if not nPins else max(nPins)

Is there any reason not to use getNumPins here?

numPins = self.getNumComponents(Flags.CLAD)

@mgjarrett mgjarrett marked this pull request as ready for review September 13, 2024 17:16
@mgjarrett mgjarrett changed the title Update block.rotatePins() to take an optional numPins argument Use a more robust method for determining number of pins in HexBlock._rotatePins() Sep 16, 2024
doc/release/0.4.rst Outdated Show resolved Hide resolved
@drewj-tp drewj-tp self-requested a review October 2, 2024 20:29
Copy link
Contributor

@drewj-tp drewj-tp left a comment

Choose a reason for hiding this comment

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

Can you update the PR description accordingly? The Block.rotatePins method has been removed, but the PR description discusses changes to it

armi/reactor/blocks.py Outdated Show resolved Hide resolved
@john-science john-science merged commit b436537 into main Oct 4, 2024
19 checks passed
@john-science john-science deleted the rotatePins_update branch October 4, 2024 16:32
drewj-tp added a commit that referenced this pull request Oct 4, 2024
* origin/main:
  Improving the robustness of  HexBlock._rotatePins() (#1859)
  Removing unnecessary column in print-out (#1925)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Smaller user request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants