Orphan elements issue resolved

Both our 2D and 3D mesh generators (Mesh and MetaMesh) must perform a critical task: identifying whether a point is inside complex closed boundaries defined by sets of line and arc vectors. The process is the core for assignment of elements to regions in Mesh. It is used in MetaMesh to assign elements to turnings and extrusions. Over the years, we have made considerable effort to ensure that the procedure is 100% accurate, an essential requirement when processing meshes of several million elements.

Nonetheless, we have observed an intermittent error that causes orphan elements — isolated elements with an incorrectly-assigned region number. Figure 1 illustrates the phenomenon in a 2D mesh. The problem is not fatal in this case because orphan elements are easily identified and the Mesh program has mechanisms to correct such errors. On the other hand, orphan elements are a major issue in 3D meshes (Figure 2). It is impractical to seek out all errors in a large mesh and to correct them manually. Isolated elements corrupt the surface-fitting procedures in MetaMesh. The program interprets them as a part of the region surface, resulting in highly distorted meshes.

 

Orphan elements in a 2D mesh

Figure 1. Orphan elements in a 2D mesh.

Orphan elements in a 3D mesh

Figure 2. Orphan elements in a 3D mesh.

It is always difficult to identify the causes of rare, isolated events. Fortunately, a recent consulting project gave us the lead we needed to eliminate the error. Figures 1 and 2 illustrate the geometry, a complex acceleration cavity defined by a large set of boundary vectors with a shaped vacuum insulator. We were able to identify the two features of the calculation that lead to orphan elements:

  • The boundary vectors were abstracted from a DXF file supplied by the customer.
  • The meshes required a large number of small elements (3.6 million for the 3D case)

We checked mesh generation for each region of the solution volume. Surprisingly, there was no problem with the main cavity, although it had a complex boundary defined by 33 line and arc vectors. The errors occurred when the vacuum insulator was included. The region had the following specification:

PART
 Region: VInsulator
 Name: VInsulator
 Type: Turning
  L     -2.38830    5.79000   -2.51603    5.64304
  L     -2.51603    5.64304   -2.51603    6.63104<<
  L     -2.51603    6.63504<< -0.93003    7.21754
  L     -0.93003    7.21754   -0.93003    6.32654
  A     -0.93003    6.32654   -2.38830    5.79000   -0.93003    4.07654
 End
END

I have added marks << to show the culprit — inconsistent dimensions between the end point of one vector and the start point of another. The DXF file we received had an error. The difference is so small that it would be difficult to recognize in a graphical editor.

This insight explains the existence of orphan elements. MetaMesh determines if an element is inside a turning or extrusion by sighting outward and counting intersections with the boundary vectors. If there is a hole in the outline, the sight line may pass through without intersecting a vector. In this case, the element is assumed to be outside. Even though the hole may be very small, with millions of elements there is a good chance that some will be in position such that their sight lines intersect it. This explains the geometric regularity for the occurrence of orphan elements in Fig. 2. The reason we did not observe the error in many tests is because we normally use the Drawing Editor of Mesh or the Boundary Editor of MetaMesh in Snap mode to construct outlines, ensuring perfect connections.

2D and 3D mesh generation is flawless when the boundary vectors of the vacuum insulator are changed to:

  L     -2.51603    5.64304   -2.51603    6.63104
  L     -2.51603    6.63104   -0.93003    7.21754

We have made the following changes to Mesh, Geometer and MetaMesh to prevent errors:

  • The tolerance for taking two floating-point numbers as equal has been tightened to 1/1000 of the width of the smallest element in the mesh.
  • In the past, the programs checked only the beginning and end points of a closed set of boundary vectors for a match. Now, the programs check every connection and stop with an error message if there is a mismatch. The error message reports which vectors do not connect to help the user correct the values.

The good news is that our previous efforts to improve element identification have been worthwhile. With a perfectly-connected boundary, the process is highly reliable.

Footnotes

[1] Contact us : techinfo@fieldp.com.

[2] Field Precision home page: www.fieldp.com.

 

Test magnetostatic solution: the role of steel in magnet design

