Cyclotron Circular Source

Continuing the discussion from Souce for Simulation of beam in a Cyclotron:

Dear FLUKA experts,

as discussed in the above linked post, I tried to implement a circular source using the source_newgen.f subroutine.
The cyclotron center is located at x0, y0, z0 as stated in the coordinate section.
To generate the particles uniformly around the circumference I used:
coordinate_x = x0 + cyclo_radius * COS(phi)
coordinate_y = y0 + cyclo_radius * SIN(phi)

For the direction of the particles I entered:
direction_cosx = SIN(phi)
direction_cosy = COS(phi)

I also include a SOURCE card in the source code and it is compiling and running.
The output of the simulation when scoring BEAMPART in the outer and inner part of the cyclotron, using USRBIN-R-phi-Z binning, looks like this:
cyclotron

My question now is, why the primary particles are distributed in such a weird way instead of around the whole circumference.

Thank you in advance

source_newgen.f (19.0 KB)

Dear @lukpblr,

there is tho issues with you source routine:

  1. To rotate the direction vector by 90 degrees, you should not only swap the sin(phi) and cos(phi) between the x and y coordinates, but you need to multiply one of them with -1, depending which way you want to rotate the vector.

  2. A more hidden error is that you leave the direction_cosz default, which is one. You need to set it to zero manually.

Cheers,
David

1 Like

Hi @horvathd ,

thank you very much for your help, it works now as expected.

Best regards,
Lukas