Fix ParticleHP fission nubar evaluated at wrong energy in const getters#103
Open
ibrahmkocaa wants to merge 1 commit into
Open
Fix ParticleHP fission nubar evaluated at wrong energy in const getters#103ibrahmkocaa wants to merge 1 commit into
ibrahmkocaa wants to merge 1 commit into
Conversation
GetMean/GetPrompt/GetDelayed(G4double) are const, so the interpolating non-const G4ParticleHPVector::GetY(G4double) is not viable on the const member vectors. Overload resolution falls back to GetY(G4int) const via an implicit double->int conversion and the yield is read as table point floor(E) instead of nubar(E), i.e. the thermal value at all reactor energies (2.4254 for U-235, G4NDL 4.7.1). All ParticleHP fission multiplicities come from these getters through G4ParticleHPFSFissionFS::SampleNeutronMult. On the Godiva benchmark (ICSBEP HEU-MET-FAST-001) this costs about 6300 pcm: keff goes from 0.9362 +/- 0.0024 to 0.9969 +/- 0.0025 with this change (benchmark 1.0000 +/- 0.0010), and the measured nubar(E) rises with energy again. Reach the interpolating lookup through const_cast; behavior of the non-const path is unchanged.
Author
|
Problem report filed on Bugzilla: https://bugzilla-geant4.kek.jp/show_bug.cgi?id=2745 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While validating a k-eigenvalue application against the Godiva benchmark
(ICSBEP HEU-MET-FAST-001) I found keff about 6300 pcm low with Geant4 11.4.0.
I traced it to G4ParticleHPParticleYield.
GetMean, GetPrompt and GetDelayed(G4double) are const member functions. Inside
them the member vectors (theSimpleMean, thePrompt, theDelayed) are seen as
const, so the interpolating GetY(G4double), which is not const, is not a viable
overload. The compiler silently converts the energy argument to an int and
calls GetY(G4int) const instead. The yield is then read as the y value of table
point floor(E), with E in internal units. For any reactor-relevant energy this
lands on the first table points, i.e. the thermal nubar (2.4254 for U-235 with
G4NDL 4.7.1), whatever the incident energy. G4ParticleHPFSFissionFS::
SampleNeutronMult takes all fission multiplicities from these getters, so every
ParticleHP fission samples a thermal-valued multiplicity.
A short demonstration with any G4NDL fission FS nubar table:
clang's -Wfloat-conversion warns at exactly these call sites, which is how the
defect stays invisible in a default build.
This patch keeps the change minimal: three const_casts in the header so the
getters reach the existing interpolating lookup again.
Results on Godiva (bare HEU sphere, Shielding physics list, G4NDL 4.7.1,
power iteration with 5000 neutrons per generation, 120 generations, 30
inactive, same application code in both rows):
The leakage fraction agrees between the two codes (0.570 in Geant4, 0.5728 in
OpenMC), so the discrepancy is confined to the fission multiplicity. I also
built this branch as-is (11.5.0.beta plus this commit) from scratch and reran
the same Godiva case against it: 0.9969 +/- 0.0025, matching the patched
11.4.0 result. Thermal
systems are barely affected because the wrongly returned value happens to be
the thermal one, which would explain why this went unnoticed. Criticality
validations published with Geant4 9.5 and 10.x do not show the deficit, so the
regression probably entered with the const-correctness rework of particle_hp.
Two remarks for the maintainers. The const_cast reaches the existing non-const
path; GetXsec(G4double) updates internal lookup state, so this path is exactly
as thread-safe (or not) as it was before. And a more durable fix would be a
const interpolating overload in G4ParticleHPVector, possibly together with
renaming the index-based GetY(G4int), so that an implicit double to int
conversion can never shadow the energy lookup again. I kept both out of this
PR to leave it a one-file change.
I will file a problem report on Bugzilla and link it here.