To complete our study of the solenoid coil, we’ll proceed to a practical design by adding a magnet-steel shield. Here, the term magnet-steel designates a soft material with high relative permeability. The term soft means that the steel has a narrow hysteresis curve and with little permanent magnetization. In this article, we’ll concentrate on numerical methods rather than the physics of the materials. Chapter 9 of Finite-element Methods for Electromagnetics (available for download at http://www.fieldp.com/femethods.html) reviews the properties of ferromagnetic materials and how they influence numerical solutions. In summary, magnet-steel serves three functions in an electromagnet:

  1. High-μr materials act as conductors of magnetic flux with little expenditure of energy. The use of material atomic currents to carry the return flux of a magnet means that the real currents in the drive coil may be reduced.
  2. Ferromagnetic materials act as shields. Return flux prefers to flow through the steel, reducing the fringing fields of the magnet.
  3. The magnetic flux density B is constrained to lie almost normal to the surface of a material with μr » 1. Control may be exerted over field variations by shaping the surfaces of the steel.

The example will demonstrate these effects. The underlying assumption is that the fields generated by drive coils are low enough so that the ferromagnetic material is not driven into saturation. The next article discusses the nature of saturation effects and how to model them.

We’ll start with the magnetic solution for the bare cylindrical coil discussed in a previous article Test magnetostatic solution: simple coil with boundaries. The solution boundaries are zmin = -6.0 cm, zmax = 6.0 cm and rmax = 9.0 cm. To review, here is the corresponding Mesh input script BareCoil.MIN:

*  -------------------------------------------------------
GLOBAL
 ZMESH
  -6.00000   -4.50000    0.20000
  -4.50000    4.50000    0.10000
   4.50000    6.00000    0.20000
 END
 RMESH
   0.00000    5.50000    0.10000
   5.50000    9.00000    0.20000
 END
END
*  -------------------------------------------------------
REGION  FILL AIR
L     -6.00000    0.00000    6.00000    0.00000
L      6.00000    0.00000    6.00000    9.00000
L      6.00000    9.00000   -6.00000    9.00000
L     -6.00000    9.00000   -6.00000    0.00000
END
*  -------------------------------------------------------
REGION  FILL COIL
L     -3.00000    2.00000    3.00000    2.00000
L      3.00000    2.00000    3.00000    4.00000
L      3.00000    4.00000   -3.00000    4.00000
L     -3.00000    4.00000   -3.00000    2.00000
END
*  -------------------------------------------------------
REGION BOUNDARY
L      6.00000    9.00000   -6.00000    9.00000
L     -6.00000    9.00000   -6.00000    0.00000
L     -6.00000    0.00000    6.00000    0.00000
L      6.00000    0.00000    6.00000    9.00000
END
*  -------------------------------------------------------
ENDFILE

We’ll add an additional region to represent the external steel shield using the Drawing Editor of Mesh. Run tc.exe, set the Data folder to the location where you are working and launch Mesh. Use the tool or the command File/Load/Load script (MIN) and choose BareCoil.MIN. Then, use the tool or command Edit script/Edit script (graphics) to open the drawing editor. The vectors for the three regions are displayed and the current region is set to 3. Click the Start next region tool. We will add vectors representing the outline of the shield as Region 4. Click the Set snap mode tool to open the dialog of Fig. 1. For convenience, entered points will snap to the drawing coordinate system with a resolution of 0.5 cm.

Set snap mode dialog of the Mesh drawing editor

Figure 1. Set snap mode dialog of the Mesh drawing editor.

Click on the Line tool to enter a series of vectors to outline the shape shown in Fig. 2:top (brown lines). In the line entry mode, move the cursor to snapped locations and left-click on the start and end point of each of the ten vectors. Take care that they all connect and define a closed shape. Snap mode helps to ensure that the end point of one vector connects exactly to the start point of the next. When you have finished the last  vector, right-click the mouse to exit the line entry mode.

Top: adding a region in the Mesh Drawing Editor

Figure 2. Top: adding a region in the Mesh Drawing Editor. Bottom: checking the fill status.

Choose the command Settings/Region properties. Give the new region the name STEEL and check the Filled box (we want to assign a high value of μr to all the enclosed elements). Exit the dialog. To confirm that the vectors of the new region constitute a connected and closed set, click the Toggle fill display tool. The display of Fig. 2:bottom indicates valid filled regions.

Region properties dialog in the Mesh Drawing Editor

Figure 3. Region properties dialog in the Mesh Drawing Editor.

Finally, it is a good practice in electrostatic and magnetostatic solutions to group regions with fixed boundary conditions (electrostatic or vector potential) at the end of the Mesh script. Choose the command Settings/Region order. Check the box for STEEL and then click the Move UP button. Finally, click the Export MIN tool and save the revised data in the file SteelShield.MIN. Exit the drawing editor. Click the Load script (MIN) tool and load the new script. Process the mesh and then click the Save mesh (MOU) tool to create the file SteelShield.MOU.

Run PerMag, click the “1” tool and choose the new mesh file. The dialog is similar to that of the previous example, except for the new region. Fill in the values as shown in Fig. 4. Save the file as SteelShield.PIN and then generate a solution. To make a comparison, we need a solution without the steel. Here’s a quick way to create it. Choose the command File/Edit files and pick SteelShield.PIN. Comment out the specification for high μr (put an asterisk at the beginning of the line) and replace it with the value for air:

* Mu(3) =   5.0000E+02
Mu(3) =   1.00

Save the result as NoShield.PIN and exit the editor. Then generate a PerMag solution.

 

Set up PerMag solution dialog

Figure 4. Set up PerMag solution dialog.

We can find out a lot about the effect of steel by looking at a plot of lines of magnetic flux density B (Fig. 5). With no steel shield, the lines spread out over the entire external region and the solution is strongly influenced by the boundaries. With the shield, the return flux lines are conducted through the steel. In this case, fringing fields are small and the boundaries have almost no effect on the solution. As expected, B lines entering and exiting the steel are normal to the surface. The shield also contains lines axially and B is more uniform within the coil.

Lines of magnetic flux density B

Figure 5. Lines of magnetic flux density B. Top: No shield. Bottom: With shield.

Scans of magnetic flux density along the axis, Bz(z,0), give a quantitative comparison . Prepare and run the following analysis script:

NScan = 100
Output Shield_Analysis.DAT
Input NoShield.POU
Scan -6.0  0.0  6.0  0.0
Input SteelShield.POU
Scan -6.0  0.0  6.0  0.0
ENDFILE

Fig. 6 shows plots of computed values for solutions with the same coil area and NI product. The shield clearly improves axial containment of magnetic flux. A significant result is that field magnitude inside the coil (i.e., the working volume) is 38% higher. Alternatively, suppose the goal is to achieve a given central value Bz(0,0). The result of Fig. 6 indicates that the required NI product with the shield is only 73% that for the air coil, so the drive power would be cut almost in half. This effect reflects the fact that the coil need not supply field energy to support the return flux.

Scans of Bz(z,0) with and without the shield

Figure 6. Scans of Bz(z,0) with and without the shield.

The condition of a fixed value of μr applies if the atomic currents in the iron are proportional to the drive currents in the coil (i.e., the hysteresis curve is a straight line). Sometimes, the hysteresis curve may have a more complex variation. Even more important, there is a maximum value of atomic current in the material equivalent to alignment of all magnetic domains. At some value of coil current, the proportionality can no longer hold. The effect is called saturation of the magnetic material. The next article discusses how these non-linear effects are represented in PerMag. In particular, want to see when we should worry about details in the variation of μr and the affects of saturation on field distributions.

Footnotes

[1] Contact us : techinfo@fieldp.com.

[2] Field Precision home page: www.fieldp.com.

Test magnetostatic solution: boundary effects and automatic operation

The previous article emphasized that finite-element calculations are performed in a finite volume and that conditions on the the boundaries must be specified. We use a Neumann condition (field lines normal to the boundary) along a symmetry plane. An example is one half of a magnetic mirror split at the midplane. Otherwise, the most common boundary is a Dirichlet condition (i.e., fixed vector potential), equivalent to a perfectly-conducting wall. Although the boundary would affect modeling a coil in infinite space, this does not represent a serious limitation on the finite-element method because practical magnets are designed to limit fringing fields.

This article has has three learning goals:

  • Quantify the effect of the Dirichlet boundaries in magnetostatic solutions.
  • Introduce the use of a variable-resolution mesh.
  • Set up an automatic calculation to do a parameter search.

We’ll continue with the cylindrical coil from the previous article. It carries a total current of 2500 A-turns uniformly distributed over the cross section, -3.0 cm ≤ z ≤ 3.0 cm, 2.0 cm ≤ r ≤ 4.0 cm. We start with close boundaries (-5.0 cm ≤ z ≤ 5.0 cm, 0.0 cm ≤ r ≤ 7.5 cm) and then expand them to see how the fields approach the infinite-space result. The element size should be relatively small near the coil, but we can use larger elements in the surrounding volume to minimize computational work. For the smallest solution, the foundation mesh definitions in the Mesh input script look like this:

GLOBAL
 ZMESH
  -5.0 -3.5  0.2
  -3.5  3.5  0.1
   3.5  5.0  0.2
 END
 RMESH
   0.0  4.5  0.1
   4.5  7.5  0.2
 END
END

The axial specification states that the initial triangular element base (before smoothing and fitting) is 0.2 cm in the zones -5.0 cm ≤ ≤ -3.5 cm and 3.5 cm ≤ ≤ 5.0 and 0.1 cm near the coil. Figure 1 shows the result. Note that Mesh has fitted the coil boundaries exactly and made smooth transitions between regions of different element sizes.

Variable resolution mesh for the magnet coil solution

Figure 1. Variable resolution mesh for the magnet coil solution.

To make useful comparisons of the numerical results, we need a baseline. A theoretical expression for the on-axis field at the midplane of a solenoid (z = 0.0 cm, r = 0.0 cm) with finite length and radial thickness is available on this website:

http://www.netdenizen.com/emagnet/solenoids/solenoidonaxis.htm

For the values Ni = 2500.0, r1 = 0.02 m, r2 = 0.04 and l = 0.06 m, the formula of Figure 2 gives the value Bz(0,0) = 0.037186 tesla.

On-axis, midplane field in the thick solenoid of finite length

Figure 2. On-axis, midplane field in the thick solenoid of finite length.

For the study, we will expand the boundaries (keeping rmax = 1.5 zmax) and compare the value of Bz(0,0) to the infinite-space result. We will use the following nine values for zmax: 5.0 cm, 6.0 cm, 7.0 cm, 8.0 cm, 9.0 cm, 10.0 cm, 12.50 cm, 15.0 cm and 20.0 cm. We could each do calculation interactively: create nine mesh scripts, run and analyze nine PerMag solutions. That’s the hard way. Field Precision programs offer a useful option for extended calculations. Batch files and external programs (e.g. python scripts) can not only run the technical programs, but they can also control how the program interprets variable quantities in the input script. The current application demonstrates how this works. The Mesh input script BatchControl.MIN is modified to the following form:

*  -------------------------------------------------------
GLOBAL
 ZMESH
   %1  -3.5  0.2
  -3.5  3.5  0.1
   3.5  %2   0.2
 END
 RMESH
   0.0  4.5  0.1
   4.5  %3   0.2
 END
END
*  -------------------------------------------------------
REGION  FILL AIR
L     %1    0.00000    %2    0.00000
L     %2    0.00000    %2    %3
L     %2    %3         %1    %3
L     %1    %3         %1    0.00000
END
*  -------------------------------------------------------
REGION  FILL COIL
L     -3.00000    2.00000    3.00000    2.00000
L      3.00000    2.00000    3.00000    4.00000
L      3.00000    4.00000   -3.00000    4.00000
L     -3.00000    4.00000   -3.00000    2.00000
END
*  -------------------------------------------------------
REGION BOUNDARY
L     %1    0.00000    %2    0.00000
L     %2    0.00000    %2    %3
L     %2    %3         %1    %3
L     %1    %3         %1    0.00000
END
*  -------------------------------------------------------
ENDFILE

Note the symbolic representation of the boundary limits, a convention familiar to users of Windows batch files. The symbol %1 represents zmin, %2 represents zmax and %3 represents rmax.

We prepare a Windows batch file with the following content:

START /B /WAIT C:\fieldp_pro\tricomp\mesh.exe C:\Simulations\BatchControl  -5.00   5.00   7.50
START /B /WAIT C:\fieldp_pro\tricomp\permag.exe C:\Simulations\BatchControl.PIN
START /B /WAIT C:\fieldp_pro\tricomp\permag.exe C:\Simulations\BatchControl.SCR
START /B /WAIT C:\fieldp_pro\tricomp\mesh.exe C:\Simulations\BatchControl  -6.00   6.00   9.00
START /B /WAIT C:\fieldp_pro\tricomp\permag.exe C:\Simulations\BatchControl.PIN
START /B /WAIT C:\fieldp_pro\tricomp\permag.exe C:\Simulations\BatchControl.SCR
START /B /WAIT C:\fieldp_pro\tricomp\mesh.exe C:\Simulations\BatchControl  -7.00   7.00  10.50
START /B /WAIT C:\fieldp_pro\tricomp\permag.exe C:\Simulations\BatchControl.PIN
START /B /WAIT C:\fieldp_pro\tricomp\permag.exe C:\Simulations\BatchControl.SCR
START /B /WAIT C:\fieldp_pro\tricomp\mesh.exe C:\Simulations\BatchControl  -8.00   8.00  12.00
START /B /WAIT C:\fieldp_pro\tricomp\permag.exe C:\Simulations\BatchControl.PIN
START /B /WAIT C:\fieldp_pro\tricomp\permag.exe C:\Simulations\BatchControl.SCR
...

The file seems verbose, but it is mainly copy-and-paste from a template prepared with the Create task button of the TriComp program launcher. The interesting lines are those that call Mesh. The first pass parameter is the input script name listed above. The three additional string parameters give numerical values for the variables %1, %2 and &3, multiple solutions with expanding boundaries. The two commands that follow call PerMag with the modified mesh and then execute the analysis script BATCHCONTROL.SCR. This file has the following content:

INPUT BatchControl.POU
OUTPUT BatchControl.DAT Append
POINT 0.0 0.0
ENDFILE

The Append specification in the second command ensures that all the data will be added in sequence to a single output file.

The full data set is generated in about two seconds by executing the batch file. The data are available as text entries in BATCHCONTROL.DAT. Figure 3 shows a plot of the results, exporting the numerical values to PsiPlot. The dashed line is the theoretical result from the equation of Fig. 2. The difference from the infinite space is about 10.4% for the close boundaries (zmax = 5.0 cm) and about 0.4% for the large boundaries (zmax = 20.0 cm). The next article discusses the role of steel in magnet design. In particular, we will improve the example solenoid, providing external shielding and minimizing the drive power needed to achieve a given internal field.

Results of the solution set

Figure 3. Results of the solution set.

Footnotes

[1] Contact us : techinfo@fieldp.com.

[2] Field Precision home page: www.fieldp.com.

New features for automatic program operation

One of the outstanding features of our software is the use of input scripts, a classic feature of early programs that we have updated. The term script refers to a text file of input data for a program run. Figure 1 shows the role of input scripts in Field Precision software. Years ago, the primary input method for technical programs followed the sequence in the middle of the illustration. A user would employ a text editor (or a punch card machine, if we go far enough back) to create the set of instructions passed to the program. Early scripts were rigid in the order and syntax of instructions and documentation was often sparse. As a result, the script method acquired a bad reputation.

Input options for Field Precision technical programs

Figure 1. Input options for Field Precision technical programs.

Users welcomed the appearance of graphical-user interfaces. Here, the programs remembered the instruction syntax and provided setup guidance. Most modern technical programs follow the sequence show by the red arrow in Fig. 1. The user sets controls or fills in fields, and the data is passed directly to the program. In contrast, Field Precision programs follow a two-step process where the interactive routines produce a text script which is then read by the program[1]. There are several reasons why we have chosen this route:

  • Compact scripts are an effective method for archiving run setups and exchanging them with colleagues.
  • Input information is transparent to the user.
  • Scripts provide expanded input options.

We will concentrate on the third advantage in this article.

Field Precision programs offer two alternatives to the graphical-user-interface. Direct editing of the script is useful for checking values and making small changes (e.g., moving objects, modifying material properties,…) without the need to negotiate the GUI. In the past, our programs have had a limited capability for control through Windows batch files and external programs (e.g., Python scripts,…), indicated by the black arrow in Fig. 1. All of our programs had the capability to run from the command line or to be called by an external program. The single pass parameter was the name of the input script.

The change described in this article, represented by the green arrow in Fig. 1, applies to the all 2D and 3D Field Precision programs. Batch files and external programs can now control how the technical program interprets variable quantities in the input script. The easiest way to describe the feature is to follow an application example. Figure 2-top shows the geometry of a test calculation, the magnetic field of a cylindrical coil in an air volume. Finite-element solutions are performed in a finite-volume and require a specified condition on the boundary. The most boundary for magnetic-field calculations is a Dirichlet condition (constant vector potential). In the case, the boundary acts like a perfectly-conducting wall (Fig. 2-bottom). The purpose of the study is to determine how large the boundaries must be to approach the infinite-space result.

Test calculation, magnetic field of a cylndrical coil in space

Figure 2. Test calculation, magnetic field of a cylndrical coil in space. Top: Mesh. Bottom: Calculated field lines.

 

The procedure is to compute several solutions with different boundaries, comparing the values of the field at the center of the coil, Bz(0,0). The mesh input script BATCHCONTROL.MIN looks  like this:

*  -------------------------------------------------------
GLOBAL
 ZMESH 
  %1  -3.5  0.2
  -3.5  3.5  0.1
  3.5  %2   0.2
 END
 RMESH
  0.0  4.5  0.1
  4.5  %3   0.2
 END
END
*  -------------------------------------------------------
REGION  FILL AIR
 L     %1    0.00000    %2    0.00000
 L     %2    0.00000    %2    %3
 L     %2    %3         %1    %3
 L     %1    %3         %1    0.00000
END
*  -------------------------------------------------------
REGION  FILL COIL
 L     -3.00000    2.00000    3.00000    2.00000
 L      3.00000    2.00000    3.00000    4.00000
 L      3.00000    4.00000   -3.00000    4.00000
 L     -3.00000    4.00000   -3.00000    2.00000
END
*  -------------------------------------------------------
REGION BOUNDARY
 L     %1    0.00000    %2    0.00000
 L     %2    0.00000    %2    %3
 L     %2    %3         %1    %3
 L     %1    %3         %1    0.00000
END
*  -------------------------------------------------------
ENDFILE

In the GLOBAL section, notice that there is region of small elements around the coil and then larger elements to the outer boundaries. Further, note the symbolic representation of the boundary limits, a convention familiar to users of Windows batch files. The symbol %1 represents ZMin, %2 represents ZMax and %3 represents RMax.

The calling batch file has the following content:

START /B /WAIT C:\fieldp_pro\tricomp\mesh.exe C:\Simulations\BatchControl  -5.00   5.00   7.50
START /B /WAIT C:\fieldp_pro\tricomp\permag.exe C:\Simulations\BatchControl.PIN
START /B /WAIT C:\fieldp_pro\tricomp\permag.exe C:\Simulations\BatchControl.SCR
START /B /WAIT C:\fieldp_pro\tricomp\mesh.exe C:\Simulations\BatchControl  -6.00   6.00   9.00
START /B /WAIT C:\fieldp_pro\tricomp\permag.exe C:\Simulations\BatchControl.PIN
START /B /WAIT C:\fieldp_pro\tricomp\permag.exe C:\Simulations\BatchControl.SCR
START /B /WAIT C:\fieldp_pro\tricomp\mesh.exe C:\Simulations\BatchControl  -7.00   7.00  10.50
START /B /WAIT C:\fieldp_pro\tricomp\permag.exe C:\Simulations\BatchControl.PIN
START /B /WAIT C:\fieldp_pro\tricomp\permag.exe C:\Simulations\BatchControl.SCR
START /B /WAIT C:\fieldp_pro\tricomp\mesh.exe C:\Simulations\BatchControl  -8.00   8.00  12.00
START /B /WAIT C:\fieldp_pro\tricomp\permag.exe C:\Simulations\BatchControl.PIN
START /B /WAIT C:\fieldp_pro\tricomp\permag.exe C:\Simulations\BatchControl.SCR
...

The file seems verbose, but it is mainly copy-and-paste from a template prepared with the Create task button of the TriComp program launcher. The interesting lines are those that call Mesh. The first pass parameter is the input script listed above. The three additional string parameters give numerical values for the variables %1, %2 and &3. There are multiple solutions with expanding boundaries with the constraint RMax = 1.5 ZMax. The two commands that follow run PerMag with the modified mesh and then execute the analysis script BATCHCONTROL.SCR. This file has the following content:

INPUT BatchControl.POU
OUTPUT BatchControl.DAT Append
POINT 0.0 0.0
ENDFILE

The Append specification in the second command ensures that all the data will be added in sequence to a single output file.

The full set of runs is generated in about two seconds by executing the batch file. The data are available as text entries in BATCHCONTROL.DAT. Figure 3 shows a plot of the results. The dashed line is the theoretical result for an infinite space.

Central field of a cylindrical coil as a function of the boundary dimension

Figure 3. Central field of a cylindrical coil as a function of the boundary dimension. The dashed line is the theoretical result for infinite space.

You can imagine the infinite possibilities for automation. For example, suppose we wanted to do a more intensive analysis of each solution and record the results in a separate file. In this case, the calling batch might look like this:

...
START /B /WAIT C:\fieldp_pro\tricomp\mesh.exe C:\Simulations\BatchControl  -6.00   6.00   9.00
START /B /WAIT C:\fieldp_pro\tricomp\permag.exe C:\Simulations\BatchControl.PIN
START /B /WAIT C:\fieldp_pro\tricomp\permag.exe C:\Simulations\BatchControl.SCR BatchControl02.DAT
...

and the OUTPUT command in the analysis script would become

OUTPUT %1

Footnotes

[1] Field Precision scripts are quite different from those of older programs. They are readable, and the technical programs use a free form input parser that does not require rigid numerical formats or a fixed order of commands.

[2] Contact us : techinfo@fieldp.com.

[3] Field Precision home page: www.fieldp.com.

Test magnetostatic solution: simple coil with boundaries

In this article, we’ll advance to 2D magnetostatic solutions using the programs Mesh and PerMag. The previous articles on electrostatics have given background on the basic concepts of FEM calculations and program operation. Therefore, in this lecture and following ones I’ll concentrate on the special features of magnetic field calculations. In preparation, I suggest you try the prepared walk-through example discussed in the PerMag manual.

To review, the calculation discussed in the previous articles determined the electrostatic potential φ (a scalar quantity) at the node points of a mesh that we created. Components of the electric field vector components at a location could then be determined by collecting local values of phi and taking numerical derivatives:

E = – ∇φ

The components were Ex and Ey for planar solutions and Ez and Er for cylindrical solutions. Things get more involved for magnetic field calculations[1]. The calculated node quantity is the vector potential A. The magnetic flux density B is given by

B = ∇ × A.

Fortunately, in 2D calculations there is only a single component of A. The node quantity is Az for planar solutions (with flux density components Bx and By) and rAθ for cylindrical solutions (with components Bz and Br). The vector potential has useful properties for making plots:

  • In planar solutions, contours of Az separated by a uniform interval ΔAz lie along lines of B separated by equal intervals of magnetic flux per length.
  • In cylindrical solutions, contours of rAθ separated by a uniform interval Δ(rAθ) lie along lines of B separated by equal intervals of magnetic flux.
Dialog to start a Mesh script in the text mode

Figure 1. Dialog to start a Mesh script in the text mode.

Let’s get to work and generate some fields. We’ll start with a cylindrical coil in free space. Because the geometry is simple, we’ll write the boundary specifications directly with an editor. In Mesh, click the New mesh (text) tool to bring up the dialog of Fig. 1. The values define a solution volume that covers the range -10.0 cm ≤ z ≤ 10.0 cm, 0.0 ≤ r ≤ 15.0 cm[2]. When you click OK, the program opens the internal text editor with the default content shown in Fig. 2. The Global section at the top sets the foundation mesh (the element geometry before adjustment of boundary nodes). It covers the range we specified with a default element size of 0.1 cm. Available advanced commands (like TriType) are listed as comment lines. We won’t need them for this calculation, so delete the comments.

Starting a Mesh script in text mode

Figure 2. Starting a Mesh script in text mode, display of the internal editor.

A default region named SolVolume (Region 1) that covers the entire solution volume has been added —the default is appropriate for this calculation[3]. Change the region name to Air. Mesh has also started a default second region. We’ll use it to define the rectangular cross section of a cylindrical coil. The comment lines show the commands that could appear within a region section. Erase the comments and rename the region Coil. The coil will have the dimensions -3.0 cm ≤ z ≤ 3.0 cm and 4.0 cm < r < 6.0 cm. Copy and paste the line vectors of Region 1 and use Search/Replace to modify the dimensions. We’ll also add a third region by copying and pasting Region 1 verbatim. Rename it Boundary and remove the word Fill in the Region command. We’ll discuss the purpose of this extra region later. For now, the modified script should look like this:

GLOBAL
 XMesh
  -10.00000   10.00000    0.10000
 End
 YMesh
  0.00000   15.00000    0.10000
 End
END
*  -------------------------------------------------------
REGION  FILL Air
 L   -10.00000    0.00000   10.00000    0.00000
 L    10.00000    0.00000   10.00000   15.00000
 L    10.00000   15.00000  -10.00000   15.00000
 L   -10.00000   15.00000  -10.00000    0.00000
END
*  -------------------------------------------------------
REGION  FILL Coil
 L    -3.00000    4.00000    3.00000    4.00000
 L     3.00000    4.00000    3.00000    6.00000
 L     3.00000    6.00000   -3.00000    6.00000
 L    -3.00000    6.00000   -3.00000    4.00000
END
*  -------------------------------------------------------
REGION  Boundary
 L   -10.00000    0.00000   10.00000    0.00000
 L    10.00000    0.00000   10.00000   15.00000
 L    10.00000   15.00000  -10.00000   15.00000
 L   -10.00000   15.00000  -10.00000    0.00000
END
*  -------------------------------------------------------
ENDFILE

Save your work and exit the editor.

Click the Load script (MIN) tool to read the boundary specifications in BARECOIL.MIN and then click Process. When complete, click Save mesh (MOU) to create the file BARECOIL.MOU. This file will be used by PerMag. You can go to the Plot/Repair menu to view a cross-section of the resulting mesh, consisting of 60,000 elements.

Run PerMag and click the “1” tool to bring up the dialog of Fig. 3. As in the previous calculation, this dialog creates a script of run and material parameters to control the solution program. We can ignore several of the fields because the values apply yo advanced runs with non-linear materials (e.g., saturable iron). For this run, we need only set the Geometry to Cylindrical and fill in the magnetic properties of the regions. Air has relative permeability μr = 1.0. The coil also has μr = 1.0. In addition, we need to set a total current that flows in the θ direction for a cylindrical solution. If the coil has N = 1000 turns and the drive current is I = 2.0 A, then the total A-turns over the cross section is 2000.0. Equivalently, the region carries a uniform azimuthal current density of (2000)/(0.06*0.02) = 1.667 MA/m2[4]. Finally, we want to see what happens if we make no special provisions for the Boundary region, so don’t set any property. Click OK and save the data in the file BARECOIL.PIN. You can check the file content with the internal PerMag editor.

PerMag dialog to define run parameters and material properties

Figure 3. PerMag dialog to define run parameters and material properties.

Click the “2” button and choose BARECOIL.PIN to find the finite-element solution. Then click “3” and load BARECOIL.POU to analyze the solution. To begin, let’s check the lines of B. Click the Plot type tool and set the option Contour lines. Then click the Plot quantity tool and choose rAthet to produce the plot of Fig. 4a. There are two interesting features:

  • Even though the field inside the coil is fairly uniform, the space between the contours is larger near the axis. This is because the lines are separated by intervals of equal magnetic flux and the area normal to z gets gets smaller near the axis. In other words, the spacing between lines is proportional to |B|/r in cylindrical coordinates.
  • The lines of B are normal to the boundaries, the standard default Neumann condition for a finite-element magnetic solution (i.e., the derivative of vector potential normal to the boundary is zero). With regard to the axial boundaries, the condition would occur if there were an infinite array of coils with alternating positive and negative currently. Certainly, this is not what we intended. Furthermore, the boundary on the outer radius is non-physical in the sense that we could find no set of real coils that would generate the field pattern.
Lines of B for the solution

Figure 4. Lines of B for the solution. a) Default Neumann boundary condition. b) Dirichlet condition, fixed vector potential.

