mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Write surface source files per batch (#3124)
Co-authored-by: Patrick Shriwise <pshriwise@gmail.com> Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
parent
b54de4d761
commit
9686851e7a
14 changed files with 167 additions and 48 deletions
|
|
@ -32,6 +32,7 @@ def geometry():
|
|||
{"max_particles": 200, "surface_ids": [2], "cell": 1},
|
||||
{"max_particles": 200, "surface_ids": [2], "cellto": 1},
|
||||
{"max_particles": 200, "surface_ids": [2], "cellfrom": 1},
|
||||
{"max_particles": 200, "surface_ids": [2], "max_source_files": 1},
|
||||
],
|
||||
)
|
||||
def test_xml_serialization(parameter, run_in_tmpdir):
|
||||
|
|
@ -44,6 +45,58 @@ def test_xml_serialization(parameter, run_in_tmpdir):
|
|||
assert read_settings.surf_source_write == parameter
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def model():
|
||||
"""Simple hydrogen sphere geometry"""
|
||||
openmc.reset_auto_ids()
|
||||
model = openmc.Model()
|
||||
|
||||
# Material
|
||||
h1 = openmc.Material(name="H1")
|
||||
h1.add_nuclide("H1", 1.0)
|
||||
h1.set_density('g/cm3', 1e-7)
|
||||
|
||||
# Geometry
|
||||
radius = 1.0
|
||||
sphere = openmc.Sphere(r=radius, boundary_type="vacuum")
|
||||
cell = openmc.Cell(region=-sphere, fill=h1)
|
||||
model.geometry = openmc.Geometry([cell])
|
||||
|
||||
# Settings
|
||||
model.settings = openmc.Settings()
|
||||
model.settings.run_mode = "fixed source"
|
||||
model.settings.particles = 100
|
||||
model.settings.batches = 3
|
||||
model.settings.seed = 1
|
||||
|
||||
distribution = openmc.stats.Point()
|
||||
model.settings.source = openmc.IndependentSource(space=distribution)
|
||||
return model
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"max_particles, max_source_files",
|
||||
[
|
||||
(100, 2),
|
||||
(100, 3),
|
||||
(100, 1),
|
||||
],
|
||||
)
|
||||
def test_number_surface_source_file_created(max_particles, max_source_files,
|
||||
run_in_tmpdir, model):
|
||||
"""Check the number of surface source files written."""
|
||||
model.settings.surf_source_write = {
|
||||
"max_particles": max_particles,
|
||||
"max_source_files": max_source_files
|
||||
}
|
||||
model.run()
|
||||
should_be_numbered = max_source_files > 1
|
||||
for i in range(1, max_source_files + 1):
|
||||
if should_be_numbered:
|
||||
assert Path(f"surface_source.{i}.h5").exists()
|
||||
if not should_be_numbered:
|
||||
assert Path("surface_source.h5").exists()
|
||||
|
||||
ERROR_MSG_1 = (
|
||||
"A maximum number of particles needs to be specified "
|
||||
"using the 'max_particles' parameter to store surface "
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue