Reading a NEC Deck

47. So You Want to Read a NEC-Deck

L. B. Cebik, W4RNL (SK)




Those who develop implementations of NEC for newer users often develop "user-friendly" interfaces between the data that the NEC core requires and what the user sees on screen. The result is very often a more effective first use of the program. However, the interface can obscure the basic structure of the NEC core and its potentials.

Many users of ELNEC and EZNEC are wholly unfamiliar with the basic elements of a standard .NEC input file, since the program uses a proprietary model file system. The model description bears a close but unclear relationship to a comparable .NEC file. Users of NEC-Win Plus may also be unfamiliar with the terms and layout of an EZNEC antenna description file (called a PD file for the abbreviated keystrokes used to generate it). Some users of Plus may never even look at the available spreadsheet screen that gives the file listing in ASCII .NEC- format terms. As an exercise in correlating user formats and .NEC files, let's compare the data of an EZNEC model description file and the corresponding lines of a standard .NEC file. The exercise will acquaint us with the basic terms of the NEC deck.

In most advanced implementations, NEC uses a card-deck input file whose format goes back to the early days of FORTRAN, when punch cards provided computational inputs. Nowadays, we simply type in a single line of input-file text as a replacement for the old punch cards--and many current FORTRAN users simply do not make a connection between the line format and the old punch card requirements. For brevity, each card contain a labeled sequence of information, the individual parts separated by a delimiter. Since we Americans use "." as our decimal indicator, we use commas or spaces to separate information. European formats may vary.

To get us started, let's compare the antenna description file for a simple 2-element Yagi with the corresponding card deck. Then we can explain each type of card we encounter. If you wish, you can try your hand at correlating each element in the NEC deck to elements in the EZNEC antenna description file before reading beyond them.

                      EZNEC Antenna Description File
2el Yagi 12M
Frequency = 24.95  MHz.
Wire Loss: Aluminum -- Resistivity = 4E-08 ohm-m, Rel. Perm. = 1

              --------------- WIRES ---------------
Wire Conn.-- End 1 (x,y,z : ft)  Conn.-- End 2 (x,y,z : ft)   Dia(in)  Segs
1         -9.100,  0.000, 40.000       9.100,  0.000, 40.000  1.00E+00   11
2         -8.800, -4.800, 40.000       8.800, -4.800, 40.000  1.00E+00   11
3         -0.200,  0.000,  1.000       0.200,  0.000,  1.000     # 14     1

              -------------- SOURCES --------------
Source    Wire      Wire #/Pct From End 1    Ampl.(V, A)  Phase(Deg.)  Type
          Seg.     Actual      (Specified)
1           1     3 / 50.00   (  3 / 50.00)      1.000       0.000       V

              --------------- LOADS ---------------
Load      Wire      Wire #/Pct From End 1      R (Ohms)       X(Ohms)
          Seg.     Actual      (Specified)
1           6     2 / 50.00   (  2 / 50.00)       1.000       100.000

                -------- TRANSMISSION LINES ---------
Line  Wire #/% From End 1   Wire #/% From End 1    Length     Z0   Vel Rev/
      Actual  (Specified)   Actual  (Specified)              Ohms Fact Norm
1      1/50.0  (  1/50.0)    3/50.0  (  3/50.0)  Actual dist  50.0  0.66  N

Ground type is Real, high-accuracy analysis
Conductivity = .005 S/m    Diel. Const. = 13

              --------------- MEDIA ---------------
Medium       Conductivity(S/m)   Dielectric Const.    Ht(ft)   R Coord(ft)

1                5.000E-03            13.00           0 (def)     0 (def)

 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

                         .NEC Input File

CM 2el Yagi 12M
CE
GW 1 11 -9.1 0 40 9.1 0 40 .04165
GW 2 11 -8.8 -4.8 40 8.8 -4.8 40 .04165
GW 3 1 -.2 0 1 .2 0 1 2.6706E-03
GS 0 0 .3048
GE 1
GN 2 0 0 0 13 .005 0 0 0 0
EX 0 3 1 0 1 0
LD 4 2 6 6 1 100 0
LD 5 1 1 11 2.4938E7
LD 5 2 1 11 2.4938E7
LD 5 3 1 1 2.4938E7
TL 1 6 3 1 50 18.01 0 0 0 0
FR 0 1 0 0 24.95 0
RP 0 1 361 1000 76 0 1 1
EN

The antenna described by these two files is shown in Fig. 1. It is a simple 2-element Yagi of relatively modest performance.

