Pulsed gamma ray emission with convoluted time structure

Dear Experts,
I am trying to setup a simulation where the gamma rays are emitted in a pulse. I am trying a solution similar to ( Pulsed proton source in FLUKA)-Pulsed proton source in FLUKA - #12 by horvathd. In my case, the pulse shape is not uniform but a convolution of gaussian (std dev = ~ 120 ps) and exponential decay (1/decay rate = 100 ps). I am trying to use source_newgen and then use “particle age = …” line to emit photons with this convolved time structure. I need some help in how to proceed with that. Will it be possible to use the “particle_age = …” to sample the emission time from a histogram containing time bins and dN/dt or from a spectrum? Like how energy is sampled in source_newgen.f. Or shall i create a file populated with (say)millions of entries for various time by inverting the convoluted function and then somehow sample the particle age from this file? I will be very obliged for any guidance.
sincerely
saurabh

Dear Saurabh,

The simplest option would be in my opinion to use following line:

particle_age = sample_spectrum_file([filename], [scaling_factor])

This will take a file with (x,y) point pairs, and sample between the points linearly.

Cheers,
David

Dear David
thank you for the reply. But there is a problem. when I try to compile the source_newgen.f with the modifications you suggested, I get the following error-
450 | particle_age = sample_spectrum(“convoluted_normalized.dat”, “sec”)
| 1
Error: Function ‘sample_spectrum’ at (1) has no IMPLICIT type
Ended: 2024.06.04 23:49:48

I tried - sample_spectrum_file(“convoluted_normalized.dat”, “sec”) - in place of the above line but that also returned error.
can you please help?
I am attaching the files.
sincerely
saurabh
P.S - could it be because of negative times in the file?
source_newgen.f (19.1 KB)
convoluted_normalized.dat (37.6 KB)

Dear Saurabh,

you need to use the latest version of the source_newgen.f routine, available in the current release of FLUKA.
Also, the [scaling factor] should be a number.

Cheers,
David

Dear David
thank you for the reply. I upgraded to the latest fluka and used the latest source_newgen.f. The error still persists.

455 |       particle_age = sample_spectrum_file{"convoluted_normalized.dat","1"}
    |       1
Error: Unclassifiable statement at (1)
Ended: 2024.06.05 11:16:54

The source.newgen.f is attached
source_newgen.f (20.8 KB)
. can you please check it and see what mistakes I am making?
sincerely
saurabh

Dear Saurabh,

you need to use round brackets (, ) instead of curly ones {, }, and the scaling factor should be a double precision floating point number (1.0D0) without the quation marks.

Cheers,
David

Dear David
that worked very well!
thanks
saurabh