Fluence Scoring with Linear Binning in Energy and Polar Angle

Dear Community

My name is David and I have the following problem:


My goal is to compute the double differential photon fluence across a predefined interface between two regions. In addition, I would like to have a linear binning for both, the photon energy and the polar angle (not the solid angle).


To my best knowledge, USRBDX only offers angular binning in the solid angle. Therefore, I tried USRYIELD using the double differential fluence yield option (see attached input file below). Unfortunately, I couldn’t find a way to have a binning in both, the photon energy as well as the polar angle in the lab frame. It seems to me, that USRYIELD offers only the option to bin one out of the two variables (with multiple bins). For the other variable, one can define only 1 bin with lower and upper limit.

My brute force solution is – at least at the moment – to define multiple USRYIELD cards for each individual polar angle bin. My problem is know, that for my more complex problems (100 different interfaces, 5 degree bin width in the polar angle between 0 and 180 degree, 3 keV bin width in energy between 0 and 3072 keV), I would need to define 100*180/5=3600 USRYIELD cards.


  1. Is there a built-in solution in FLAIR/FLUKA to perform the requested double differential fluence scoring with linear binning in the photon energy and the polar angle?

  2. If the answer to question 1 is no, could you maybe point to a specific user routine and sketch a way how to alter the corresponding user routine?

  3. Regarding my brute force method, is there maybe a nicer/easier way to write multiple USRYIELD cards in FLAIR, e.g. with preprocessor cards?


For your convenience, I’m attaching here my toy problem with the brute force solution mentioned above:

USRYIELD_test.flair (5.8 KB)
USRYIELD_test.inp (5.0 KB)

To limit the number of USRYIELD cards for this toy problem, I applied a coarse binning in the polar angle (30 degree) and included only 1 scoring interface.

Thank you very much for your support
Kind regards,

1 Like

Hi David,

Indeed, none of the building scoring can do that. With USRYIELD the definition of the binning is only possible for one of the variables, the other one is taken in a single bin as you correctly said.

Your approach is the best one, i.e., use multiple USRYIELD cards for each range of the second variable although the number of these cards is limited to 1000 and you need 3600. Therefore, either you reduce the resolution in angle or you need to change the strategy. In case you manage to stay below 1000 cards, you can write a separate script to define all the cards and then copy them into your input file. Unfortunately, there is no way in FLAIR to implement a DO-loop.

If the resolution reduction is not possible, I would suggest you to use the mgdraw.f user routine (take the one named as mgdraw_empty.f in the database to avoid undesirable outputs), this allows to dump particle information when the particle crosses a boundary between two FLUKA regions (entry BXDRAW). There, you can select the particle type (for photons the condition will be: JTRACK .EQ. 7) and the information needed: particle ID (JTRACK), position (XSCO, YSCO, ZSCO), kinetic energy (ETRACK - AM(JTRACK)), direction cosines (CXTRCK, CYTRCK, CZTRCK ) from where you can extract the polar angle, etc. Notice that the direction cosines are referred to the the Z-axis, which is usually the direction of the primary beam.

Check the description of the mgdraw user routine on the manual and in the following presentation:

In order to call the mgdraw routine, the USERDUMP card must be included in the input file.

Recommendations for the output of the data:

Option 1) Dump the information event by event directly with mgdraw routine in a file that you can post-process afterwards. The drawback of this option is the size of the file, that could be very heavy and difficult to handle.

Option 2) Store the information, for instance, in a 3 dimensional array (surface crossing, kinetic energy, polar angle) defining it in the mgdraw routine. Then you can use the usrout.f user routine for further data processing and print special user-written output. In order to call this routine, include the USROCALL card in your input right after the START card. Important! to pass the array from mgdraw.f to usrout.f you have to include a COMMON line on the top of both routines after all the INCLUDE.

Hope these directives help you.

Kind regards,


1 Like

Hi Marta

Thank you very much for your very detailed reply. I really appreciate your support and the time you have invested in answering my questions. Regarding your suggested options for my problem: I will consider reducing my resolution and try to write a separate script to define all the USRYIELD cards. If this shouldn’t work out, I will try the MGDRAW option. In the latter case, I will probably have some more question, but I will ask them in another post in the Advanced Features and User Routines category.

Thanks again for your help
Kind regards,