Merge pull request #2233 from shimwell/adding_from_domain_to_CylindricalMesh

added from domain to CylindricalMesh
This commit is contained in:
Paul Romano 2022-10-06 09:36:32 -05:00 committed by GitHub
commit 47ff27e77f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 114 additions and 8 deletions

View file

@ -16,6 +16,22 @@ def test_reg_mesh_from_cell():
assert np.array_equal(mesh.upper_right, cell.bounding_box[1])
def test_cylindrical_mesh_from_cell():
"""Tests a CylindricalMesh can be made from a Cell and the specified
dimensions are propagated through. Cell is not centralized"""
cy_surface = openmc.ZCylinder(r=50)
z_surface_1 = openmc.ZPlane(z0=30)
z_surface_2 = openmc.ZPlane(z0=0)
cell = openmc.Cell(region=-cy_surface & -z_surface_1 & +z_surface_2)
mesh = openmc.CylindricalMesh.from_domain(cell, dimension=[2, 4, 3])
assert isinstance(mesh, openmc.CylindricalMesh)
assert np.array_equal(mesh.dimension, (2, 4, 3))
assert np.array_equal(mesh.r_grid, [0., 25., 50.])
assert np.array_equal(mesh.phi_grid, [0., 0.5*np.pi, np.pi, 1.5*np.pi, 2.*np.pi])
assert np.array_equal(mesh.z_grid, [0., 10., 20., 30.])
def test_reg_mesh_from_region():
"""Tests a RegularMesh can be made from a Region and the default dimensions
are propagated through. Region is not centralized"""
@ -24,28 +40,48 @@ def test_reg_mesh_from_region():
mesh = openmc.RegularMesh.from_domain(region)
assert isinstance(mesh, openmc.RegularMesh)
assert np.array_equal(mesh.dimension, (100, 100, 100)) # default values
assert np.array_equal(mesh.dimension, (10, 10, 10)) # default values
assert np.array_equal(mesh.lower_left, region.bounding_box[0])
assert np.array_equal(mesh.upper_right, region.bounding_box[1])
def test_cylindrical_mesh_from_region():
"""Tests a CylindricalMesh can be made from a Region and the specified
dimensions and phi_grid_bounds are propagated through. Cell is centralized"""
cy_surface = openmc.ZCylinder(r=6)
z_surface_1 = openmc.ZPlane(z0=30)
z_surface_2 = openmc.ZPlane(z0=-30)
cell = openmc.Cell(region=-cy_surface & -z_surface_1 & +z_surface_2)
mesh = openmc.CylindricalMesh.from_domain(
cell,
dimension=(6, 2, 3),
phi_grid_bounds=(0., np.pi)
)
assert isinstance(mesh, openmc.CylindricalMesh)
assert np.array_equal(mesh.dimension, (6, 2, 3))
assert np.array_equal(mesh.r_grid, [0., 1., 2., 3., 4., 5., 6.])
assert np.array_equal(mesh.phi_grid, [0., 0.5*np.pi, np.pi])
assert np.array_equal(mesh.z_grid, [-30., -10., 10., 30.])
def test_reg_mesh_from_universe():
"""Tests a RegularMesh can be made from a Universe and the default dimensions
are propagated through. Universe is centralized"""
"""Tests a RegularMesh can be made from a Universe and the default
dimensions are propagated through. Universe is centralized"""
surface = openmc.Sphere(r=42)
cell = openmc.Cell(region=-surface)
universe = openmc.Universe(cells=[cell])
mesh = openmc.RegularMesh.from_domain(universe)
assert isinstance(mesh, openmc.RegularMesh)
assert np.array_equal(mesh.dimension, (100, 100, 100)) # default values
assert np.array_equal(mesh.dimension, (10, 10, 10)) # default values
assert np.array_equal(mesh.lower_left, universe.bounding_box[0])
assert np.array_equal(mesh.upper_right, universe.bounding_box[1])
def test_reg_mesh_from_geometry():
"""Tests a RegularMesh can be made from a Geometry and the default dimensions
are propagated through. Geometry is centralized"""
"""Tests a RegularMesh can be made from a Geometry and the default
dimensions are propagated through. Geometry is centralized"""
surface = openmc.Sphere(r=42)
cell = openmc.Cell(region=-surface)
universe = openmc.Universe(cells=[cell])
@ -53,7 +89,7 @@ def test_reg_mesh_from_geometry():
mesh = openmc.RegularMesh.from_domain(geometry)
assert isinstance(mesh, openmc.RegularMesh)
assert np.array_equal(mesh.dimension, (100, 100, 100)) # default values
assert np.array_equal(mesh.dimension, (10, 10, 10)) # default values
assert np.array_equal(mesh.lower_left, geometry.bounding_box[0])
assert np.array_equal(mesh.upper_right, geometry.bounding_box[1])