From b66d9e0a907c2bd87547d6016f3d41c8455e8a22 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 29 Nov 2022 16:21:47 -0600 Subject: [PATCH] Add check for presence of atomic relaxation data in PhotonInteraction --- include/openmc/photon.h | 3 +++ openmc/data/photon.py | 4 +++- src/photon.cpp | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/openmc/photon.h b/include/openmc/photon.h index 09fb3ba01..9901c8c6d 100644 --- a/include/openmc/photon.h +++ b/include/openmc/photon.h @@ -100,6 +100,9 @@ public: // Bremsstrahlung scaled DCS xt::xtensor dcs_; + // Whether atomic relaxation data is present + bool has_atomic_relaxation_ {false}; + // Constant data static constexpr int MAX_STACK_SIZE = 7; //!< maximum possible size of atomic relaxation stack diff --git a/openmc/data/photon.py b/openmc/data/photon.py index 48ecc3748..fc5da19eb 100644 --- a/openmc/data/photon.py +++ b/openmc/data/photon.py @@ -13,7 +13,7 @@ from scipy.interpolate import CubicSpline import openmc.checkvalue as cv from openmc.mixin import EqualityMixin -from . import HDF5_VERSION +from . import HDF5_VERSION, HDF5_VERSION_MAJOR from .ace import Table, get_metadata, get_table from .data import ATOMIC_SYMBOL, EV_PER_MEV from .endf import Evaluation, get_head_record, get_tab1_record, get_list_record @@ -143,6 +143,8 @@ class AtomicRelaxation(EqualityMixin): Dictionary indicating the number of electrons in a subshell when neutral (values) for given subshells (keys). The subshells should be given as strings, e.g., 'K', 'L1', 'L2', etc. + subshells : list + List of subshells as strings, e.g. ``['K', 'L1', ...]`` transitions : pandas.DataFrame Dictionary indicating allowed transitions and their probabilities (values) for given subshells (keys). The subshells should be given as diff --git a/src/photon.cpp b/src/photon.cpp index a500ff2d4..590e0cc9f 100644 --- a/src/photon.cpp +++ b/src/photon.cpp @@ -156,8 +156,14 @@ PhotonInteraction::PhotonInteraction(hid_t group) // Read binding energy and number of electrons hid_t tgroup = open_group(rgroup, designator.c_str()); - read_attribute(tgroup, "binding_energy", shell.binding_energy); - read_attribute(tgroup, "num_electrons", shell.n_electrons); + + // Read binding energy energy and number of electrons if atomic relaxation + // data is present + if (attribute_exists(tgroup, "binding_energy")) { + has_atomic_relaxation_ = true; + read_attribute(tgroup, "binding_energy", shell.binding_energy); + read_attribute(tgroup, "num_electrons", shell.n_electrons); + } // Read subshell cross section xt::xtensor xs; @@ -757,6 +763,10 @@ void PhotonInteraction::pair_production(double alpha, double* E_electron, void PhotonInteraction::atomic_relaxation(int i_shell, Particle& p) const { + // Return if no atomic relaxation data is present + if (!has_atomic_relaxation_) + return; + // Stack for unprocessed holes left by transitioning electrons int n_holes = 0; array holes;