-
Notifications
You must be signed in to change notification settings - Fork 498
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
Differentiate materials in DAGMC universes #3056
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an easy task @bam241 and I think I see where you're going with it. My main concern with the current implementation is the amount of DAGMC-specific code in higher-level sections of the Python API. I think there's some refactoring we can do to avoid special logic in the Model
and (maybe) Geometry
classes.
I'd say this is optional for this PR, but now that we have additional DAGMC*
classes appearing I wonder if it would be best to move them all into a dagmc.py
file in the Python API. I thought doing this in the C++ code was nice as DAGMC constructs have their own special logic to some degree. It would reduce the size of our cell.py
and universe.py
files as well. I can tackle that afte we finish this PR though. Making an issue to track...
…benefit from them
@pshriwise I think I have addressed all your comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good @bam241! We're getting into the nit-picky phase now.
There are one or two sections that are DAGMC-specific in model.py
and I wonder if we can figure out a way to build those into the DAGMC classes. I'll think on it some more, but then it'll fit in pretty seamlessly with native geometry in OpenMC.
@@ -252,12 +252,12 @@ void Cell::to_hdf5(hid_t cell_group) const | |||
// default constructor | |||
CSGCell::CSGCell() | |||
{ | |||
geom_type_ = GeometryType::CSG; | |||
geom_type() = GeometryType::CSG; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a couple usages of geom_type_
directly in particle.cpp
(and perhaps elsewhere). Can you update those lines as well please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed all geom_type_
call to geom_type()
changed suface.h
accordingly
f"Material name '{mat_name}' not found in DAGMC file") | ||
cv.check_iterable_type('material objects', overrides, str) | ||
|
||
self.material_overrides[mat_name] = overrides |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this support a single override as well as a list? Might be convenient to support that if one wants to override a material for all of the cell instances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should allow to override per cell_id and material name
openmc/dagmc.py
Outdated
None | ||
""" | ||
for cell in self.cells.values(): | ||
if cell.n_instances > 1 and isinstance(cell.fill, Iterable): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this is restriced to cells with more than one instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
your comment made me thinking :)
You are right, if cell.fill
is an Iterable
then cell.n_instances
has to have more than one instance.
I though about the eventuallity to remove restrictions on Iterable
,(and cell.n_instance
), but as all DAGMCcells, when sync get their fill
property that would me filling the override materials dict with all the fill of all DAGMCcells overridden or not.
@pshriwise I think I addressed your last round of comments. As I moved the DAGMCUniverse from I would suggest extra caution when reviewing those part, in case I missed any (I have been careful... but I might have missed something) and would ask for as much swiftness as we can have to conclude this (without impacting the quality) to avoid any additional complicated conflict :) |
@pshriwise here is an other illustration of the CI inconsistance: I have a PR with this branch on my fork, the |
openmc/lib/__init__.py
Outdated
@@ -68,6 +68,7 @@ def _uwuw_enabled(): | |||
from .math import * | |||
from .plot import * | |||
from .weight_windows import * | |||
from .dagmc import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's either import the required function names directly or include an __all__
paramter in dagmc.py
to prevent symbol/name pollution from the wildcard import here.
@@ -211,15 +230,44 @@ void DAGUniverse::init_geometry() | |||
if (mat_str == "graveyard") { | |||
graveyard = vol_handle; | |||
} | |||
|
|||
// material void checks | |||
if (mat_str == "void" || mat_str == "vacuum" || mat_str == "graveyard") { | |||
c->material_.push_back(MATERIAL_VOID); | |||
} else { | |||
if (uses_uwuw()) { | |||
uwuw_assign_material(vol_handle, c); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we want the overrides to work when UWUW materials are present? I think that we'd want them to override UWUW material assignments as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did something about this:
- first check if override is path by cell ID,
- then check if uwuw is used to recover the material name (as override key),
- finally use the mat_str as override key
in all 3 cases, use to legacy assignment to override mat assignment.
tests/unit_tests/dagmc/test_model.py
Outdated
mats["Water"].add_s_alpha_beta("c_H_in_H2O") | ||
mats["Water"].name = "Water" | ||
|
||
p = pkg_resources.resource_filename(__name__, "dagmc_differentiate_mat.h5m") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the interest of minimizing the number of binary files in the repo and it's overall size, would one of the other existing DAGMC files in the regression tests work for this test instead?
*n = dag_cell_ids.size(); | ||
} | ||
|
||
extern "C" int openmc_dagmc_universe_get_num_cells(int32_t univ_id, size_t* n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll want all of these functions to return proper error codes to satisfy the C interface.
Another set of comments for you @bam241. Sorry if they're a little hard to track -- should've done a proper review. This is looking quite good! Just a few spots to polish up and I think it'll be ready |
@pshriwise I added an other test, to check more extensively what is done, I can probably factorise some code between the 2 tests, will do today or tomorrow. Not that I had to remove the test that checked that the number of instance of the cells matched the number of instance of the override when applying the material assignment override in |
I also, make an addition split method, to allow splitting based on an arbitrary |
Description
This allows to differentiate materials in DAGMC universe when using the same DAGMC geometry to fill different CG cells
This provides a mechanism to overload material assignment embedded in the DAGMC geometry by providing a dict
{ref_mat_name:[mat_instances]}
This allows enrich the
Model.differentiate_depletable_material()
method from the Python API, to allows automatic differentiation of the depletable materials of a DAGMC geometry inserted multiple times.Checklist
this should address #2923
This work has been sponsored by NAAREA.