diff --git a/openmc/model/funcs.py b/openmc/model/funcs.py index e0aabc872..1912b4215 100644 --- a/openmc/model/funcs.py +++ b/openmc/model/funcs.py @@ -449,7 +449,7 @@ def subdivide(surfaces): def pin(surfaces, materials, subdivisions=None, divide_vols=True, - universe_id=None, name=""): + **kwargs): """Convenience function for building a fuel pin Parameters @@ -472,10 +472,9 @@ def pin(surfaces, materials, subdivisions=None, divide_vols=True, materials will also be divided by the number of divisions. Otherwise the volume of the original material will not be modified before subdivision - universe_id : None or int - Identifier for this universe - name : str - Name for this universe + kwargs: + Additional key-word arguments to be passed to + :class:`openmc.Universe`, like ``name="Fuel pin"`` Returns ------- @@ -483,6 +482,9 @@ def pin(surfaces, materials, subdivisions=None, divide_vols=True, Universe of concentric cylinders filled with the desired materials """ + if "cells" in kwargs: + raise SyntaxError( + "Cells will be set by this function, not from input arguments.") check_type("materials", materials, Iterable, Material) check_length("surfaces", surfaces, len(materials) - 1, len(materials) - 1) # Check that all surfaces are of similar orientation @@ -573,4 +575,4 @@ def pin(surfaces, materials, subdivisions=None, divide_vols=True, # Build the universe regions = subdivide(surfaces) cells = [Cell(fill=f, region=r) for r, f in zip(regions, materials)] - return Universe(universe_id=universe_id, name=name, cells=cells) + return Universe(cells=cells, **kwargs) diff --git a/tests/unit_tests/test_pin.py b/tests/unit_tests/test_pin.py index 9a4fd19c2..391ed816a 100644 --- a/tests/unit_tests/test_pin.py +++ b/tests/unit_tests/test_pin.py @@ -61,14 +61,19 @@ def test_failure(pin_mats, good_radii): with pytest.raises(TypeError, match="surfaces"): pin(surfs, pin_mats) + # Passing cells argument + with pytest.raises(SyntaxError, match="Cells"): + pin(surfs, pin_mats, cells=[]) + @pytest.mark.parametrize( "surf_type", [openmc.ZCylinder, openmc.XCylinder, openmc.YCylinder]) def test_subdivide(pin_mats, good_radii, surf_type): """Test the subdivision with various orientations""" surfs = [surf_type(r=r) for r in good_radii] - fresh = pin(surfs, pin_mats) + fresh = pin(surfs, pin_mats, name="fresh pin") assert len(fresh.cells) == len(pin_mats) + assert fresh.name == "fresh pin" # subdivide inner region N = 5