Skip to content

Commit 49ac308

Browse files
pshriwiseclaude
andcommitted
Remove deprecated material_overrides property and related methods
Removes DAGMCUniverse.material_overrides (getter/setter), replace_material_assignment, _get_cell_material_overrides, and the associated _material_overrides internal attribute. Cell material assignments are now managed directly via DAGMCCell objects. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d64f26b commit 49ac308

1 file changed

Lines changed: 1 addition & 83 deletions

File tree

openmc/dagmc.py

Lines changed: 1 addition & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ class DAGMCUniverse(openmc.UniverseBase):
3636
auto_mat_ids : bool
3737
Set IDs automatically on initialization (True) or report overlaps in ID
3838
space between OpenMC and UWUW materials (False)
39-
material_overrides : dict, optional
40-
A dictionary of material overrides. Keys are cell IDs (or
41-
:class:`openmc.DAGMCCell` objects), and values are
42-
:class:`openmc.Material` objects or iterables of
43-
:class:`openmc.Material` objects.
44-
4539
Attributes
4640
----------
4741
id : int
@@ -78,32 +72,19 @@ class DAGMCUniverse(openmc.UniverseBase):
7872
The number of surfaces in the model.
7973
8074
.. versionadded:: 0.13.2
81-
material_overrides : dict
82-
A dictionary of material overrides. Keys are cell IDs; values are
83-
iterables of :class:`openmc.Material` objects. The material assignment
84-
of each DAGMC cell ID key will be replaced with the
85-
:class:`~openmc.Material` object in the value. If the value contains
86-
multiple :class:`~openmc.Material` objects, each Material in the list
87-
will be assigned to the corresponding instance of the cell.
88-
89-
.. versionadded:: 0.15.1
9075
"""
9176

9277
def __init__(self,
9378
filename: cv.PathLike,
9479
universe_id=None,
9580
name='',
9681
auto_geom_ids=False,
97-
auto_mat_ids=False,
98-
material_overrides=None):
82+
auto_mat_ids=False):
9983
super().__init__(universe_id, name)
10084
# Initialize class attributes
10185
self.filename = filename
10286
self.auto_geom_ids = auto_geom_ids
10387
self.auto_mat_ids = auto_mat_ids
104-
self._material_overrides = {}
105-
if material_overrides is not None:
106-
self.material_overrides = material_overrides
10788

10889
def __repr__(self):
10990
string = super().__repr__()
@@ -128,52 +109,6 @@ def filename(self, val: cv.PathLike):
128109
cv.check_type('DAGMC filename', val, cv.PathLike)
129110
self._filename = input_path(val)
130111

131-
@property
132-
def material_overrides(self):
133-
if self.cells:
134-
return self._get_cell_material_overrides()
135-
return self._material_overrides
136-
137-
@material_overrides.setter
138-
def material_overrides(self, val):
139-
cv.check_type('material overrides', val, Mapping)
140-
for key, value in val.items():
141-
self.add_material_override(key, value)
142-
143-
def replace_material_assignment(self, material_name: str, material: openmc.Material):
144-
"""Replace a material assignment within the DAGMC universe.
145-
146-
Replace the material assignment of all cells filled with a material in
147-
the DAGMC universe. The universe must be synchronized in an initialized
148-
Model (see :meth:`~openmc.DAGMCUniverse.sync_dagmc_cells`) before
149-
calling this method.
150-
151-
.. versionadded:: 0.15.1
152-
153-
Parameters
154-
----------
155-
material_name : str
156-
Material name to replace
157-
material : openmc.Material
158-
Material to replace the material_name with
159-
160-
"""
161-
if material_name not in self.material_names:
162-
raise ValueError(
163-
f"No material with name '{material_name}' found in the DAGMC universe")
164-
165-
if not self.cells:
166-
raise RuntimeError("This DAGMC universe has not been synchronized "
167-
"on an initialized Model.")
168-
169-
for cell in self.cells.values():
170-
if cell.fill is None:
171-
continue
172-
if isinstance(cell.fill, openmc.Iterable):
173-
cell.fill = list(map(lambda x: material if x.name == material_name else x, cell.fill))
174-
else:
175-
cell.fill = material if cell.fill.name == material_name else cell.fill
176-
177112
def add_material_override(self, key, overrides=None):
178113
"""Add a material override to the universe.
179114
@@ -203,7 +138,6 @@ def add_material_override(self, key, overrides=None):
203138
if key not in self.cells:
204139
raise ValueError(f"Cell ID '{key}' not found in DAGMC universe")
205140

206-
self._material_overrides[key] = list(overrides)
207141
if len(overrides) == 1:
208142
self.cells[key].fill = overrides[0]
209143
else:
@@ -287,21 +221,6 @@ def n_cells(self):
287221
def n_surfaces(self):
288222
return self._n_geom_elements('surface')
289223

290-
def _get_cell_material_overrides(self):
291-
overrides = {}
292-
for cell in self.cells.values():
293-
if cell.fill_type == 'material':
294-
overrides[cell.id] = [cell.fill]
295-
elif cell.fill_type == 'distribmat':
296-
overrides[cell.id] = list(cell.fill)
297-
elif cell.fill_type == 'void':
298-
overrides[cell.id] = [None]
299-
else:
300-
raise ValueError(
301-
"Only material fills are supported for DAGMC cell "
302-
"overrides.")
303-
return overrides
304-
305224
def create_xml_subelement(self, xml_element, memo=None):
306225
if memo is None:
307226
memo = set()
@@ -323,7 +242,6 @@ def create_xml_subelement(self, xml_element, memo=None):
323242
dagmc_element.set('auto_mat_ids', 'true')
324243
dagmc_element.set('filename', str(self.filename))
325244
if self.cells:
326-
self._material_overrides = self._get_cell_material_overrides()
327245
for cell in self.cells.values():
328246
cell_element = cell.create_xml_subelement(xml_element, memo)
329247
dagmc_element.append(cell_element)

0 commit comments

Comments
 (0)