Programming problem of generating phase space files using user routines

FLUKA:4-5.0
Flair:3.4-3
Operating system:Ubuntu 22.04.5

Dear FLUKA expert

I want to create a phase space file that contains the energy, position, and exit angle of neutrons crossing from the Pb region to the Vout region. After carefully reading the manual, I found that this seems to require using the entry BXDRAW in the mgdraw.f routine. However, I am completely unfamiliar with Fortran, Therefore, I utilized AI tools and combined them with the existing mgdraw.f routine on the forum to write a piece of code to achieve my goal. But I don’t know if this code can achieve my goal, nor do I know if there are any syntax errors in it. Please provide guidance from experts.

mgdraw_test.f.txt (10.5 KB)

1 Like

Dear Yaoxuan Cui,

thank you for your question. While I appreciate your inquiry, I suggest that you also consult the FLUKA lecture on the mgdraw routine (Advanced course), where several useful examples are provided. Please allow me some time to review your problem in detail. In the meantime, I kindly ask you to upload a working input file for the simulation.

If the suggested material helps you make progress in your modelling, please feel free to update this post with your advances.

Best regards,
Tommaso

Dear Tommaso Lorenzon

I have studied Fortran and modified the mgdraw.f routine, which works properly and achieves my expected goals. But I still have one more question, when I use source_newgen.f to read external phase space files, I can set sequencialid_local_flag to false. If I set the 1e6 primary in the START card of the inp file, will FLUKA randomly sample from the phase space file until the primary reaches 1e6? (There are only 1e5 particles in the phase space file)

Dear Yaoxuan,

apologies for my late reply.

The source_newgen gives you the possibility to sample from a phase space file. In this context the sequential_logical_flag allows you to choose between two reading modes, with different behaviours:

  • .false.: Particles from the phase space file selected randomly
  • .true. : Particles from the phase space file read sequentially, the simulation stops if all particles has been read

Therefore, considering your needs:

  • Setting the variable to TRUE will make FLUKA perform a full sequential replay of your phase space data and eventually stop at 1e+5 particles.
  • Value FALSE will make FLUKA sample your phase space files even 1e+6 times.

Best regards,

Tommaso

On this basis, setting to .false. is the recommended option for production runs.