Re: [fluka-discuss]: Quadrupole magnets

From: Santana, Mario <msantana_at_slac.stanford.edu>
Date: Mon, 13 Oct 2014 18:41:26 +0000

Hi Kilian

Yes, there are ways to implement quadruples in FLUKA, this is quite a
common thing to do. In the following I assume your question is about how
to implement the quadrupole field,s the geometry of the quadrupoles will
depend on your actual component and how much detail you need for your
study.
To implement the quadrupole fields you will need to modify the magfld.f
routine, you can't just do it through cards in the input file but you ALSO
need cards in the input file to tell FLUKA you need magnetic properties in
some regions of your beam line.

- For the region of interest, ASSIGNMA what(5) needs to be set to 1.0 to
tell FLUKA a magnetic field is present in that region
- MGNFLD whats(4-6) need to be set to 0.0 (to tell FLUKA you will be
providing the magnetic field through a subroutine)


In Subroutine MAGFLD, NREG is the region number (FLUKA assigns numbers to
all regions and internally works with that) where the particle is at. You
can compare that region with the number of the region where you want the
field to be active to tell FLUKA what field to apply, e.g. If your first
quadrupole vacuum region is 5 (you can get that from the output table,
look for "1Region" in your output file) then:

IF (NREG.eq.5) THEN
  corresponding code
END IF

Alternatively you could convert the region number NREG to the the
corresponding name and compare to the region name for you quad by using
function
GEOR2N, or you could even use the opposed scheme, but maybe you can live
without those refinements for now.

So the "corresponding code" should be something like:

   BTX = k * Y
   BTY = k * X
   BTZ = ZERZER
   B = SQRT(BTX**2 + BTY**2 + BTZ**2)
   IF (B.gt.1E-12) THEN
     BTX = BTX / B
     BTY = BTY / B
     BTZ = BTZ / B
   ELSE
     BTZ = ZERZER
     BTY = ZERZER
     BTZ = ONEONE
     B = ZERZER
   END IF

Where k is the gradient of your quad ([T/cm]). If your quad if offset from
the X=Y=0 axis or if it is not aligned with Z, you would have to transform
this equation accordingly. Also, to change the polarity of your quad, use
-k.

You will need to recompile the code with your modified routine,
$FLUPRO/flutil/lfluka -m fluka -o ./flukahp magfld.f

And observe if you had any coding errorsŠ

In your tests you can tell magfld.f to print to output messages of values,
e.g. Write(LUNOUT,*)'Region,B,BTX',NREG,B,BTX

Hope this helps

Mario





On 10/13/14 8:59 AM, "Kilian-Simon Baumann"
<kilian-simon.baumann_at_kmub.thm.de> wrote:

>Dear Fluka-experts,
>
>I am building/simulating a device for the particle therapy. Since the
>beam is focused with the help of qudrupole magnets to maintain a
>convergent beam, I wanted to ask, if there is a (if possible, easy) way
>to build those quadrupole magnets in Fluka.
>However, if it is too complicated to handle those quadrupole magnets in
>Fluka, is there any other way to get a convergent beam?
>
>Thanking you in advance,
>
>Kilian Baumann
>
Received on Mon Oct 13 2014 - 21:56:09 CEST

This archive was generated by hypermail 2.3.0 : Mon Oct 13 2014 - 21:56:12 CEST