SM 5 BSZ - Computer Program For Antenna Optimisation Using Modified NEC2
(Jan 20 2005)

OMNEC

Optimising Modified NEC program is not particularly user friendly. It is free to use for anyone interested I have devised it for my own use. Error messages are sometimes misleading. The OMNEC program does its job properly and I find it sufficiently easy to use myself to not spend time making it more userfriendly.

OMNEC is now available under Linux. Under Linux there is no other restriction to program size than given by your hardware. Under MSDOS the DOS4GW limits the maximum number of segments. The Linux version is the only one supported for the future, the MSDOS version will NOT be updated and/or corrected any more. The last MSDOS version is 1.30

To install omnec under Linux, download the packed source file here, place it somewhere (typically /usr/src or /home/passwd).

The commands are then:
bunzip2 omnecxxx.tbz for the bzip version
or gunzip omnecxxx.tgz for the gzip version.
As a result you will get the tar (tape archive) file.

then type:
tar xvf omnecxxx.tar to create a subdirectory omnec with all the source files. Descend into the new directory and press:
make

The make command will produce omnec. Make a link to it in /usr/bin. It is practical to have a separate sub-directory for each antenna project and therefore it is convenient to have omnec under /usr/bin so the command omnec becomes available everywhere. You must have write permission to /usr/bin for this last step. You could also include the place of omnec into your path.

There is an example included among the source files, the 2SA13 antenna in a 4-stack. Just press omnec to verify that the program runs properly.

omnec200.tbz packed with bzip2 (33623 bytes)
omnec200.tgz packed with gzip (39341 bytes)

The .EXE file can be fetched here: OMNEC.EXE(vers 1.30 124k) It is in zipped format, to convert from .ZIP to .EXE use PKUNZIP.

To run OMNEC you need 32 megabytes of RAM and DOS4GW.EXE (zip file) (Type: DOS4GW OMNEC.EXE)

If your computer is not powerful enough, try the old versions

In case you like to add your own options or recompile with other matrix sizes, here is the complete OMNEC source code (vers 1.30 124k)

OMNEC uses two input data files: INPUT.NEC and PARNR.NEC

Example using all parameters

OMNEC minimises the normalised far field from the antenna to obtain maximum gain as described here: Theory with examples OMNEC also allows more equations to be added on top of those leading to maximum main so the optimised antenna gets other desireable properties.

Try EXAMPLE1.ZIP which contains input files that will optimise a 4 stack of 6 element yagis. The parameters are:
Weight for Z(voltage) = 0.07 (Weight to get the desired impedance)
Z = 50 (desired impedance = 50 ohms)
Weight for efficiency = 0.025 (reduce ohmic losses)
Weight for back lobe = 0.5 (reduce radiation at 180 degrees)
Weight for G/T enhancement = 0.03 (improve G/T)
The optimisation is done for 144.0 and 144.5 MHz simultaneously.

EXAMPLE1 runs quickly because few segments are used on the elements and few points in the radiation pattern. Of course the accuracy is influenced but the result is accurate enough to allow a judgement.

EXAMPLE1 output:
Gain 19.4dBi at 144.0 and 19.5dBi at 144.5
G/T -5.5dB at both frequencies
Impedance (44,i -4)at 144.0 (41,i 7) at 144.5
Back lobe -26dB at 144.0 and -17dB at 144.5
Boom length 3.607 m.
Stacking distances 3.37 x 4.05 meters.

The first observation is that the impedance is not very close to 50 ohms. This means that moving elements for a better impedance match will cause a less good optimum, the structure is not flexible enough to allow correct impedanc simultaneously with optimum for the other desired properties.

The natural next step is EXAMPLE2.ZIP Here a seventh element is placed between the radiator and the first director. It is always a good idea to try to add extra elements between the old ones in the design of long yagi antennas. If the added element is not improving it will remove itself by moving into one of its neighbours.

EXAMPLE2 runs a little slower than EXAMPLE1 (more iterations are needed because the the optimum is more shallow.) The number of segments and integration points is still low because it is always a good idea to get an approximate result to look at first.

