Antennas in Linux

For this article, I want to introduce a piece of software I've actually used recently in my own work. My new day job involves studying the ionosphere using an instrument called an ionosonde. This device is basically a giant radio transmitter that bounces radio waves off the ionosphere to see its structure and composition. Obviously, an important part of this is knowing the radiation pattern of the various transmitters and receivers.

Several methods exist for modeling the electromagnetic fields around conductors, but here I'm covering one called NEC2 (Numerical Electromagnetics Code). It originally was developed in FORTRAN at the Lawrence Livermore National Laboratory in the 1970s. Since then, it's been re-implemented several times in various languages. Specifically, let's look at xnec2c. This package implements NEC2 in C, and it also provides a GTK front end for interacting with the core engine.

xnec2c should be available in most Linux distributions. In Debian-based distributions, you can install it with the command:


sudo apt-get install xnec2c

Once it's installed, you can start it with xnec2c. The default display doesn't show anything until you actually start using it.

Figure 1. Launching xnec2c gives you a pretty boring starting point.

xnec2c's history still affects how it behaves to the present day. This is most clear when you look at the input file's format. The basic structure is based on the idea of a punch card, where each "command" to xnec2c is given by a command card—a definite holdover from its FORTRAN roots. Luckily, the GTK front end to xnec2c provides a reasonably functional way of building up these input files.

Several example files should be available with your installation of xnec2c. In my Ubuntu distribution, they're located in /usr/share/doc/xnec2c/examples. These input files have a filename ending of ".nec". Select one as a starting off point to play with xnec2c, and then go ahead and make the required alterations necessary for your own project.

Figure 2. Loading an input file, you begin with a geometric view of the relevant antenna wires, other conductors and any ground planes.

The central window pane provides a geometric view of the actual antenna structure in three dimensions. You can click and drag the diagram to rotate the view and see it from all angles. There are two larger buttons at the top of the window, named Currents and Charges. Selecting them alternately will show either the distribution of currents or the distribution of charges caused by the driving current.