From 52eef1adf5a764fe3d8e88898282cf29d7024eb1 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 26 Sep 2022 12:23:40 -0500 Subject: [PATCH] Reset decay source if config['chain_file'] changes --- openmc/config.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openmc/config.py b/openmc/config.py index 628df7edc1..3c031ee7dc 100644 --- a/openmc/config.py +++ b/openmc/config.py @@ -4,6 +4,7 @@ from pathlib import Path import warnings from openmc.data import DataLibrary +from openmc.data.decay import _DECAY_PHOTON_SOURCE __all__ = ["config"] @@ -22,6 +23,10 @@ class _Config(MutableMapping): del os.environ['OPENMC_CROSS_SECTIONS'] elif key == 'mg_cross_sections': del os.environ['OPENMC_MG_CROSS_SECTIONS'] + elif key == 'chain_file': + del os.environ['OPENMC_CHAIN_FILE'] + # Reset photon source data since it relies on chain file + _DECAY_PHOTON_SOURCE.clear() def __setitem__(self, key, value): if key == 'cross_sections': @@ -34,6 +39,8 @@ class _Config(MutableMapping): elif key == 'chain_file': self._set_path(key, value) os.environ['OPENMC_CHAIN_FILE'] = str(value) + # Reset photon source data since it relies on chain file + _DECAY_PHOTON_SOURCE.clear() else: raise KeyError(f'Unrecognized config key: {key}')