EXAMPLE2 output:
Gain 19.9dBi at 144.0 and 144.5
G/T -4.7 at 144.0 and -4.8 at 144.5
Impedance (48,i 3)at 144.0 (50,i -3) at 144.5
Back lobe -14dB at 144.0 and -13dB at 144.5
Boom length 3.735 m.
Stacking distances 3.51 x 4.11 meters.

This is a good antenna. It is an optimum for the selected parameters but no constraint is given to the antenna size. For practical purposes we are not really interested in the best geometry for a given number of elements - more important is to get the optimum antenna for a given antenna size. Rather than including some equations in the optimisation procedure that would favour smaller size one can keep some dimensions fixed. As an illustration EXAMPLE3.ZIP is the output of EXAMPLE2 where the last director is moved to a fixed position at 3.700m while the stacking geometry is fixed at 3.4 x 4.0 meters. The number of segments is increased for better accuracy and so is the number of points for the pattern. Note that the gain calculated from the absolute value of the far field and the gain calculated by integration of the pattern now give the same value which was not the case for the previous examples.

With EXAMPLE3 each iteration is much slower. The start geometry is close to an optimum and both the boom length and the stacking distances are fixed so convergency is obtained with a modest number of iterations.

EXAMPLE3 output:
Gain 19.88dBi at 144.0 and 19.91dBi at 144.5
G/T -4.7 at 144.0 and -4.8 at 144.5
Impedance (48,i 3)at 144.0 (50,i -3) at 144.5
Back lobe -14dB at 144.0 and -13dB at 144.5
Boom length 3.700 m.
Stacking distances 3.40 x 4.00 meters.

Making a final design

OUTPUT.NEC is the converged output with example3 as input data. With this file renamed to INPUT.NEC it is possible to analyse the design.
These are the results for different frequencies
F=143.00 G=19.711(19.711)dB E=99.256% G/T=-4.775dB Z=(40.528   4.359)
F=143.20 G=19.755(19.756)dB E=99.231% G/T=-4.740dB Z=(41.813   5.132)
F=143.40 G=19.795(19.795)dB E=99.204% G/T=-4.717dB Z=(43.274   5.571)
F=143.60 G=19.829(19.830)dB E=99.172% G/T=-4.710dB Z=(44.862   5.555)
F=143.80 G=19.859(19.859)dB E=99.135% G/T=-4.717dB Z=(46.479   4.948)
F=144.00 G=19.882(19.882)dB E=99.091% G/T=-4.738dB Z=(47.943   3.613)
F=144.20 G=19.899(19.900)dB E=99.037% G/T=-4.775dB Z=(48.969   1.463)
F=144.40 G=19.911(19.911)dB E=98.970% G/T=-4.825dB Z=(49.168  -1.469)
F=144.60 G=19.916(19.917)dB E=98.887% G/T=-4.887dB Z=(48.111  -4.934)
F=144.80 G=19.917(19.917)dB E=98.781% G/T=-4.960dB Z=(45.480  -8.416)
F=145.00 G=19.913(19.913)dB E=98.647% G/T=-5.040dB Z=(41.258 -11.217)
By changing the input parameters of EXAMPLE3 and rerunning the optimisation process it is possible to investigate the effect of the different parameters in order to select the design that will fit in a particular location.

Below is a description of the input sequence in OMNEC. Each input section reads data from INPUT.NEC, PARNR.NEC or from both files. Below all lines of EXAMPLE3 are described. Bold numbers are those values that should be changed one by one in the search for the antenna that will fit best in a particular environment.

***********************************************************
***********************************************************
INPUT.NEC:
CE
This is just a comment line. Like in NEC2 this line may be preceded by any
number of additional comment lines having CM as the first two characters.
***********************************************************
PARNR.NEC:
MO  1
This line tells OMNEC to use the modified wire radius when calculating matrix
elements for the interaction between wire segments and to use a more modern
value for the speed of light.
Alternative:
MO  0
Optimise with NEC2 in original form.

