Simulating coil systems with fasthenry and coilgen

coilgen is a small program which generates fasthenry input files for simulating coil structures. It can be used, for example, to calculate the inductance of a variometer under different positions of the coils.

The coil geometry is read from the configuration file coilgenrc: this text file contains a row for every coil in the system; everything after a # character is considered a comment and thus ignored.

The format of the coil description lines is:

diameter length turns wire_diameter centre_x centre_y centre_z

For example, my main variometer is composed of two concentrical coils; the bigger one has 62 turns of 48.5 cm diameter and is 26.5 cm long, while the smaller has 57 turns of 33.0 cm diameter and is 24.0 cm long. Wire diameter is 2 mm for both coils.

The coilgenrc file for this configuration is:

0.485 0.265 62 2e-03 0.0 0.0 0.0
0.33 0.24 57 2e-03 0.0 0.0 0.0

Note that coils centers are at the origin, but this is not important, as long as the relative positions are correct...

coilgen accepts also some command line parameters; usage is:

coilgen [options] [outfile]

where options can be:
  -d n : use n segments per turn (default is 16)
  -h   : print usage help
  -v   : print version information

Simulation frequency is fixed to 0.1592 Hz, so the resulting impedance value is numerically equal to the inductance.
If the outfile parameter is not specified, output goes to stdout; the output can be piped directly to fasthenry, like:

coilgen | fasthenry

For the above command the resulting output from fasthenry is:

Running FastHenry 3.0 (29Sep96)
  Date: Mon Sep 24 22:02:39 2001
  Host: pc
Solution technique: ITERATIVE
Matrix vector product method: MULTIPOLE
  Order of expansion: 2
Preconditioner: ON
Error tolerance: 0.001
No input file given.  Reading from stdin...
* File generated by coilgen, Mon Sep 24 22:02:39 2001

all lengths multiplied by 0.001 to convert to meters
Total number of filaments before multipole refine: 1902
Total number of filaments after multipole refine: 3804

Multipole Summary
  Expansion order: 2
  Number of partitioning levels: 3
  Total number of filaments: 3804
Percentage of multiplies done by multipole: 100%
Scanning graph to find fundamental circuits...
Number of Groundplanes : 0 
Number of filaments:       3804
Number of segments:        3804
Number of nodes:           3806
Number of meshes:             2
          ----from tree:                   2 
          ----from planes: (before holes)  0 
Number of conductors:         2   (rows of matrix in Zc.mat) 
Number of columns:            2   (columns of matrix in Zc.mat) 
Number of real nodes:      3806
filling M...
filling R and L...
Total Memory allocated: 34262 kilobytes
Frequency = 0.1592
Forming sparse matrix preconditioner..
conductor 0 from node n992
Calling gmres...
1 2 
conductor 1 from node n0
Calling gmres...
1 2 

All impedance matrices dumped to file Zc.mat

Times:  Read geometry   1.75
        Multipole setup 236.45
        Scanning graph  0.02
        Form A M and Z  0.15
        form M'ZM       0
        Form precond    0.14
        GMRES time      13.34
   Total:               251.85

And the fasthenry output file Zc.mat is:

Row 2:  n992  to  n1903
Row 1:  n0  to  n991
Impedance matrix for frequency = 0.1592 2 x 2
      0.408091   +0.00182523j   1.03128e-19   +0.00069845j 
 -1.67805e-19  +0.000698737j      0.255256   +0.00088569j 

So the first coil has an inductance of 1.826 mH, the second 886 µH and the mutual inductance between the two is 699 µH. These results can be compared with the formulas reported by Terman [1] and used in my variometer design form which gives 1.842 mH, 896 µH and 703 µH respectively. The difference between the two methods is about 1 % maximum; note that the analytical formulas yield higher number than the electromagnetic simulation, probably because the former are based on the current sheet approximation, which requires closely spaced turns, and here the winding pitch is about 4.2 mm with a wire diameter of only 2 mm so the inductance will be slightly overestimated.

About the number of segments per turn in coilgen

Since the system geometry description to fasthenry can only be made in term of segments (straight conductors), every round turn is approximated by coilgen with a polygon, whose number of sides can be varied with the -d option. Of course, more sides means better approximation, but at the price of more time spent in the calculations; I have done some fasthenry simulations to show how the calculated inductance, time, total number of segments and memory allocated change with the number of segments per turn, using the following configuration file:

0.485 0.265 62 1e-03 0.0 0.0 0.0
0.33 0.24 57 1e-03 0.0 0.0 0.0

This is almost the same coil configuration as the previous example, with the wire diameter changed to 1 mm.


[1] F.E. Terman, "Radio Engineers' Handbook," London, McGraw-Hill, 1st ed., Sep. 1950.