编辑: 飞翔的荷兰人 2019-09-23
FLUKA Advanced Course User Programming in the FLUKA environment

2 Why user routines ? Fluka offers a rich choice of built-in options for scoring most quantities and for applying variance reduction techniques, without requiring the users to write a single line of code ? However there are special cases where ad-hoc routines are unavoidable, because the needed information cannot be obtained through standard options

3 What is available for the users ? A number of user routine templates are available in the $FLUPRO/usermvax directory and can be modified/activated by the user in order to fulfill non-standard tasks ? The INCLUDE files containing the COMMON blocks are in the $FLUPRO/flukapro directory ? An extended mathematical library can in principle be exploited by properly calling its members from inside an user routine ? The compiling and linking scripts are in the directory $FLUPRO/flutil ? Most user routines need to be activated by input directives Flair can be used to edit, compile and link user routines in order to build a user-specific FLUKA executable

4 Flair interface (I) Flair has a button in the Compile frame which scans the input file for possible cards that require an user routine It allows to copy the template routine from $FLUPRO/usermvax to the project directory

5 Flair interface (II)

6 Card C user routine correspondence USRICALL USERDUMP USROCALL USERWEIG SOURCE usrini.

f usrein.f??? usrout.f usreou.f source.f mgdraw.f comscw.f fluscw.f usrrnc.f MAT-PROP usrmed.f USRGCALL usrglo.f History loop

7 User routine scope (I) ? comscw.f ? fluscw.f ? endscp.f ? fldscp.f ? musrbr.f ? lusrbl.f ? fusrbv.f ? usrrnc.f ? usbset.f ? usimbs.f ? udcdrl.f SCORING BIASING ? abscff.f ? dffcff.f ? frghns.f ? ophbdx.f ? queffc.f ? rflctv.f ? rfrndx.f OPTICAL PHOTONS SOURCE GENERATION ? source.f ? (soevsv.f) MAGNETIC FIELD ? magfld.f LATTICE GEOMETRY ? lattic.f INITIALIZATION ? usrglo.f ? usrini.f ? usrein.f OUTPUT ? usreou.f ? usrout.f

8 User routine scope (II) ? mgdraw.f multipurpose ? usrmed.f accessing (almost) everything accessing particle stack ? mdstck.f ? stupre.f ? stuprf.f Compiling and linking ? A FLUKA executable with user routines is in general application specific. It must be named and kept separately from the standard FLUKA ? Everything is managed today by FLAIR, however it is important to know the following details (managed automatically inside FLAIR): ? $FLUPRO/flutil/fff is the compiling script with the proper path to the INCLUDE subdirectory and the required compiler (g77 or gfortran ) options Example: $FLUPRO/flutil/fff usrini.f generates usrini.o then $FLUPRO/flutil/lfluka Cm fluka Co flukamy usrini.o will perform the proper linking generating the executable here called flukamy ? Tip: $FLUPRO/flutil/lfluka Cm fluka Co flukamy usrini.f will automatically call $FLUPRO/flutil/fff

9 ? Language is Fortran

77 (C routines can be linked) ? Double Precision everywhere, except for integer variables beginning with a letter in the range [i-n] ? Common blocks are in $FLUPRO/flukapro files and are loaded by the INCLUDE statement ? Each routine must start with the following includes/common blocks: INCLUDE '

(DBLPRC)'

INCLUDE '

(DIMPAR)'

INCLUDE '

(IOUNIT)'

Note the parentheses which are an integral part of the Fluka INCLUDE file names ? Users may add other FLUKA commons as well as their own commons which may reside in different places FLUKA programming rules

