Hi Jianqi,
First of all, sorry for the late reply, it took me a while to go through your request.
From your code I can see that you are quite an advanced FLUKA user already. I am sure that you would figure out the solution yourself, but I leave you some advice below.
Let me start from the end, I think that the difference in NPFLKA comes from the fact that between the place where these two functions are invoked in the main fluka code, some kind of main stack management is happening.
Even though among the files that you attached there is not sturpf.f
, from what I understand, you are well aware of this user routine. If you want to have a variable which acts similarly to G4 trackID, you should in fact use one of the available user variable and assign them inside the sturpf.f
. You could try to use a similar logic that you have in your mdstck.f
function to flag the neutrons and then print out the flags when the neutrons get detected in your USDRAW
subroutine of ‘mgdraw.f’. I am attaching a version of stupfre.f
that should do the same thing as your mdstck.f
and also flag the interaction type origin to all the produced particles according to your logic.
stuprf.f (3.1 KB)
this routine can be used together with your mgdraw.f
where in your USDRAW
you can print just one more variable LLOUSE
WRITE(10,*) NCASE,ATRACK,JTRACK,XSCO,YSCO,ZSCO,
& NAM,NP,KPART(1:NP),TKI(1:NP), LLOUSE
to identify the origin of your detected neutrons.
When you use the above stupr.f
, DO NOT include your mdstck.f
to your executable.
There are a few small things in your code that I think don’t act as you would like them to.
Firstly, with such code
WRITE(7,*) 2, NCASE, XTRACK(NTRACK), YTRACK(NTRACK),
& ZTRACK(NTRACK),CXR(NTRACK),CYR(NTRACK),
& CZR(NTRACK),KPART(IPNEW), TKI(IPNEW)
the cosines are always taken from the parent particle and they end up to be all the same for all the daughters (interaction products). Instead of using CZR(NTRACK)
you should rather take CZR(IPNEW)
, see the genstk
variables in fluka_dir/include/genstk.inc
.
Secondly, when you put conditions for the elastic scattering,
ELSE IF ( NCASE .EQ. TEMP_INL(IPNCASE).AND. NP.EQ.1) THEN
* & .AND.JTRACK .EQ.8) THEN
EKIN = ETRACK-AM(JTRACK)
* PLOSS= DPTRCK(1,NTRACK)**2+
TXX= (PTRACK*CXTRCK-PLR(NTRACK)*CXR(NTRACK))/PTRACK
TYY= (PTRACK*CYTRCK-PLR(NTRACK)*CYR(NTRACK))/PTRACK
TZZ= (PTRACK*CZTRCK-PLR(NTRACK)*CZR(NTRACK))/PTRACK
PRINT *,"DTRACK=", DTRACK
PRINT *,"DPTRCK=", DPTRCK
DO IPNEW = 1, NPSECN
* IF(KPART(IPNEW) .EQ. 8) THEN
WRITE(7,*) 0, NCASE, XTRACK(NTRACK), YTRACK(NTRACK),
& ZTRACK(NTRACK),TXX, TYY,
& TZZ, 8 , EKIN-TKI(IPNEW)
* END IF
END DO
END IF
you are printing the information about the only particle on the stack and you assume it’s a neutron, but in reality it is always a gold residual nucleus -7919707. You should maybe rethink the way you want to tag the interaction types that you are interested in.
I hope that helps, let me know.
Cheers,
Jerzy