Help implementing B fields with new MGNCREAT and MGNFIELD inputs

Dear FLUKA experts,

I have questions about implementing magnetic fields for dipoles, quadrupoles, sextupoles, etc. with the new input cards MGNCREAT and MGNFIELD. Basically, I am not sure if I am doing it correctly!

I have a set of magnets, which compose an arc of the ALS storage ring and which are repeated along the arc. I built the arc by create prototypes of the unique magnets and then creating replicas and moving them into place with ROT-DEFI. I have the magnet parameters (image below) and would like to assign fields to all the replica magnets in the arc via MGNCREAT and MGNFIELD. This is where I am stuck.

How is this done for a magnet, which has both a bending and a focusing/de-focusing effect? Even more simply, what about just only a focusing/de-focusing effect?

For a dipole, it seems straightforward, but for a quadrupole, I am not sure where to input the Bx, By, and Bz. In addition, I find that the flair interface is unchanged whether a dipole or quadrupole is selected (image below).

If there are lecture slides from one of your workshops with an example, could you please direct me towards those as well?

Thanks!

Dear @ted.liang,

To answer your questions:

Just like you placed your replicas of the magnets in place with ROT-DEFI cards, the magnetic field you have defined by combining an MGNFIELD card (with e.g. SDUM = “FIELD”) with an MGNCREATe card (with SDUM = “FIELD”) can also be associated to the replica through the MGNFIELD card. If you check the documentation in the manual*, you can see that there are several options to do this, also shown in your screenshot from Flair above (first MGNFIELD card, entry “On” you can select either Region, Prototype or Replica).

For now FLUKA only has the functionality to define up to 1 type of field per region so combining DIPOLE and QUADRUPOLE fields is not possible. In case it could help however, you could have the desired combined function magnet effect by offsetting a QUADRUPOLE field by applying an offset to the quadrupole field in the MGNCREATe card by adjusting the X0 and Y0 parameters (WHAT(3) and WHAT(4) respectively). In addition you can even also define a bending radius and sagitta (WHAT(2) and WHAT(3) respectively) in the first MGNCREATe continuation card. This is however not yet available in Flair and is not up to date in the MGNCREATE documentation but you are able to define in the input file directly according to this example:

MGNCREAT 4.0 20.0 1.5 0.0 0.0 0.0 QB
MGNCREAT 0.0 -10000 -10 0.0 0.0 0.0 &
MGNFIELD -3.0 ROTDEF 0.0 ROTDEF 0.0 0.0 QB

for a quadrupole field named “QB” with strength -3.0 T/cm and with -10000 and -10 the bending radius and sagitta (in cm). Another option is to use an interpolated 3D map using MGNDATA cards but is a bit more cumbersome.

Indeed for a quadrupole type of field you cannot set Bx, By and Bz since it is not a constant field. The Flair interface is indeed unchanged between DIPOLE and QUADRUPOLE but the meaning of the “strength” parameter K (WHAT(1) in MGNFIELD) is changed as you can check in the MGNCREATe documentation**:

And last but most importantly it will surely be helpful if you use the plotting functionality in Flair to visually check if the fields you defined are correctly implemented. Please have a look at the Basic FLUKA course lecture on EM fields, slide 12 for instructions on how to do so.

Let me know if you face any difficulties,

Andreas

*: Note that under the “For any other SDUM” paragraph it should not state “For SDUM = DIPOLE, QUADRUPOLE …” but rather “For the associated MGNCREATe card’s WHAT(1) = DIPOLE, QUADRUPOLE, …”. This should be fixed in the manual.

1 Like

Dear @anwaets,

Thank you for taking the time to address my question. Your advice was indeed very helpful, and the visualization of the magnetic field vectors in flair was especially helpful too.

Cheers!
Ted

1 Like