Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/source/dev/add_benchmark/where_inputs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ OpenMC
of a same benchmark. If possible, the tallies identifiers should be the same as the ones used in the
other transport codes.

.. note::
If the benchmark contains total heating tallies, total heating can be obtained when a heating score is recorded and
no ``openmc.ParticleFilter`` is applied to the tally. This is equivalent to the ``+F6`` tally option in MCNP. If the
benchmark contains a photon heating tally, the user should add 3 separate tallies for the same ``openmc.CellFilter``, with
``openmc.ParticleFilter`` values set to "photon", "positron" and "electron" respectively. JADE will automatically combine
these tallies together, to produce an equivalent response to the MCNP photon tally.


Serpent
-------
TODO
Expand Down
43 changes: 27 additions & 16 deletions src/jade/helper/openmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,27 +558,38 @@ def _combine_heating_tallies(self, heating_tallies: dict) -> dict:
photon_tallies = {}
heating_tallies_df = {}
for id, tally in heating_tallies.items():
particle_filter = tally.find_filter(openmc.ParticleFilter)
if "neutron" in particle_filter.bins:
heating_tallies_df[id] = self._get_tally_data(tally)
if "photon" in particle_filter.bins:
photon_tallies[id] = tally
try:
particle_filter = tally.find_filter(openmc.ParticleFilter)
except ValueError:
particle_filter = None
if particle_filter:
if "neutron" in particle_filter.bins:
heating_tallies_df[id] = self._get_tally_data(tally)
if "photon" in particle_filter.bins:
photon_tallies[id] = tally
heating_tallies_df[id] = self._get_tally_data(tally)
else:
heating_tallies_df[id] = self._get_tally_data(tally)
for id, photon_tally in photon_tallies.items():
photon_cell_filter = photon_tally.find_filter(openmc.CellFilter)
for _, tally in heating_tallies.items():
particle_filter = tally.find_filter(openmc.ParticleFilter)
try:
particle_filter = tally.find_filter(openmc.ParticleFilter)
except ValueError:
particle_filter = None
cell_filter = tally.find_filter(openmc.CellFilter)
if (
("electron" in particle_filter.bins)
or ("positron" in particle_filter.bins)
) and (photon_cell_filter == cell_filter):
tally_df = self._get_tally_data(tally)
heating_tallies_df[id]["mean"] += tally_df["mean"]
heating_tallies_df[id]["std. dev."] = (
heating_tallies_df[id]["std. dev."].pow(2)
+ tally_df["std. dev."].pow(2)
).pow(0.5)
if particle_filter and cell_filter:
if photon_cell_filter == cell_filter:
if (
"electron" in particle_filter.bins
or "positron" in particle_filter.bins
):
tally_df = self._get_tally_data(tally)
heating_tallies_df[id]["mean"] += tally_df["mean"]
heating_tallies_df[id]["std. dev."] = (
heating_tallies_df[id]["std. dev."].pow(2)
+ tally_df["std. dev."].pow(2)
).pow(0.5)
return heating_tallies_df

def tallies_to_dataframes(self) -> dict:
Expand Down
13 changes: 10 additions & 3 deletions tests/app/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,16 @@ def test_continue_run_sphere(self, tmp_path):
run_cfg = RunConfig(env_vars, {"Sphere": cfg1})
app.run_cfg = run_cfg
command = app.continue_run(testing=True)
assert "#!/bin/sh\n\n#SBATCH" in command[0][1]
assert "Sphere_dummy1" in command[0][1]
assert "Sphere_m101" in command[1][1]

command_sorted = sorted(command, key=lambda x: x[1])

assert "#!/bin/sh\n\n#SBATCH" in command_sorted[0][1]
assert "Sphere_dummy1" in command_sorted[0][1]
assert "Sphere_m101" in command_sorted[1][1]

#assert "#!/bin/sh\n\n#SBATCH" in command[0][1]
#assert "Sphere_dummy1" in command[1][1]
#assert "Sphere_m101" in command[0][1]

app.run_cfg.env_vars.run_mode = RunMode.GLOBAL_JOB
command = app.continue_run(testing=True)
Expand Down
5 changes: 3 additions & 2 deletions tests/helper/test_openmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ def test_tallies_to_dataframes(self):
out = omc.OpenMCStatePoint(STATEPOINT, CELL_VOLUMES)
tallies = out.tallies_to_dataframes()
assert "photon" == tallies[56]["particle"][5]
assert "total" == tallies[86]["nuclide"][0]
assert 11 == tallies[56]["cell"][2]
assert 5.388881950654537e-06 == pytest.approx(
assert 5.398984399675055e-06 == pytest.approx(
tallies[24]["mean"][5] / out.cell_data.cell_volumes[tallies[24]["cell"][5]]
)
assert 4.331494120455328e-08 == pytest.approx(
assert 3.70844522806895e-08 == pytest.approx(
tallies[24]["std. dev."][5]
/ out.cell_data.cell_volumes[tallies[24]["cell"][5]]
)
Binary file modified tests/post/resources/openmc/statepoint.10.h5
Binary file not shown.
Loading