NEC Tutorial -- Basic Introduction
NEC can seem a bit imposing at first glance, with its manuals dating back
to the good old days of Fortran IV and punched cards. However to use it
for amateur radio antenna modelling is not that hard.
What NEC does?
An antenna described to NEC is given in two parts, a structure
and a sequence of controls. The structure is simply a numerical
description of where any part of the antenna is located, and how the wires
are connected up. It's no different from the instructions which you would
give to someone else who wanted to built the antenna, but thanks to the old
fashioned structure card style input, it looks quite daunting.
The controls tell NEC where the RF source is connected (note that an antenna
is modelled when transmitting). There is a famous reciprocity theorem which
says that the transmitting gain pattern is the same as the receiving one,
so in fact this is sufficient to understand the antenna's behaviour completely.
The range of frequencies (or maybe just one frequency) of the RF signal
must be specified, as can also loading (such as a loading coil).
The next important element is the character of the ground. The conductivity
of the earth varies from place to place, but in many cases it plays a vital
role in determining the antenna gain pattern. A case when it doesn't is
that of a very tall non conducting mast carrying a small antenna.
A worked example
To see NEC perform, let's look through a worked example of a vertical
monopole antenna above conducting ground. I have followed each line of the
input file by a description of what it does; but for a fuller description
of what an input card does, look in Part III of the NEC manual (available
as HTML). The examples here assume that a modern version of NEC
is being used which doesn't require fixed format input -- the latter
being highly suited to punched card users, but a bit of a pain on a modern
workstation.
Comments
After a few weeks it's easy to forget what a file which took hours of time
to prepare actually represents, so it is a good idea to begin each file with
a brief description of what is being modelled, and at what frequency.
CM NEC Input File
CM Monopole radius 0.001m, length 17m above perfect ground
CM Excitation at base by a 1V source
As you can see, any line at the start of the NEC input file
beginning CM will be treated by
NEC as a comment, and thus totally ignored by the computer.
Now that the comments are finished, a CE end of comments card
is inserted.
CE
The Structure
NEC structures are built up of elements such as straight wires, small surface
patches, or helices. In this case the model is very simple, a single vertical
wire.
GW 1 8 0.00000 0.00000 0.00000 0.00000 0.00000 17.00000 0.00100
Let's look at this in more detail... After the initial card type is a number,
which is the tag number used to identify all parts of this wire,
useful for explaining where a source connects (for example). The next
number tells NEC how many segments this wire should be divided up into.
The reason this is needed is that NEC models the current distribution
on the wire by the values at various points (equally spaced). The more
points used, usually means the more accurate the results, but as will all
good things, there is a penalty -- too many segments slows the program
execution time down a lot. In this case we choose to use eight segments,
a fairly small number.
The next six numbers specify the X,Y, and Z cartesian co-ordinates of the
first and second ends of the wire. So in this case end one is located
at the origin (0.0,0.0,0.0) and the second end is located 17m above this
at (0.0,0.0,17.0). As is usual in mathematics the co-ordinates are such that
the X and Y axes lie in a horizontal plane, and the Z axis points vertically
upwards. The final number in the GW card specifies the radius of the wire
(again in metres so be careful with the units). It's possible to miss
this value out and use a GC card to describe a tapering wire;
but for our simple monopole a single value suffices.
As that concludes our structure specification, a GE card is
now used to signify Geometry End.
GE 1
The one is to indicate that a Ground Plane is going to be used; in fact
you probably want one for most amateur radio applications, but it wouldn't
be appropriate if you were modelling an aircraft antenna, or something a long
way from (conducting) ground.
The ground plane in the NEC code is always taken to be the X-Y plane, that
is all the points where the Z co-ordinate is zero.
If you have been thinking hard you will have seen a possible problem. Earlier
on we said that the antenna would be energised at the ground; but doesn't
the antenna touching ground at its base simply `short-out' the energising
source? The answer is, that with the `1' flag, no it doesn't. If a `-1' flag
had been used, then the current at the ground would be zero.
Before we go on, it is now possible to use a structure viewer like
xnecview to check the structure looks correct. In this
case a single vertical line is drawn, which is exactly as it should
be!
Control Cards
Ground modelling is a difficult problem, since in most places it isn't
a particularly good conductor (at sea is an exception to this of course!).
There are various degrees of sophistication possible with NEC (including
a Sommerfield-Norton ground model). In our example we will use a perfectly
conducting ground.
GN 1 0 0 0 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00
The first number, here `1' means use a perfectly conducting ground. The
remaining numbers are all zero for a perfect ground. They can be used
however to specify the conductivity and dielectric constant of a non-perfect
ground. Hopefully a description of some of the other models will be
added to this tutorial in due course.
Frequency Range
FR 0 1 0 0 1.81E+01 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00
This is a simple single frequency analysis, so the card tells the computer
to energise the source at 18.1MHz (16.6 metres wavelength).
Excitation
We've described the antenna, and the frequency to energise it at, but not
how the RF energy is applied to the antenna. This is to be done at the
bottom, and the EXcitation card does this.
EX 0 1 1 0 1.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00
This means energise by a voltage source (i.e. and applied Electric Field), at
the segment with tag number one, at the first segment (i.e. the bottom end).
The eighth segment would of course be the top end. The other numbers
are only used for incident plane wave excitation, so they are left at zero.
What to Plot
Now we must tell NEC where we want to know the antenna gain distribution.
This is done via the Radiation Pattern card.
RP 0 37 72 1000 0.00E+00 0.00E+00 5.00E+00 5.0E+02 0.00E+00 0.00E+00
This example asks for a Normal Mode plot (that is compute just the space-wave
fields and not the surface wave along the ground). The `37' specifies that
the plot is to be at 37 values of Theta, and the `72' the number of values of
Phi, at which the field is to be computed. The `1000' isn't a number but a
series of binary flags, telling the computer what information to print out.
In our example vertical and horizontal together with total gain are to
be printed, and the gain printed is to be power gain, not averaged over
any region.
Now the initial values of theta and phi are given (both zero degrees),
and the increment angles (both 5 degrees).
Finishing Off
Now tell the computer that this is the end of the input data.
EN
In the case of a simple model like this the program will automatically
execute the analysis and there is no need for a special XQ
card to tell it to do this.
Now Ready to Run
Here's the complete NEC input program which has been described, all ready
for input into the computer
CM NEC Input File
CM Monopole radius 0.001m, length 17m above perfect ground
CM Excitation at base by a 1V source
E
GW 1 8 0.00000 0.00000 0.00000 0.00000 0.00000 17.00000 0.00100
GE 1
GN 1 0 0 0 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00
FR 0 1 0 0 1.81E+01 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00
EX 0 1 1 0 1.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00
RP 0 37 72 1000 0.00E+00 0.00E+00 5.00E+00 5.0E+02 0.00E+00 0.00E+00
EN
Running the Model
You now need to find out how to invoke NEC on your computer system. On
a debian linux system it is easy; once the nec2 package (from the hamradio
section) is installed you type nec2 and enter the input and
output filenames. If you are using debian linux, it is also worth
installing the xnecview package for structure verification
and radiation pattern plotting.
So copy the model above into a text file; and execute the model. If all
went well you should have a fairly large file containing the output which
should look something like this.
NEC model output to be inserted.
The output can be broken up into various sections; but for a quick idea
of what it represents a gain pattern can be plotted using
xnecview. You should see the expected pattern, horizontally
omnidirectional, with a peak at the optimum angle of takeoff in the
vertical direction; however we knew all that already from antenna
theory. The advantage of NEC is that we can now rapidly progress to
a complex antenna, without the many advantages of cylindrical symmetry
possesed by the monopole. The next part of this tutorial considers
an antenna above an imperfect ground.
Return to the Main Page
This text of this tutorial is Copyright © 1999 Alan Bain. It may
be reproduced freely for non-commerical purposes.