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

Rotate more parameters in HexBlock.rotate #1877

Open
wants to merge 46 commits into
base: main
Choose a base branch
from

Conversation

drewj-tp
Copy link
Contributor

@drewj-tp drewj-tp commented Sep 13, 2024

What is the change?

Calls to HexBlock.rotate will additionally rotate parameters on the block with the ParamLocation.CHILDREN tag.

Why is the change being made?

Rotating a block previously did not update all of the relevant parameters.

Closes #1860


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.

@drewj-tp
Copy link
Contributor Author

cc @albeanth @onufer
who else should peek at this?

@drewj-tp
Copy link
Contributor Author

Tests are failing because we have a test that does HexAssembly.rotate and then does extensive testing on parameters on the hex block. These are redundant if we also have extensive testing on HexBlock.rotate.

I'm of the opinion those should be moved to the block tests. Then we just need to make sure that HexAssembly.rotate calls HexBlock.rotate

@albeanth
Copy link
Member

cc @albeanth @onufer who else should peek at this?

Maybe @alexhjames since he wrote some of the rotation stuff, I believe

@albeanth
Copy link
Member

Tests are failing because we have a test that does HexAssembly.rotate and then does extensive testing on parameters on the hex block. These are redundant if we also have extensive testing on HexBlock.rotate.

I'm of the opinion those should be moved to the block tests. Then we just need to make sure that HexAssembly.rotate calls HexBlock.rotate

I haven't look at the tests in question, but if they are repetitive and can be moved, then I think it's probably fair to do.

@onufer
Copy link
Member

onufer commented Sep 16, 2024

i agree with this. it makes no sense to rotate rates (flux/fast flux/dpa rate). When you rotate an assembly the solution changes so the rates need to be recalculated (and we do that). Integrated params (fluence, fast fluence, dpa) should be rotated and we intend to. Thanks!

@alexhjames
Copy link
Contributor

i agree with this. it makes no sense to rotate rates (flux/fast flux/dpa rate). When you rotate an assembly the solution changes so the rates need to be recalculated (and we do that). Integrated params (fluence, fast fluence, dpa) should be rotated and we intend to. Thanks!

Not sure I agree with this. The rotate method gets called both during shuffling, in which case your comment makes sense, but also during growToFullCore where it doesn't. The assemblies that are out of the first third need ALL spatially varying parameters rotated as well.

maybe we should have two methods, one for growing to full core and one for shuffling? Like a
rotate vs a reflect?

-----
Parameters marked with the ``rotatable``
:class:`~armi.reactor.parameters.parameterDefinitions.Category` will be rotated.
These parameters must adhere to one of the following rules to be rotated:
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing vector valued quantities like displacementX and displacementY where two block parameters form a vector. Alternatively, you could restructure displacementX and displacmentY to be a single parameter that follows these rules.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that was not called out in the docs. I've revamped the PR and kept the existing rotation routines (displacement, orientation) so those should be unimpacted

@drewj-tp drewj-tp mentioned this pull request Sep 17, 2024
7 tasks
@drewj-tp
Copy link
Contributor Author

Summarizing a separate chat.

During rotation from shuffling and moving assemblies, some parameters will be wrong because they don't match the state of the reactor. And that's acceptable for now.

I'll make a separate ticket to capture that

@drewj-tp
Copy link
Contributor Author

maybe we should have two methods, one for growing to full core and one for shuffling? Like a rotate vs a reflect?

If we were only rotating certain parameters during shuffling-based HexBlock.rotate and doing a lot more in growToFullCore, this could be a good strategy. My intention now is to rotate everything that looks rotatable in HexBlock.rotate so the reflect method may not be needed now.

Imagine storing neutron, gamma, and total multi-group flux per cell. That is not
something we currently do, but it's not outside the realm of something
someone might want to do. We do store multigroup flux per hex cell, but that would still be
a vector of data per cell.
This gets harder to make consise if we check 200+ entries.
So instead, the test checks
1. Are the first two rings exactly correct? Using existing helper functionality.
2. If we rotated, are all entries except the center different?
3. If we did not, or rotated a full 360 degrees, did we get the original array?
4. If we rotate again to reach the original state (e.g., 2 and then 4 rotations), do we get the original data?
Felt redundant. Rather infer the number of sites in a full
hexagonal lattice and compare against that.
@drewj-tp drewj-tp marked this pull request as ready for review September 20, 2024 18:30
@drewj-tp
Copy link
Contributor Author

