Hello,
In this case, the only place you could act (at FLUKA level) is usbsuw.f.
In particular, during postprocessing, for each bin, this program collects the output data from the simulation (the one you’re correctly producing now), calculate the average value producing the requested statistics.
Let’s focus on line 301-304-305-376-377 to understand the behaviour of this program:
...
READ (1) (GMSTOR(J), J = K0, K1)
...
GDSTOR (J) = GDSTOR (J) + DBLE (GMSTOR(J))
& * ( DBLE (NCASE) + DBLE(MCASE) * 1.D+09 )
...
GDSTOR (J) = GDSTOR (J)
& / ( DBLE (NCTOT) + DBLE (MCTOT) * 1.D+09 )
This is what’s happening here: from the usrbin file you produced, you are reading the scored quantity from each bin, saving it in GMSTOR. Then, you accumulate the sum of each cycle with their (primary) weight in GDSTOR and finally you divide GDSTOR by the total (primary) particle weight to get the requested quantity.
The statistical error calculation works in a similar way, using the same data.
By default, when you process the output with flair, you are executing this program.
Since you want to plug in your function at a FLUKA level, I would suggest you to apply some small modification to this routine (copied in your working directory, to avoid any harms to the fluka installation one).
Immediately after you read the data (line 304), you could plug in your equation, i.e.:
...
READ (1) (GMSTOR(J), J = K0, K1)
IRECRD = IRECRD + 1
DO J = K0, K1
GMSTOR (J) = A + B * EXP
& ( -( GMSTOR (J) - B ) ** 2 / C )
GDSTOR (J) = GDSTOR (J) + DBLE (GMSTOR(J))
& * ( DBLE (NCASE) + DBLE(MCASE) * 1.D+09 )
GBSTOR (J) = GBSTOR (J) + DBLE (GMSTOR(J))**2
& * ( DBLE (NCASE) + DBLE (MCASE) * 1.D+09 )
END DO
...
This is just a snipped of how the implementation could look like. Then, you need to call the usbsuw.f via terminal, since flair will continue to call the default one. Notice that, since this process is detached from the fluka run, you don’t need to link this routine to the executable for the simulation.
Let me know if this solution could work for you.
Cheers,
Daniele