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 a check on the grid/component consistency in the blueprints #2045

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

Conversation

keckler
Copy link
Member

@keckler keckler commented Jan 4, 2025

What is the change?

Close #1400 .

This PR adds a check on the grids associated with a block to ensure that the components that are supposed to be in the grid (based on them having the latticeIDs attribute) actually are, and in the correct number.

Specifically, this PR enforces the following conditions:

  1. If a block has a grid, all latticeID values defined over all the components in that block must be present in the grid
  2. If a block has a grid, all the IDs present in that grid must appear at least once in the latticeIDs of at least one component in the block

If the conditions above are not met, it is very likely that the user has a bug in their blueprints that would otherwise be silently skipped.

Why is the change being made?

#1400 pointed out that there can be inconsistency here by pretty simple user errors. This has come up in my own work, and having ARMI be more robust to this kind of error is desirable.


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.

@keckler keckler requested a review from john-science January 4, 2025 17:19
@john-science john-science added the enhancement New feature or request label Jan 5, 2025
@john-science john-science changed the title Add a check on the grid/component consistency in the blueprints Adding a check on the grid/component consistency in the blueprints Feb 3, 2025
Co-authored-by: John Stilley <1831479+john-science@users.noreply.github.com>
@john-science john-science marked this pull request as draft February 4, 2025 21:06
@john-science john-science self-requested a review February 4, 2025 21:06
@keckler
Copy link
Member Author

keckler commented Feb 8, 2025

Running integration tests, will update when they are done.

@keckler
Copy link
Member Author

keckler commented Feb 10, 2025

The internal integration tests came back clean. I think this is ready for you to look at @john-science .

@keckler keckler marked this pull request as ready for review February 10, 2025 14:48
Copy link
Member

@john-science john-science left a comment

Choose a reason for hiding this comment

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

I only had one comment.

Comment on lines +188 to +200
idsInGrid = list(gridDesign.gridContents.values())
if componentDesign.latticeIDs:
for latticeID in componentDesign.latticeIDs:
allLatticeIds.add(str(latticeID))
# the user has given this component latticeIDs. check that
# each of the ids appears in the grid, otherwise
# their blueprints are probably wrong
if len([i for i in idsInGrid if i == str(latticeID)]) == 0:
raise ValueError(
f"latticeID {latticeID} in block blueprint '{self.name}' is expected "
"to be present in the associated block grid. "
"Check that the component's latticeIDs align with the block's grid."
)
Copy link
Member

Choose a reason for hiding this comment

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

Just a thought.

This method is suddenly quite long.

Could we move this to a private helper method that just does the error handling? What do you think?

Comment on lines +202 to +210
# for every id in grid, confirm that at least one component had it
if gridDesign:
idsInGrid = list(gridDesign.gridContents.values())
for idInGrid in idsInGrid:
if str(idInGrid) not in allLatticeIds:
raise ValueError(
f"ID {idInGrid} in grid {gridDesign.name} is not in any components of block {self.name}. "
"All IDs in the grid must appear in at least one component."
)
Copy link
Member

Choose a reason for hiding this comment

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

Just a thought.

This method is suddenly quite long.

Could we move this to a private helper method that just does the error handling? What do you think?

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.

latticeIDs and associated grids can be inconsistent
2 participants