The main screen of EZNEC 3.0 shows us the basic modeling data in the form illustrated in Fig. 2. Most of the detail resides in sub-screens that the user accesses by mouse-clicking on the entry line in the main screen. The results appear in Fig. 3, which I have shown as an elevation plot, even though the model specifies an azimuth plot.

NEC-Win Plus uses a different type of main screen, with considerable, but far from total, data entry up front. Frequency, wires, element diameter, and material all may be done from the lead page, although the specifics of the pattern request, ground, source, load, and transmission line require sub-screens. Fig. 4 illustrates the situation. A full readout of the .NEC file, like the one shown below the EZNEC model description file, is available from the "NEC Code" tab of the spreadsheet.

Whatever the program, the performance results are the same: Gain: 11.1 dBi; 180-degree front-to-back ratio: 11.1 dB; feedpoint impedance: 42 + j5 ohms. The general azimuth pattern at the take-off angle of 14 degrees appears in Fig. 5. NEC-Win Plus has a data ("Analysis") screen attached to its polar plot, but it has been omitted here.

I have purposely modified a simple antenna to include an inductive load in the reflector, thus making it physically shorter than the driven element. I have also run a 50-ohm transmission line straight down to within 1' of the ground and created a source wire there. If we had only the simple 2-element Yagi with which to work, our NEC deck would be pretty skimpy.

Let's look at each card in the deck and read out the information, cross checking it against the EZNEC file. In most cases, I have spread the data units out and labeled them beneath.

1.  CM 2el Yagi 12M

This is a comment card for storing information about the file in ASCII text. It does not enter into the calculations. You may have any number of comment cards, although some implementations limit them. In EZNEC, you may have only one CM card, called the "title." (However, EZNEC 3.0 permits the user to generate a text file to accompany the model with any number of ASCII text comments added. This replaces the CM cards of a standard NEC file.)

2.  CE

This card is the "comment end" card, signaling that data for calculation follows.

3.  GW    1    11   -9.1     0    40     9.1    0    40    .04165
    GW    2    11   -8.8   -4.8   40     8.8  -4.8   40    .04165
    GW    3     1    -.2     0     1      .2    0     1    2.6706E-03
   Type  Tag  Segs  E1 X   E1 Y  E1 Z   E2 X  E2 Y  E2 Z    Radius

