Skip to content
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

Fix #1065: source collection fluence #1076

Merged

Conversation

blakewalters
Copy link
Contributor

@blakewalters blakewalters commented Nov 13, 2023

Fluence for the source collection was not calculated properly in the case of a collection consisting of N transformations, i, of a single base source. EGS_SourceCollection::getFluence() sums the results of getFluence() for the i individual sources. If they are transformations of a single base source, then for each source i, getFluence returns the total fluence (of the base source), F_tot. Thus, EGS_SourceCollection::getFluence() erroneously returns N*F_tot.

The solution is to "detect" a group of sources sharing a common base source by looking for increases in the fluence of source i != j, where j is the source in the collection from which a given particle is being sampled. Before summing individual source fluences, EGS_SourceCollection::getFluence() then multiplies the result of getFluence() for source i by p[i]/p_tot, where p[i] is the user input probability for source i and p_tot is the sum of all probabilities of the N sources sharing the same base source. We are thus able to obtain an estimate of the fluence from each source i.

A further issue occurs when the results of parallel runs are combined. During a parallel run, we store the fluence for each source, i, in the source collection in the .egsdat file from each job. On recombining, results are first added up for each source. If these share a common base source, then these separate additions are actually cumulative with respect to the base source, with the result being that each source, i, will have (erroneous) fluence NF_tot. Then, to obtain the fluence of the source collection, we sum over the N sources, resulting in an additional multiplicative factor of N, so the total fluence is NN*F_tot. In this fix, we now detect when results are being combined and, prior to summing fluence from individual sources, divide by an additional factor N. Note that in order to determine N, we make use of new information written to the .egsdat file for each source i listing the other sources j != i sharing a common base source.

Fixes issue #1065

@blakewalters blakewalters requested a review from a team as a code owner November 13, 2023 18:44
@blakewalters blakewalters requested review from ftessier, mainegra and rtownson and removed request for a team November 13, 2023 18:44
@rtownson rtownson changed the title Fix source collection fluence Fix #1065: source collection fluence Dec 4, 2023
@rtownson
Copy link
Collaborator

rtownson commented Dec 4, 2023

Great work Blake!

Just a note that this should be rebased to merge into develop.

@blakewalters blakewalters changed the base branch from master to develop December 9, 2023 00:21
@rtownson rtownson linked an issue Jan 24, 2024 that may be closed by this pull request
4 tasks
Copy link
Member

@ftessier ftessier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to adjust commit titles, could use some squashing before merge.

Fix a bug where the source collection fluence was not calculated
properly when multiple transformations were performed on a single base
source.
@ftessier ftessier force-pushed the fix-source_collection_fluence branch from a366402 to 6c738bf Compare September 4, 2024 18:05
@ftessier
Copy link
Member

ftessier commented Sep 4, 2024

Rebased on new develop tip.

@ftessier ftessier merged commit 55faaf5 into nrc-cnrc:develop Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error in fluence when transformed sources used in source collection
4 participants