From 5bf576250eda4824cf4ec4c25a2726aaedd8d82d Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 14 Dec 2022 17:06:03 +0000 Subject: [PATCH 1/2] making use of from_cell_with_material --- openmc/model/model.py | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/openmc/model/model.py b/openmc/model/model.py index d989c0b22d4..ab815b96cc2 100644 --- a/openmc/model/model.py +++ b/openmc/model/model.py @@ -963,28 +963,12 @@ def execute_run(self, **kwargs): new_mats = matlist[tidx] rundir = self.ptransport_path / f'timestep_{tidx}' - # Collect all source energy distributions from model - dist_map = {} - for mat in new_mats: - pdist = mat.decay_photon_energy - if pdist is not None: - dist_map[mat.id] = pdist - - # Collect all spatial distributions of the sources from the model - box_map = {} + # Create Source for every depleted region + src_list = [] for cell in self.geometry.get_all_cells().values(): if cell.fill is None: continue - lower_left, upper_right = cell.region.bounding_box - box = openmc.stats.Box(lower_left, upper_right) - box_map[cell.fill.id] = box - - # Create Source for every depleted region - src_list = [] - for idx in dist_map.keys(): - src = openmc.Source(energy=dist_map[idx], space=box_map[idx]) - src.strength = dist_map[idx].integral() - src.particle = 'photon' + src = openmc.Source.from_cell_with_material(cell) src_list.append(src) self.settings.source = src_list From 18091feb759f24ee48d6c76b056e28a580f8ca0e Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 1 Feb 2023 13:59:45 +0000 Subject: [PATCH 2/2] catching None photon source --- openmc/model/model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openmc/model/model.py b/openmc/model/model.py index ab815b96cc2..71d9a948d81 100644 --- a/openmc/model/model.py +++ b/openmc/model/model.py @@ -969,7 +969,8 @@ def execute_run(self, **kwargs): if cell.fill is None: continue src = openmc.Source.from_cell_with_material(cell) - src_list.append(src) + if src is not None: # materials may have no photon emission + src_list.append(src) self.settings.source = src_list self.export_to_xml(rundir)