Skip to content

Fix inconsistent densities as a result of repeated changes of electron fractions in prob3 #925

Merged
thehrh merged 2 commits intomasterfrom
fix/repeatedly_set_electron_fractions
Apr 17, 2026
Merged

Fix inconsistent densities as a result of repeated changes of electron fractions in prob3 #925
thehrh merged 2 commits intomasterfrom
fix/repeatedly_set_electron_fractions

Conversation

@thehrh
Copy link
Copy Markdown
Collaborator

@thehrh thehrh commented Apr 10, 2026

Bugs were present in both Layers.weight_density_to_YeFrac() and Layers.weight_density_to_YnFrac(), where the attribute self.rhos_unweighted—never self.rhos—should have been rescaled. A test function demonstrates the reproducibility of the densities of the Layers object.

The code snippet in #868 now yields consistent event counts:

modell = DistributionMaker("IceCube_3y_neutrinos.cfg")
print(modell.params.YeM.value) # 0.4957 dimensionless
verteilung = modell.get_outputs(return_sum=True)[0]
count = verteilung.num_entries
print(count) # 39180.40671817049
modell.params.YeM.value = 0.5 * ureg.dimensionless
print(modell.params.YeM.value) # 0.5 dimensionless
count = modell.get_outputs(return_sum=True)[0].num_entries
print(count) # 39179.68692132214
modell.params.reset_all()
print(modell.params.YeM.value) # 0.4957 dimensionless (initial value)
count = modell.get_outputs(return_sum=True)[0].num_entries
print(count) # 39180.40671817049 (initial value)
count = modell.get_outputs(return_sum=True)[0].num_entries
print(count) # 39180.40671817049 (initial value)

Fixes #868

@thehrh thehrh added this to the 4.3 milestone Apr 10, 2026
@thehrh thehrh added the bug label Apr 10, 2026
@thehrh thehrh merged commit cfb3566 into master Apr 17, 2026
@thehrh thehrh deleted the fix/repeatedly_set_electron_fractions branch April 17, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repeatedly setting electron fractions in prob3 yields inconsistent results

2 participants