@@ -70,30 +70,6 @@ def model(request):
7070 openmc .reset_auto_ids ()
7171
7272
73- def test_dagmc_replace_material_assignment (model ):
74- mats = {}
75-
76- mats ["foo" ] = openmc .Material (name = "foo" )
77- mats ["foo" ].add_nuclide ("H1" , 2.0 )
78- mats ["foo" ].add_element ("O" , 1.0 )
79- mats ["foo" ].set_density ("g/cm3" , 1.0 )
80- mats ["foo" ].add_s_alpha_beta ("c_H_in_H2O" )
81-
82- for univ in model .geometry .get_all_universes ().values ():
83- if not isinstance (univ , openmc .DAGMCUniverse ):
84- break
85-
86- cells_with_41 = []
87- for cell in univ .cells .values ():
88- if cell .fill is None :
89- continue
90- if cell .fill .name == "41" :
91- cells_with_41 .append (cell .id )
92- univ .replace_material_assignment ("41" , mats ["foo" ])
93- for cell_id in cells_with_41 :
94- assert univ .cells [cell_id ].fill == mats ["foo" ]
95-
96-
9773def test_dagmc_sync_cell_names (model ):
9874 dag_univ = None
9975 for univ in model .geometry .get_all_universes ().values ():
@@ -190,57 +166,20 @@ def test_model_differentiate_with_dagmc(model):
190166 assert len (model .materials ) == 4 * 2 + 4
191167
192168
193- def test_bad_override_cell_id (model ):
194- for univ in model .geometry .get_all_universes ().values ():
195- if isinstance (univ , openmc .DAGMCUniverse ):
196- break
197- with pytest .raises (ValueError , match = "Cell ID '1' not found in DAGMC universe" ):
198- univ .material_overrides = {1 : model .materials [0 ]}
199-
200-
201- def test_bad_override_type (model ):
202- not_a_dag_cell = openmc .Cell ()
203- for univ in model .geometry .get_all_universes ().values ():
204- if isinstance (univ , openmc .DAGMCUniverse ):
205- break
206- with pytest .raises (ValueError , match = "Unrecognized key type. Must be an integer or openmc.DAGMCCell object" ):
207- univ .material_overrides = {not_a_dag_cell : model .materials [0 ]}
208-
209-
210- def test_bad_replacement_mat_name (model ):
211- for univ in model .geometry .get_all_universes ().values ():
212- if isinstance (univ , openmc .DAGMCUniverse ):
213- break
214- with pytest .raises (ValueError , match = "No material with name 'not_a_mat' found in the DAGMC universe" ):
215- univ .replace_material_assignment ("not_a_mat" , model .materials [0 ])
216-
217-
218169def test_dagmc_xml (model ):
219- # Set the environment
220- mats = {}
221- mats ["no-void fuel" ] = openmc .Material (1 , name = "no-void fuel" )
222- mats ["no-void fuel" ].add_nuclide ("U235" , 0.03 )
223- mats ["no-void fuel" ].add_nuclide ("U238" , 0.97 )
224- mats ["no-void fuel" ].add_nuclide ("O16" , 2.0 )
225- mats ["no-void fuel" ].set_density ("g/cm3" , 10.0 )
226-
227- mats [5 ] = openmc .Material (name = "41" )
228- mats [5 ].add_nuclide ("H1" , 2.0 )
229- mats [5 ].add_element ("O" , 1.0 )
230- mats [5 ].set_density ("g/cm3" , 1.0 )
231- mats [5 ].add_s_alpha_beta ("c_H_in_H2O" )
170+ override_mat = openmc .Material (name = "41" )
171+ override_mat .add_nuclide ("H1" , 2.0 )
172+ override_mat .add_element ("O" , 1.0 )
173+ override_mat .set_density ("g/cm3" , 1.0 )
174+ override_mat .add_s_alpha_beta ("c_H_in_H2O" )
175+ model .materials .append (override_mat )
232176
233177 for univ in model .geometry .get_all_universes ().values ():
234178 if isinstance (univ , openmc .DAGMCUniverse ):
235179 dag_univ = univ
236180 break
237181
238- for k , v in mats .items ():
239- if isinstance (k , int ):
240- dag_univ .add_material_override (k , v )
241- model .materials .append (v )
242- elif isinstance (k , str ):
243- dag_univ .replace_material_assignment (k , v )
182+ dag_univ .add_material_override (5 , override_mat )
244183
245184 # Tesing the XML subelement generation
246185 root = ET .Element ('dagmc_universe' )
@@ -304,7 +243,7 @@ def test_dagmc_xml_reject_fill_override():
304243 '<cell id="1" fill="2"/>'
305244 '</dagmc_universe>'
306245 )
307- with pytest .raises (ValueError , match = "only support material fills " ):
246+ with pytest .raises (ValueError , match = "cannot specify 'fill' " ):
308247 openmc .DAGMCUniverse .from_xml_element (elem , mats )
309248
310249
@@ -315,7 +254,7 @@ def test_dagmc_xml_reject_region_override():
315254 '<cell id="1" material="1" region="-1"/>'
316255 '</dagmc_universe>'
317256 )
318- with pytest .raises (ValueError , match = "cannot include a region" ):
257+ with pytest .raises (ValueError , match = "cannot specify ' region' " ):
319258 openmc .DAGMCUniverse .from_xml_element (elem , mats )
320259
321260
@@ -413,14 +352,14 @@ def test_dagmc_xml_temperature_roundtrip():
413352
414353 dag_univ = openmc .DAGMCUniverse .from_xml_element (elem , mats )
415354 assert dag_univ .cells [7 ].fill .id == 1
416- assert dag_univ .cells [7 ].temperature == pytest .approx (825.0 )
355+ assert dag_univ .cells [7 ].temperature == pytest .approx ([ 825.0 ] )
417356
418357 root = ET .Element ('geometry' )
419358 dag_univ .create_xml_subelement (root )
420359 dagmc_elem = root .find ('dagmc_universe' )
421360 xml_cell = dagmc_elem .find ('cell' )
422- assert xml_cell .get ('temperature' ) == '825.0'
361+ assert xml_cell .find ('temperature' ). text == '825.0'
423362
424363 dag_univ_roundtrip = openmc .DAGMCUniverse .from_xml_element (dagmc_elem , mats )
425364 assert dag_univ_roundtrip .cells [7 ].fill .id == 1
426- assert dag_univ_roundtrip .cells [7 ].temperature == pytest .approx (825.0 )
365+ assert dag_univ_roundtrip .cells [7 ].temperature == pytest .approx ([ 825.0 ] )
0 commit comments