Skip to content

A novel particle source 'egs_focal_spot_source' for egs++, an equivalent… #1251

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Apelova
Copy link

@Apelova Apelova commented Feb 7, 2025

…to BEAMNrc's ISOURCE19

This pull request aims at adding a new particle source to EGS++ which could be used for modelling electron focal spots in linear accelerators or x-ray tubes. I have implemented a new particle source for EGS++, which serves as the EGS++ equivalent of the BEAMnrc ISOURCE 19. This source is designed to replicate the behavior of ISOURCE 19 entirely but offers some additional features such as a different angular spread (from the z-axis) along the x- and y-direction. As well as shifting and rotating the particles created (To understand the behaviour of the focal spot source an Input file for the usercode tutor7pp is attached).

An example Input file to test the source for tutot7pp is given below:

 
################################################################################
#
#  Author:          Marvin Apel, 2025
#
#
################################################################################
#
#  An example input file for tutor7pp demonstrating the use of the egs_focal_spot_source. 
#  It is the egs++ equivalent  of an expanded version of BEAMnrc's ISOURCE19.
#
################################################################################
######################################## Run control
:start run control:
    ncase = 4000
:stop run control:

# Comment/Uncomment/Change the Parameters and View the particle tracks in egs_view
######################################## Define the source:
:start source definition:
    :start source:
        library     = egs_focal_spot_source
        name        = my_first_focal_spot
        z position       = 0   #cm
        spatial spread x = 0.3 #cm always standard deviation never FWHM !
        spatial spread y = 0.3 #cm always standard deviation never FWHM !
        #--- translation 
        x translation    = 1.0 #cm (optional) 
        y translation    = 2.0 #cm (optional) 
        #--- cutoff spatial distribution 
        spatial cutoff x = 0.6  #cm (optional, eliptical shape) 
        spatial cutoff y = 9.0  #cm (optional, eliptical shape) 
        #--- angular deviation 
        angular spread x =   0  #° (optional, standard deviation from z-axis)
        angular spread y = 5.0  #° (optional, standard deviation from z-axis)
        #--- rotation of particles (and interpolation back towards z position specified above)
        z of rotation    = -2     #cm (optional) 
        x rotation       =  0  #°  (optional) 
        y rotation       = -5  #°  (optional) 
        :start spectrum:
            type    = monoenergetic
            energy  = 1.0
        :stop spectrum:
        charge      = 0
    :stop source:

    simulation source = my_first_focal_spot
:stop source definition:

:start ausgab object definition:
    :start ausgab object:
        library = egs_track_scoring
        name    = some_name
        stop scoring = 2056
    :stop ausgab object:
:stop ausgab object definition:


######################################## Define the geometry:
:start geometry definition:
    :start geometry:
        name        = WORLD
        library     = egs_box
        box size    = 10 10 10
        :start media input:
            media = air
        :stop media input:
    :stop geometry:
    
    simulation geometry = WORLD
:stop geometry definition:

:start media definition:
    :start air:
        density correction file = air_dry_nearsealevel
    :stop air:
:stop media definition:

######################################### Transport parameters
:start MC transport parameter:
    Global ECUT = 1.5
    Global PCUT = 0.1
:stop MC transport parameter:


######################################### Scoring options.
:start scoring options:
:stop scoring options:

:start view control:
    set color = air 255 255 255 50
:stop view control:

P.S. I do have an implementation for BEAMnrc available (entirely in the beamnrc.mortran file) which would probably require an additional change of the GUI to be usefull for most people, as for now it can only be used by editing the raw egsinp-files.

@Apelova Apelova requested a review from a team as a code owner February 7, 2025 21:43
@Apelova Apelova requested review from ftessier, mainegra and rtownson and removed request for a team February 7, 2025 21:43
@rtownson
Copy link
Collaborator

Great contribution! It'll be a while until we get around to reviewing this. Just so you know, when we do it will likely involve force pushing to your branch on your repository (to format commit style, etc). If you'd like to maintain your original work, just make a local renamed copy of your branch now.

@rtownson rtownson changed the base branch from master to develop February 10, 2025 19:14
@rtownson rtownson added this to the Release 2026 milestone Feb 10, 2025
@Apelova Apelova changed the title A novel particle source 'egs_focal_spot_source' for egs++, a pendant … A novel particle source 'egs_focal_spot_source' for egs++, an equivalent… Feb 18, 2025
@mainegra
Copy link
Contributor

@Apelova this is great! What was the motivation for this implementation and for what kind of scenario did you find significant effects compared to a simplistic rectangular focal spot?

@Apelova
Copy link
Author

Apelova commented Mar 24, 2025

@mainegra I appreciate the feedback. My original intent for writing this source was to approximate the properties of an electron beam impinging on a bremsstrahlung target (in BEAMnrc) and to investigate how a deviation in the angular spread along the X- and Y-directions affects the transverse dose profiles in a water phantom and whether this could be the root of discrepancies between LINAC simulations and measurements. I decided to implement the source in egs++ again because 1. I considered it to be useful for future investigations and 2. there is no source available that behaves like ISOURCE19 initially while also offering the features that this implementation does.

The major improvement that this implementation offers is a better agreement between simulations and experiments along the Y-direction while maintaining identical agreement along the X-direction. This is best illustrated by the example below. The graphs show the gamma-index (DOI: 10.1118/1.1598711) calculated for the experimentally determined and simulated dose profiles. The red dashed line indicates the points where the gamma criterion is being breached. The blue curve shows the gamma-index using ISOURCE19, where the angular deviation (from the z-axis) along the X- and Y-directions is equivalent, while the green curve shows the performance of the simulation using the new "EGS_FOCAL_SPOT_SOURCE."
To summarize, experimental dose profiles exhibit differences along the X- and Y-directions in the regions affected by the angular distribution, which can only be addressed using "EGS_FOCAL_SPOT_SOURCE."

Gamma-Index_IS19_vs_EGS_FOCAL_SPOT_6MV

Not only does the angular distribution of "EGS_FOCAL_SPOT_SOURCE", in comparison to a rectangular distribution (with no angular deviation) improve agreement tremendously, but the spatial gaussian distributions affects the penumbra region of the transverse dose profiles of the emerging photon beam. By adjusting the width of a rectangular distribution, one could achieve satisfactory agreement along the typical transverse dose profiles (X-profile at Y = 0, Z = 5 cm and Y-profile at X = 0, Z = 5 cm), but not along the diagonals.

Additionally, I added features for rotating and translating the focal spot to observe the effect of a faulty adjustment in the bending magnets during experiments and to estimate this source of uncertainty. The effects of rotating the focal spot around the X-axis and translating the focal spot towards -Y within the bremsstrahlung target above the primary collimator are shown below.

Effect_of_Transformations

I’m happy to discuss this further if you have any additional questions.

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