With regard to the second point, we must do some thinking about the boundary conditions. The alternative is to set the vector potential equal to a constant along the boundary. The Dirichlet condition is rAθ = 0.0. In this case, the component of B normal to boundary is zero, so that lines of B are parallel. To do this, we change the specification of Region 3 to:

* Region 3: BOUNDARY
VecPot(3) = 0.0000E+00

The command states that the node quantity has a fixed value.

Figure 4b shows the modified solution. It is better in one respect. The field pattern could be achieved in an actual physical system — a coil inside a superconducting can. At this point, you may protest that you wanted a coil in infinite space, not in a superconducting can. We must recognize that there is a limitation to finite-element calculations. They must be performed in a finite volume. There will always be boundaries, and the conditions on the boundaries must be specified. Without additional information, the choices are Neumann or Dirichlet[5].

But, is it a limitation? Often, issues in a numerical solution mirror concerns in the physical system. When is the last time you operated a magnet in infinite space? In a real system, there is usually an array of nearby objects in unpredictable locations. These objects would strongly alter the far fields and could affect field components in the working volume of the magnet. The inmplication is that the magnet of Fig. 4, with its widely-distributed pattern of fringing fields, is a poor design. An additional disadvantage of the external fields is that they represent wasted field energy. We shall see that the extra energy means that more power must be supplied to the drive  coil. In a following article, we will consider the use of ferromagnetic materials to improve the design. In the next article, we will carry out a numerical study to quantify how much the boundaries in a finite-element solution affect the results.

Footnotes

[1] For a review of magnetic-field physics, see S. Humphries, Finite-element Methods for Electromagnetics (CRC Press, 1997), available at http://www.fieldp.com/femethods.html

[2] Mesh displays an error message if you try to open a cylindrical solution with r < 0.0. As an exercise, can you think of a solution where you would use r > 0.0?s

[3] Although Region 1 often covers the full solution, it is not a necessary condition (as we saw in the previous electrostatic solution).

[4] Coil regions in PerMag always have uniform average current density. To represent a coil with variations of winding density, divide it into multiple regions.

[5] Looking ahead to later articles, Field Precision programs can approximate infinite-space magnetic calculations via the Boundary procedure (computed Dirichlet boundary)

[6] Contact us : techinfo@fieldp.com.

[7] Field Precision home page: www.fieldp.com.