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 #
30 ###############################################################################
31 */
32 
33 
86 #ifndef EGS_INTERFACE1_
87 #define EGS_INTERFACE1_
88 
89 #include "egs_config1.h"
90 
91 /* Note: The C-preprocessor macros MXMED and MXSTACK must be defined in the
92  file array_sizes.h. */
93 #include "array_sizes.h"
94 
98 #define MXAUS 35 /* there are 35 different calls to ausgab */
99 
107 struct EGS_Stack {
109  double E[MXSTACK];
111  EGS_Float x[MXSTACK];
113  EGS_Float y[MXSTACK];
115  EGS_Float z[MXSTACK];
117  EGS_Float u[MXSTACK];
119  EGS_Float v[MXSTACK];
121  EGS_Float w[MXSTACK];
123  EGS_Float dnear[MXSTACK];
125  EGS_Float wt[MXSTACK];
127  EGS_I32 iq[MXSTACK];
129  EGS_I32 ir[MXSTACK];
133  EGS_I32 latch[MXSTACK];
135  EGS_I32 latchi;
137  EGS_I32 np;
139  EGS_I32 npold;
140 };
141 
177 struct EGS_Bounds {
180  EGS_Float ecut;
182  EGS_Float pcut;
184  EGS_Float ecut_new;
186  EGS_Float pcut_new;
188  EGS_Float vacdst;
189 };
190 
203 struct EGS_Thresh {
205  EGS_Float rmt2;
207  EGS_Float rmsq;
211  EGS_Float ap[MXMED];
215  EGS_Float ae[MXMED];
217  EGS_Float up[MXMED];
219  EGS_Float ue[MXMED];
221  EGS_Float te[MXMED];
223  EGS_Float thmoll[MXMED];
224 };
225 
231 struct EGS_Epcont {
233  double edep;
235  double edep_local;
237  EGS_Float tstep;
239  EGS_Float tustep;
242  EGS_Float ustep;
244  EGS_Float tvstep;
246  EGS_Float vstep;
249  EGS_Float rhof;
251  EGS_Float eold;
253  EGS_Float enew;
255  EGS_Float eke;
257  EGS_Float elke;
259  EGS_Float gle;
261  EGS_Float e_range;
263  EGS_Float x_final, y_final, z_final;
266  EGS_Float u_final, v_final, w_final;
274  EGS_I32 idisc;
276  EGS_I32 irold;
278  EGS_I32 irnew;
280  EGS_I32 iausfl[MXAUS];
281 };
282 
290  EGS_Float smaxir;
292  EGS_Float smax_new;
294  EGS_Float estepe;
296  EGS_Float ximax;
301  EGS_Float skindepth_for_bca;
306  EGS_I32 bca_algorithm;
312  EGS_I32 exact_bca;
313 };
314 
319 struct EGS_Media {
321  EGS_Float rho[MXMED];
323  char pxsec[16];
325  char eiixsec[16];
327  char compxsec[16];
329  char photonucxsec[16];
331  EGS_I32 nmed;
332 };
333 
338 struct EGS_Rayleigh {
340  char ff_media[MXMED][24];
342  char ff_file[MXMED][128];
343 };
344 
350 struct EGS_Useful {
351  double pzero,
352  prm,
353  prmt2;
354  EGS_Float rm,
355  rhor,
356  rhor_new;
357  EGS_I32 medium,
358  medium_new,
359  medold;
360 };
361 
389 struct EGS_XOptions {
390 
404  EGS_I32 ibrdst;
405 
417  EGS_I32 iprdst;
418 
432  EGS_I32 ibr_nist;
433 
442  EGS_I32 spin_effects;
443 
455  EGS_I32 ibcmp;
456 
467  EGS_I32 iraylr;
468 
477  EGS_I32 iedgfl;
478 
489  EGS_I32 iphter;
490 
504  EGS_I32 pair_nrc;
505 
515  EGS_I32 itriplet;
516 
529  EGS_I32 radc_flag;
530 
540  EGS_I32 eii_flag;
541 
549  EGS_I32 iphotonuc;
550 
551  EGS_I32 eadl_relax;
552 
553  EGS_I32 mcdf_pe_xsections;
554 
555 };
556 
575  EGS_Float e_max_rr;
576 
578  EGS_Float e_max_rr_new;
579 
582  EGS_Float prob_RR;
583 
585  EGS_I32 nbr_split;
586 
592  EGS_I32 i_play_RR;
593 
598  EGS_I32 i_survived_RR;
599 
601  EGS_I32 n_RR_warning;
602 
605  EGS_I32 i_do_rr;
606 };
607 
616 struct EGS_IO {
617  char file_extensions[20][10];
618  EGS_I32 file_units[20];
619  char user_code[64];
620  char input_file[256];
621  char output_file[256];
622  char pegs_file[256];
623  char hen_house[128];
624  char egs_home[128];
625  char work_dir[128];
626  char host_name[64];
627  EGS_I32 n_parallel, i_parallel, first_parallel, n_max_parallel,
628  n_chunk, n_files, i_input, i_log, i_incoh, i_nist_data,
629  i_mscat, i_photo_cs, i_photo_relax, xsec_out, is_batch,
630  is_uniform_run, is_pegsless;
631 };
632 
640  EGS_Float ExIN, EyIN, EzIN, EMLMTIN,
641  BxIN, ByIN, BzIN, Bx, By, Bz, Bx_new, By_new, Bz_new;
642  bool emfield_on;
643 };
644 
647 extern __extc__ struct EGS_Stack *the_stack;
648 
651 extern __extc__ struct EGS_Bounds *the_bounds;
652 
655 extern __extc__ struct EGS_Thresh *the_thresh;
656 
659 extern __extc__ struct EGS_Epcont *the_epcont;
660 
663 extern __extc__ struct EGS_EtControl *the_etcontrol;
664 
667 extern __extc__ struct EGS_Media *the_media;
668 
671 extern __extc__ struct EGS_Useful *the_useful;
672 
675 extern __extc__ struct EGS_XOptions *the_xoptions;
676 
679 extern __extc__ struct EGS_IO *the_egsio;
680 
683 extern __extc__ struct EGS_VarianceReduction *the_egsvr;
684 
687 extern __extc__ struct EGS_Rayleigh *the_rayleigh;
688 
691 extern __extc__ struct EGS_emfInputs *the_emf;
692 
693 /* ******************* EGSnrc interface functions *************************/
694 
695 
711 extern __extc__ void egsInit(int argc, char **argv);
712 
714 #define egsFinish F77_OBJ_(egs_finish,EGS_FINISH)
715 
724 extern __extc__ void egsFinish(void);
725 
727 #define egsAddMedium F77_OBJ_(egs_add_medium,EGS_ADD_MEDIUM)
728 
739 extern __extc__ EGS_I32 egsAddMedium(const char *medname, EGS_I32 length);
740 
744 #define egsHatch F77_OBJ_(egs_hatch,EGS_HATCH)
745 
755 extern __extc__ void egsHatch(void);
756 
760 #define egsShower F77_OBJ_(egs_shower,EGS_SHOWER)
761 
770 extern __extc__ void egsShower(void);
771 
772 /****************************************************************************
773  Functions for using the EGSnrc random number generator
774  Only relevant for user codes written in C
775  ****************************************************************************/
776 
778 #define egsRandomDefaultInit F77_OBJ_(egs_init_default_rng,EGS_INIT_DEFAULT_RNG)
779 
788 extern __extc__ void egsRandomDefaultInit();
789 
791 #define egsRandomInit F77_OBJ_(egs_init_rng,EGS_INIT_RNG)
792 
803 extern __extc__ void egsRandomInit(const EGS_I32 *s1, const EGS_I32 *s2);
804 
806 #define egsRandomGet F77_OBJ_(egs_get_rndm,EGS_GET_RNDM)
807 
817 extern __extc__ void egsRandomGet(EGS_Float *ranno);
818 
820 #define egsFillRandomArray F77_OBJ_(egs_fill_rndm_array,EGS_GET_RNDM_ARRAY)
821 
830 extern __extc__ void egsFillRandomArray(const EGS_I32 *n, EGS_Float *rarray);
831 
832 /*****************************************************************************
833  Some utility functions
834  *****************************************************************************/
835 
837 #define egsElapsedTime F77_OBJ_(egs_tot_time,EGS_TOT_TIME)
838 
843 extern __extc__ EGS_Float egsElapsedTime(int *flag);
844 
846 #define egsCpuTime F77_OBJ_(egs_etime,EGS_ETIME)
847 
852 extern __extc__ EGS_Float egsCpuTime(void);
853 
855 #define egsGetTransportParameter F77_OBJ_(get_transport_parameter,GET_TRANSPORT_PARAMETER)
856 
864 extern __extc__ void egsGetTransportParameter(const int *ounit);
865 
866 
867 /*****************************************************************************
868  Fuctions that must be implemented by user codes written in C
869  *****************************************************************************/
870 
872 #define egsHowfar F77_OBJ_(egs_howfar,EGS_HOWFAR)
873 
902 extern __extc__ void egsHowfar(void);
903 
905 #define egsHownear F77_OBJ_(egs_hownear,EGS_HOWNEAR)
906 
918 extern __extc__ void egsHownear(EGS_Float *tperp);
919 
921 #define egsAusgab F77_OBJ_(egs_ausgab,EGS_AUSGAB)
922 
931 extern __extc__ void egsAusgab(EGS_I32 *iarg);
932 
934 #define egsStartParticle F77_OBJ_(egs_start_particle,EGS_START_PARTICLE)
935 
958 extern __extc__ void egsStartParticle(void);
959 
960 #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...
#define egsGetTransportParameter
EGS_I32 transport_algorithm
EGS_I32 iq[MXSTACK]
EGS_Float rhor_new
Mass density ratio in the new region.
EGS_Float eke
__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...
A structure corresponding to the EGSnrc transport threshold energies common block BOUNDS...
#define egsElapsedTime
EGS_Float ue[MXMED]
A structure corresponding to the EGSnrc particle stack common block STACK.
double prmt2
2*prm
EGS_I32 medium
Current medium.
EGS_Float v[MXSTACK]
A structure corresponding to the EPCONT common block.
__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...
EGS_Float rho[MXMED]
EGS_Float estepe
__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...
char pxsec[16]
EGS_Float enew
EGS_Float thmoll[MXMED]
EGS_Float pcut_new
EGS_Float rhor
Mass density ratio.
EGS_I32 ir[MXSTACK]
double pzero
Precise zero.
EGS_I32 npold
EGS_Float ae[MXMED]
EGS_I32 radc_flag
EGS_Float eold
char photonucxsec[16]
double prm
Precise electron rest energy in MeV.
#define egsRandomGet
EGS_Float ap[MXMED]
#define egsHatch
A structure corresponding to the egs_io common block.
EGS_Float pcut
EGS_Float w[MXSTACK]
char ff_file[MXMED][128]
__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 egsStartParticle
EGS_Float tstep
#define egsAddMedium
EGS_I32 spin_effects
EGS_I32 medium_new
Medium in the new region.
EGS_I32 iphotonuc
EGS_Float dnear[MXSTACK]
double edep_local
A structure corresponding to the EMF_INPUTS common block.
__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...
EGS_Float ximax
A structure corresponding to the rayleigh_inputs common block.
EGS_I32 pair_nrc
EGS_Float ecut_new
__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...
__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...
#define egsFinish
char compxsec[16]
A structure corresponding to the ET_control common block.
EGS_Float vacdst
EGS_Float smaxir
EGS_I32 latchi
EGS_I32 bca_algorithm
EGS_I32 ibr_nist
EGS_I32 latch[MXSTACK]
A structure corresponding to the particle production threshold energies common block THRESH...
EGS_Float x_final
EGS_I32 np
EGS_Float x[MXSTACK]
EGS_Float te[MXMED]
EGS_I32 itriplet
EGS_Float gle
EGS_Float tustep
__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...
#define MXAUS
EGS_Float e_range
EGS_Float rhof
EGS_I32 nmed
#define egsFillRandomArray
#define egsRandomInit
#define egsRandomDefaultInit
#define egsAusgab
EGS_Float smax_new
EGS_Float elke
A structure corresponding to the xsection_options common block.
A structure corresponding to the MEDIA common block.
double E[MXSTACK]
A structure corresponding to the USEFUL common block.
EGS_I32 medold
Old medium.
EGS_Float ustep
EGS_Float u_final
EGS_Float tvstep
__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...
EGS_I32 iausfl[MXAUS]
__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...
EGS_Float ExIN
EGS_Float y[MXSTACK]
EGS_Float rm
Electron rest energy.
EGS_Float wt[MXSTACK]
#define egsHowfar
__extc__ void egsInit(int argc, char **argv)
Initializes the EGSnrc mortran back-end.
EGS_Float skindepth_for_bca
A structure corresponding to the egs_vr common block.
#define egsHownear
EGS_I32 irold
#define egsCpuTime
__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...
EGS_Float up[MXMED]
EGS_Float u[MXSTACK]
EGS_I32 eii_flag
#define egsShower
EGS_Float ecut
char ff_media[MXMED][24]
EGS_Float rmsq
EGS_I32 irnew
EGS_Float vstep
char eiixsec[16]
EGS_Float rmt2
EGS_I32 idisc
EGS_Float z[MXSTACK]