From e423b1018dc9e59e6868113aaf716cba9852e925 Mon Sep 17 00:00:00 2001 From: Amanda Lund Date: Wed, 30 Apr 2025 17:51:18 -0500 Subject: [PATCH 1/2] Map Compton subshell data to atomic relaxation data --- include/openmc/photon.h | 6 +++++- src/photon.cpp | 30 ++++++++++++++++++++++-------- src/physics.cpp | 10 +++++----- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/include/openmc/photon.h b/include/openmc/photon.h index 1fee6c9f5b6..f6f28a4df1d 100644 --- a/include/openmc/photon.h +++ b/include/openmc/photon.h @@ -33,7 +33,6 @@ class ElectronSubshell { int index_subshell; //!< index in SUBSHELLS int threshold; - double n_electrons; double binding_energy; vector transitions; }; @@ -90,6 +89,11 @@ class PhotonInteraction { xt::xtensor binding_energy_; xt::xtensor electron_pdf_; + // Map subshells from Compton profile data obtained from Biggs et al, + // "Hartree-Fock Compton profiles for the elements" to ENDF/B atomic + // relaxation data + xt::xtensor subshell_map_; + // Stopping power data double I_; // mean excitation energy xt::xtensor n_electrons_; diff --git a/src/photon.cpp b/src/photon.cpp index 4b2fb41978f..0d516f24cf7 100644 --- a/src/photon.cpp +++ b/src/photon.cpp @@ -165,7 +165,6 @@ PhotonInteraction::PhotonInteraction(hid_t group) 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 @@ -233,6 +232,28 @@ PhotonInteraction::PhotonInteraction(hid_t group) } close_group(rgroup); + // Map Compton subshell data to atomic relaxation data by finding the + // subshell with the equivalent binding energy + if (has_atomic_relaxation_) { + auto is_close = [](double a, double b) { + return std::abs(a - b) / a < FP_REL_PRECISION; + }; + subshell_map_ = xt::full_like(binding_energy_, -1); + for (int i = 0; i < binding_energy_.shape(0); ++i) { + double E_b = binding_energy_[i]; + if (i < n_shell && is_close(E_b, shells_[i].binding_energy)) { + subshell_map_[i] = i; + } else { + for (int j = 0; j < n_shell; ++j) { + if (is_close(E_b, shells_[j].binding_energy)) { + subshell_map_[i] = j; + break; + } + } + } + } + } + // Create Compton profile CDF auto n_profile = data::compton_profile_pz.size(); auto n_shell_compton = profile_pdf_.shape(0); @@ -423,13 +444,6 @@ void PhotonInteraction::compton_scatter(double alpha, bool doppler, double E_out; this->compton_doppler(alpha, *mu, &E_out, i_shell, seed); *alpha_out = E_out / MASS_ELECTRON_EV; - - // It's possible for the Compton profile data to have more shells than - // there are in the ENDF data. Make sure the shell index doesn't end up - // out of bounds. - if (*i_shell >= shells_.size()) { - *i_shell = -1; - } } else { *i_shell = -1; } diff --git a/src/physics.cpp b/src/physics.cpp index a8e5b9e8135..01f3ec634cf 100644 --- a/src/physics.cpp +++ b/src/physics.cpp @@ -340,11 +340,11 @@ void sample_photon_reaction(Particle& p) p.create_secondary(p.wgt(), u, E_electron, ParticleType::electron); } - // TODO: Compton subshell data does not match atomic relaxation data - // Allow electrons to fill orbital and produce auger electrons - // and fluorescent photons - if (i_shell >= 0) { - element.atomic_relaxation(i_shell, p); + // Allow electrons to fill orbital and produce auger electrons and + // fluorescent photons. Since Compton subshell data does not match atomic + // relaxation data, use the mapping between the data to find the subshell + if (i_shell >= 0 && element.subshell_map_[i_shell] >= 0) { + element.atomic_relaxation(element.subshell_map_[i_shell], p); } phi += PI; From 5bc1ec35f22400dcebd9bc3b43fea06373506a0d Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 5 May 2025 10:38:40 -0500 Subject: [PATCH 2/2] Update a few test results --- src/photon.cpp | 2 +- src/physics.cpp | 2 +- .../photon_production/results_true.dat | 52 +++++++++---------- .../weightwindows/results_true.dat | 2 +- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/photon.cpp b/src/photon.cpp index 0d516f24cf7..385fd5ea793 100644 --- a/src/photon.cpp +++ b/src/photon.cpp @@ -239,7 +239,7 @@ PhotonInteraction::PhotonInteraction(hid_t group) return std::abs(a - b) / a < FP_REL_PRECISION; }; subshell_map_ = xt::full_like(binding_energy_, -1); - for (int i = 0; i < binding_energy_.shape(0); ++i) { + for (int i = 0; i < binding_energy_.size(); ++i) { double E_b = binding_energy_[i]; if (i < n_shell && is_close(E_b, shells_[i].binding_energy)) { subshell_map_[i] = i; diff --git a/src/physics.cpp b/src/physics.cpp index 01f3ec634cf..3c06e543de1 100644 --- a/src/physics.cpp +++ b/src/physics.cpp @@ -340,7 +340,7 @@ void sample_photon_reaction(Particle& p) p.create_secondary(p.wgt(), u, E_electron, ParticleType::electron); } - // Allow electrons to fill orbital and produce auger electrons and + // Allow electrons to fill orbital and produce Auger electrons and // fluorescent photons. Since Compton subshell data does not match atomic // relaxation data, use the mapping between the data to find the subshell if (i_shell >= 0 && element.subshell_map_[i_shell] >= 0) { diff --git a/tests/regression_tests/photon_production/results_true.dat b/tests/regression_tests/photon_production/results_true.dat index 398deeed8b0..a911fed3b8d 100644 --- a/tests/regression_tests/photon_production/results_true.dat +++ b/tests/regression_tests/photon_production/results_true.dat @@ -1,8 +1,8 @@ tally 1: 8.610000E-01 7.413210E-01 -9.493000E-01 -9.011705E-01 +9.491000E-01 +9.007908E-01 0.000000E+00 0.000000E+00 0.000000E+00 @@ -16,12 +16,12 @@ tally 2: 1.573004E+00 4.296434E-04 1.845934E-07 -2.337049E-01 -5.461796E-02 +2.350021E-01 +5.522600E-02 0.000000E+00 0.000000E+00 -2.337049E-01 -5.461796E-02 +2.350021E-01 +5.522600E-02 0.000000E+00 0.000000E+00 0.000000E+00 @@ -53,16 +53,16 @@ tally 3: 4.104374E+12 4.296582E-04 1.846062E-07 -2.286000E-01 -5.225796E-02 -7.054033E+03 -4.975938E+07 +2.297000E-01 +5.276209E-02 +7.055982E+03 +4.978688E+07 0.000000E+00 0.000000E+00 -2.286000E-01 -5.225796E-02 -7.054033E+03 -4.975938E+07 +2.297000E-01 +5.276209E-02 +7.055982E+03 +4.978688E+07 0.000000E+00 0.000000E+00 0.000000E+00 @@ -73,8 +73,8 @@ tally 3: 0.000000E+00 0.000000E+00 0.000000E+00 -1.764573E+05 -3.113718E+10 +1.774451E+05 +3.148675E+10 0.000000E+00 0.000000E+00 0.000000E+00 @@ -102,16 +102,16 @@ tally 4: 4.104374E+12 0.000000E+00 0.000000E+00 -2.286000E-01 -5.225796E-02 -7.054033E+03 -4.975938E+07 +2.297000E-01 +5.276209E-02 +7.055982E+03 +4.978688E+07 0.000000E+00 0.000000E+00 -2.286000E-01 -5.225796E-02 -7.054033E+03 -4.975938E+07 +2.297000E-01 +5.276209E-02 +7.055982E+03 +4.978688E+07 0.000000E+00 0.000000E+00 0.000000E+00 @@ -122,8 +122,8 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -1.764573E+05 -3.113718E+10 +1.774451E+05 +3.148675E+10 0.000000E+00 0.000000E+00 0.000000E+00 diff --git a/tests/regression_tests/weightwindows/results_true.dat b/tests/regression_tests/weightwindows/results_true.dat index 6c05af31aa3..6bb992cd488 100644 --- a/tests/regression_tests/weightwindows/results_true.dat +++ b/tests/regression_tests/weightwindows/results_true.dat @@ -1 +1 @@ -ebc761815175b25fc95a226174928c226a3ab5dbf3b2a2abf09e079a0b87dee1dee74aa9b9eaec35acd58b8c481d264be7e9b3f052905bcc14ccd76f36b01549 \ No newline at end of file +952c20fefac374d3b9fd28627fda7d5ae262f8cd7c01a33f0381526204a2287c18e56259a599dc6fdc1b59a2d2866fdfeedea371154c8fa7a69dc5c445b08c2d \ No newline at end of file