Magnetic field calculations are often a bit more complicated than electrostatic ones since potential is a vector and there are complications of permeability, current density, and hysteresis.
In SIMION, there are three main ways to define a magnetic field:
- in terms of magnetic scalar potentials
- in terms of magnetic vector potential (experimental in 22.214.171.124).
- in terms of magnetic field vectors
These cases are explained below:
- in terms of magnetic scalar potentials – Scalar magnetic potential is analogous to scalar potential in electric fields (i.e. voltage). The magnetic field vector is the negative gradient of scalar magnetic potential, just as the electric field vector is the negative gradient of electrostatic potential. SIMION can solve scalar magnetic potential using the Laplace Equation in the same manner as electric potential is solved, and after doing so the magnetic field vector can be immediately obtained and used for particle trajectory solving. However, not all magnetic fields can be expressed as scalars but rather as vectors, and the meaning of potential can be less intuitive with magnetic fields. Magnetic potential will be a scalar under certain conditions, such as when there is no current density in the domain modeled (and in a different way if the system has 2D symmetry). See Magnetic Potential for details. SIMION Early Access Mode adds Permeability support.
- in terms of magnetic vector potential – Magnetic vector potential can take into account a non-zero current density in space. SIMION Early Access Mode has experimental support for magnetic vector potential. See Magnetic Potential.
- in terms of magnetic field vectors –
Magnetic fields here are defined directly in terms of field vectors.
During the trajectory integration the magnetic field vector seen by
the particle can be defined programmatically. You may have an analytical
mathematical expression for it, or you may have field data
(calculated from some external program and stored in a text file)
that can be interpolated (SIMION 8.0.3 includes field grid
interpolation routines, and SIMION 8.1.0 allows regular PA files to
represent this), or the magnetic field may be defined via a
configuration of wire currents (SIMION 8.0.3 provides support for
Biot-Savart Law calculations). In all these cases, the magnetic field
can be superimposed on a system via an
mfield\_adjustuser program segment attached to an empty magnetic potential array. This program segment defines magnetic field vector directly however you like. SIMION 126.96.36.199 adds some capabilities and examples that make this easier to use in terms of storing vector data in regular PA files and visualizing the field vectors (and/or Biot-Savart wires) on the View screen. See SIMION Example: field_array, SIMION Example: contour (contourlib81), SIMION Example: helmholtz_coil, and SIMION Example: solenoid).
- SIMION 8.0.3 includes features for Biot-Savart calculations of magnetic fields from wire currents and solenoids. See Biot-Savart Law.
- SIMION 8.0.3 includes features for importing magnetic field arrays from a text file (see field_array example)
- The _Magnet examples in SIMION 7/8 (scalar potential arrays,
including simple magnetic sector). Also see
examples\geometry\sector.gem(simple sector geometry example added in 8.1.0)
- The following resources apply more to SIMION versions prior to
- Manipulating SIMION Potential Arrays Programmatically (outdated)
- Solenoid Magentic Field, Helmholtz Coil and importing into SIMION by various methods (outdated)
- Exporting Electrostatic and Magnetic Field Data from SIMION (and Importing it too) (outdated)
- SL Tools Tutorial: Importing/Exporting PA Files (outdated)
- SIMION Discussion: import (magnetic) field maps from poisson superfish into SIMION (outdated)
Applying a constant magnetic field¶
It’s very common to require simply a constant magnetic field, so we describe that here. There are two main methods to define a constant magnetic field in SIMION: with a user program or without a user program. Each is explained below. Both methods are almost equally suitable, but the user program approach is recommended because it avoids magnetic potentials and therefore can be more intuitive.
Via a user program in SIMION 8/8.1¶
For this example, we’ll assume you want a constant 100 gauss magnetic field in the +X direction.
Create an empty basic PA of “magnetic” type. We’ll assume this PA is named “mag.pa”. This PA will not define a magnetic field itself but rather just defines the volume in which the magnetic field is to be applied (by a user program). So, it must be sized appropriately. It does not contain any pole points nor does it need to be refined. To conserve memory, it’s recommended to make this PA be 2D planar or 2D cylindrical (no need for a 3D array), and it doesn’t matter if your magnetic field does not actually have that symmetry since it’s merely defining a volume. Note: this step can be avoided when using
sim_segment_global(in version 8.2EA).
Add an instance of the PA to a workbench (View > PAs > Add). We’ll assume this IOB is named “system.iob”. Appropriately size and position the PA instance in the workbench (View | PAs | Positioning). If you use 2D planar, be sure to set the “nz use” value appropriately in “View | PAs”. You may rescale the array size on the workbench too (“View | PAs | Positioning | scale”). The magnetic PA may overlap your electric PA’s if you want electric and magnetic fields to overlap. Note that if a particle is located at a point inside multiple PA instances, it only sees the electric field from the electric PA of highest priority number and only sees the magnetic field from the magnetic PA of highest priority number. (Priority numbers are seen on the PA instances list on the PAs tab and are changeable via the L-/L+ buttons).
Add a user program to your workbench. The simplest way is to click the “User Program…” button on the Particles tab. (This creates a file “system.lua”–i.e. with the same base file name “system” as the IOB file and in the same folder.) Paste the following text into it and save:
simion.workbench_program() adjustable bx = 100 -- gauss adjustable by = 0 -- gauss adjustable bz = 0 -- gauss function segment.mfield_adjust() ion_bfieldx_gu = bx ion_bfieldy_gu = by ion_bfieldz_gu = bz end
This works as follows. SIMION sees the system.iob has a corresponding system.lua, and whenever a particle is flying inside mag.pa, this user program applies a constant magnetic field to the particle.
Verify the correctness of the magnetic field with SIMION Data Recording. Caution: The magnetic field defined via a user program (rather than without one) will not normally be visible with the PE/Contours viewing options (though can be visualized with contourlib81 in SIMION Example: contour).
Via a user program in SIMION 6 or 7 (also works in 8)¶
SIMION 7 can do this with a PRG program. Create a user program file “mag.prg” (i.e. with the same base file name “mag” as the PA file, not IOB file, and in the same folder):
defa bx 100 ; gauss defa by 0 ; gauss defa bz 0 ; gauss seg mfield_adjust rcl bx sto ion_bfieldx_gu rcl by sto ion_bfieldy_gu rcl bz sto ion_bfieldz_gu
Via magnetic potentials in a PA¶
An alternate method of creating a magnetic field is to create magnetic pole in a magnetic PA. The negative gradient of the scalar magnetic potential then defines the magnetic field. This is suggested on p. 2-10 of the SIMION 8.0 and 7.0 manuals. This is described in Magnetic Potential.
Combining electric and magnetic fields¶
Electric and magnetic fields cannot be combined in the same PA. Rather, you need two PA’s, one electric and one magnetic. You then overlap the PAs on the workbench. If a particle is inside multiple PA’s, it will see the electric field from the electric PA of highest priority number (in the PA Instances list on the PAs tab) and the magnetic field of the magnetic PA of highest priority number. See also the SIMION Example: magnet (magnet1.iob) example, which does this, or SIMION Example: icrcell.
Mu Metals (High Permeability)¶
Mu metals (i.e. metals with high Permeability ) are often used for magnetic shielding. Mu metals can be handled in SIMION. See the discussion in Floating Conductor and the user group posts linked from that page. The approach for doing mu metals is similar as noted in the user group posts.