Question over quadrupole units in own magfld.f routine

Dear FLUKA users and experts,

I am just trying to understand what the units of FLUKA’s quadrupole strengths are – I assume that they would be in T/cm but I have a slightly strange result. I have compared the dose distribution from FLUKA with the input file and magfld.f routines I have made (for a 250 MeV VHEE beam passing through a 20 cm quadrupole with a strength of 1 T/m i.e. 0.01 T/cm and then a water phantom), with the same modelled in TOPAS and they don’t match, I’m just wondering if I’ve made a mistake with my FLUKA user routine?

QuadInAir.inp (2.6 KB)

magfld_quad.f (2.6 KB)


Dear Lucy,

since you are using the quadrupole’s magnetic field gradient only in a user routine, you can use it as [T/m] or [T/cm], given you match the unit of length correctly.

However, there is a programming error in your routine. You store the field gradient in the variable k. In Fortran the variables starting with the letters I, J, K, L, M and N are considered by default as integers, thus k can’t store the value 0.01. You need to change the name to something else.

To be able to see if the magnetic field is correctly set up, you can plot the magnetic field intensity in Flair. See slide 9 from the following lecture:


1 Like

Hi David,

That makes so much sense, thank you!