Type GW cards describe the antenna geometry. Each antenna wire, or "Tag," has a separate numbered card or line (1, 2, and 3). The Segs (segmentation) entry tells how many segments the wire is divided into (11 each for Tags 1 and 2, 1 segment for Tag 3). Then come the Cartesian coordinates for End 1 and End 2 of each straight wire. Here, as in the EZNEC file, they are given in feet. Finally, the wire size is given as a radius (1/2 the diameter given in the EZNEC file. However, the EZNEC file lists the diameter in inches. The NEC deck must use the same units throughout the GW cards, so a 1" diameter become a 0.04165' radius. See also the NEC-Win Plus entry for diameter--also in feet and hence 0.0833. The wire size figure for Tag 3 is the radius of #14 wire, in feet.)

4.  GS    0    0    .3048
   Type            Multiplier

Although most implementations of NEC, such as NEC-Win and EZNEC, give the user a choice of common units of measure for setting up the antenna geometry, NEC itself calculates only in meters. In the last of its 4 columns, the "geometry scaling" card gives the multiplier needed to convert to meters.

5.  GE    1
   Type  End

The "geometry end" type card signals the end of the wire set-up and prepares the way for other data that enter into the calculations.

6.  GN    2      0    0    0    13    .005    0    0    0    0
   Type  G-type               Die-C.  Cond.

The ground parameter card specifies the type of ground calculation system and the necessary parameters to make the calculation. Here, we show a single medium, although a second medium can be set.

There are 4 types of ground systems used with NEC: -1 = free space; 0 = a finite ground with a reflection coefficient approximation (the "fast" ground in EZNEC); 1 = a perfectly conducting ground; and 2 (used here) specifies a finite ground using the Sommerfeld-Norton method of calculation for greatest accuracy. (In addition, EZNEC implements the MININEC ground calculation system for users who may find it convenient for some vertical antenna models.)

Finite ground conditions (cases 0 - 2) require two numbers to implement calculations. The first is a relative dielectric constant, usually given as an integer. Second is the conductivity in Siemens/meter (mhos/meter in older terminology). Both are generally derived from tables. The values shown represent a default presumption of medium earth conditions. Both numbers are omitted for perfect ground.

As with many cards in the NEC deck, there are unlabled "0" fields. Some of these represent fields simply left blank; others represent input positions for more specialized conditions not relevant to most common ham HF antennas. (Some may be relevant to VHF and UHF antennas.)

7.   EX     0     3     1     0                1     0
    Type  S-type Tag   Seg        Voltage:   Real  Imaginary

The "excitation" or source information card allows for many types of excitation, of which only voltage sourcing is usual in HF ham use. Hence, the source-type is "0". The next two columns specify the placement of the source in terms of tag number and segment number in that wire. Here, the remote wire has only one segment, and the source is placed at its center. Many programs allow specification of the source at some distance from End-1 of the designated wire, and will then place the source as close to that point as segmentation permits.

For most ham uses, sources are either voltage or current. The latter is useful for scanning current levels along a wire, since a voltage source of "1" yields small fractions of an amp current, making scanning more difficult. Current sources may also be necessary for some advanced applications.

Nonetheless, both types of sources are voltage sources ultimately. The current source is generated by a voltage source set on a remote wire and transformed into a current source by a transmission line. The NEC deck for a NEC-Win Plus model will show the wire and line, while EZNEC stores this information internally.

Voltages are given in terms of X and Y ("real" and "imaginary") coordinates derived from inputs that can be given as a voltage and its phase angle. User current magnitude and phase angle inputs are converted to appropriate voltage values at the remote source wire.

In general, when converting among programs (for example, between EZNEC Pro and NEC-Win Pro), it is best to use a voltage source to avoid the possibility that one program cannot read the other's remote wire current source technique. Changing back to a current source can be done after file conversion is complete.

8.    LD      4      2      6           6      1      100      0
     Type  L-type   Tag   Start Seg   End Seg  R     L or X    C

There are two types of loads to consider: concentrated element loading quantities and distributed element material loads. This card illustrates an inductive load added to the center of the reflector. Load types 0 through 3 represent categories of R-L-C combinations that can make up a load. This card shows a type 4 load, which is specified in terms of a series resistance and reactance in ohms.

The "tag" and "segment" items locate the load at the midpoint of wire 2. Since there are start and end segment numbers, some loads may be distributed for more than a single section, but most ham antennas employ concentrated loading located within a single segment.

The final two values (1 and 100) specify the resistance and reactance of the load in ohms. Capacitive reactance, of course, would be entered as a negative number.

9.    LD       5      1      1         11        2.4938E7
      LD       5      2      1         11        2.4938E7
      LD       5      3      1          1        2.4938E7
     Type   L-type   Tag  Start Seg End Seg    Conductivity

Material losses are type-5 loads. As with other loads, the wire (tag) must be identified, along with the first and last segments to which the load applies. Note that these loads apply in addition to any lumped-constant loading of types 0 through 4.

To avoid confusion by newer modelers, EZNEC only refers to lumped constants as loads, preferring instead to call material loads "wire losses." EZNEC also expresses these losses as a function of resistivity and relative permittivity. However, the value of resistivity in this case, 4.0E-08 ohms, is simply the reciprocal of the NEC deck conductivity value of 2.4938E7 mhos or Siemens. Additionally, EZNEC restricts antennas to one type of material per model, although the NEC deck permits a specification of a different conductivity value for each wire. Note the NEC-Win Plus entry space for a conductivity value for each wire in the antenna model.

10.    TL        1    6       3    1    50    18.01    0    0    0    0
      Type Start tag/seg  End tag/seg   Zo    Length

Transmission lines are not physical models in NEC, but mathematical constructs. Hence, they can have any length, regardless of the actual distance between their start and end points on wires. Special techniques are used for shorted and open stubs, but the example here runs a common coax line from the antenna proper to a short segment used a. to terminate the transmission line and b. to serve as the overall source point for the antenna system.

By now, the start and end wire and segment numbers are obvious. As in the EZNEC PD file, the next two columns specify the characteristic impedance of the line and its length. In EZNEC, this can be done in several ways, all of which translate into a final characteristic impedance and definite length in meters. In the PD file, the length was given as the actual distance between wires, 39', modified by the velocity factor of the line, .66. This results in an electrical length of 59.1' or 18.01 meters. In NEC-Win Plus and Pro, one must enter the total electrical length and hence Pre-calculate the value from the physical length and the velocity factor of the line used.

11.    FR     0         1         0     0     24.95     0
      Type  Stepping   No. of FQs            Start FQ  Increment

Antennas are modeled at one or more frequencies. If a single frequency is used, as in this example, the information needed is limited. "Frequency sweeping" requires more information.

Stepping can be non-linear (stepping = 1), but normal ham frequency sweeps are linear, changing frequency by the same amount each time. For sweeps, the user specifies the number of frequency steps, the start frequency, and the increment by which to step. For this single frequency model, the number of frequency steps is 1, and the increment is 0, while the modeled frequency is 24.95 MHz.

12.  RP     0     1           361     1000     76     0     1       1
   Type   Mode  No. Theta   No. Phi  Special  Theta  Phi  Th Inc  Ph Inc

The report card specifies what output data is desired from the calculations. Mode "0" is the normal mode for far field data.

Horizontal angular changes are measured as "phi" degrees. Elevation angular changes are measured as "theta" degrees. Although most hams are used to counting elevation from the ground up, NEC counts theta angles from the zenith down.

This example specifies a report for one theta (elevation) angle, but a full circle of azimuth (phi) angles. Skipping the "Special" column for a moment, the theta angle is 76 (or 90 - 76 for a 14 elevation angle). The figure is a start figure, although only one theta angle has been specified. The azimuth or phi start angle is 0, but will pass through 361 (to ensure a complete circle with a common value at each end of the progression). Both theta and phi are specified for increments of 1 for good resolution.

The "Special" column contains 4 values that direct the calculations to produce certain types of outputs. 1000 is normally used for vertical, horizontal, and total non-normalized power gains with no averaging. Other outputs are available, and the user is usually interrogated in plain language for the desired output data and form by each program.

Users of NEC will sometimes be surprised to find that a symmetrical antenna, such as a Yagi, produces a main lobe identified by as much as 2 to 3 less than the expected bearing. Implementations of NEC may identify either the first instance of the maximum power gain as the main lobe or may sample the subsequent headings and center the identified main lobe heading among equal maximum readings. If a program uses the first of these options, then increasing the phi increment will often return the main lobe to its expected position.

13.    EN

EN signals the end of the .NEC file.

Hopefully, this brief trip through a short NEC deck will orient you to how the input files are constructed for use with NEC. Remember that the card explanations have not covered all the ways in which one may place data on a card of a given type. Only the most common kinds of data inputs for typical ham antenna installations have been illustrated.

The low-end implementations of NEC-2 omit many of the features and functions available with core in order to create the user-friendly interface that covers the features most needed by the average user. However, high-end programs designed with less "friendliness" and more calculating potential (such as NEC-Win Pro and--for NEC-4--GNEC) tend to make the entire deck available to the user. As a reference, here is a list of NEC-2 cards, some of which we have reviewed and some of which will seem odd. In addition, cards like the RP request have far more options than we have covered, including not only far field patterns, but ground wave patterns as well. EX allows not only for definite voltage sources, but as well for plane-wave excitation for receiving analysis.

Structure Geometry Input Cards

CM, CE        Comment Cards                        GA            Wire Arc Specification
GE            End Geometry Input                   GF            Read Num. Greens Function
GH            Helix-Spiral Specification           GM            Coordinate Transformation
GR            Generate Cylindrical Structure       GS            Scale Structure Dimensions
GW            Wire Specification                   GX            Reflection in Coordinate Planes
SP            Surface Patch

Program Control Cards

CP            Maximum Coupling Calculation         EK            Extended Thin-Wire Kernal
EN            End of Run                           EX            Excitation
FR            Frequency                            GN, GD        Ground Parameters
KH            Interaction Approximation Range      LD            Loading
NE, NH        Near Fields                          NT            Networks
NX            Next Structure                       PQ            Print Control for Charge on Wires
PT            Print Control for Current on Wires   RP            Radiation Pattern
TL            Transmission Lines                   WG            Write Num. Greens Function File
XQ            Execute

Some programs, like EZNEC, do not generate a NEC deck, but instead communicate with the NEC-2 calculating engine via a number of binary files. (A NEC deck is available in EZNEC Pro with the NEC-4 calculating engine.) Some programs, like NEC-Win Plus, use alternative formatting methods--a spreadsheet file in this case, but also make available the option of saving the mode as a .NEC file. Others, like NEC-Win Pro or GNEC, make the deck an integral part of the modeling process. Getting used to the NEC deck can increase your ability to glean more from whatever program you choose as your basic modeling vehicle. Familiarity may also aid you in interpreting articles that present antenna modeling data in .NEC input file format. Patches, Green's functions, networks, and wire grids are beyond the scope of this introduction, but may be found in NOSC Technical Document 116, Volume 2, Numerical Electromagnetics Code (NEC)--Method of Moments, Part III: User's Guide (1981), which is the source of most of this data.


Go to Main Index