EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
Functions | Variables
egs_simple_application.cpp File Reference

EGS_SimpleApplication implementation. More...

#include "egs_simple_application.h"
#include "egs_input.h"
#include "egs_base_source.h"
#include "egs_timer.h"
#include "egs_rndm.h"
#include "egs_interface2.h"
#include <cstring>
#include <cstdlib>

Go to the source code of this file.

Functions

void _null_terminate (char *s, int len)
 
__extc__ void egsHowfar ()
 Calculate distance to the next boundary along the current direction of motion. More...
 
__extc__ void egsAusgab (EGS_I32 *iarg)
 User scoring function. More...
 
__extc__ void egsHownear (EGS_Float *tperp)
 Calculate minimum perpendicular distance to any surrounding boundary and return it in tperp. More...
 
__extc__ void egsStartParticle ()
 Start the transport of a new particle. More...
 
__extc__ void egsFillRandomArray (const EGS_I32 *n, EGS_Float *rarray)
 Get n random numbers stored in the array pointed to by rarray. More...
 

Variables

const char fs = '/'
 

Detailed Description

EGS_SimpleApplication implementation.

Author
Iwan Kawrakow, NRC

Also provides C-style functions needed to link with the mortran back-end.

Definition in file egs_simple_application.cpp.

Function Documentation

__extc__ void egsHowfar ( void  )

Calculate distance to the next boundary along the current direction of motion.

This function must be implemented in user codes written in C. (implementation is automatically provided for C++ applications deriving from EGS_SimpleApplication or EGS_AdvancedApplication). The intended step length is available in the_epcont->ustep, particle position, direction, region number, etc. from the top particle on the particle stack the_stack. This function must calculate the distance t to the next boundary along the particle direction and

  • If t > the_epcont->ustep, just return
  • If t <= the_epcont->ustep, set the_epcont->ustep to t, set the_epcont->irnew to the new region index and set the_useful->medium_new to the new medium. If you wish to have a transport cutoff higher than the particle production threshold of the medium in the region, set the_bounds->ecut_new or the_bounds->pcut_new to the desired value(depending on particle charge). If the current particle is an electron and you want to restrict the step size in the new region, set the_etcontrol->smax_new to the desired value. If you want to have a non-default mass density in the new region, set the_useful->rhor_new to the desired value (ratio of desired mass density to the default mass density).
  • If you want to discard the particle immediately, set the_useful->idisc to a positive value.
  • If you want to discard the particle after the step is completed, set the_useful->idisc to a negative value.

Definition at line 357 of file egs_simple_application.cpp.

References egsWarning, EGS_SimpleApplication::howfar(), EGS_Epcont::idisc, EGS_Stack::ir, EGS_Epcont::irnew, EGS_Useful::medium_new, EGS_Stack::np, the_epcont, the_stack, the_useful, EGS_Stack::u, EGS_Epcont::ustep, EGS_Stack::v, EGS_Stack::w, EGS_Stack::x, EGS_Stack::y, and EGS_Stack::z.

__extc__ void egsAusgab ( EGS_I32 *  iarg)

User scoring function.

This function must be implemented by user codes written in C to perform the actual scoring. The value of iarg depends on the event that triggered the call (see PIRS-701 for details). C++ applications deriving from EGS_SimpleApplication or EGS_AdvancedApplication must implement the respective ausgab() virtual function.

Definition at line 379 of file egs_simple_application.cpp.

References EGS_SimpleApplication::ausgab(), EGS_Stack::E, EGS_Stack::iq, EGS_Stack::ir, EGS_Stack::latch, EGS_Stack::np, the_stack, EGS_Stack::u, EGS_Stack::v, EGS_Stack::w, EGS_Stack::wt, EGS_Stack::x, EGS_Stack::y, and EGS_Stack::z.

__extc__ void egsHownear ( EGS_Float *  tperp)

Calculate minimum perpendicular distance to any surrounding boundary and return it in tperp.

This function must be implemented by user codes written in C (implementation is automatically provided for C++ applications deriving from EGS_SimpleApplication or EGS_AdvancedApplication). If it is impossible to calculate tperp, you must set tperp to 0. In this case the transport will be determined by the setings of EGS_EtControl::transport_algorithm, EGS_EtControl::bca_algorithm and EGS_EtControl::skin_depth_for_bca (see PIRS-701 for details).

Definition at line 383 of file egs_simple_application.cpp.

References EGS_SimpleApplication::hownear(), EGS_Stack::ir, EGS_Stack::np, the_stack, EGS_Stack::x, EGS_Stack::y, and EGS_Stack::z.

__extc__ void egsStartParticle ( void  )

Start the transport of a new particle.

This function is called just before the transport of a new particle begins (this may be either directly a source particle or just the next particle on the stack). User codes written in C must implement this function to set

  • the_useful->medium to the medium in the region the particle is in.
  • the_useful->rhor to the ratio of the region mass density to the default mass density (if you want to use a non-default mass density)
  • the_bounds->ecut or the_bounds->pcut to the transport cut-off energy (depending on the particle charge). Note that e/pcut must be greater than, or equal to, the_thresh->ae/p of the current medium
  • the_etcontrol->smaxir to the maximum geometrical step-size restriction, if the particle is an electron and you wish to impose such restrictions. Simple C++ applications deriving from EGS_SimpleApplication can not have a region-by-region variation of transport threshold energies, smax or non-default mass densities and an implementation is automatically provided. An implementation is also provided for advanced C++ applications deriving from EGS_AdvancedApplication. Such applications can implement region-by-region variation of these quantities by re-implementing EGS_AdvancedApplication::startNewParticle().

Definition at line 390 of file egs_simple_application.cpp.

References EGS_SimpleApplication::getMedium(), EGS_Epcont::idisc, EGS_Stack::ir, EGS_Useful::medium, EGS_Stack::np, the_epcont, the_stack, and the_useful.

__extc__ void egsFillRandomArray ( const EGS_I32 *  n,
EGS_Float *  rarray 
)

Get n random numbers stored in the array pointed to by rarray.

This function should only be used from the C interface after the RNG has been initialized using egsRandomInit() or egsRandomDefaultInit(). C++ objects should use EGS_RandomGenerator objetcs instead, either EGS_SimpleApplication::rndm or EGS_AdvancedApplication::rndm or their own RNG object.

Definition at line 397 of file egs_simple_application.cpp.

References EGS_SimpleApplication::fillRandomArray().