10 Numerical precision ? Floating point representation ± d0d1d2 … dp-1 * be where: b=base, 0.dddd=significant ? Represents the number ± (d0 + d1 b-1 + … + dp-1 b-(p-1)) be, (0≤di>

4ac, then √(b2-4ac)≈|b| therefore will introduce cancelation

13 Some COMMON blocks in short BEAMCM: beam particle properties (from BEAM and BEAMPOS) SOURCM: user variables and information for a user-written source SOUEVT: recording of the source event CASLIM: number of primary particles followed FLKSTK: main particle stack of FLUKA EMFSTK: particle stack for electrons and photons GENSTK: properties of secondaries created in a hadronic event FHEAVY: special stack for nuclear fragments FLKMAT: material properties LTCLCM: LaTtice CeLl CoMmon for lattice cell identification TRACKR: properties of the particle currently transported PAPROP: intrinsic particle properties (mass, charge, half live…) SCOHLP: variables concerning the current estimator type

14 (DBLPRC) (I) DouBLe PReCision common Included in all routines of Fluka, contains the declaration IMPLICIT DOUBLE PRECISION (A-H,O-Z) and sets many mathematical and physical constants. Users are strongly encouraged to adhere to Fluka style by ? using systematically double precision (except for very good reasons such as calling external single precision scoring packages) ? and to use constants defined in this file for maximum accuracy.

15 (DBLPRC) (II) M A T H E M A T I C A L C O N S T A N T S Numerical constants (double precision) * Zerzer =

0 * PARAMETER ( ZERZER = 0.D+00 ) * Oneone =

1 * PARAMETER ( ONEONE = 1.D+00 ) * Twotwo =

2 * PARAMETER ( TWOTWO = 2.D+00 ) * Pipipi = Circumference / diameter * PARAMETER ( PIPIPI = 3.141592653589793238462643383279D+00 ) * Twopip =

2 x Pipipi * PARAMETER ( TWOPIP = 6.283185307179586476925286766559D+00 ) * Eneper = e , base of natural logarithm * PARAMETER ( ENEPER = 2.718281828459045235360287471353D+00 ) * Sqrtwo = square root of

2 * PARAMETER ( SQRTWO = 1.414213562373095048801688724210D+00 )

16 (DBLPRC) (III) P H Y S I C A L C O N S T A N T S Primary constants: * Clight = speed of light in cm s-1 * PARAMETER ( CLIGHT = 2.99792458 D+10 ) * Boltzm = k Boltzmann constant (J K-1) * PARAMETER ( BOLTZM = 1.380658 D-23 ) * Amelgr = electron mass (g) * PARAMETER ( AMELGR = 9.1093897 D-28 ) * Plckbr = reduced Planck constant (erg s) * PARAMETER ( PLCKBR = 1.05457266 D-27 ) Derived constants: *Alamb0 = Compton wavelength =

2 pi r0 / fsc , being r0 the classical electron radius * * and fsc the fine structure constant * PARAMETER ( ALAMB0 = TWOTWO * PIPIPI * RCLSEL / ALPFSC ) Astronomical constants: * Rearth = Earth equatorial radius (cm) * PARAMETER ( REARTH = 6.378140 D+08 ) Conversion constants: * GeVMeV = from GeV to MeV * PARAMETER ( GEVMEV = 1.0 D+03 )

17 (IOUNIT) Logical input and output unit numbers The logical units up to

19 (included) are reserved for FLUKA * lunin = standard input unit * PARAMETER ( LUNIN =

5 ) * lunout = standard output unit * PARAMETER ( LUNOUT =

11 ) * lunerr = standard error unit * PARAMETER ( LUNERR =

15 ) … Use the pre-defined output units when you need messages from your user routines: WRITE ( LUNOUT, *) '

My initialization is active'

WRITE (LUNERR, *) '

MySource : warning, energy is 0'

18 (CASLIM) Keeps preset number of histories and current number of histories * /caslim/ is needed to decide when to stop the run * Trnlim = if cpu-time-left 0, Mtrack >

0 : energy loss distributed along the track Ntrack >

0, Mtrack =

0 : no energy loss along the track Ntrack = 0, Mtrack =

0 : local energy deposition (the value and the point are not re- corded in Trackr) COMMON / TRACKR / XTRACK ( 0:MXTRCK ), YTRACK ( 0:MXTRCK ), &

ZTRACK ( 0:MXTRCK ), TTRACK ( MXTRCK ), &

DTRACK ( MXTRCK ), DPTRCK ( 3,MXTRCK ),

24 (TRACKR) : 2nd part Jtrack = identity number of the particle: for recoils or kerma deposition it can be outside the allowed particle id range, assuming values like: 208: heavy recoil 211: EM below threshold 308: low energy neutron kerma in those cases the id of the particle originating the interaction is saved inside J0trck (which othe- rwise is zero) J0trck = see above Etrack = total energy of the particle Ptrack = momentum of the particle (not always defined, if <

0 must be obtained from Etrack) Cx,y,ztrck = direction cosines of the current particle Cx,y,ztrpl = polarization cosines of the current particle Wtrack = weight of the particle Wscrng = scoring weight: it can differ from Wtrack if some biasing techniques are used (for example inelastic interaction length biasing) Ctrack = total curved path Cmtrck = cumulative curved path since particle birth

25 (TRACKR) : 3rd part Zfftrk = of the particle Zfrttk = actual Z_eff of the particle Atrack = age of the particle Wninou = neutron algebraic balance of interactions (both for high energy particles and low energy neutrons) Wcinou = charge algebraic balance of interactions (for all interactions) Spausr = user defined spare variables for the current particle Ktrack = if >

0 neutron group of the particle (neutron) Lt1trk = initial lattice cell of the current track (or lattice cell for a point energy deposition) Lt2trk = final lattice cell of the current track Iprodc = flag for prompt(=1)/radioactive products(=2) Ltrack = flag recording the generation number Llouse = user defined flag for the current particle Ispusr = user defined spare flags for the current particle … &

SPAUSR(MKBMX1), STTRCK, SATRCK, TKNIEL, TKEDPA, &

WCINOU, … &

IPRODC, ISPUSR(MKBMX2), LFSSSC, LPKILL

26 (EVTFLG) EVenT FLaGs: Flags indicating the event interaction type: LELEVT = Elastic interaction LINEVT = Inelastic interaction LDECAY = Particle decay LDLTRY = Delta ray production (Moller and Bhabha included) LPAIRP = Pair production LBRMSP = Bremsstrahlung LANNRS = Annihilation at rest LANNFL = Annihilation in flight LPHOEL = Photoelectric effect LCMPTN = Compton effect LCOHSC = Rayleigh scattering LLENSC = Low energy neutron scattering LOPPSC = Optical photon scattering LELDIS = Electromagnetic dissociation LRDCAY = Radioactive decay All LOGICAL variables!!!

27 28 comscw.f [1] ??? Activated by option USERWEIG with WHAT(6) >

0.0. Energy and stars obtained via SCORE, USRBIN &

EVENTBIN and production of residual nuclei obtained via RESNUCLEi are multiplied by the value returned by this function. If the logical flag LSCZER is set to .TRUE. , no amount will be scored. weighting energy deposition or star production

29 comscw.f [2] The user can implement any desired logic according to the argument list (particle type, position, region, amount deposited, particle generation) and information available in the included COMMONs. COMMON SCOHLP provides the binning number JSCRNG [printed in the output file between the estimator type and the detector name] and the type ISCRNG of scored quantity: ISCRNG =

1 ? Energy density binning ISCRNG =

2 ? Star density binning ISCRNG =

3 ? Residual nuclei scoring ISCRNG =

4 ? Momentum transfer ISCRNG =

5 ? Activity density binning ISCRNG =

6 ? Net charge Note that the same JSCRNG number can correspond to different detector types ISCRNG (use both to discriminate) COMMON TRACKR gives current particle'

s properties and COMMON SOUEVT gives current source particle'

s ones COMMON FLKMAT allows to access data concerning the current material, identified by the index MEDFLK(MREG,IPRODC) (IPRODC=1 for prompt and IPRODC=2 for radioactive decay particles)

30 fluscw.f [1] Activated ........

下载(注:源文件不在本站服务器,都将跳转到源网站下载)
备用下载
发帖评论
相关话题
发布一个新话题