The most convenient way to define the source parameters you describe is through the source_gausslinopt.f source routine, which I am attaching to this reply.
This routine was created precisely to sample from a gaussian beam defined from the linear optical parameters. For each plane, it generates a pair of independent random numbers sampled from a normalised gaussian distribution, and uses them to calculate physical transverse phase-space coordinates based on the defined optical parameters. Finally, it transforms the phase-space coordinates into the FLUKA geometry coordinates.
You can find a detailed description of how to use the routine in its header. In your case, since no dispersion is defined, the FLUKA cards should simply look something like this (for a 1GeV proton beam starting at an arbitrary position, assuming the emittance value is the geometric and not the normalised one):
Be aware that the routine expects the beta and emittance parameters to be expressed in meters. There is no need to define ParticleFractionX/ParticleFractionY, as these values arise naturally from a Bi-Gaussian distribution.
You can profit from the FREE/FIXED cards combo to increase the precision of your input values. Keep in mind that `BEAM` and BEAMPOS cards still need to be defined. Additionally, if present, the routine takes into account the BEAMAXES card to rotate the beam as specified.
A feature which may be useful is the possibility to dump the particle phase-space / FLUKA coordinates at the end of each of the 3 initially described steps. This can be achieved by setting WHAT(18)>0.
I hope this fulfils your request. Let me know if you encounter any issues with the routine.
I would like to thank Nuno for his previous reply on my topic “How to define a source using Twiss or Bi-Gaussian parameters?”. It helped me a lot! Since I didn’t reply before the topic was closed, I would like to resume the discussion.
I would just like to confirm if I understood it correctly. Since I am using the Fortran routine, it takes full control of the sampling, using the Twiss parameters inserted in the SOURCE card to generate random numbers and independently calculate the physical coordinates of the transverse phase space.
Given this, I would only need to specify the beam energy, energy spread, and particle type in the BEAM card (leaving the spatial profile and divergence fields blank/zero), and keep the BEAMPOS card to define the starting position. Is that correct?
I am also attaching a screenshot of my current BEAM and BEAMPOS cards, as well as the inputs sent to me regarding the source (which are from another Monte Carlo code) for reference.
That is correct, the source routine will take care of the geometrical sampling of the primary particles according to the Twiss parameters provided through the SOURCE card. Your PB_250MeV_NZ1.txt file contains all the information that you need to include: Beta, Alpha, and Emittance for both planes. You only need to convert from mm to m.
The other cards are also correct: no need to fill any other WHATs as they will be ignored.