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

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

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.

@@ -87,7 +87,7 @@ REPLACE {$COVMIN} WITH {10} "min. no. of particles crossing a scoring"
REPLACE {$MXMED} WITH {12} "max # of media
REPLACE {$MXREG} WITH {3000} "maximum number of regions (absolute)
REPLACE {$MXSTACK} WITH {900000} "maximum stack (much less if no brem split)
REPLACE {$MAXBRSPLIT} WITH {2000} "maximum number of bremsstrahlung splits
REPLACE {$MAXBRSPLIT} WITH {5000} "maximum number of bremsstrahlung splits
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks like an accidental addition to this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it is, @rtownson. This file shouldn't even be part of this PR. I'll remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh wait, my mistake @rtownson! I've accidentally issued this PR against the master branch when I meant to do it against develop. Let me try that....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There!

@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
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
2 participants