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

Extending axial expansion classes #1920

Merged
merged 46 commits into from
Oct 29, 2024
Merged

Conversation

drewj-tp
Copy link
Contributor

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

What is the change?

A handful of improvements to allow subclasses of axial expansion things more control. A general theme was to take large methods and break them up so subclasses can override at their discretion.

Some documentation has been added to axial expansion related classes. It's by no means complete, nor to the level of #935. But as I fumbled through the code and got helped from @albeanth, I added what I could to the docstrings.
 

Why is the change being made?

I am working on features internally that need more control over performing axial expansion that require these changes.

Closes #1453

Closes #1918


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.

Use early `return` statements to dedent the function. Renamed
to `areAxiallyLinked` to be a bit more declarative, even though
this function lives in the axial expansion routine.

Add some type hints
The values in the linkage dictionaries on `AssemblyAxialLinkage` were
lists of two items where the position meant something: `0` for linked
item below the current thing, and `1` for linked item above the current
thing. Some functionality was based on `links[1] is not None` which is
not super readable unless you're familiar with what's going on.

This introduces a small data class with two attributes: `lower` and
`upper` such that `links.lower is links[0]` and `links.upper is
links[1]`. This improves readability and extensibility by making a more
explicit and declarative thing. The position-based getters and setters
are retained and tested.

The class is "templated" with a `typing.Generic[typing.TypeVar]` that
could be either `Block` or `Component`. This is because the the two
linked dictionaries on the `AssemblyAxialLinkage` class only differ
based on the types of their values. We still need to know lower/upper as
determined by the values, but for the block link dict we want blocks and
then components from the component link dict.
Also rename componentLst to components in
setExpansionFactors in an effort to remove type names from variable names
Single method that iterate over all blocks in an assembly and then
all components in each block is now broken across a per-block method
and a per-component method. This distinction will also allow subclasses
to provide specific expansion methods on a more granular level.
The getSolidComponents produces a list which may not be needed in all situations. Lots
of usage of getSolidComponents was for iteration, e.g.,
`for c in getSolidComponents(b)` where producing an iterable is sufficient.
Move docstring to class definition and outside `__init__` for
consistency.
Useful for testing what you get is what you expect. Tests added
to this effect.

Renamed an internal variable from `componentWFlag` to `candidates` because
the name implied `componentWFlag` was a single component when it was a
(potentially empty) list of components.

Finally, bring out the setting of the target component to a separate
method. This is useful for subclasses that may need custom logic to
determine their target component, but want to perform the same actions
on the setter.
Useful for subclasses to override. Calls back to existing function
for small code change.
@drewj-tp drewj-tp added the enhancement New feature or request label Sep 30, 2024
@drewj-tp drewj-tp self-assigned this Sep 30, 2024
…xial-linkage