If you really intend to build the antenna set the "MO" flag = 1
because the modified version of NEC is more accurate.
(at least for a yagi antenna)
***********************************************************
PARNR.NEC:
GS  0    0      .001      .000      .000      .000      .000      .000     .000
This line has to be identical to the corresponding line in INPUT. It tells
that the dimensions have to be scaled by a factor 0.001 To convert from
millimetres to meters
Alternative:
GS  0    0 .02540000      .000      .000      .000      .000      .000     .000
To convert from inches to meters, so the antenna coordinates can be given in
inches.
***********************************************************
PARNR.NEC:
FR  0    2    0   0 0.14400E+03    0.5000    0.0000    0.0000    0.0000   0.0000
This line has to be identical to the corresponding line in INPUT. It tells,
exactly as in NEC2 what frequency to perform the calculation for.
Alternative:
FR  0    1    0   0  144.000       0.0000     .0000     .0000     .0000    .0000
Optimise a single frequency (144.000).

If more than one frequency is used the sum of the sum of squares
from all frequencies is minimised. In this way the bandwidth will be
improved.
***********************************************************
INPUT.NEC:
GW  1   19     0.000  -497.006     0.000     0.000   497.006     0.000    5.000
PARNR.NEC:
GW  1    9       0       -1         0         0         1         0
These two lines specify the first wire.
cols  3-5   ITAG, specifies the wire by associating this number to
            all segments that constitute this wire.
cols  6-10  NS, number of segments for this wire. The value in INPUT.NEC
            is used, while the value in PARNR.NEC is not used at all.
cols 11-20  X1,INPUT=.000 the X coordinate of end 1 of this wire is 0
            X1,PARNR=0 keep the X koordinate fixed.
cols 21-30  Y1,INPUT=-495. the Y coordinate of end 1 of this wire is -495
            Y1,PARNR=-1 Optimise the Y coordinate. Increasing parameter
            number 1 will cause element end 1 to move away from the element
            midpoint.
cols 31-40  Z1,INPUT=.000 the Z coordinate of end 1 of this wire is 0
            Z1,PARNR=0 keep the Z koordinate fixed.
cols 41-50  X2,INPUT=.000 the X coordinate of end 2 of this wire is 0
            X2,PARNR=0 keep the X koordinate fixed.
cols 51-60  Y2,INPUT=495. the Y coordinate of end 2 of this wire is 495
            Y2,PARNR=1 Optimise the Y coordinate. Increasing parameter
            number 1 will cause element end 2 to move away from the element
            midpoint.
cols 61-70  Z2,INPUT=.000 the Z coordinate of end 1 of this wire is 0
            Z2,PARNR=0 keep the Z koordinate fixed.
