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 egs++ 3ddose output and change getMass to getVolume #759

Merged
merged 1 commit into from
Oct 18, 2022

Conversation

MartinMartinov
Copy link
Contributor

The egs_base_geometry getMass virtual function is exchanged with
a getVolume function that returns region volume instead of mass.
This change was performed because typically, initGeometry() is
invoked before any media data is read in egs_applications, thus
getMass' dependence on medium data could be unreliable. The
getMass function was thus replaced with a getVolume function,
which only relies on internal gemoetry definitions to return a
value.
The geometries in egs_autoenvelope, egs_nd_geometry, egs_rz,
and egs_spheres are affected. The ausgab dose scoring object
which outputs a 3ddose file was also changed to reflect the
change from getMass to getVolume. This modification of
egs_dose_scoring also now includes relativeRho in the mass
calculation.

@MartinMartinov
Copy link
Contributor Author

I've tested the changes to egs_nd_geometry and egs_dose_scoring by comparing an ausgab object 3ddose file with egs_chamber results (where I calculate mass by hand), and I get the exact same dose and uncertainty per voxel. I have also performed checks of all of the geometries that were changed using egs_brachy, which was also changed to modify to use getVolume instead of getMass, and things seems to be working well.

Copy link
Collaborator

@rtownson rtownson left a comment

Choose a reason for hiding this comment

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

We need to merge this in asap. It could include one more change, while we're at it:

--- a/HEN_HOUSE/egs++/egs_advanced_application.cpp
+++ b/HEN_HOUSE/egs++/egs_advanced_application.cpp
@@ -1171,7 +1171,8 @@ void EGS_AdvancedApplication::resetRNGState() {
 //************************************************************
 // Returns density for medium ind
 EGS_Float EGS_AdvancedApplication::getMediumRho(int ind) {
-    return the_media->rho[ind];
+    // Handle a negative index for vacuum
+    return ind < 0 ? 0.0 : the_media->rho[ind];
 }

I just don't have permission to push to Martin's branch.

@rtownson rtownson changed the title Changing egs++ geometry getMass to getVolume Fix egs++ 3ddose output and change getMass to getVolume Jul 5, 2022
@ftessier ftessier added this to the Release 2022 milestone Jul 5, 2022
@ftessier
Copy link
Member

Rebased on develop, no conflict.

@ftessier
Copy link
Member

Applied astyle, only whitespace changes.

@MartinMartinov
Copy link
Contributor Author

Rebased on develop, no conflict.

Honestly, a little surprised, but I'll take it. :)

@ftessier
Copy link
Member

ftessier commented Jul 12, 2022

Surprised that there is no rebase conflict, or that it is being merged in? 😆

@ftessier
Copy link
Member

ftessier commented Jul 12, 2022

Added Reid's patch (see above); changed ternary if-expression to if-statement. To squash before merging.

Change the egs_base_geometry getMass virtual function to a getVolume
function that returns region volume instead of mass. Typically,
initGeometry() is invoked before any media data is read in the
application, hence getMass was unreliable. The getMass function was
replaced with a getVolume function, which only depends on internal
gemoetry definitions.

The geometries in egs_autoenvelope, egs_nd_geometry, egs_rz, and
egs_spheres are affected. The ausgab dose scoring object which outputs a
3ddose file was also changed to reflect the change from getMass to
getVolume. This modification of egs_dose_scoring also now properly
accounts for relativeRho in the mass calculation.

Also, handle vacuum medium index appropriately in getMediumRho.
@ftessier
Copy link
Member

Squashed the commits and fix typo in commit message. No code change.

@ftessier ftessier merged commit 35a59d3 into nrc-cnrc:develop Oct 18, 2022
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.

5 participants