User routine wvlnsh.f

Dear FLUKA expert,
This is my first time to use user routine.
I want to simulate a wavelength shifting fiber,we know it has absorption spectrum and emission spectrum.

  1. FLUKA only simulate monochromatic photon(lambda-i),is that to say I can only get secondary photons of monochromatic?
  2. Should I give parameters of " Mreg " ,“Mxwsph” ,“NWVSHP” here? How to set it?
  3. I want to get secondary photons’ angular distribution(the relationship of photon number and angular),should I use USRBDX or wvlnsh.f here?
  4. Below is content of my wvlnsh.f. Could you help me to see is there any errors?
    Look forward to your help,Thank you.
  • Input variables: *
  •                                                                  *
    
  •      Ekphot = absorbed photon energy     (GeV)                   *
    
  •      Wvlngt = absorbed photon wave-length (cm)                   *
    
  •      Mreg   = current region                                     *
    
  •      Mmat   = current material                                   *
    
  •      Mxwsph = maximum number of secondary photons                *
    
  •                                                                  *
    
  • Output variables: *
  •                                                                  *
    
  •      Nwvshp = number of produced secondary photons               *
    
  •   Wvshph(i) > 0 -> energy    (GeV) of the i_th produced photon   *
    
  •             < 0 -> wavelength (cm) of the i_th produced photon   *
    
  •   Dwvshp(i) = production delay (s) of the i_th produced photon   *
    
  •                                                                  *
    

----------------------------------------------------------------------
*
DIMENSION WVSHPH (MXWSPH), DWVSHP (MXWSPH)
Ekphot = 0.00000000275556
Wvlngt = 0.000045
Mreg = ?
Mmat = POLYSTYR
Mxwsph = ?
NWVSHP = ?
Wvshph(1) = -0.000051

Dwvshp(1) = 0.0000027
RETURN
=== End of subroutine Wvlnsh =========================================
END

Dear@ceruttif ,
For wvlnsh.f ,if I use these card and compiled the user routine ,it will automatically called?(the material of wavelength shifting fiber is POLYSTYR)
图片

See this dedicated discussion and please note the difference between INPUT variables and OUTPUT variables: evidently you need to set the latter ones only (by the way MREG would require an integer, not a character string, but it’s an input variable not to be reset).

wvlnsh.f is not a scoring routine, it serves to generate optical photons with a different wavelength as a formerly traveling optical photon is absorbed. Therefore, the resulting angular distribution on a given region boundary is rather provided by the USRBDX and USRYIELD cards.

Dear @ceruttif ,
Nwvshp = number of produced secondary photons.
It is an OUTPUT variable,I have a little confused about its meaning.
It express the number of produced secondary photons by all the primary photons or just by each one primary photon ?
If it is former,How can I set this value?Because I only have the data of primary photons.

Dear@ceruttif ,
When I run the file ,it gives error “Optical photon stack overflow in absorption by -23413, execution terminated”
mix.flair (3.5 KB)
wvlnsh.f (2.5 KB)

The latter: as one optical photon is absorbed, NWVSHP wavelength shifted secondary photons are produced. You set it to the non-sense value of 23414 (while defining the properties of only the first of them), which necessarily leads to the resulting optical photon stack overflow (FLUKA cannot track a number of particles tending to infinite).

Dear@ceruttif ,
Thank you for your answer,I have set it to 1 and works.
But this value must be integer,if one primary photon generate secondary photon below one ,how to set it?
For example,many primary photon just go through the wavelength shifting fiber and not generate secondary photon,so the mean value is below one?

This was exactly answered, even with an implementation example by @cesc , in the February 2020 discussion I brought above to your attention.

Dear@ceruttif ,
I have read the topic you said once again and remembered it clearly ,thank you for your help.