Source definition for each primary

Dear all,

I have a question regarding particle generation using source_newgen.f user routine.
I am trying to generate particles on a straight line in a cylindrical region.
As an example, if I want my particles to be generated on a straight line on a plane at z=50 cm and at angle theta=55 degrees, my code looks like this:

  !random = FLRNDM(xdummy)
  !angle = 360 * random
  !theta = angle * PIPIPI/180
  R = sample_flat_distribution (-28.5D0 , 28.5D0 )
  theta = 55 * PIPIPI/180 !example for 55 degrees
  coordinate_x = R * cos(theta)
  coordinate_y = R * sin(theta)
  coordinate_z = 50D0

My question is the following: Is it possible to generate 1000 particles on a straight line at a specific angle for each primary event, and then for the second primary event, generate the particles on a straight line at a different angle? If not, is it possible to generate 1000 primaries on a line and then distribute the next 1000 on another line, and so on?

Thank you in advance for your assistance,
Mihaela

Dear Mihaela,

in case you don’t want to use event-by-event scoring, you can save the parameters of the line and get new values only after every 1000 primaries using a counter variable.
See: SAVE (FORTRAN 77 Language Reference)

Cheers,
David

1 Like

Dear David,

Thank you so much! I managed to generate my particles accordingly.
One more question. Is it possible to generate the particles along the line in one specific region (for example along the yellow line)? I noticed that regionsource subroutine overwrites the previously defined variables.

All the best,
Mihaela

Dear Mihaela,

you just need to modify the regionsource subroutine so that the line sampling is done there.

Cheers,
David

1 Like

Dear David,

Thank you very much for your help! I managed to do it!

Best,
Mihaela