From 592efd4dda0e8811f16822aa4008b69ce1737270 Mon Sep 17 00:00:00 2001 From: GuySten Date: Sun, 19 Jul 2026 17:08:35 +0300 Subject: [PATCH] control NJOY damage energy threshold --- openmc/data/njoy.py | 14 +++++++++++--- tests/unit_tests/test_data_neutron.py | 8 ++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/openmc/data/njoy.py b/openmc/data/njoy.py index ddc68cc378..3d0fcc1109 100644 --- a/openmc/data/njoy.py +++ b/openmc/data/njoy.py @@ -259,14 +259,14 @@ broadr / %%%%%%%%%%%%%%%%%%%%%%% Doppler broaden XS %%%%%%%%%%%%%%%%%%%%%%%%%%%% _TEMPLATE_HEATR = """ heatr / %%%%%%%%%%%%%%%%%%%%%%%%% Add heating kerma %%%%%%%%%%%%%%%%%%%%%%%%%%%% {nendf} {nheatr_in} {nheatr} / -{mat} 4 0 0 0 / +{mat} 4 0 0 0 0 {damage_threshold}/ 302 318 402 444 / """ _TEMPLATE_HEATR_LOCAL = """ heatr / %%%%%%%%%%%%%%%%% Add heating kerma (local photons) %%%%%%%%%%%%%%%%%%%% {nendf} {nheatr_in} {nheatr_local} / -{mat} 4 0 0 1 / +{mat} 4 0 0 1 0 {damage_threshold}/ 302 318 402 444 / """ @@ -411,7 +411,7 @@ def make_pendf(filename, pendf='pendf', **kwargs): def make_ace(filename, temperatures=None, acer=True, xsdir=None, output_dir=None, pendf=False, error=0.001, broadr=True, heatr=True, gaspr=True, purr=True, evaluation=None, - smoothing=True, **kwargs): + smoothing=True, damage_threshold=None, **kwargs): """Generate incident neutron ACE file from an ENDF file File names can be passed to @@ -463,6 +463,8 @@ def make_ace(filename, temperatures=None, acer=True, xsdir=None, indicates which evaluation should be used. smoothing : bool, optional If the smoothing option (ACER card 6) is on (True) or off (False). + damage_threshold : float, optional + Displacement damage threshold in eV. Used in heatr to calculate damage-energy cross section. When None use NJOY defaults. **kwargs Keyword arguments passed to :func:`openmc.data.njoy.run` @@ -515,6 +517,12 @@ def make_ace(filename, temperatures=None, acer=True, xsdir=None, # heatr if heatr: + # prevent using NJOY default by setting to a small number + if damage_threshold == 0.0: + damage_threshold = 1e-5 + # the NJOY default is 0 + if damage_threshold is None: + damage_threshold = 0.0 nheatr_in = nlast nheatr_local = nheatr_in + 1 tapeout[nheatr_local] = (output_dir / "heatr_local") if heatr is True \ diff --git a/tests/unit_tests/test_data_neutron.py b/tests/unit_tests/test_data_neutron.py index c767f01712..115541a06c 100644 --- a/tests/unit_tests/test_data_neutron.py +++ b/tests/unit_tests/test_data_neutron.py @@ -244,6 +244,14 @@ def test_kerma(run_in_tmpdir, am244, h2): assert 901 in read_in assert np.all(read_in[901].xs['300K'].y == h2[901].xs['300K'].y) +@needs_njoy +def test_damage_energy(tmpdir, endf_data): + endf_file = os.path.join(endf_data, 'neutrons', 'n-014_Si_030.endf') + si30 = openmc.data.IncidentNeutron.from_njoy(endf_file) + + si30_copy = openmc.data.IncidentNeutron.from_njoy(endf_file, damage_threshold=100) + assert not np.allclose(si30[444].xs['294K'].y, si30_copy[444].xs['294K'](si30[444].xs['294K'].x)) + def test_urr(pu239): for T, ptable in pu239.urr.items():