# Using two-dimensional field solutions in OmniTrak

An OmniTrak feature that may not be familiar is the capability to include two-dimensional field solutions from Estat or PerMag. I recently had a consulting job where this was just the thing I needed, so I thought I would take this opportunity to review why the feature is valuable and how to apply it.

There are two application areas that come to mine where two-dimensional field solutions are useful. The first is when a three-dimensional beam propagates through a symmetric magnetic focusing device (like a solenoidal lens). If we want to include space-charge effects, the electric-field solution is certainly three-dimensional. On the other hand, the beam may have little or no effect on the strong magnetic field. In this case, it is much quicker and more accurate to construct a solution with PerMag rather than Magnum.

The second area can be illustrated with an application example. Figure 1 shows the cross section of a configuration proposed by Harald Enge[1] for an achromatic bending magnet for electrons and ions. The vertical field in the plane z = 0.0 varies as

Bz(x,0,0) = A x^n

Particles enter near the point (0.0, 0.0, 0.0) though a small slot in the left-hand pole at an angle ? with respect to the x-axis. The configuration has the property that particles follow a loop trajectory such that they leave the magnet at the same position with angle -?, independent of their kinetic energy. A value n = 0.8 corresponds to a 90° reflection (? = 45°). A value n = 1.0 gives a 81.4° deflection (? = 40.7°). A field with n = 1 is easily achieved — the configuration of Fig. 1 represents one-half of a magnetic quadrupole lens. In this case, the pole faces adjacent to the vacuum gap have a hyperbolic shape, xz = K [2].

Figure 1. PerMag solution for an Enge magnet with n = 1.0. The red arrows show the magnetization directions in permanent-magnet regions.

The bending-field properties hold if the assembly of Fig. 1 has infinite length in y (out of the page). On the other hand, a practical system has finite length. One of the goals of calculations is to determine the effect fringing fields. In other words, adding length in y costs money — what is the shortest length consistent with accuracy? We would like to compare trajectories in a finite quadrupole to those in an infinite system. Years of experience have taught me that it is relatively easy to model real-world devices with three-dimensional codes, but extremely difficult and wasteful to approximate ideal devices like the infinite quadrupole. It’s usually much more effective to use a two-dimensional solution.

For this example, I generated the PerMag field solution of Fig. 1 for input to OmniTrak. The goal was to calculate three-dimensional electron trajectories with horizontal and vertical input displacements in the single-particle limit (TRACK mode). There are two points to note:

• OmniTrak requires at least one three dimensional mesh to record trajectory vectors. Therefore, it is necessary to include a dummy electric field solution with no applied field. I defined a region covering the volume of anticipated orbits (0.0 ? x ? 280.0, -100.0 ? y ? 100.0, -20.0 ? z ? 20.0) with grounded plates at the top and bottom boundaries in z (i.e., zero electric field everywhere).
• In planar calculations, the PerMag convention is that the system has variations in x-y with infinite length in z. The field variations in the Enge paper have the same x axis but infinite length in y. Therefore we must rotate the two-dimensional field about the x axis on entry to OmniTrak.

Here is the complete OmniTrak input script to represent electron beams at 2.0, 4.0, 8.0, 16.0 and 20.0 MeV entering at ?= 40.7° with a horizontal with of +-3.2 mm:

```FIELDS
EField3D: DummyField.HOU
BField2D: PMSolution.POU
Rotate B 90.0 0.0 0.0
DUnit: 1.0000E+03
END
PARTICLES TRACK
PLIST
* Mass Charge Ke      x     y    z     ux      uy      ux
* =========================================================
0.0 -1.0  2.0E6  0.001 -5.0  0.0  0.7501  0.6613  0.0000
0.0 -1.0  2.0E6  0.001  0.0  0.0  0.7501  0.6613  0.0000
0.0 -1.0  2.0E6  0.001  5.0  0.0  0.7501  0.6613  0.0000
0.0 -1.0  4.0E6  0.001 -5.0  0.0  0.7501  0.6613  0.0000
0.0 -1.0  4.0E6  0.001  0.0  0.0  0.7501  0.6613  0.0000
0.0 -1.0  4.0E6  0.001  5.0  0.0  0.7501  0.6613  0.0000
0.0 -1.0  8.0E6  0.001 -5.0  0.0  0.7501  0.6613  0.0000
0.0 -1.0  8.0E6  0.001  0.0  0.0  0.7501  0.6613  0.0000
0.0 -1.0  8.0E6  0.001  5.0  0.0  0.7501  0.6613  0.0000
0.0 -1.0 16.0E6  0.001 -5.0  0.0  0.7501  0.6613  0.0000
0.0 -1.0 16.0E6  0.001  0.0  0.0  0.7501  0.6613  0.0000
0.0 -1.0 16.0E6  0.001  5.0  0.0  0.7501  0.6613  0.0000
0.0 -1.0 20.0E6  0.001 -5.0  0.0  0.7501  0.6613  0.0000
0.0 -1.0 20.0E6  0.001  0.0  0.0  0.7501  0.6613  0.0000
0.0 -1.0 20.0E6  0.001  5.0  0.0  0.7501  0.6613  0.0000
END
DT  1.0E-12
END
DIAGNOSTICS
PARTLIST
END
ENDFILE```

Here, DummyField.HOU is the dummy electric field solution to define the three-dimensional mesh and PMSolution.POU is the field calculated by PerMag. The time step of 1.0^{-12} s corresponds to a vector length of 0.3 mm. For this choice, the particle list shows that energy is conserved to better than 0.5 parts in 10^6. Figure 2 shows the resulting trajectory projections in the plane z = 0.0. The results are not quite perfect because the calculated field for the geometry of Fig. 1 had n = 0.99.

Figure 2. Electron trajectories at 2.0, 4.0, 8.0, 16.0 and 20.0 MeV.

Footnotes

[1] H.A. Enge, Achromatic magnetic mirror for ion beams, Rev. Sci. Instrum 35 (1963), 385.

[2] My book Principles of Charged Particle Acceleration discusses magnetic quadrupoles on page 96.