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 ability to create multiple groups of volumes at once #9

Merged
merged 3 commits into from
Mar 27, 2024

Conversation

eepeterson
Copy link
Contributor

This PR simply adds the capability to generate multiple groups of volumes in the DAGModel which will help facilitate material assignment and MCNP UM model conversion.

Copy link
Member

@gonuke gonuke left a comment

Choose a reason for hiding this comment

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

One comment about desired interface here.

Could also use a test.

dagmc/dagnav.py Outdated
Comment on lines 107 to 110
if isinstance(volume, Volume):
group.add_set(volume)
else:
group.add_set(self.volumes[volume])
Copy link
Member

Choose a reason for hiding this comment

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

This allows mix-and-match of volume IDs and Volume objects in a single list/dict... that could be confusing, but may it's OK?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good - I'll add a test. I wasn't sure what the more popular use-case would be (I would probably just use IDs). This would allow for both without having to explicitly validate all the entries in the dictionary. I'm happy to add more input validation or change the data that is getting passed based on people's feedback (For instance, I'm not sure if the group ID is a good idea or bad idea. i.e. would we rather autogenerate group IDs similar to the IDManager in OpenMC?)

Copy link
Member

Choose a reason for hiding this comment

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

I'm good with a mix of Volume objects and IDs. I think it's rare that a mix would be used, but if both are present the volume IDs still get validated by nature of a lookup on the DAGModel.volumes property.

I think auto-generation of Group IDs is a good idea. Maybe we can get to that soon.

Copy link
Member

@pshriwise pshriwise left a comment

Choose a reason for hiding this comment

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

A couple of thoughts on the data structure and org. Auto-generated group IDs are a good idea IMO.

dagmc/dagnav.py Show resolved Hide resolved
dagmc/dagnav.py Outdated
group_map : dict
A dictionary mapping group names to a 2-tuple of (int, list) whose
first element is the group ID and the second element is a list of
volume IDs or Volume objects in the group.
Copy link
Member

Choose a reason for hiding this comment

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

Since groups contain either surfaces or volumes in a DAGMC model, what do you think about a generic function for generating a groups of surfaces. Probably less common that it would be used compared to the volume version.. idk. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree and think the functionality to add multiple DagSets to a Group should probably live in the Group class. I just hadn't yet worked through exactly what the handles are and how to deal with that, but if you think an add_sets (rather than add_set) method or add/set_volumes/surfaces type methods would be valuable on the Group class I will go that route and use that functionality in the model level add_volume_groups method instead.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah let's start down that route, but if you hit any major road blocks don't spend too much time worrying about it at this point?

Copy link
Member

@gonuke gonuke left a comment

Choose a reason for hiding this comment

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

Thanks @eepeterson - I just have one recommendation to expand testing.

group = Group.create(self, name=group_name, group_id=group_id)

for dagset in dagsets:
if isinstance(dagset, DAGSet):
Copy link
Member

Choose a reason for hiding this comment

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

This case isn't tested. No reason to think it won't work, but may as well keep the test coverage up...

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 point - I added a case for volume and surfaces

Copy link
Member

@gonuke gonuke left a comment

Choose a reason for hiding this comment

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

Thanks @eepeterson - LGTM. I'll let @pshriwise chime in and/or merge

Copy link
Member

@pshriwise pshriwise left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks @eepeterson.

@pshriwise pshriwise merged commit 0227df6 into svalinn:main Mar 27, 2024
1 check passed
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.

3 participants