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

EGS_AdvancedApplication implementation. More...

#include "egs_advanced_application.h"
#include "egs_functions.h"
#include "egs_interface2.h"
#include "egs_run_control.h"
#include "egs_base_source.h"
#include "egs_input.h"
#include "egs_interpolator.h"
#include "egs_rndm.h"
#include "egs_math.h"
#include "egs_ausgab_object.h"
#include <string>
#include <cstdio>
#include <cstdarg>
#include <cstdlib>
#include <cstring>

Go to the source code of this file.

Macros

#define CHECK_GET_APPLICATION(a, b)   EGS_Application *a = EGS_Application::activeApplication();
 
#define egsGetRNGPointers   F77_OBJ_(egs_get_rng_pointers,EGS_GET_RNG_POINTERS)
 
#define egsGetRNGArray   F77_OBJ_(egs_get_rng_array,EGS_GET_RNG_ARRAY)
 
#define egsSetRNGState   F77_OBJ_(egs_set_rng_state,EGS_SET_RNG_STATE)
 
#define egsGetSteps   F77_OBJ_(egs_get_steps,EGS_GET_STEPS)
 
#define egsSetSteps   F77_OBJ_(egs_set_steps,EGS_SET_STEPS)
 
#define egsOpenUnits   F77_OBJ_(egs_open_units,EGS_OPEN_UNITS)
 
#define egsGetElectronData   F77_OBJ_(egs_get_electron_data,EGS_GET_ELECTRON_DATA)
 
#define egsGetPhotonData   F77_OBJ_(egs_get_photon_data,EGS_GET_PHOTON_DATA)
 

Functions

__extc__ void egsGetRNGPointers (EGS_I32 *, EGS_I32 *)
 
__extc__ void egsGetRNGArray (EGS_Float *)
 
__extc__ void egsSetRNGState (const EGS_I32 *, const EGS_Float *)
 
__extc__ void egsGetSteps (double *, double *)
 
__extc__ void egsSetSteps (const double *, const double *)
 
__extc__ void egsOpenUnits (const EGS_I32 *)
 
__extc__ void egsGetElectronData (void(*func)(EGS_I32 *, EGS_Float *, EGS_Float *, EGS_Float *, EGS_Float *), const EGS_I32 *, const EGS_I32 *)
 
__extc__ void egsGetPhotonData (void(*func)(EGS_I32 *, EGS_Float *, EGS_Float *, EGS_Float *, EGS_Float *), const EGS_I32 *, const EGS_I32 *)
 
__extc__ void F77_OBJ_ (egs_write_string, EGS_WRITE_STRING)(int *
 
void EGS_LOCAL __write_to_fortran_file (const char *msg,...)
 
void EGS_LOCAL __write_to_fortran_file_and_exit (const char *msg,...)
 
__extc__ void F77_OBJ_ (egs_set_defaults, EGS_SET_DEFAULTS)()
 
__extc__ void F77_OBJ_ (egs_init1, EGS_INIT1)()
 
void F77_OBJ_ (set_elastic_parameter, SET_ELASTIC_PARAMETER)()
 
__extc__ void egsHowfar ()
 Calculate distance to the next boundary along the current direction of motion. More...
 
__extc__ void egsHownear (EGS_Float *tperp)
 Calculate minimum perpendicular distance to any surrounding boundary and return it in tperp. More...
 
__extc__ void egsFillRandomArray (const EGS_I32 *n, EGS_Float *rarray)
 Get n random numbers stored in the array pointed to by rarray. More...
 
__extc__ void egsAusgab (EGS_I32 *iarg)
 User scoring function. More...
 
__extc__ void egsStartParticle ()
 Start the transport of a new particle. More...
 

Variables

__extc__ void const char int
 

Detailed Description

EGS_AdvancedApplication implementation.

Author
Iwan Kawrakow, NRC

Also provides implementations of the C-style functions needed to link against the mortran back-end egsHowfar(), egsHownear(), egsAusgab(), and egsStartParticle().

Definition in file egs_advanced_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 1264 of file egs_advanced_application.cpp.

__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 1311 of file egs_advanced_application.cpp.

__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 1319 of file egs_advanced_application.cpp.

__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 1328 of file egs_advanced_application.cpp.

__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 1343 of file egs_advanced_application.cpp.