* origin/main:
  Alphabetizing Flags.toString results (#1912)
  Organizing test settings files by category (#1914)
This implementation an O(N^2) iteration where each block also iterates over all blocks in the assembly. The use of itertools.chain and itertools.islice provide
a more efficient and streamlined iteration look.

The call signature is for a `Sequence[Block]` which could just as easily be
`Assembly`. We can't use just `Iterable[Block]` because we need to perform
multiple iterations on the object at once. And things like a generator may
get consumed part way through the iteration. And for testing, passing a list
of blocks gets the same behavior as passing one assembly.

Tests for zero blocks, one block, and multiple blocks added.
@john-science john-science marked this pull request as ready for review October 2, 2024 20:18
drewj-tp and others added 6 commits October 7, 2024 12:02
…e' into drewj/improve-assem-axial-linkage

* origin/drewj/improve-assem-axial-linkage:
  Apply suggestions from code review
Only really provided for back compatability with the existing list
API. But this is far enough down the axial expansion API, which already
has dubious widespread usage, that we're okay removing this
unceremoniously.
…xial-linkage

* origin/main:
  Adding support for ex-core structures (#1891)
  Fixing edge case in assemblyBlueprint._checkParamConsistency (#1929)
  Improving the robustness of  HexBlock._rotatePins() (#1859)
  Removing unnecessary column in print-out (#1925)
  Updating parameter-related docs (#1919)
@albeanth
Copy link
Member

albeanth commented Oct 8, 2024

@john-science this PR is apart of a larger downstream internal change, so please hold off on merging this. thank you!

john-science and others added 8 commits October 9, 2024 10:54
…xial-linkage

* origin/main:
  Relaxing copyInterfaceInputs to not require a valid Setting (#1934)
  Moving C5G7 into its own test dir (#1941)
  Transposing pinMgFluxes so that the leading dimension represents pin index (#1937)
…xial-linkage

* origin/main:
  Removing defunct comment from getPinCoordinates (#1931)
…-axial-linkage' into drewj/improve-assem-axial-linkage

* refs/remotes/origin/drewj/improve-assem-axial-linkage:
  Black
  Update armi/reactor/converters/tests/test_axialExpansionChanger.py
…xial-linkage

* origin/main:
  New plugin hook for before reactor construction (#1945)
  Removing DoseResultsMapper (#1952)
  Adding logic so HexAssemblies are hexagonal (#1935)
  Adding Block.getInputHeight (#1927)
  Removing Assembly.doubleResolution (#1951)
  Adding DeprecationWarning for HistoryTrackerInterface (#1950)
  Removing tabulate as a dependency (#1948)
…xial-linkage

* origin/main:
  Loading some ARMI DBs without the App that created them (#1917)
  Revert "Revert "Updating cluster settings (#1958)" (#1965)" (#1969)
  Allowing users to define flag names with digits (#1966)
  Revert "Updating cluster settings (#1958)" (#1965)
  Updating cluster settings (#1958)
  Reducing warnings while building the docs (#1959)
  Moving anl-afci-177 test files to their own directory (#1957)
@john-science
Copy link
Member

Holler when you guys want this merged. I see it is doubly approved.

@albeanth
Copy link
Member

Holler when you guys want this merged. I see it is doubly approved.

This is getting run on additional downstream testing. If all goes well, it should be good to go today. I'll ping you when we're ready.

* main:
  Skipping XS generation when using tight coupling (#1963)
  Renaming Database3 to Database, but preserving the API (#1961)
  Changing default of syncDbAfterWrite to True (#1968)
  Removing upper bound pin on HDF5 (#1932)
@john-science john-science changed the title Extensibility improvements to axial expansion classes Extending axial expansion classes Oct 24, 2024
@john-science
Copy link
Member

@drewj-tp I see this as approved, and we have a release coming up. Any status on when this might get merged?

@albeanth
Copy link
Member

albeanth commented Oct 24, 2024

@drewj-tp I see this as approved, and we have a release coming up. Any status on when this might get merged?

Same status as yesterday. Blocked by downstream testing going awry. @drewj-tp, @mgjarrett, and myself need to troubleshoot today.

…xial-linkage

* origin/main:
  Adding some missing nuclides to nuclides.dat (#1903)
  Improving efficiency of reaction rate calcs (#1887)
  Adding description of EOL time node in DB (#1967)
…xial-linkage

* origin/main:
  Ensuring reaction rate parameters are set after calc (#1971)
@john-science
Copy link
Member

bump

@drewj-tp
Copy link
Contributor Author

bump

I think today's the day!

* main:
  Fixing HexBlock docstrings (#1981)
  Removing a duplicate hex rotation impl tag (#1979)
  Avoiding closing plots that are meant to be interactive (#1978)
  Ensuring HexBlock.rotate updates child spatial locators (#1943)
  Add new memory runLog info to memoryProfiler.py  (#1970)
  Fixing various doc build issues (#1974)
  Hiding sphinx-needs warnings during doc build (#1973)
  Fixing warnings in CLI startup (#1972)
@john-science john-science merged commit 0a6995b into main Oct 29, 2024
19 checks passed
@john-science john-science deleted the drewj/improve-assem-axial-linkage branch October 29, 2024 17:02
drewj-tp added a commit that referenced this pull request Oct 29, 2024
* main:
  Extending axial expansion classes (#1920)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow axial expansion related classes to be more extensible Remove unnecessary spec for dummy block
3 participants