From 211ad35f85e01df21e2e41a0f9ffad676129cef9 Mon Sep 17 00:00:00 2001 From: Adam G Nelson Date: Sun, 5 Jan 2025 09:06:13 -0600 Subject: [PATCH 1/3] Updated setting of zero xs from exp(-500) to exp(-900) so they are truly 0 on 64-bit computers instead of ~1e-219. This is needed as photon scores (e.g., photoelectric) below thresholds had non-zero values. --- src/photon.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/photon.cpp b/src/photon.cpp index 08062a2e9f5..c98682a0efc 100644 --- a/src/photon.cpp +++ b/src/photon.cpp @@ -330,13 +330,14 @@ PhotonInteraction::PhotonInteraction(hid_t group) // Take logarithm of energies and cross sections since they are log-log // interpolated energy_ = xt::log(energy_); - coherent_ = xt::where(coherent_ > 0.0, xt::log(coherent_), -500.0); - incoherent_ = xt::where(incoherent_ > 0.0, xt::log(incoherent_), -500.0); + coherent_ = xt::where(coherent_ > 0.0, xt::log(coherent_), -900.0); + incoherent_ = xt::where(incoherent_ > 0.0, xt::log(incoherent_), -900.0); photoelectric_total_ = xt::where( - photoelectric_total_ > 0.0, xt::log(photoelectric_total_), -500.0); + photoelectric_total_ > 0.0, xt::log(photoelectric_total_), -900.0); pair_production_total_ = xt::where( - pair_production_total_ > 0.0, xt::log(pair_production_total_), -500.0); - heating_ = xt::where(heating_ > 0.0, xt::log(heating_), -500.0); + pair_production_total_ > 0.0, xt::log(pair_production_total_), -900.0); + heating_ = xt::where(heating_ > 0.0, xt::log(heating_), -900.0); + } PhotonInteraction::~PhotonInteraction() From 170fe26089706de6e540242660853924017af84b Mon Sep 17 00:00:00 2001 From: Adam G Nelson Date: Sun, 5 Jan 2025 12:26:47 -0600 Subject: [PATCH 2/3] incorporate clang-format changes --- src/photon.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/photon.cpp b/src/photon.cpp index c98682a0efc..4953e0ec157 100644 --- a/src/photon.cpp +++ b/src/photon.cpp @@ -337,7 +337,6 @@ PhotonInteraction::PhotonInteraction(hid_t group) pair_production_total_ = xt::where( pair_production_total_ > 0.0, xt::log(pair_production_total_), -900.0); heating_ = xt::where(heating_ > 0.0, xt::log(heating_), -900.0); - } PhotonInteraction::~PhotonInteraction() From 650f2c09ec2c3c56445a65ed06c5f5c7f3bca2d8 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 8 Jan 2025 09:00:29 -0600 Subject: [PATCH 3/3] Handle 'zero' photon cross sections from ACE-derived libraries --- src/photon.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/photon.cpp b/src/photon.cpp index 4953e0ec157..4b2fb41978f 100644 --- a/src/photon.cpp +++ b/src/photon.cpp @@ -328,15 +328,19 @@ PhotonInteraction::PhotonInteraction(hid_t group) } // Take logarithm of energies and cross sections since they are log-log - // interpolated + // interpolated. Note that cross section libraries converted from ACE files + // represent zero as exp(-500) to avoid log-log interpolation errors. For + // values below exp(-499) we store the log as -900, for which exp(-900) + // evaluates to zero. + double limit = std::exp(-499.0); energy_ = xt::log(energy_); - coherent_ = xt::where(coherent_ > 0.0, xt::log(coherent_), -900.0); - incoherent_ = xt::where(incoherent_ > 0.0, xt::log(incoherent_), -900.0); + coherent_ = xt::where(coherent_ > limit, xt::log(coherent_), -900.0); + incoherent_ = xt::where(incoherent_ > limit, xt::log(incoherent_), -900.0); photoelectric_total_ = xt::where( - photoelectric_total_ > 0.0, xt::log(photoelectric_total_), -900.0); + photoelectric_total_ > limit, xt::log(photoelectric_total_), -900.0); pair_production_total_ = xt::where( - pair_production_total_ > 0.0, xt::log(pair_production_total_), -900.0); - heating_ = xt::where(heating_ > 0.0, xt::log(heating_), -900.0); + pair_production_total_ > limit, xt::log(pair_production_total_), -900.0); + heating_ = xt::where(heating_ > limit, xt::log(heating_), -900.0); } PhotonInteraction::~PhotonInteraction()