okay @HunterPSmith @john-science @alexhjames @onufer this feels much better now.

Existing rotation is not touched. Duct params, orientation, and displacement should be rotated as they were before.

Any block parameter with the ParamLocation.CHILDREN will be rotated, assuming it has enough entries to fill a full hexagonal lattice. So if you have three hex rings of things, you should provide an array with 19 items.

A couple cases where this could be a problem:

  1. You have empty sites so there are no pins at certain locations.
  2. You have intermixed pin types (e.g., fuel and coolant) on different lattice sites

A concrete example of where this could be a problem would be the MHTGR 350 benchmark (#224). The assemblies have fuel compacts and coolant channels on the same hexagonal lattice. Users would have to make sure the things that are populating Block.p["linPowByPin"] and Block.p["percentBuByPin"] provide empty data the coolant sites.

If we want to remove that assumption, we need to find a way to pass through the pin positions. Maybe with the spatial grid locations? But that's not clear to me right now.

doc/release/0.4.rst Outdated Show resolved Hide resolved
@@ -2167,6 +2175,25 @@ def _rotatePins(self, rotNum, justCompute=False):

return rotateIndexLookup

def _rotatePinParameters(self, rotNum: int):
Copy link
Member

Choose a reason for hiding this comment

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

Could use a one-line comment. WE had to talk about this a lot, so there must be something interesting to say about it.

Up to you though; not a deal breaker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good with me

@john-science
Copy link
Member

Love the tests, man!

doc/release/0.4.rst Outdated Show resolved Hide resolved
armi/reactor/blocks.py Show resolved Hide resolved
@@ -2167,6 +2175,25 @@ def _rotatePins(self, rotNum, justCompute=False):

return rotateIndexLookup

def _rotatePinParameters(self, rotNum: int):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good with me

Comment on lines -58 to +72
"""
A "namespace" for storing parameter categories.

Notes
-----
* `cumulative` parameters are accumulated over many time steps
* `pinQuantities` parameters are defined on the pin level within a block
* `multiGroupQuantities` parameters have group dependence (often a 1D numpy array)
* `fluxQuantities` parameters are related to neutron or gamma flux
* `neutronics` parameters are calculated in a neutronics global flux solve
* `gamma` parameters are calculated in a fixed-source gamma solve
* `detailedAxialExpansion` parameters are marked as such so that they are mapped from the
uniform mesh back to the non-uniform mesh
* `reactivity coefficients` parameters are related to reactivity coefficient or kinetics
parameters for kinetics solutions
* `thermal hydraulics` parameters come from a thermal hydraulics physics plugin (e.g., flow
rates, temperatures, etc.)
"""
"""A "namespace" for storing parameter categories."""

depletion = "depletion"
"""Parameters used in or calculated by a depletion plugin."""
cumulative = "cumulative"
"""Parameters are accumulated over many time steps"""
cumulativeOverCycle = "cumulative over cycle"
"""Parameters that are reset at beginning of cycle and accumulated over each cycle."""
assignInBlueprints = "assign in blueprints"
"""Parameters that should be assigned in blueprints (e.g., control rod elevation)"""
retainOnReplacement = "retain on replacement"
pinQuantities = "pinQuantities"
"""Parameters are defined on the pin level within a block"""
fluxQuantities = "fluxQuantities"
"""Parameters are related to neutron or gamma flux"""
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(This came up in a chat so wanted to put my motivation here)

The change here is to make these docstrings attached to the class constants. They were already documented in the Category docstring (some of them at least) but I found two flaws

  1. They were documented in the Notes section but would make more sense to be properly documented as class attributes
  2. Attaching the docstring to the object itself means tools like python, ipython, vscode, etc. can provide context where you are about the thing you're looking at. You don't need to separately pull up the ARMI docs.

I'm not going to die on this hill if people have stronger opinions. This is just my rationale for this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rotate more parameters during HexBlock.rotate
5 participants