Add 'fwhm' input key to angular spread source#1384
Add 'fwhm' input key to angular spread source#1384cptfinch wants to merge 51 commits intonrc-cnrc:developfrom
Conversation
This gets rid of compilation warnings that LITTLE_ENDIAN, BIG_ENDIAN, and PDP_ENDIAN were already defined on macOS.
Add a new case for aarch64 in the config guess script. The -mcmodel=medium option is not available on ARM architecture, so this is handled. Some of the programs fail to build on aarch64 without setting -Wno-narrowing compiler option, so this is added.
* setup.sh is called when container is created. It installs required packages and performs the EGSnrc configuration * build-gui-apps.sh is called after the container is created and builds the GUI apps. It relies upon the configuration being created and the .bashrc having been setup * .gitignore is updated to ignore the files created when building the devcontainer configuration. Also added additional QT conf files that are generated during build * README.md provides some basic documentation about using devcontainer
Fix a bug in the field definition pop-up window for dynamic and sync jaws in beamnrc_gui. The GUI would display an error about a bad window parent. Rebase on develop
Add particle tracks that including a time index Add egs++ time synchronization and viewer support Allow saving time index to the base source for all simulation objects, as well as support to visualize simulations in time in the viewer. Add a pause feature to the viewer play button If user pushes the play button while the simulation is playing it will pause the simulation at the current time index. Pushing play again causes the simulation to restart from paused position. Also, simulations will now play from current time index instead of defaulting to starting at zero. If the current time index is the last one it will set time to zero and start from the beginning. Set initial position when the viewer is launched Polish dynamic geometry comments and documentation Update documentation and formatting Remove motion control point numbering syntax Update author first name to match other files Fix a few minor typos and formatting issues Apply egs coding style standard with astyle Run astyle (3.4.11) on all files modified .cpp and .h files in this dynamic geometry addition. Tidy up comments to more uniform style and margin Add time into the standard ptracks format The ptracks file will now start with "include time index=" and then a boolean value. egs_view has been updated to support this. This avoids creating a new .syncptracks file extension, that was originally done in this implementation. Also changed the default behaviour for egs_track_scoring so that time index scoring is automatically turned on when dynamic geometries or sources are used, if "include time index" is excluded from the input file. Update references of mu to be time index This changes the egs_phsp_scoring input parameter "score mu" to instead be "score time index". Both inputs are supported, for backwards compatibility.
Add a shape that handles dynamic motion, synchronized with the motion of geometries and sources. Add dynamic shape doxygen documentation, astyle Fix flickering of dynamic particle tracks Fix flickering that occurred when dragging the time slider with the mouse. Particle tracks would flash on the screen from a longer time range than the selected window. Fix memory leak in dynamic geometry and shape Fix motion for shapes lacking source direction Adjust the default viewer time window Change the time window default to 1% of the simulation duration for tracks visualization. Also add a new input in egs_view for the number of time steps to take in the animation. This allows for better control of the visual speed of the motion. Remove shape motion control point numbering syntax Adjust coding style to EGSnrc standard with astyle Fix missing updateNumTimeSteps function Somehow a function got deleted during some git manipulation, so this is just adding it back it. Set the slider based on the number of time steps
Add an application for calculating gamma spectrometry related quantities, like detector efficiency and coincidence summing corrections. The egs_radionuclide_source was changed slightly to allow for the calculations - it now returns the number of decays from getNextParticle, instead of the number of source particles. This does not change the normalization when using the source, but apps specially designed to use current_case and last_case for the radionuclide source may be affected.
Change the radionuclide spectrum so that it is no longer part of egs_spectra.cpp. Instead, it is in egs_radionuclide_source, because it is not compatible with any other source. Also, add virtual functions to the base source class to be able to extract information from the radionuclide source without needing to do a static cast. These functions were also added to the source collection and transformed source classes.
Add the feature for egs_gammaspec to get the gamma analysis energies automatically from the radionuclide decay scheme, if one is used. Also fix the normalization of the efficiency calculations.
Change the output spectra from egs_gammaspec to report the energy at the middle of each energy bin, instead of the lower edge of the bin.
Fix a bug where some ensdf files from the nndc caused a segmentation fault for egs_radionuclide source. This was due to comment lines following gamma records in the file. The code did not check to see if a normalization record existed before trying to use it, and this has been fixed.
Fix a bug in egs_ensdf that resulted in the x-rays and auger electrons in the ensdf file for Zn-65 not being used. This has no impact if the relaxations are set to the default of using EADL data.
- Total fluence normalization bug during output: expression norm /= volume[k]; reduces normalization for F[k] by V[k-1]*V[k-2]*...*V[1] changed to norm = norma/volume[k]; - Eliminate misleading message in fluence scoring When scoring photon fluence, no message related to electron fluence calculation method should be issued. Thanks to Alexandra Bourgouin for drawing my attention to this issue! Fixes issue nrc-cnrc#1002 - Read user-requested normalization not only when differential fluence requested as it is also needed for integral fluence
Same bug affecting total fluence whereby in the case of differential fluence scoring in multiple regions the normalization for region i was divided by the volume of the precedent regions.
If estimating differential fluence for several regions, one might want to turn off diff fluence output to terminal. This can be achieved by setting verbose = no In the AO input block. Added a clarifying message stating that diff fluence is output as a Grace plot file.
It was being read outside that block which didn't make sense and was error prone as one would have expected to find it inside that block.
Forgot to use proper spacing in IF block for diff fluence scaling inputs.
BUG: Commit 8023cd01 labels fluorescent photons from EII as secondaries.
The pertinent block for UBS and BCSE requires knowledge of the
local region number IRL, which is only set later in AUSGAB.
FIX: Set IRL above the UBS/BCSE block in the AUSGAB routine.
Funnily enough this bug only showed when using BEAMnrc as library, not
during BEAM simulations. Perhaps IRL was taking values below smaller
than the dimension of the IREGION_TO_BIT array, set to 3000.
Follow-up on previous commit: Why did the bug not appear during standalone BEAMnrc runs? During direct BEAMnrc simulations, when IRL isn't set in the block to split EII-generated secondary photons, it takes value 2, the first region of the geometry, set during previous calls to AUSGAB. When using BEAMnrc as a library with other applications, the memory location IRL is pointing to can change, taking an arbitrary number. In my case it was a very large integer.
Add libclean target to standard beam_makefile which removes BEAMnrc library related files. Until now one had to do this manually!
Fixes
=====
- Average source energy calculation was assuming a statistical weight of
1 and lumping all particles together. Now weight is accounted for, and
average energy for photons and charge particles scored separately.
Moreover, average energy of scoring photons is also estimated.
- Typos in differential fluence xmgrace file output
Additions
=========
- Flexible scoring region input spares user from having to enter huge
number of regions one at the time. Here are the different input
schemes:
a) Individual entries using 'scoring regions' input key Simply enter
scoring regions individually
b) Initial and final region pairs using `scoring region ranges`
Expects pairs of initial and final scoring regions
c) Groups of regions using 'scoring start region' and 'scoring stop
region' input keys. Requires using two input keys on two lines,
similar to what is done for the dose scoring ausgab object.
d) Equally spaced scoring regions using key 'Incremental scoring
regions' The most general scheme, expects triplets of initial,
final and increment regions allowing the definition of ranges where
scoring is performed at specified intervals (increments) between
regions. Note that using an increment of 1 is equivalent to schemes
b) and c).
If an error in these inputs is detected, code aborts with a warning
message, rather than simply ignoring the error.
- Scoring regions mass input schemes:
Using `scoring region masses` input key
a) One value per region, regardless of scoring region input scheme
b) One value per group (pair or triplet) when using scoring input
options b, c, or d above.
c) One value for all regions (positive)
d) One value for whole scoring volume (negative)
Using `scoring volume mass` input key assumes mass for whole scoring
volume as in d).
- Fluence calculation expanded to estimating integral fluence on all
scoring regions ir for each calculation geometry ig, Ftot(ig,ir), and
differential fluence (spectrum) Fdiff(ig,E), for each calculation
geometry ig in the total scoring volume.
TODO: Add option to specify spectral scoring regions rather than using
all scoring regions.
- Estimate average mass-energy absorption coefficient in each scoring
region when integral fluence is calculated.
- Fix small typo in output
The new, more natural way of projection input, had a typo in the projection variable iproj
- To avoid potential clashes with BEAM sources and AOs that might rely on the use of latch, particles entering exclusion zones are now killed. This approach is about 40% faster for the example input file example_1m_40keV_FD.egsinp Results using both options, latch set to -1 or killing the photons when entering an exclusion regions are consistent within 0.004% k=1 uncertainty when estimating concrete wall contributions to a 5 cm air sphere in the middle of an 8 m X 8 m room. Fixes bug noted by @bwalters when multiplying latch by -1 which was wrong for cases where latch = 0. - A check has been added to verify that the user did not mistakenly define regions as being both scoring and exclusion regions. Although the code gives preferences to the scoring region, it is deemed safer to abort issuing a warning.
- It was still using the old file name emuen_icru90_1.5MeV.data - It should be emuen_rho_air_1keV-1.5MeV.data
- Added comment line on top of the E*muen/rho file names stating that these values were ontained uding the g app with the MCDF-XCOM option
- For e- sources was adding the e- rest mass to the e- kinetic energy which is actually done in the EGS_AdvancedApplication::shower method
Fix missing initialization of variables for IAEA phase-spaces in the RZ codes. While this didn't result in a crash, it did result in a bug where all particles were assigned a charge of 0 during the transport.
Address issue where IAEA phase-space variables weren't properly initialized in RZ applications, causing all particles to be incorrectly processed as photons. This serious bug warrants release 2025a. IMPORTANT: Anyone who has ever utilized IAEA phase-space files with RZ applications should review their simulation results.
ftessier
left a comment
There was a problem hiding this comment.
The fwhm input key is certainly an improvement over the old negative-sigma overload!
Minor suggestions
-
Consider defining
0.4246609001440095285as a named constant for readability, perhaps something like:// 1 / (2*sqrt(2*ln(2))) static const EGS_Float FWHM_TO_SIGMA = 0.4246609001440095285; -
A comment noting that
sigmaholds σ² (in rad²) after conversion, and not σ, would help future developers.
Pre-existing bug
I noted another bug: The egsWarning call for a missing source name is missing its format argument:
// current (reads garbage for %s):
egsWarning("...a source named %s does not exist\n");
// should be:
egsWarning("...a source named %s does not exist\n", sname.c_str());Might be worth fixing while we're in this file!
Fix a bug in EGS_PlanarFluence::initScoring where the affine transform for the scoring rectangle was applied to the outer ausgab object input block instead of the inner planar scoring object. As a result, any transformation defined within ":start planar scoring:" was silently ignored and never applied to the rectangle's position or orientation.
The default settings of $MAXCDOSE and $MAXRADII required a larger $MXREG, so this is fixed.
Add a dedicated 'fwhm' input key for specifying the angular spread as full width at half maximum, replacing the unintuitive convention of using negative 'sigma' values. Negative 'sigma' now produces a fatal error with a message directing users to the new 'fwhm' key. Address review feedback: - Extract FWHM-to-sigma conversion factor as named constant - Clarify that sigma stores sigma^2 in rad^2 after conversion - Fix pre-existing bug: missing format argument in egsWarning
a698a0d to
ba90783
Compare
cptfinch
left a comment
There was a problem hiding this comment.
Points addressed. Named the FWHM-to-sigma conversion constant; added comments clarifying that sigma stores sigma^2 in rad^2; fixed the missing egsWarning format argument. Rebased onto develop — the original branch was mistakenly based on master.
|
There are not conflicts of course, since this pr is only adding 2 new files. |
Fixes #1214
Summary
fwhminput key for specifying angular spread as full width at half maximum (in degrees)sigmavalues now produce a fatal error with a message directing users to the newfwhmkeysigmaandfwhmsimultaneouslyChanges
egs_angular_spread_source.cpp: Restructured the input parsing in the constructor to accept eithersigmaorfwhm, with appropriate error handling for invalid combinations.egs_angular_spread_source.h: Updated the doxygen documentation block to show both input keys and describe their usage.Testing
0.4246609001440095285 = 1/(2*sqrt(2*ln(2)))) as the previous negative-sigma path