mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-25 20:45:35 -04:00
Add support for Universe kwargs to openmc.model.pin
This commit is contained in:
parent
87fea93714
commit
0cebc507a9
2 changed files with 14 additions and 7 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue