2016-01-09 20:42:40 -05:00
|
|
|
import openmc
|
|
|
|
|
|
2018-01-29 10:53:46 -06:00
|
|
|
from tests.testing_harness import TestHarness, PyAPITestHarness
|
|
|
|
|
|
2016-01-09 20:42:40 -05:00
|
|
|
|
|
|
|
|
class DistribmatTestHarness(PyAPITestHarness):
|
2023-02-28 11:31:04 -05:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
|
super().__init__(*args, **kwargs)
|
2016-01-09 20:42:40 -05:00
|
|
|
####################
|
|
|
|
|
# Materials
|
|
|
|
|
####################
|
|
|
|
|
|
|
|
|
|
moderator = openmc.Material(material_id=1)
|
|
|
|
|
moderator.set_density('g/cc', 1.0)
|
2016-05-13 15:57:39 -05:00
|
|
|
moderator.add_nuclide('H1', 2.0)
|
|
|
|
|
moderator.add_nuclide('O16', 1.0)
|
2016-01-09 20:42:40 -05:00
|
|
|
|
|
|
|
|
dense_fuel = openmc.Material(material_id=2)
|
|
|
|
|
dense_fuel.set_density('g/cc', 4.5)
|
2016-05-13 15:57:39 -05:00
|
|
|
dense_fuel.add_nuclide('U235', 1.0)
|
2016-01-09 20:42:40 -05:00
|
|
|
|
|
|
|
|
light_fuel = openmc.Material(material_id=3)
|
|
|
|
|
light_fuel.set_density('g/cc', 2.0)
|
2016-05-13 15:57:39 -05:00
|
|
|
light_fuel.add_nuclide('U235', 1.0)
|
2016-01-09 20:42:40 -05:00
|
|
|
|
2023-02-28 11:31:04 -05:00
|
|
|
self._model.materials = openmc.Materials([moderator, dense_fuel,
|
|
|
|
|
light_fuel])
|
2016-01-09 20:42:40 -05:00
|
|
|
|
|
|
|
|
####################
|
|
|
|
|
# Geometry
|
|
|
|
|
####################
|
|
|
|
|
|
2017-04-07 10:25:24 -05:00
|
|
|
c1 = openmc.Cell(cell_id=1, fill=moderator)
|
|
|
|
|
mod_univ = openmc.Universe(universe_id=1, cells=[c1])
|
2016-01-09 20:42:40 -05:00
|
|
|
|
2019-03-08 11:25:26 -06:00
|
|
|
r0 = openmc.ZCylinder(r=0.3)
|
2017-04-07 10:25:24 -05:00
|
|
|
c11 = openmc.Cell(cell_id=11, region=-r0)
|
2018-05-16 18:17:23 -04:00
|
|
|
c11.fill = [dense_fuel, None, light_fuel, dense_fuel]
|
2017-04-07 10:25:24 -05:00
|
|
|
c12 = openmc.Cell(cell_id=12, region=+r0, fill=moderator)
|
|
|
|
|
fuel_univ = openmc.Universe(universe_id=11, cells=[c11, c12])
|
2016-01-09 20:42:40 -05:00
|
|
|
|
|
|
|
|
lat = openmc.RectLattice(lattice_id=101)
|
|
|
|
|
lat.lower_left = [-2.0, -2.0]
|
|
|
|
|
lat.pitch = [2.0, 2.0]
|
|
|
|
|
lat.universes = [[fuel_univ]*2]*2
|
|
|
|
|
lat.outer = mod_univ
|
|
|
|
|
|
|
|
|
|
x0 = openmc.XPlane(x0=-3.0)
|
|
|
|
|
x1 = openmc.XPlane(x0=3.0)
|
|
|
|
|
y0 = openmc.YPlane(y0=-3.0)
|
|
|
|
|
y1 = openmc.YPlane(y0=3.0)
|
|
|
|
|
for s in [x0, x1, y0, y1]:
|
|
|
|
|
s.boundary_type = 'reflective'
|
2017-04-07 10:25:24 -05:00
|
|
|
c101 = openmc.Cell(cell_id=101, fill=lat)
|
2016-01-09 20:42:40 -05:00
|
|
|
c101.region = +x0 & -x1 & +y0 & -y1
|
2017-04-07 10:25:24 -05:00
|
|
|
root_univ = openmc.Universe(universe_id=0, cells=[c101])
|
2016-01-09 20:42:40 -05:00
|
|
|
|
2023-02-28 11:31:04 -05:00
|
|
|
self._model.geometry = openmc.Geometry(root_univ)
|
2016-01-09 20:42:40 -05:00
|
|
|
|
|
|
|
|
####################
|
|
|
|
|
# Settings
|
|
|
|
|
####################
|
|
|
|
|
|
2016-04-25 10:37:06 -05:00
|
|
|
sets_file = openmc.Settings()
|
2016-01-09 20:42:40 -05:00
|
|
|
sets_file.batches = 5
|
|
|
|
|
sets_file.inactive = 0
|
|
|
|
|
sets_file.particles = 1000
|
2023-06-20 21:27:55 -05:00
|
|
|
sets_file.source = openmc.IndependentSource(space=openmc.stats.Box(
|
2017-04-07 10:25:24 -05:00
|
|
|
[-1, -1, -1], [1, 1, 1]))
|
2023-02-28 11:31:04 -05:00
|
|
|
self._model.settings = sets_file
|
2016-01-09 20:42:40 -05:00
|
|
|
|
2016-01-13 11:36:05 -05:00
|
|
|
####################
|
|
|
|
|
# Plots
|
|
|
|
|
####################
|
|
|
|
|
|
2025-12-05 12:17:09 -08:00
|
|
|
plot1 = openmc.SlicePlot(plot_id=1)
|
2017-04-07 10:25:24 -05:00
|
|
|
plot1.basis = 'xy'
|
|
|
|
|
plot1.color_by = 'cell'
|
|
|
|
|
plot1.filename = 'cellplot'
|
|
|
|
|
plot1.origin = (0, 0, 0)
|
|
|
|
|
plot1.width = (7, 7)
|
|
|
|
|
plot1.pixels = (400, 400)
|
|
|
|
|
|
2025-12-05 12:17:09 -08:00
|
|
|
plot2 = openmc.SlicePlot(plot_id=2)
|
2017-04-07 10:25:24 -05:00
|
|
|
plot2.basis = 'xy'
|
|
|
|
|
plot2.color_by = 'material'
|
|
|
|
|
plot2.filename = 'matplot'
|
|
|
|
|
plot2.origin = (0, 0, 0)
|
|
|
|
|
plot2.width = (7, 7)
|
|
|
|
|
plot2.pixels = (400, 400)
|
|
|
|
|
|
2023-02-28 11:31:04 -05:00
|
|
|
self._model.plots = openmc.Plots([plot1, plot2])
|
2016-01-09 20:42:40 -05:00
|
|
|
|
2016-01-09 23:02:29 -05:00
|
|
|
def _get_results(self):
|
2018-02-06 13:14:17 -05:00
|
|
|
outstr = super()._get_results()
|
2016-01-09 23:02:29 -05:00
|
|
|
su = openmc.Summary('summary.h5')
|
2017-02-23 07:39:28 -06:00
|
|
|
outstr += str(su.geometry.get_all_cells()[11])
|
2016-01-09 23:02:29 -05:00
|
|
|
return outstr
|
|
|
|
|
|
2016-01-09 20:42:40 -05:00
|
|
|
|
2018-01-29 12:10:24 -06:00
|
|
|
def test_distribmat():
|
2023-02-28 11:31:04 -05:00
|
|
|
harness = DistribmatTestHarness('statepoint.5.h5', model=openmc.Model())
|
2016-01-09 20:42:40 -05:00
|
|
|
harness.main()
|