EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_interface2.h
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc simple C interface headers
5 # Copyright (C) 2015 National Research Council Canada
6 #
7 # This file is part of EGSnrc.
8 #
9 # EGSnrc is free software: you can redistribute it and/or modify it under
10 # the terms of the GNU Affero General Public License as published by the
11 # Free Software Foundation, either version 3 of the License, or (at your
12 # option) any later version.
13 #
14 # EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
17 # more details.
18 #
19 # You should have received a copy of the GNU Affero General Public License
20 # along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
21 #
22 ###############################################################################
23 #
24 # Author: Iwan Kawrakow, 2003
25 #
26 # Contributors: Ernesto Mainegra-Hing
27 # Blake Walters
28 # Reid Townson
29 # Max Orok
30 #
31 ###############################################################################
32 */
33 
34 
87 #ifndef EGS_INTERFACE1_
88 #define EGS_INTERFACE1_
89 
90 #include "egs_config1.h"
91 
92 /* Note: The C-preprocessor macros MXMED and MXSTACK must be defined in the
93  file array_sizes.h. */
94 #include "array_sizes.h"
95 
99 #define MXAUS 35 /* there are 35 different calls to ausgab */
100 
108 struct EGS_Stack {
110  double E[MXSTACK];
112  EGS_Float x[MXSTACK];
114  EGS_Float y[MXSTACK];
116  EGS_Float z[MXSTACK];
118  EGS_Float u[MXSTACK];
120  EGS_Float v[MXSTACK];
122  EGS_Float w[MXSTACK];
124  EGS_Float dnear[MXSTACK];
126  EGS_Float wt[MXSTACK];
128  EGS_I32 iq[MXSTACK];
130  EGS_I32 ir[MXSTACK];
134  EGS_I32 latch[MXSTACK];
136  EGS_I32 latchi;
138  EGS_I32 np;
140  EGS_I32 npold;
141 };
142 
178 struct EGS_Bounds {
181  EGS_Float ecut;
183  EGS_Float pcut;
185  EGS_Float ecut_new;
187  EGS_Float pcut_new;
189  EGS_Float vacdst;
190 };
191 
204 struct EGS_Thresh {
206  EGS_Float rmt2;
208  EGS_Float rmsq;
212  EGS_Float ap[MXMED];
216  EGS_Float ae[MXMED];
218  EGS_Float up[MXMED];
220  EGS_Float ue[MXMED];
222  EGS_Float te[MXMED];
224  EGS_Float thmoll[MXMED];
225 };
226 
232 struct EGS_Epcont {
234  double edep;
236  double edep_local;
238  EGS_Float tstep;
240  EGS_Float tustep;
243  EGS_Float ustep;
245  EGS_Float tvstep;
247  EGS_Float vstep;
250  EGS_Float rhof;
252  EGS_Float eold;
254  EGS_Float enew;
256  EGS_Float eke;
258  EGS_Float elke;
260  EGS_Float gle;
262  EGS_Float e_range;
264  EGS_Float x_final, y_final, z_final;
267  EGS_Float u_final, v_final, w_final;
275  EGS_I32 idisc;
277  EGS_I32 irold;
279  EGS_I32 irnew;
281  EGS_I32 iausfl[MXAUS];
282 };
283 
291  EGS_Float smaxir;
293  EGS_Float smax_new;
295  EGS_Float estepe;
297  EGS_Float ximax;
302  EGS_Float skindepth_for_bca;
307  EGS_I32 bca_algorithm;
313  EGS_I32 exact_bca;
314 };
315 
320 struct EGS_Media {
322  EGS_Float rho[MXMED];
324  char pxsec[16];
326  char eiixsec[16];
328  char compxsec[16];
330  char photonucxsec[16];
332  EGS_I32 nmed;
333 };
334 
339 struct EGS_Rayleigh {
341  char ff_media[MXMED][24];
343  char ff_file[MXMED][128];
344 };
345 
351 struct EGS_Useful {
352  double pzero,
353  prm,
355  EGS_Float rm,
358  EGS_I32 medium,
361 };
362 
390 struct EGS_XOptions {
391 
405  EGS_I32 ibrdst;
406 
418  EGS_I32 iprdst;
419 
433  EGS_I32 ibr_nist;
434 
443  EGS_I32 spin_effects;
444 
456  EGS_I32 ibcmp;
457 
468  EGS_I32 iraylr;
469 
478  EGS_I32 iedgfl;
479 
490  EGS_I32 iphter;
491 
505  EGS_I32 pair_nrc;
506 
516  EGS_I32 itriplet;
517 
530  EGS_I32 radc_flag;
531 
541  EGS_I32 eii_flag;
542 
550  EGS_I32 iphotonuc;
551 
552  EGS_I32 eadl_relax;
553 
554  EGS_I32 mcdf_pe_xsections;
555 
556 };
557 
576  EGS_Float e_max_rr;
577 
579  EGS_Float e_max_rr_new;
580 
583  EGS_Float prob_RR;
584 
586  EGS_I32 nbr_split;
587 
593  EGS_I32 i_play_RR;
594 
599  EGS_I32 i_survived_RR;
600 
602  EGS_I32 n_RR_warning;
603 
606  EGS_I32 i_do_rr;
607 };
608 
617 struct EGS_IO {
618  char file_extensions[20][10];
619  EGS_I32 file_units[20];
620  char user_code[64];
621  char input_file[256];
622  char output_file[256];
623  char pegs_file[256];
624  char hen_house[128];
625  char egs_home[128];
626  char work_dir[128];
627  char host_name[64];
628  EGS_I32 n_parallel, i_parallel, first_parallel, n_max_parallel,
629  n_chunk, n_files, i_input, i_log, i_incoh, i_nist_data,
630  i_mscat, i_photo_cs, i_photo_relax, xsec_out, is_batch,
631  is_uniform_run, is_pegsless;
632 };
633 
641  EGS_Float ExIN, EyIN, EzIN, EMLMTIN,
642  BxIN, ByIN, BzIN, Bx, By, Bz, Bx_new, By_new, Bz_new;
643  bool emfield_on;
644 };
645 
648 extern __extc__ struct EGS_Stack *the_stack;
649 
652 extern __extc__ struct EGS_Bounds *the_bounds;
653 
656 extern __extc__ struct EGS_Thresh *the_thresh;
657 
660 extern __extc__ struct EGS_Epcont *the_epcont;
661 
664 extern __extc__ struct EGS_EtControl *the_etcontrol;
665 
668 extern __extc__ struct EGS_Media *the_media;
669 
672 extern __extc__ struct EGS_Useful *the_useful;
673 
676 extern __extc__ struct EGS_XOptions *the_xoptions;
677 
680 extern __extc__ struct EGS_IO *the_egsio;
681 
684 extern __extc__ struct EGS_VarianceReduction *the_egsvr;
685 
688 extern __extc__ struct EGS_Rayleigh *the_rayleigh;
689 
692 extern __extc__ struct EGS_emfInputs *the_emf;
693 
694 /* ******************* EGSnrc interface functions *************************/
695 
696 
712 extern __extc__ void egsInit(int argc, char **argv);
713 
715 #define egsFinish F77_OBJ_(egs_finish,EGS_FINISH)
716 
725 extern __extc__ void egsFinish(void);
726 
728 #define egsAddMedium F77_OBJ_(egs_add_medium,EGS_ADD_MEDIUM)
729 
740 extern __extc__ EGS_I32 egsAddMedium(const char *medname, EGS_I32 length);
741 
745 #define egsHatch F77_OBJ_(egs_hatch,EGS_HATCH)
756 extern __extc__ void egsHatch(void);
757 
761 #define egsShower F77_OBJ_(egs_shower,EGS_SHOWER)
771 extern __extc__ void egsShower(void);
772 
773 /****************************************************************************
774  Functions for using the EGSnrc random number generator
775  Only relevant for user codes written in C
776  ****************************************************************************/
777 
779 #define egsRandomDefaultInit F77_OBJ_(egs_init_default_rng,EGS_INIT_DEFAULT_RNG)
789 extern __extc__ void egsRandomDefaultInit();
790 
792 #define egsRandomInit F77_OBJ_(egs_init_rng,EGS_INIT_RNG)
804 extern __extc__ void egsRandomInit(const EGS_I32 *s1, const EGS_I32 *s2);
805 
807 #define egsRandomGet F77_OBJ_(egs_get_rndm,EGS_GET_RNDM)
818 extern __extc__ void egsRandomGet(EGS_Float *ranno);
819 
821 #define egsFillRandomArray F77_OBJ_(egs_fill_rndm_array,EGS_GET_RNDM_ARRAY)
822 
831 extern __extc__ void egsFillRandomArray(const EGS_I32 *n, EGS_Float *rarray);
832 
833 /*****************************************************************************
834  Some utility functions
835  *****************************************************************************/
836 
838 #define egsElapsedTime F77_OBJ_(egs_tot_time,EGS_TOT_TIME)
844 extern __extc__ EGS_Float egsElapsedTime(int *flag);
845 
847 #define egsCpuTime F77_OBJ_(egs_etime,EGS_ETIME)
853 extern __extc__ EGS_Float egsCpuTime(void);
854 
856 #define egsGetTransportParameter F77_OBJ_(get_transport_parameter,GET_TRANSPORT_PARAMETER)
865 extern __extc__ void egsGetTransportParameter(const int *ounit);
866 
867 
868 /*****************************************************************************
869  Fuctions that must be implemented by user codes written in C
870  *****************************************************************************/
871 
873 #define egsHowfar F77_OBJ_(egs_howfar,EGS_HOWFAR)
903 extern __extc__ void egsHowfar(void);
904 
906 #define egsHownear F77_OBJ_(egs_hownear,EGS_HOWNEAR)
919 extern __extc__ void egsHownear(EGS_Float *tperp);
920 
922 #define egsAusgab F77_OBJ_(egs_ausgab,EGS_AUSGAB)
932 extern __extc__ void egsAusgab(EGS_I32 *iarg);
933 
935 #define egsStartParticle F77_OBJ_(egs_start_particle,EGS_START_PARTICLE)
959 extern __extc__ void egsStartParticle(void);
960 
961 #endif
__extc__ struct EGS_VarianceReduction * the_egsvr
The address of the mortran egs_vr common block as a pointer to a C-structure of type EGS_VarianceRedu...
__extc__ struct EGS_Useful * the_useful
The address of the mortran USEFUL common block as a pointer to a C-structure of type EGS_Useful.
__extc__ struct EGS_Bounds * the_bounds
The address of the morrtan BOUNDS common block as a pointer to a C-structure of type EGS_Bounds.
__extc__ struct EGS_Epcont * the_epcont
The address of the mortran EPCONT common block as a pointer to a C-structure of type EGS_Epcont.
#define egsRandomInit
#define egsHatch
Initialize cross section data from a PEGS4 data file.
__extc__ struct EGS_emfInputs * the_emf
The address of the mortran EMF-INPUTS common block as a pointer to a C-structure of type EGS_emfInput...
#define egsHowfar
Calculate distance to the next boundary along the current direction of motion.
#define egsRandomGet
#define egsShower
Transport the particles currently on the particle stack.
#define egsElapsedTime
#define egsAusgab
__extc__ struct EGS_EtControl * the_etcontrol
The address of the mortran Et_Control common block as a pointer to a C-structure of type EGS_EtContro...
__extc__ struct EGS_XOptions * the_xoptions
The address of the mortran cross section options common block as a pointer to a C-structure of type E...
__extc__ void egsInit(int argc, char **argv)
Initializes the EGSnrc mortran back-end.
#define egsStartParticle
Start the transport of a new particle.
#define egsGetTransportParameter
#define egsHownear
#define egsFillRandomArray
#define egsFinish
Finish a simulation.
__extc__ struct EGS_Rayleigh * the_rayleigh
The address of the mortran rayleigh_inputs common block as a pointer to a C-structure of type EGS_Ray...
__extc__ struct EGS_Stack * the_stack
The address of the mortran STACK common block as a pointer to a C-structure of type EGS_Stack.
#define egsAddMedium
__extc__ struct EGS_Media * the_media
The address of the mortran MEDIA common block as a pointer to a C-structure of type EGS_Media
#define egsRandomDefaultInit
Initialize the EGSnrc RNG using default values.
__extc__ struct EGS_IO * the_egsio
The address of the mortran egs_io common block as a pointer to a C-structure of type EGS_IO.
#define MXAUS
__extc__ struct EGS_Thresh * the_thresh
The address of the mortran THRESH common block as a pointer to a C-structure of type EGS_Thresh.
#define egsCpuTime
Get the CPU time used since the process started.
A structure corresponding to the EGSnrc transport threshold energies common block BOUNDS.
EGS_Float pcut_new
EGS_Float pcut
EGS_Float vacdst
EGS_Float ecut
EGS_Float ecut_new
A structure corresponding to the EPCONT common block.
EGS_Float e_range
EGS_Float tvstep
EGS_Float x_final
EGS_Float u_final
EGS_Float ustep
double edep_local
EGS_Float tustep
EGS_Float enew
EGS_Float rhof
EGS_I32 idisc
EGS_Float elke
EGS_Float vstep
EGS_Float gle
EGS_Float eold
EGS_I32 irnew
EGS_I32 irold
EGS_Float tstep
EGS_Float eke
EGS_I32 iausfl[MXAUS]
A structure corresponding to the ET_control common block.
EGS_Float smaxir
EGS_Float estepe
EGS_Float ximax
EGS_Float smax_new
EGS_Float skindepth_for_bca
EGS_I32 bca_algorithm
EGS_I32 transport_algorithm
A structure corresponding to the egs_io common block.
A structure corresponding to the MEDIA common block.
char pxsec[16]
char eiixsec[16]
char photonucxsec[16]
EGS_I32 nmed
char compxsec[16]
EGS_Float rho[MXMED]
A structure corresponding to the rayleigh_inputs common block.
char ff_file[MXMED][128]
char ff_media[MXMED][24]
A structure corresponding to the EGSnrc particle stack common block STACK.
EGS_Float z[MXSTACK]
double E[MXSTACK]
EGS_Float x[MXSTACK]
EGS_Float v[MXSTACK]
EGS_Float w[MXSTACK]
EGS_I32 ir[MXSTACK]
EGS_I32 iq[MXSTACK]
EGS_Float dnear[MXSTACK]
EGS_Float y[MXSTACK]
EGS_Float u[MXSTACK]
EGS_Float wt[MXSTACK]
EGS_I32 npold
EGS_I32 np
EGS_I32 latch[MXSTACK]
EGS_I32 latchi
A structure corresponding to the particle production threshold energies common block THRESH.
EGS_Float ap[MXMED]
EGS_Float up[MXMED]
EGS_Float rmt2
EGS_Float rmsq
EGS_Float thmoll[MXMED]
EGS_Float ae[MXMED]
EGS_Float ue[MXMED]
EGS_Float te[MXMED]
A structure corresponding to the USEFUL common block.
double prm
Precise electron rest energy in MeV.
EGS_Float rhor
Mass density ratio.
double pzero
Precise zero.
EGS_I32 medium
Current medium.
EGS_Float rm
Electron rest energy.
double prmt2
2*prm
EGS_Float rhor_new
Mass density ratio in the new region.
EGS_I32 medium_new
Medium in the new region.
EGS_I32 medold
Old medium.
A structure corresponding to the egs_vr common block.
A structure corresponding to the xsection_options common block.
EGS_I32 ibr_nist
EGS_I32 pair_nrc
EGS_I32 spin_effects
EGS_I32 iphotonuc
EGS_I32 radc_flag
EGS_I32 itriplet
EGS_I32 eii_flag
A structure corresponding to the EMF_INPUTS common block.
EGS_Float ExIN