cols 71-80  RAD, The wire radius.
The two ends of an element are changed in opposite directions in order to
keep the element centred on the boom.
***********************************************************
INPUT.NEC:
GW  2   19     0.000  -489.006   503.323     0.000   489.006   503.323    5.000
PARNR.NEC:
GW  2    9       0       -2         3         0         2         3
Use parameter 2 to vary the length of wire 2, and use parameter 3 to vary
the Z coordinate for wire 2. Since radiation is maximised in the Z direction
this means that both length and position are optimised for this wire.
***********************************************************
INPUT.NEC:
GW  3   19     0.000  -450.346  1438.657     0.000   450.346  1438.657    5.000
GW  4   19     0.000  -443.217  2250.236     0.000   443.217  2250.236    5.000
GW  5   19     0.000  -438.389  3075.115     0.000   438.389  3075.115    5.000
GW  6   19     0.000  -455.177  3700.000     0.000   455.177  3700.000    5.000
GW  7   19     0.000  -466.278   851.988     0.000   466.278   851.988    5.000
PARNR.NEC:
GW  3    9       0       -4         5         0         4         5
GW  4    9       0       -6         7         0         6         7
GW  5    9       0       -8         9         0         8         9
GW  6    9       0      -10        11         0        10        11
GW  7    9       0      -12         0         0        12         0
Associate parameters 4 to 12 to these 5 wires.
Alternative for PARNR.NEC:
GW  7    9       0      -12        13         0        12        13
Add parameter 13 to allow the boom length to vary.
***********************************************************
INPUT.NEC:
GM  0    0     0.000     0.000     0.000  1700.000  2000.000     0.000    0.000
PARNR.NEC:
GM  0    0      .000      .000      .000     0.        0.      .000     .000
The antenna was placed with the midpoint of the reflector at the origin.
Move the whole structure 1700 millimetres in the X direction and
2000 millimetres in the Y direction.
Keep the stacking configuration fixed.
Alternative for PARNR.NEC:
GM  0    0      .000      .000      .000    13.       14.         .000     .000
or
GM  0    0      .000      .000      .000    14.       15.         .000     .000
Optimise the position for this antenna
by associating the parameters 13 and 14 to the X and Y shift respectively.
(or 14 and 15 in case 13 is already assigned to wire 7)
Causes optimisation of the stacking configuration in combination with
the GX option.
When optimising a single antenna, remove these lines and the GX line.
***********************************************************
INPUT.NEC:
GS  0    0 .00100000      .000      .000      .000      .000      .000     .000
Has to be identical to the GS line in PARNR, see above.
***********************************************************
INPUT.NEC:
GX100  110      .000      .000      .000      .000      .000      .000     .000
Reflection of structure in coordinate planes. This will create new wires
at the opposite side of the specified reflection plane(s). These new wires
will be numbered by adding the 100 (cols 3-5) to the ITAG value of the
original wires. Cols 8 to 10 specify the reflection planes. 110 means X and Y
but not Z.
First the structure, wires 1 to 6, is reflected along the X axis,
producing a new identical 6 element antenna with the centre of each element
at X=-1700 and Y=2000. The wires (elements) of this new antenna are numbered
201 to 206. Since the elements are along the Y axis the structure now
corresponds to two yagis stacked above each other at 3.4 meters distance.
Then the whole structure, wires 1-6 and 201-206, is reflected along the
Y-axis, producing two new antennas at the other side of the XZ plane so
the total structure becomes an array of 4 yagis at 3.4 vertical and 4.0
horizontal the new wires are numbered 201-206 and 301-306.
***********************************************************
INPUT.NEC:
GE  0    0     0.000     0.000     0.000     0.000     0.000     0.000    0.000
End of structure section.
***********************************************************
INPUT.NEC:
FR  0    2    0   0 0.14400E+03    0.5000    0.0000    0.0000    0.0000   0.0000
Has to be identical to the corresponding line in PARNR.NEC, see above.
***********************************************************
INPUT.NEC:
EK  0    0    0   0 0.00000E+00    0.0000    0.0000    0.0000    0.0000   0.0000
Use the extended thin wire model of NEC2 (always do so!!)
***********************************************************
INPUT.NEC:
LD  5    1    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5    2    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5    3    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5    4    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5    5    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5    6    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5    7    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  101    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  102    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  103    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  104    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  105    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  106    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  107    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  201    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  202    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  203    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  204    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  205    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  207    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  206    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  301    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  302    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  303    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  304    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  305    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  306    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
LD  5  307    0   0 0.27010E+08    0.0000    0.0000    0.0000    0.0000   0.0000
To account for ohmic losses, which is essential in optimising yagis, all
elements have to be loaded. The LD lines above specify aluminium as the
element material. There are more options for LD - refer to the NEC2 manual.
***********************************************************
INPUT.NEC:
KH  0    0    0   0 0.15000E+03    0.5000    0.0000    0.0000    0.0000   0.0000
cols 21-31  Distance above which to use a simplified field approximation
            Here 150 wavelengths (=never).
cols 32-41  Weight for suppressing the back lobe (at 180 degrees)
***********************************************************
INPUT.NEC:
EX  0    2   10   0 0.10000E+01    0.0000    0.0000    0.0000    0.0000   0.0000
PARNR.NEC:
EX  0    2    5   00    50        0         0.07
Specify feed point.
cols  3-5   Type of excitation 0=Voltage source (applied-E-field source)
                               5=Voltage source (current-slope-discontinuity)
            The other modes available in NEC2 are illegal in OMNEC
cols  6-10  Number of wire to feed. The number has to be the same in both
            inputs and here 2 specifies the wire with ITAG=2 to be a radiator.
cols 11-15  Segment number for segment to feed. The number is taken from
            INPUT.NEC while the number in PARNR.NEC is ignored. If this
            number = (NS+1)/2 the element is fed at its centre. Here with
            NS=5 (see above, GW  2 ...) the centre point is on segment 3.
