Repository navigation
Fix ACE law 4/44/61 sampling of discrete lines, missing continua and single incident energies #4102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
3de5b4a
12c3f49
deff3ef
f1aff6e
771b54c
1d6dc4c
88ffda4
ceac986
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,26 +122,19 @@ void KalbachMann::sample_params( | |
| double r; | ||
| get_energy_index(energy_, E_in, i, r); | ||
|
|
||
| // Sample between the ith and [i+1]th bin | ||
| int l = r > prn(seed) ? i + 1 : i; | ||
|
|
||
| // Interpolation for energy E1 and EK | ||
| int n_energy_out = distribution_[i].e_out.size(); | ||
| int n_discrete = distribution_[i].n_discrete; | ||
| double E_i_1 = distribution_[i].e_out[n_discrete]; | ||
| double E_i_K = distribution_[i].e_out[n_energy_out - 1]; | ||
| const int i1 = upper_energy_index(energy_, i); | ||
|
|
||
| n_energy_out = distribution_[i + 1].e_out.size(); | ||
| n_discrete = distribution_[i + 1].n_discrete; | ||
| double E_i1_1 = distribution_[i + 1].e_out[n_discrete]; | ||
| double E_i1_K = distribution_[i + 1].e_out[n_energy_out - 1]; | ||
| // With histogram interpolation on the incident energy grid, the table at i | ||
| // applies as tabulated | ||
| const bool histogram_interp = | ||
| n_region_ == 1 && interpolation_[0] == Interpolation::histogram; | ||
|
|
||
| double E_1 = E_i_1 + r * (E_i1_1 - E_i_1); | ||
| double E_K = E_i_K + r * (E_i1_K - E_i_K); | ||
| // Sample between the ith and [i+1]th bin | ||
| int l = histogram_interp ? i : (r > prn(seed) ? i1 : i); | ||
|
|
||
| // Determine outgoing energy bin | ||
| n_energy_out = distribution_[l].e_out.size(); | ||
| n_discrete = distribution_[l].n_discrete; | ||
| int n_energy_out = distribution_[l].e_out.size(); | ||
| int n_discrete = distribution_[l].n_discrete; | ||
| double r1 = prn(seed); | ||
| double c_k = distribution_[l].c[0]; | ||
| int k = 0; | ||
|
|
@@ -170,8 +163,13 @@ void KalbachMann::sample_params( | |
|
|
||
| double E_l_k = distribution_[l].e_out[k]; | ||
| if (k < n_discrete) { | ||
| // Discrete case | ||
| E_out = E_l_k; | ||
| // Discrete case. Discrete lines correspond by index between adjacent | ||
| // incident energies, so interpolate the line energy rather than using the | ||
| // value tabulated at grid l alone. Histogram interpolation on the | ||
| // incident energy grid pins l to i, so no interpolation is applied there. | ||
| const auto& e_lo = distribution_[i].e_out; | ||
| const auto& e_hi = distribution_[i1].e_out; | ||
| E_out = e_lo[k] + (histogram_interp ? 0.0 : r) * (e_hi[k] - e_lo[k]); | ||
|
Comment on lines
+166
to
+172
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Use the lower table’s line for every histogram interval. When the ACE incident-energy grid has multiple regions and the active region uses histogram interpolation, Set 🤖 Prompt for AI Agents |
||
| km_r = distribution_[l].r[k]; | ||
| km_a = distribution_[l].a[k]; | ||
|
|
||
|
|
@@ -215,11 +213,35 @@ void KalbachMann::sample_params( | |
| (distribution_[l].a[k + 1] - distribution_[l].a[k]); | ||
| } | ||
|
|
||
| // Now interpolate between incident energy bins i and i + 1 | ||
| if (l == i) { | ||
| E_out = E_1 + (E_out - E_i_1) * (E_K - E_1) / (E_i_K - E_i_1); | ||
| } else { | ||
| E_out = E_1 + (E_out - E_i1_1) * (E_K - E_1) / (E_i1_K - E_i1_1); | ||
| // Histogram interpolation on the incident energy grid means the table at i | ||
| // applies as tabulated, with no interpolation between grids | ||
| if (!histogram_interp) { | ||
| // Unit-base interpolation between the continua at i and i + 1. The ACE | ||
| // format requires the number of discrete lines to match at every incident | ||
| // energy, but does not require a continuum to be present at each one, so | ||
| // check for each side and fall back to whichever one has a continuum. | ||
| const int n_i = distribution_[i].e_out.size(); | ||
| const int nd_i = distribution_[i].n_discrete; | ||
| const int n_i1 = distribution_[i1].e_out.size(); | ||
| const int nd_i1 = distribution_[i1].n_discrete; | ||
| const bool cont_i = nd_i < n_i; | ||
| const bool cont_i1 = nd_i1 < n_i1; | ||
|
|
||
| const double r_c = cont_i ? (cont_i1 ? r : 0.0) : 1.0; | ||
| const double E_i_1 = cont_i ? distribution_[i].e_out[nd_i] : 0.0; | ||
| const double E_i_K = cont_i ? distribution_[i].e_out[n_i - 1] : 0.0; | ||
| const double E_i1_1 = cont_i1 ? distribution_[i1].e_out[nd_i1] : 0.0; | ||
| const double E_i1_K = cont_i1 ? distribution_[i1].e_out[n_i1 - 1] : 0.0; | ||
|
|
||
| const double E_1 = E_i_1 + r_c * (E_i1_1 - E_i_1); | ||
| const double E_K = E_i_K + r_c * (E_i1_K - E_i_K); | ||
|
|
||
| // Now interpolate between incident energy bins i and i + 1 | ||
| const double E_lo = (l == i) ? E_i_1 : E_i1_1; | ||
| const double E_hi = (l == i) ? E_i_K : E_i1_K; | ||
| if (E_hi != E_lo) { | ||
| E_out = E_1 + (E_out - E_lo) * (E_K - E_1) / (E_hi - E_lo); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 19b676a5e0f2784747d95fe884a44af3b31b4f5193e5ac514378d6d83cfa8ae9f4722da408a98b9b9cd3e369517d0b29bc523fd6f5492856f457e14d15007fa0 | ||
| 3916cc59d580f8caf1dac2ae30d7a5926f650ab1e314af4ecedd3521c87aa7ab60f3ddfee940ed221dbfd2a40deb0f726eb6252ca3333445c7aa8155e7003094 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use the active ACE interpolation code for discrete lines.
histogram_interpis enabled only for a single-region incident-energy grid. In a reachable multi-region interval whose applicable ACE code is histogram, this branch therefore usesrand returns an interpolated outgoing line betweene_lo[k]ande_hi[k]. The repository’s interpolation contract defines histogram interpolation as the lower tabulated value. Resolve the interpolation code for the incident-energy interval before this branch, and pin the line toe_lo[k]when that code is histogram. Keep the existing linear interpolation and single-region behavior unchanged.🤖 Prompt for AI Agents