EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
Classes
Particle sources

This module contains classes that model particle sources. If you are looking for description of how to define a certain particle source in your input file, click on the corresponding class and see the detailed description. More...

Classes

class  EGS_BaseSource
 Base source class. All particle sources must be derived from this class. More...
 
class  EGS_BaseSpectrum
 Base class for energy spectra. All energy spectra in the EGSnrc C++ class library are derived from this class. More...
 
class  EGS_BaseSimpleSource
 Base class for 'simple' particle sources. More...
 
class  EGS_AngularSpreadSource
 A source that adds additional Gaussian angular spread to another source. More...
 
class  EGS_BeamSource
 A BEAM simulation source. More...
 
class  EGS_CollimatedSource
 A collimated particle source. More...
 
class  EGS_DynamicSource
 A source with time-varying rotations/translations. More...
 
class  EGS_FanoSource
 A Fano source. More...
 
class  EGS_IsotropicSource
 An isotropic source. More...
 
class  EGS_ParallelBeam
 A parallel beam. More...
 
class  EGS_PhspSource
 A phase-space file source. More...
 
class  EGS_PointSource
 A point source. More...
 
class  EGS_RadionuclideSource
 A radionuclide source. More...
 
class  EGS_SourceCollection
 A source collection. More...
 
class  EGS_TransformedSource
 A transformed source. More...
 
class  IAEA_PhspSource
 An IAEA phase-space file source. More...
 

Detailed Description

This module contains classes that model particle sources. If you are looking for description of how to define a certain particle source in your input file, click on the corresponding class and see the detailed description.

General discussion

A particle source is an object that is able to deliver the charge $q$, energies $E$, positions $\vec{x}$, directions $\vec{u}$ and statistical weights $w$ of particles distributed according to a certain probability distribution, given a random number generator. Based on this abstraction, particle sources in the EGSnrc class library are classes derived from an abstract base source class , which specifies the interface to a particle source object. The main method in this interface is the

getNextParticle()

function, which takes a random number generator object as input and returns the parameters of a single particle.

Apart from a phase-space file particle source, all other sources provided in the RZ series of EGSnrc applications, in DOSXYZnrc and in BEAMnrc, are sources which consist of two independent objects: the first object determines the particle energy, the other object the particle position, direction and statistical weight. Because of this, there is a partial specification of the base source class, called EGS_BaseSimpleSource, that consists of a spectrum object and a virtual function that determines $\vec{x}, \vec{u}$ and $w$. Several particle sources are derived from EGS_BaseSimpleSource so that they can use any spectrum together with their method for picking positions, directions and energies. In addition to the particle source class handling phase-space files and the sources derived from EGS_BaseSimpleSource, which can be considered as "elementary" or "primitive" sources in analogy to the elementary geometries (i.e. they implement the getNextParticle method directly, there are two "composite" sources, where the getNextParticle method is implemented using the getNextParticle methods of their constituents. It is worth noting that, unlike the sources used in the RZ series of EGSnrc applications, DOSXYZnrc and BEAMnrc, all particle sources in the EGSnrc C++ class library are completely decoupled from the geometry. During the simulation particles are taken from the source and it is checked if the particle position is already inside the simulation geometry using its isWhere() method. If the position is inside, or if the particle trajectory intersects the geometry (determined using the howfar() geometry method called with an outside region index), the particle is put on the EGSnrc particle stack with the just determined region index and its transport through the geometry is simulated. This approach permits any source to be used with any geometry in any application using the EGSnrc C++ class library.

Design of the egspp particle sources package

All particle sources in the egspp package are derived from the EGS_BaseSource class, which is part of the main egspp library. Classes modeling concrete particle sources are compiled into separate shared libraries (a.k.a. dynamic shared objects, DSO, or dynamically linkable library, DLL) that can be loaded dynamically at run time as needed. Each of these sources libraries provides a

EGS_BaseSource *createSource(EGS_Input *inp)

C-style function, the address of which is resolved when a source library is loaded and is used to create a source object from the input information stored in an EGS_Input object and pointed to by inp. The information stored in the input object is typically extracted from an input file that specifies the various aspects of a particle simulation. It is of course possible to create an EGS_Input object specifying one or more particle sources by other means (e.g. within a GUI) and then use the source creation functions EGS_BaseGeometry::createSource() to obtain a pointer to the particle source object.

The motivation behind this design is twofold:

Common sources input syntax

Because the design of the particle sources package is very similar to the design of the geometry package, the input syntax of an input object specifying particle sources follows the same principles as the geometry package explained in section Common geometry input syntax a particle source is specified with a source composite property within a source definition property. Each source definition must define a name for the source using a name key and the library in which the source is found using a library key. For instance,

:start source definition:
    :start source:
        library = egs_point_source
        name = some_name
        other input
    :stop source:
    simulation source = some_name
:stop source definition:

placed in the input file controlling the simulation will result in the creation of a point source named some_source from the library egs_point_source.

Creating a new particle source

The list of particle sources provided with egspp is by no means exhaustive. We will be adding additional sources as the need arrives. In the meantime, if your simulation problem requires a source not available with the current version of egspp, you will need to create your own particle source DSO. This is not very hard as demonstrated by this example.

Todo:
Add a general simulation source, i.e. a source that takes particles from some other source, simulates their transport through a geometry and collects the particles exiting/entering some region in space, and returns these when asked for a particle.