cols 21-30  INPUT.NEC: Real part of applied feed voltage.
            PARNR.NEC: Desired value for real part of feed impedance
cols 31-40  Imaginary part of feed voltage.
            PARNR.NEC: Desired value for imaginary part of feed impedance
cols 41-50  ZWEI, a weight factor giving the weight for the impedance error
            equation in the total least squares problem. Large values
            give impedances close to the desired value even if the cost is
            high in gain, while small values will give the desired impedance
            only if it can be obtained at a marginal loss of gain.
***********************************************************
INPUT.NEC:
EX  0  102   10   0 -.10000E+01    0.0000    0.0000    0.0000    0.0000   0.0000
EX  0  202   10   0 0.10000E+01    0.0000    0.0000    0.0000    0.0000   0.0000
EX  0  302   10   0 -.10000E+01    0.0000    0.0000    0.0000    0.0000   0.0000
PARNR.NEC:
EX  0  102    5   00    50        0           0
EX  0  202    5   00    50        0           0
EX  0  302    5   00    50        0           0
Note that all image antennas have to be properly fed. When an antenna is
reflected along the Y axis, the direction of the elements change sign so
in order to be properly phased, these antennas have to be fed with
a 180 degrees phase shift.
Since the feed impedance is identical for identical antennas, there is
no reason to include more equations doing the same thing. Therefore
cols 41-50 is 0.
***********************************************************
INPUT.NEC:
RP  0   50  150   0 0.90000E+02    0.0000   0.0300    0.0250    0.0000   0.0000
Calculate radiation pattern. This line allows a compromise between computing
speed and accuracy. The optimisation is done by a simultaneous minimisation
of the power radiated in all directions except forward. The directions for
which the field is calculated are controlled by the stepping parameters of
this line.
cols  3-5  NPPRT, a parameter to control radiation pattern listed in
           output file PATTERN.NEC.
           NPPRT=0  No radiation pattern in output.
           NPPRT=1  Pattern with theta=0, phi is stepped.
           NPPRT=2  Complete pattern, phi and thete stepped.
           NPPRT=3  Integrated pattern: Power radiated from 0 to
                    phi (integrated over theta) as a function of phi.
           NPPRT=4  Produce RESULT.NEC without any optimisation
cols 6-10  NTH is the number of values of theta. Theta is a rotation
           around the Z-axis, and for a single yagi very few points are
           needed. For a stacking configuration like in this example, more
           points are needed.
cols 11-15 NPH is the number of values for phi, the angle to the forward
           direction. phi=0 means forward and phi=180 degrees is backwards.
cols 21-31 Largest value for theta. For a symmetric antenna there is no
           need to turn more than 90 degrees on theta. Continuing up to
           360 degrees will just repeat the lobe pattern which does not
           help the optimisation. In this example the radiation pattern is
           calculated in 12 directions. The step size is 90/12=7.5 degrees
           and the radiated power is calculated with theta=3.75, 11.25,
           18.75,.....,86.25
cols 32-41 Start value for phi. If this value is not 0, the summation
           excludes points near the forward direction, and the gain as
           calculated by integration becomes incorrect. The optimisation
           results in a broader main lobe and better suppression of the
           lobes above the start value. Do not use large numbers here.
           Try points on the main lobe of the initial structure.
cols 42-51 GOVERT,a weight factor on an equation in the least squares fit
           for G/T. With this parameter better G/T is obtained
           at the expense of gain.
cols 52-61 EFFWEI, a weight factor on an equation in the least squares fit
           for ohmic losses. With this parameter lower losses are obtained
           at the expense of gain. Lower losses means less current so this
           parameter tends to reduce Q and thereby it improves bandwidth.
cols 62-71 T(sky), the sky temperature in the G/T calculation.
           If this value is 0 the standard value 1000K is used.
cols 72-81 T(gnd), the ground temperature in the G/T calculation.
           If this value is 0 the standard value 200K is used.
***********************************************************
INPUT.NEC:
EN
The last line - an end mark.
***********************************************************
***********************************************************

To SM 5 BSZ Main Page