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

Integrate ESTAR density effect corrections into EGSnrc #888

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

Conversation

rtownson
Copy link
Collaborator

@rtownson rtownson commented Jul 5, 2022

The ESTAR fortran code from NIST has been translated into C++ and integrated into EGSnrc, so that density effect corrections are now calculated on-the-fly during the initialization of a simulation. Materials can be defined directly in the input file, so .pegs4dat and .density (density correction files) are no longer needed.

Example:

:start media definition:
  :start water:
    elements = H, O
    number of atoms = 2, 1
    bulk density = 1.0 # g/cm^3 used for transport
    local density = 1.0 # g/cm^3 used for density corrections
    ivalue = 0.000075 # MeV, optional
    output density file = /mypath/water.density # full path to output density corrections to file, optional
  :stop water:
:stop media definition:

For mixtures of compounds:

    :start saltWater:
        mixture compounds = H2O, NaCl
        mass fractions = 0.95, 0.05
        bulk density = 1.0
    :stop saltWater:

For comparison, there's an option to output a density file when the simulation is run.

This adds the options for bulk and local densities to be specified separately. The bulk density is the density used for transport, and the local density is used for the density effect corrections (when a density file is not provided). Density correction files, if provided, will always override these inputs. If the local density is not provided, bulk density (or rho) is used for everything. The old rho input is still accepted, and if provided is used both as the bulk and local density.

Thanks to our co-op student @Sehmimul for this significant contribution!

@rtownson rtownson self-assigned this Jul 5, 2022
@ftessier ftessier added this to the Release 2023 milestone Jul 5, 2022
@ftessier
Copy link
Member

ftessier commented Jul 5, 2022

This will be merged in develop after 2022 release.

@ftessier
Copy link
Member

ftessier commented Jul 6, 2022

Is there an option in the integrated estar code to compute density corrections for a density that is different from the bulk density, e.g., for the grain density in graphite? Perhaps we can have inputs for bulk density (which is simply passed through, and local density which is used for the density correction calculation?

@rtownson
Copy link
Collaborator Author

rtownson commented Jul 6, 2022

Is there an option in the integrated estar code to compute density corrections for a density that is different from the bulk density, e.g., for the grain density in graphite? Perhaps we can have inputs for bulk density (which is simply passed through, and local density which is used for the density correction calculation?

I like your suggestion, yes we could add those options. Currently density is just used for both, so you can't have a different bulk density.

@rtownson
Copy link
Collaborator Author

rtownson commented Jul 6, 2022

I'm also planning to change the I-value to be specified in MeV, like all other energy parameters..

Sehmimul and others added 22 commits August 2, 2023 19:22
…n. Density correction factors are printed when running application. ESTAR can be used only with applications which use egs_advancedapplication class for now
…h pegs4_routines.mortran without the use of density correction files
…If no I-value is given, I-value found by ESTAR will be used
Fix a typo in the makefile for compiling the Mortran applications. Also
switch the flag to use the new root finding method in the density
correction algorithm.
@ftessier
Copy link
Member

ftessier commented Aug 8, 2023

@rtownson What is the status of this draft? Should I start working on this branch towards merging, or should I hold off?

@rtownson
Copy link
Collaborator Author

rtownson commented Aug 8, 2023

I think hold off, I'm planning to add a few more features.

@ftessier
Copy link
Member

ftessier commented Aug 8, 2023

Sounds good. I will start reviewing and "cleaning" it on the side, please add stuff on top of the existing estar-cpp-integration f21697d, so that I can integrate your new commits cleanly at the end. Don't forget to update to f21697d, I synced it with develop last week.

@ftessier
Copy link
Member

ftessier commented Aug 9, 2023

Note that I started cleaning up this branch on the side on branch cleanup-estar-cpp-integration. CLeanup strategy is to keep a null diff between the two branches:

https://github.com/nrc-cnrc/EGSnrc/compare/estar-cpp-integration..cleanup-estar-cpp-integration

@rtownson
Copy link
Collaborator Author

Currently the gas pressure is applied only when a density correction file is not used. It has only one line of action, in the subroutine MIX which "calculates MS parameters", it modifies the density:

IF (GASPP.NE.0.0) [RHOP=GASPP*RHOP;]

Is there a reason that the density itself is not just immediately modified after arguments are read in? For the ESTAR implementation, this would mean that the density change from gas pressure is not considered in the density corrections (just like it is ignored when you use a density correction file). Since a user can just modify the density directly in-line, why have the gas pressure separated?

@rtownson rtownson modified the milestones: Release 2024, Release 2025 Jun 12, 2024
@rtownson rtownson marked this pull request as ready for review June 12, 2024 17:30
@rtownson rtownson requested a review from a team as a code owner June 12, 2024 17:30
@rtownson
Copy link
Collaborator Author

This PR is ready for review / testing :)

@rtownson
Copy link
Collaborator Author

rtownson commented Oct 3, 2024

There seems to be an outstanding bug where elements input with 2 letters (e.g. Al) results in a crash. Mixture compounds with 2 letter elements work fine.

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.

3 participants