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

Add armi.reactor.compositeList.CompositeList : base class for Assemblies #1088

Conversation

drewj-usnctech
Copy link
Contributor

@drewj-usnctech drewj-usnctech commented Jan 13, 2023

Description

The intention of the abstract parent class is to shift most of the composite-tree traversal routines onto a generic parent class. It's abstract only because the Assembly does some re-naming of children during Assembly.add which subclasses might want to override. Might not be enough to justify all the metaclasses and just make that an empty method.

Later, another subclass of CompositeList could be used to model stacks of fuel pellets in a Block. But that would require many blueprint side modifications that are to be discussed.

Some assembly methods like getBlockAndZ pass directly off to the parent method to maintain the same API. Wondering if there is room to make some of these iterator-based methods a generator? But that would also be an API change and should be done after some discussions.

Added a test for getBlocksAtElevation.

Closes #1030

Checklist

  • This PR has only one purpose or idea.
  • Tests have been added/updated to verify that the new/changed code works.
  • The release notes (location doc/release/0.X.rst) are up-to-date with any bug fixes or new features.
  • The documentation is still up-to-date in the doc folder.
  • The dependencies are still up-to-date in setup.py.

spatialGrid: Optional[Grid]

def __init__(self, name):
super().__init__(name)
Copy link
Member

Choose a reason for hiding this comment

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

Style points thing.

For reasons that pre-date my involvement in this project, we have a style guide in the docs that says to not use super(), in favor of more explicit calls to the super class __init__() function.

Just to be entirely clear, we use super() all over ARMI, and no one has bothered to fix it yet. So, it's not mission-critical. But probably we should at least leave the Assembly one as-is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Roger. We will need to change the assembly __init__ to not point to Composite.__init__ instead the parent class, but I think the spirit of the request would still be preserved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do we feel about this in light of #1155?

def _renameChild(self, child: Composite, index: int):
"""Rename a child at a given index in the list"""

def calculateZCoords(self):
Copy link
Member

Choose a reason for hiding this comment

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

It would be cool if all these methods had their own unit tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Excellent request. Since the Assembly is the primary concrete subclass, and it's well tested through armi/reactor/tests/test_assemblies.py, all if not most of these methods should be tested.

The alternative approach could be to make another child subclass specific for testing the composite list methods. It would look similar to those in the assembly testing, but maybe not tied strictly to blocks? Ah but we need the children to have a getHeight method...

Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, you're counting on the Assembly subclasses unit tests. I see.

Well, in that case, your unit test coverage is pretty high for the new file (~91%).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you're alright with it, I'll extend the existing assembly tests to bump the coverage up. There's some edge cases in some pretty public methods (getChildrenAndZ -> getBlocksAndZ) that aren't touched

@john-science john-science added the feature request Smaller user request label Jan 17, 2023
@drewj-usnctech
Copy link
Contributor Author

drewj-usnctech commented Jan 17, 2023

Personal todo

  • License header
  • Changelog / release notes entry

@drewj-usnctech
Copy link
Contributor Author

@john-science other than some conflicts in the release notes, is there anything else you're looking to see?

@@ -0,0 +1,260 @@
# Copyright 2019 TerraPower, LLC
Copy link
Member

Choose a reason for hiding this comment

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

It's 2023 now!

hehe

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated copyright year

The intention of the abstract parent class is to shift most of the composite-tree
traversal routines onto a generic parent class. It's abstract only because the
Assembly does some re-naming of children during `Assembly.add` which subclasses
might want to override. Might not be enough to justify all the metaclasses and just
make that an empty method.

Later, another subclass of `CompositeList` could be used to model stacks of fuel
pellets in a ``Block``. But that would require many blueprint side modifications
that are to be discussed.

Some assembly methods like `getBlockAndZ` pass directly off to the parent method
to maintain the same API. Wondering if there is room to make some of these
iterator-based methods a generator? But that would also be an API change and should
be done after some discussions.

Added a test for getBlocksAtElevation.

Closes terrapower#1030

Signed-off-by: Andrew Johnson <a.johnson@usnc-tech.com>
@drewj-usnctech drewj-usnctech force-pushed the drewj-usnctech/1030/assembly-1d-parent-class branch from 83cbd1f to b406975 Compare February 13, 2023 16:23
@drewj-usnctech
Copy link
Contributor Author

@john-science getting back to this. Is there anything you'd want to see before calling this change acceptable?

@jakehader
Copy link
Member

@john-science getting back to this. Is there anything you'd want to see before calling this change acceptable?

@drewj-usnctech, @john-science bump!

@drewj-usnctech
Copy link
Contributor Author

Going to close this for now because it's dropped off our radar. We might re-investigate this after a few months

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.

Add a 1-D collection of composites to support assemblies and particle fuel compacts
3 participants