Automatic Design of Planar Antennas Using Genetic Algorithms and The NEC Simulation Package
Automatic Design of Planar Antennas Using Genetic Algorithms and The NEC Simulation Package
Automatic Design of Planar Antennas Using Genetic Algorithms and The NEC Simulation Package
Shu Wang
Bachelor of Engineering
(Telecommunication Engineering)
May, 2010
Antennas are being used in communication systems such as radio and television
exploration and so on, whose purpose is to convert between circuit power, voltage and
current at the radio terminals, and radiated power carried in an electromagnetic wave.
and evolution principles. In recent years, the idea of using a genetic algorithm combing
with an electromagnetic simulator has been introduced into antenna design, and is
becoming increasingly popular. The genetic algorithm has been successfully used for
Numerical electromagnetic codes (NEC) are the method of moments (MoM) simulator
developed at Lawrence Livermore National Laboratory in the early 1980s [10]. NEC is
used to analyze random structure of antenna by dividing antennas into some straight
wires. Generated antennas by NEC, the characteristics of various antennas are easy to
be seen. In addition, it is common that output files of NEC are applied by others
The aim of this thesis is to design a number of high-gain 2.4 GHz microwave planar
antennas, which can be manufactured and tested with 802.11 radio hardware. the
codes (NEC).
I
Statement of Originality
I, Shu Wang, declare that this thesis, submitted as part of the requirements for the award
unless otherwise referenced or acknowledged. The document has not been submitted for
Signature:
Print Name:
Student ID Number:
Date:
II
Contents
Abstract I
State of Originality II
List of Figures VI
1 INTRODUCTION .................................................................................................................... 1
1.1 Overview................................................................................................................. 1
1.2 Objective................................................................................................................. 1
2 LITERATURE REVIEW........................................................................................................ 5
2.1 Overview................................................................................................................. 5
III
2.32 Basic Models................................................................................................... 12
4.2.5.2 Mutation.................................................................................................. 39
IV
5 ANALYSING SIMULATION RESULTS ........................................................................... 41
6 CONCLUSION....................................................................................................................... 46
V
List of Figure
Figure 2.4 (b) Directional antenna’s radiation pattern on the horizontal and vertical plane.......................12
Figure 2.4 (a) Omni-directional antenna’s radiation pattern on the horizontal and vertical plane .............12
Figure 4.2.3 basic implementation from current generation to the next generation [26]............................36
VI
Figure 4.2.5.2 two-point crossover..............................................................................................................38
VII
List of abbreviations and Symbols
EM Electromagnetic
RF Radio Frequency
GA Genetic Algorithms
VIII
Chapter 1
Introduction
1.1 Overview
1.2 Objective
The aim of this thesis is to design a number of high-gain 2.4 GHz microwave planar
antennas, which can be manufactured and tested with 802.11-radio hardware. To
1
achieve respectable results, the structural parameters of designed antenna are optimized
in an automated design, by applying of the genetic algorithm (GA) in conjunction with
numerical electromagnetic codes (NEC). The project starts with the background reading
about antenna design, familiar with the basic information about antenna; antenna design
software, GA and Perl programming language. The next step is to create an initial
prototype antenna, and than utilize NEC expresses and generates it. And besides, GA is
applied to optimize the results. After improving the antenna, we could obtain the best
radiation pattern result, which is the closest to the reference pattern. At last, simulate
aimed antennas and comparing and analysing the data results.
Even though the antenna is one of the most complicated parts of RF design, it is also
considered as the most ignored part in an RF design [1]. Antennas give effect to the
range and performance of an RF connection directly and critically. Important factors for
antenna design are its gain, shape, placement and orientation. In general, the length of
an antenna is directly related to the wavelength, while the antenna’s efficiency is
directly relative to its volume. During the design process, the common problem is that
the antenna usually occupies insufficient free space around it.
2
broadly, as it is easy to write, read and calculate an antenna effectively. NEC software is
used to analyze the electromagnetic response of the random structure of antenna,
including wires and surfaces, in free space or over a ground plane. The analysis method
is based on the numerical solution of integral equations for induced currents. This
approach not only avoids many problems caused by other solution methods such as
simplifying assumptions, but also provides a highly accurate and flexible tool for
electromagnetic analysis.
3
random bits. Chapter 4 provides the workflow of Genetic Algorithms optimizing
antenna. Chapter 5 aims to analyse simulation results, at last Chapter 6 is as conclusion
summarizing the entire thesis.
4
Chapter 2
Literature Review
2.1 Overview
This chapter provides a review of every major element, related to the task of antenna
design for this project. It also contains the brief and concise analysis of the major
factors, according to background reading and preparatory research. In addition, this
section also introduces some useful implementation tools, such as software and
programming languages, which can be used in this project.
5
electrical field (E) supplies the reference for the polarization’s direction. The following
figure depicts the case of a forward propagating wave (figure 2.1) [3].
Hand rules are used to indicate the sense of circular polarization. The sense is defined
by which hand would be used in order to point that thumb in the direction of
propagation and point the fingers of the same hand in the direction of rotation of the
Electric-E field vector.
Left Hand Circular Polarization (LHCP) is used, when thumb is pointed in the
direction of propagation and the rotation is counterclockwise looking in the
direction of travel.
Right Hand Circular Polarization (RHCP) is used, when the rotation is
clockwise.
Maxwell's equations are a set of four partial differential equations, which defines the
properties of the electric and magnetic fields, and also involve them with their sources,
charge density and current density [16].
6
The first equation is Faraday’s law of induction; the second is Ampère’s law corrected
and advanced by Maxwell, which is including the displacement current ∂D/∂t; the third
and fourth equations stands for Gauss’ laws used for the electric and magnetic fields.
The electric and magnetic field intensities are represent by quantity E and H
respectively. E is measured in units of volt/m, whereas, H is measured in units of
ampere/m. The displacement current ∂D/∂t in Ampère’s law is important in predicting
the existence of propagating electromagnetic waves. The quantity D is the electric flux
density, in units of coulomb/m2. B represents magnetic flux density, also called the
magnetic induction, which is in units of coulomb/m2. The volume charge density of any
external charges is presented by the quantity ρ, besides J is electric current density. ρ
and J are qualified in units of coulomb/m3 and ampere/m2, respectively. The zero in the
fourth equation means there are no magnetic monopole charges.
2.3 Antenna
In any telecommunication system, all radios require some kind of antenna, regardless of
transmitting or receiving [19]. The purpose of antenna is to convert between circuit
power, voltage and current at the radio terminals, and radiated power carried in an
electromagnetic wave. The antenna collects power from the transmitter and sends off it
7
into space as an electromagnetic or radio wave. At the receiving terminal, a similar
antenna gathers energy from the passing electromagnetic wave and transforms it into a
variable electric current or signal, so that the receiver can detect. A radio link consists of
seven components, which are transmitter, power supply, transmission lines, transmitting
antenna, propagation path, receiving antenna, and receiver (figure 2.2) [4]. Whether a
communication system is reliable and quality, it is directly effected by how well
antennas launch and collect electromagnetic waves; therefore antenna designing plays a
critical role in the information explosion age.
8
• Bandwidth: The bandwidth of an antenna measures the range of frequencies
over which the antenna is in effect, which is usually centered on the resonant
frequency. The bandwidth of an antenna may be improved by a number of
techniques and methods, such as using thicker wires, taking the place of wires
with cages to simulate a thicker wire, making antenna components taper, and
combining various antennas into a single assembly, applying the natural
impedance to choose the proper antenna and so on.
9
• Polarization: The polarization of an antenna, determined by the physical
structure of the antenna and its orientation, is the direction of the electric field
(E-plane) of the radio wave relating to the Earth's surface. They are two main
categories linear and circular, linear includes Vertical, Horizontal and Oblique,
while circular, which comprises, Circular Right Hand (RHCP); Circular Left
Hand (LHCP), Elliptical Right Hand and Elliptical Left Hand. Polarization is
one of the most critical parameters affecting the performance from the antennas
greatly.
10
used to measure the wave’s ratio of maximum power to minimum power, which
is also named as VSWR.
VSWR
11
Figure 2.4 (a) Omni-directional antenna’s radiation pattern on the
horizontal and vertical plane
There are several different types of antennas. Below are some antenna models, which
are the most relevant to antenna designing.
12
transmit and receive signals from the broadside of the antenna. The dipole
antenna is simple and inexpensive, which is two wires arranged in opposite
directions either horizontally or vertically. One end of wires is connected to the
radio, and the other end points into free space. All dipole antennas have a
general radiation pattern. The antennas work evenly well in a complete 360
degrees around the antenna, namely the dipole antenna that is not a directive
antenna splits its power equally through 360 degrees around the antenna.
Physically, dipole antennas are usually fed through an input at the bottom of the
antenna, and it also can be fed into the center of the antenna
• Random wire antenna: The random wire antenna is a very long wire, which is
more than one quarter of its wavelength. One end of the antenna is connected to
the radio, and the other is in free space. It is arranged arbitrarily for the most
space available. Normally, if a random wire antenna is used in a properly turned
network, it could be used to transmit electromagnetic waves on various
nonlinearly frequency [9].
13
recent years, the idea of using a genetic algorithm combing with an electromagnetic
simulator has been introduced into antenna design, and it is becoming more and more
popular. The genetic algorithm has been widely applied to design wire antennas and
microstrip antennas. Using genetic algorithms takes many advantages for antenna
design, such as it could immediately provide the accurate, and reliable solutions for
antenna structures, in addition, it could filter obvious worse designs, even to
experienced specialists [17]. The main considerations of Genetic Algorithm as follows:
14
• Reproduction: After selection and generation the first breed population, the
next step is to generate a second-generation population of solutions from those
selected by crossover and mutation. For each new solution to be produced, a pair
of parent solutions is selected for breeding, which are chosen from the pool
(where fitter solutions are gathered). In order to produce an offspring solution,
the methods of crossover and mutation are applied, and a new solution is
created, which normally succeeds a number of the characteristics from its
"parents". New parents are selected for breeding child of next generation; at last
process operator is terminated, when a termination condition has been reached.
In general, the average fitness will rise by this produce for the population, since
only the best genes and a few less-fit solutions from the previous generation are
inherited by the new generation [10].
15
Figure 2.5, the structure of Genetic Algorithm[ 26]
The figure above, it indicates the whole working process of Genetic Algorithm. At first,
a random generation of initial population is produced. Following is the step to select
and decode chromosome. Then the antenna is constructed. Analyzing parameters of
antenna and calculating of the cost function values for every chromosome are executed.
Based on the fitness function of Genetic Algorithm, chromosomes are ranked and
selected. Crossover is the process of exchanging pieces of the chromosomes within
every pair of the parents, which are arbitrarily selected, and establishment of new
16
chromosomes like progeny. In this case, the chromosomes with the better fitness will
have more chances of randomization. Mutation leads to selected bit(s) of the
corresponding chromosomes is reversed at random, while very occasionally a gene may
be mutated. In this way, the construction of next population with better fitness is
executed. After verification of the optimization conditions, the process is completed or
repeated, for the sake of producing the new population. The entire optimization
completes after several rounds of duplication process, or when optimization condition is
satisfied.
17
4. Designate which analysis to achieve.
5. Execute nec2c and interpret the terribly unreadable and confusion results.
LD 5 tag_number 0 0 cond 1
tag _number is the tag of the wire of interest. The cond is the conductivity in
Siemens. The 0 0 before the conductivity is just applied for other unrelated
functions of the LD directive.
18
• Voltage sources is designated by the EX command. The source_segment is the
segment number of the wire that is to be driven. source_tag is the tag number of the
wire, which was chosen in the antenna geometry.
At present, there are a great many of tools and software successfully applied for antenna
design. In this part of the report, some of the most popular and valuable tools will be
introduced, such as 4NEC2, QAntenna, EZNEC, Antenna maker and Perl language.
4NEC2: 4nec2 is a completely free Nec2, Nec4 and windows based tool for creating,
viewing, optimizing and checking 2D and 3D style antenna geometry structures and
generate, display and/or compare near/far-field radiation patterns for both the starting
and experienced antenna modeler [11]. 4NEC2 is with a number of useful features, such
as Graphical 2D and 3D visualization of Far- and Near-field data and Geometry
structures, Line-chart visualization for freq-sweep Gain, F/B, F/R, SWR and impedance
data. Furthermore, Genetic Algorithms based optimizer is build-in.
19
It provides the user with a 3D view of the models. QAntenna is also capable of zooming,
rotating, and so on [12]. The popularity of QAntenna gets much benefits from
free/Libre/Open Source, multiplatform and 3D viewing of models. In addition,
QAntenna is with the special function of Snapshot generation.
EZNEC: EZNEC and EZNEC+ are powerful but very easy-to-use programs for
modeling and analyzing nearly any kind of antenna in its actual operating environment.
EZNEC plots azimuth and elevation patterns; calculate gain, feedpoint impedance,
SWR, and current distribution; finds and reports beamwidth, 3-dB pattern points, f/b
ratio, takeoff angle, sidelobe characteristics, and so on. EZNEC outlines the antenna
(and other nearby structures if desired) as a group of straight conductors. Using this
method, users could quickly analyze Yagis, quads, phased arrays, towers, loops- almost
all kinds of antenna. The most excellence of this software is displaying on multiple
patterns, which makes compare and analyze antenna data easily.
Antenna Maker: It is a freeware based one dos program, and developed by John
Agrelius in early 90's but still very useful and actual [14]. It is dedicated to quickly
compute antenna’s dimensions, including Quads antennas, Yagi antenna, Inverted vees
antennas as well as J-poles and Traps to extend dipoles band coverage.
20
Matlab: Matlab is a powerful tool used for computing, with a scripting language and
toolboxes. It is the best characterized by number of variables and fitness function are
user- defined, in the window of genetic algorithm setting tool.
Besides NASA, various types of antennas that are implemented by applying GA and
NEC has gained a huge success, such as “Crooked-wire” genetic antenna, Broadband
Yagi , High-gain Yagi, three-dimensional fishbone antenna and so on. .
21
Chapter 3
This chapter illustrates the technical design of planar antenna. Section 3.1 provides the
overview of planar antenna design. Section 3.2 describes the methods of generating bits.
Section 3.3 introduces techniques how to create patches.
In this project, a number of high-gain 2.4 GHz microwave planar antennas are to be
designed. The most popular planar antenna for many applications is the ‘’patch’’ or
‘’panel’’ antenna. The patch antenna gains its name based on the fact that it basically
consists of radiating patches, which are bonded on one side of the dielectric substrate.
On the other side of the dielectric usually is a ground plane layer such as the PC board.
In general, the patch material is the sort of conducting material, for example copper,
gold. Any possible shape of the patch can be applied, which is generally square,
rectangular, circular, triangular, elliptical and any other common shape. For microwave
frequencies, through making arrays of patches to form a phased array, it is the easy way
to get antennas, which have gain, directivity, and the ability to incorporate
beamfrorming and steering [7]. Figure 3.1 below shows the basic structure of the patch
antenna.
22
A microstrip or patch antenna has a number of advantages over other types of antennas:
inexpensive and economical, low weight and volume, Low profile planar configuration
(can be easily made conformal to host surface), supporting both linear and circular
polarization, integrated with microwave integrated circuits (MICs) easily, capable of
dual and triple frequency operations, etc. Whereas compared with the conventional
antenna, the patch antenna suffers from a number of drawbacks, such as narrow
bandwidth, low efficiency and low Gain, extraneous radiation from feeds and junctions,
poor end fire radiator except tapered slot antennas, low power handling capacity,
surface wave excitation and so on.
23
these bits, it reduces the difficulty of programming to some extend. Next, some
approaches for generating random bits will be introduced.
• Method A
It is the simplest method to generate the bit strings. In basic, the theory of this method is
that bit 1 means having a patch, bit 0 means no patch. In other words, the length of the
bit string depends on the number of the patch grids. Taking the 4 x 4 patch antenna for
an example, this planar antenna consists of 8 patches, which are indivated as P1, P2, P3,
P4, P5, P6, P7 and P8 respectively. It is worthy to be mentioned that normally we get
start from the leftmost column, and the order of grids description is from the bottom of
the column up to the top. Finally, it finishes at the rightmost column. According to the
rules of method A, we got the results, shown as below:
24
• Method B
Taking the same 4 x 4 patch antenna as an example, in the case of this method, we sign
every grid on this planar surface by a 6 bits of binary string. Based on this antenna is 4 x
4, every patch obtains log24 = 2 bits on both vertical direction and horizontal direction.
Combining two direction bits together gets a 4-bit string, which represents the gird
location. Each patch’s bit string is linked, generating a long bit string, which indicates
the all the patches locations on this planar antenna. According to this rule, we generate
all the patches on the planar antenna. Results are shown as below:
Patches numbers: 8
Patches Locations: P1 (0001) P2 (0011) P3 (0100) P4 (0110)
P5 (1001) P6 (1011) P7 (1100) P8 (1110)
Bit string: 00010011010001101001101111001110
According to the methods above, locations of patches are denoted by binary-bit strings.
In the other words,any random bit sequence is capable of generating patches with
relative locations by encoding.
25
3.3 Create Patches
In order to create whole planar patch, the best and easiest way is to build one patch first.
And then, we could use the same way to finish the entire planar antenna construction.
An example of one patch is shown as Figure 3.3. We define h stands for the height of
the patch, and w stands for the width of the patch. The coordinates of the patch centre
point are (x0, y0). Point A (xa, ya) and point B (xb, yb) are two corner points.
According to the NEC design flow, the antenna is divided into some straight wires. The
patch are divided by m segments on the width direction, whereas, the wires on the
height direction are broken up into n tiny segments, hence one patch is considered as
number (m+1) and number (n+1) wires on the vertical and horizontal directions.
According to above, each patch consists of (m+1+n+1) wires and divided into the (m*
n) segments. In addition, Dv represents the length of divided wire on horizontal
direction, while Dh stands for divided wire’s length on the vertical direction.
w =Width
h = Height
Dv = W/m
Dh = H/n
In order to apply the NEC generating the antenna, the coordinates of each divided wire
are required, especially the start point and end point. For point A, its coordinates on x-
26
axis is (x0 – w/2), and the coordinates on y- axis is (y0 – h/2). The coordinates of point
As shown in Figure 3.3, generating the vertical wire segments also means to
generate the wire from x= xa to x= xb. For this patch, the start point of leftmost
wire is A (x0 – w/2, y0 – h/2), whereas the coordinates of the wire’s endpoint are
(x0 – w/2, y0 + h/2). It is obvious that each wire on the vertical is with the same
coordinates on the y- axis at start point and end point as well. In terms of the x –
axis coordinates, the wires coordinates are calculated by adding a length Dv to
the right adjacent wire, which equals to w/m (W is patch width, and m is
number of wire segments on the width direction). By utilizing this method, all
the vertical wires could be generated with the coordinates.
Compared with the method of generating vertical wire, the difference is that
wires are with the same x- axis a coordinates instead of y- axis, at the start point
and the end point. Describing the horizontal wires from y= ya to y= yb, the x-
axis coordinates is (x0 – w/2) for the start points of all the horizontal wires,
while the end point coordinates is (x0 + w/2) on the x- axis. Referring to y
coordinates, the wires are calculated by adding a length Dh to the adjacent wire.
The value of Dh is calculated as h/n. H means the height of the patch, and n is
the number of the divided wire segments on horizontal. In this way, all the
27
horizontal wires segments are expressed. The coordinates of wires start and end
points are also useful, when applying the NEC generates radiation patterns.
One complete planar antenna may be constituted by only one patch, but most of patch
antennas are composed of several patches. Figure 3.3 is the photograph of a patch
antenna. Based on the method of creating one patch, which is supposed to generate the
wire segments from vertical and horizontal, all the patches could be generated in
required locations by the bit strings, and we expect each antenna string to be of a certain
fixed length. As we mentioned in chapter 3.2, a random binary bit string is considered
as the measure, which indicates the location of the patch. As shown, figure 3.3.2 is an
example planar antenna with 3 patches. Compared with figure 3.3.1, the W indicates the
width of the antenna, and H is the whole height of the antenna, whereas, w and h are
patch width and patch height respectively. Patches are located in the shadow grid. The
centre point of each patch is the connected point. The next section will explain the
question, which is how to generate and draw the patches on the planar surface by the
random bits.
28
Figure 3.3.2 planar antenna with 3 patches
In the first instance, the new set of reference frame (i, j reference frame) is introduced
into the program. The starting value is 0 for both i and j, and the value of i, j is only
integer. Decimals is not existing in this reference frame. In terms of point C, (i, j )
equals to (1, 1). For point D, (i, j) is (1,3). According to i, j reference frame, the i, j
array is generated. For one random bits string, at first split up the input string of zeros
and ones into individual bits, and then put them in the i, j array. The order of putting
individual is start from the column i =0 going along the direction, which is value of j
increasing. When the first column is filled up, turn around to the second column j=2, the
bits are assigned by the same order as the first column. In this way, all the individual
bits are assigned into i, j array. This process is terminal, when both i and j reaching the
maximums. At last any individual bit gains the coordinates by i, j reference system,
regardless bit 1 or bit 0. The coordinates of 1s are recorded, preparing to generate patch.
A random bits string contains several 0s and 1s. When the bit 1 emerges, one patch is
created. As mentioned before, one patch could be supposed as a number of vertical and
horizontal wires. In order to construct patches, the location of each patch is required,
namely, the coordinates of each patch is a critical factor in the entire process of antenna
design. From the part of “creating one patch”, it is known that location of center point
of target patch is needed to generate vertical and horizontal wires. When the bit is 1,
29
draw the patch, whose coordinates of center point by x, y reference frame is shown as
following:
x = (i+0.5) * w +x0
y = (j+0.5) * h +y0
In formulas above, w and h indicate the width and height of a patch. The center point
coordinates of the patch (i, j) =(0,0) is x0, y0, while the values of x0, y0 are related to
the number of patches at x, y direction, and the total length, width of the planar antenna.
3.4 Conclusion:
By the methods above, the planar antenna is constructed. Referring to this project,
inputting 16 binary bits in patch.pl, the binary bits are converted into decimal numbers
instantly,which are needed by generating NEC files. And then Simulated by NEC
simulator, the relative output files are produced, which are composed of antenna
characteristics. At last, applying QAntenna software simulates the generated NEC files.
The following Figure 3.4.1 shows the example of 4 x 4 patch antenna simulated by
QAntenna, and Figure 3.4.2 is the same antenna with radiation pattern.
30
Figure 3.4.1 4 x 4 patch antenna simulated by QAntenna
31
Chapter 4
From the chapter 3, any random bit strings could be generated by NEC and simulated
by QAntenna. In the chapter 4, section 4.1 introduces the general workflow of Genetic
Algorithm, and section 4.2 illustrates the implementation of GA in antenna design.
Based on traditional local search algorithms, genetic algorithm (GA) provides a more
optimal algorithm, which is inspired by the biological nature processes of genetics and
evolution. Evolution is close conjunction with genetics, which leads to genetic
alterations through natural selection, genetic drift, mutation, and migration. A new
population is optimized by genetics and evolution; namely, it is better adapted to thrive
in its environment [20].
GA is quite simple and powerful. The whole process of genetic algorithm is considered
as the following 7 steps:
32
3. Invoke natural selection.
4. Select parents for crossover.
5. Generate offspring.
6. Mutate selected members of intermediate generation
7. Terminate the operation
Based on the basic information about GA, utilizing GA optimizes the designed antenna,
which has been created by the approaches illustrated in Chapter 3.
$population_size = 100;
$bit_mutation_probability = 0.08;
$nbits = 16;
$iterations = 400;
In the program of this project, we set population as 100 and the probability of mutation
occurs is 0.08. The number of bit is denoted as 16 and the iteration is 400. It means the
whole process is carried out 400 times and one time generating 100 random16-bit
strings. Basically, the progress begins with randomly choosing 100 individuals as the
33
first generation, and then every individual is tested by the fitness, which is with
radiation pattern as reference condition. Calculating the mean square error of each
individual with reference antenna. The testing results MSE are sorted from the best to
the worst. Strings with high quality are produced a number of replications, which give
priority to be chosen as the parents to reproduce next generation. By crossover and
mutation of the parents (two higher fitness antennas), the further generation is produced.
When processes above going through 400 iterations, the entire program is terminated.
The first step of GA is that generate an initial population of random individuals. Each
individual is represented by a 16 bits binary number,which suggests the patch number
and patch location on the planar antenna. And then the 16- bit umber is converted into
decimal number. Generate a random number between 0 and 65535 (2^16) and store the
individuals into an array (population) of hashes. The hash element that we initialize is
called 'value'. Arbitrarily choose 100 individuals, which are considered to constitute the
initial population.
In order to go through all individuals in the current population, simulate each individual
member using NEC2++. NEC simulator generates NEC files, which consists of wires
coordinates, conductivity, voltage source, frequency, radiation pattern and so on.
Extract radiation patterns data from the generated NEC output file, which is needed to
calculate of MSE (mean square error). It is @sorted = sort { ${$a}{'mse'} <=>
${$b}{'mse'} } @population that ranks the results of individuals from the lowest mse to
the highest one in the list.
34
GW 1 21 ‐0.5 ‐0.5 0 ‐0.5 ‐0.25 0 0.001
GW 1 21 ‐0.416666666666667 ‐0.5 0 ‐0.416666666666667 ‐0.25 0 0.001
GW 1 21 ‐0.333333333333333 ‐0.5 0 ‐0.333333333333333 ‐0.25 0 0.001
GW 1 21 ‐0.25 ‐0.5 0 ‐0.25 ‐0.25 0 0.001
GW 1 21 ‐0.5 ‐0.5 0 ‐0.25 ‐0.5 0 0.001
GW 17 21 ‐0.5 ‐0.6 0 0.5 ‐0.6 0 0.001
………
GE 0
FR 0 1 0 0 2400
EX 0 17 10 0 12
RP 0 90 2 0000 0 0 1 90
EN
For this project, the program nec2plot is used to compute MSE and the operating
principle is presented as following. It scans through the entire generated NEC output
file and extracts the radiation patter, print it to standard output, and then we can redirect
this to a file to save the output. In Octave or Matlab this file can be read to plot in polar
coordinates. To compute the mean squared error between two radiation patterns, run the
NEC simulations for each, using a different filename each time, and then load the
results into Octave or Matlab. To obtain the MSE, Each random 16-bit is calculated by
comparing with the reference antenna. For example:
# load vertical_reference.dat
# load vertical_test.dat
# mean ((vertical_test (:, 3) ‐ vertical_reference (:, 3)) .^ 2)
# mean ((vertical_test (:, 3) ‐ vertical_reference (:, 3)) .^ 2)
Program statements above will provide the mean square error of radiation pattern on
vertical.
35
4.2.3 Nature Selection
According to the natural selection, only the healthiest members of the population are
allowed to survive to the next generation. The most common way to invoke natural
selection is to keep healthy chromosomes and abandon the rest.
Figure 4.2.3 basic implementation from current generation to the next generation [26]
It is helpful to suppose the execution of the GA as a two main parts. It starts with the
current population. To create an intermediate population from current population,
selection is invoked. Then recombination and mutation are applied to the intermediate
population. The strings with high fitting faculty are generated a number of duplications.
The individual with higher fitness value has higher percent chance of being the parents
to produce next generation.
In this case, the fitness of individual is the MSE between simulated radiation pattern
and reference pattern. After evaluating 100 individuals, the fitness results are sorted
from the best to the worst. The higher fitness individuals are chosen to store in the
36
mating pool, where strings are duplicated, and constituting intermediate generation. In
addition, duplications of strings are assigned in slots randomly, preparing to crossover.
Duplication methods are roughly classified by Roulette Wheel, Tournament Selection.
Based on Roulette Wheel, Monte Carlo Wheel theory has been most broadly used in
practical applications [23]. The basic theory is the number of offspring reproduced by a
chromosome is proportional to the chromosome’s fitness grade. Hypothetically, the
population size is n and the fitness value of chromosome Ai is ƒ (Ai). P (Ai) is the
probability of chromosome selected as a parent; therefore the expression of P (Ai) is
shown as:
In terms of Tournament Selection method, the main idea is that randomly choose k
(normally k equals to 20) chromosomes from the entire population, and the
chromosome with the highest fitness grade is reproduced. Repeat this process until the
number of chromosome reproductions reaches the default size of intermediate
generation.
Comparing and contrasting with two ways of duplication, the Tournament Selection
method is adopted, as by Roulette Wheel even though the high fitness chromosomes
generate reproductions with the higher probability, while the lower fitness
chromosomes still have possibility to be reproduced as the parents of the next
generation. Therefore the advantages of Tournament Selection are that this method not
only guarantees offspring chromosomes have better dispersion in solution space, but
also ensures all the offspring chromosomes are with splendid fitness.
With the Genetic Algorithms operation, crossover and mutation are applied to the
intermediate population, and then new population is generated.
37
4.2.5.1 Crossover
Compared with the first two ways of crossover, the uniform crossover is the most
general procedure for binary chromosomes. Instead of crossover point, selector is
applied to determine the swap bits. A mask that is the random range of 0s and 1s has the
same number of bits as the parent chromosomes. For uniform crossover,
mask=round(rand(1,nvar*nbit)).
If mask= 1
Parent A → offspring A,
Parent B → offspring B.
If mask= 0
Parent A → offspring B,
38
Parent B → offspring A.
Taking the 16-bit mask (1100011010010101) for the example, two random patch
antennas are illustrated by 1010101010100011 and 1111110000000011, respectively.
Parent A = [1 0 1 0 1 0 1 0 1 0 1 0 0 0 1 1]
Parent B = [1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1]
Mask = [1 1 0 0 0 1 1 0 1 0 0 1 0 1 0 1]
offspring A=[1 0 1 1 1 0 1 0 1 0 0 0 0 0 1 1]
offspring B=[1 1 1 0 1 1 0 0 0 0 1 0 0 0 1 1]
It is worthy to mention that in some reference research, the crossover rate is defined as
the ratio of the number of offspring produced in each generation to the population size
[23]. Overall, the rate should be high about 80% to 90%. Whereas some papers point
that for some problems crossover rate about 60% is the best.
4.2.5.2 Mutation
For binary chromosomes, mutation that is bits inversing a one to a zero or a zero to a
one, causes to random variations in the population [24]. More precisely, mutation is
aimed at changing gens in offspring generation, and it prevents the chromosomes of
omitting of important information or falling into local optimal solution in the process of
reproducing and mating. Compared with crossover; the mutation rate is much lower.
According to some research, it suggests that mutation rate about 0.5% to 1% is the best.
39
4.2.6 Terminate the Operation
Iteration is denoted as 400, therefore the generational process is repeated until the
number of iterations reaches 400 terminating the operation.
For a general problem, besides set number of iteration, common terminating conditions
are that set time achieved, fitness value of population falls lower than an acceptable
minimum, the best solution gets stuck after a set number of iterations, etc.
40
Chapter 5
Basically, this chapter aims to analyze the simulation results produced by combined
application of chapter 3 and chapter 4 from two aspects, which are radiation patter
comparison and MSE tendency analysis.
41
Figure 5.1 (b) the radiation of iteration 3
42
5.2 MSE Tendency Analysis
The evaluation results that are MSE values of individuals are stored in
$population[$i]{'mse'}, while the results of the population are stored in results_file.dat,
in which every content line is expressed by the fixed format: run number of iteration,
average MSE, best MSE, worst MSE, and code of the best antenna. Using Gnuplot
plots the results of average MSE, best MSE and worst MSE respectively. In these
figures, X-axis denotes the number of iteration, whereas Y-axis indicates the value of
MSE of current population.
43
Figure 5.2 (b) Best MSE
As can be seen from the Figure 5.2(a), 5.2(b) and 5.2(c) that even though the average
MSE of population seems to be a little bit faulty, the tendency of the best MSE and
worst MSE are goodish. To be more exact, three values of MSE all sink dramatically in
44
a few generations at first. However, the value of average MSE fluctuates markedly in
the continued generations. Referring to the best MSE, it tends to drop with substantial
fluctuations at first, but after reaching the bottom, it shoots up immediately. At last, it
stabilizes at 20 approximately. In terms of the worst MSE, even though it fluctuates
significantly in the first generations, the value is level off at the lowest point finally.
At last, it is worth considering that the results should be variable by changing the
mutation rate, population size, the number of iteration and so on.
45
Chapter 6
Conclusion
Overall, the original plan for the project is achieved. The start-up of the project is
background reading about antenna, NEC simulation and Genetic Algorithms; and
familiar with Linux system, programming language and software used for antenna
design. The following progress is general design of a planar antenna, by generating
patches from vertical segments and horizontal segments, which could be generated by
NEC simulator and simulated by QAntenna. Using 16-bit sequence decodes the location
of each patch. At last, utilizing Genetic Algorithms optimizes the result. The workflow
is as following: randomly generate 100 16-bit strings, evaluate 100 individuals,
according to MSE, which is obtained by comparing the simulated radiation pattern with
reference patter. Rank the mse of each individual in the population, and then select the
individuals with high fitness to crossover for generating offspring. After mutating of
selected members in intermediate generation, the new generation is produced. Generally
the average fitness of individuals will increase, since only the best chromosomes from
the preceding generation are inherited for breeding. Repeating the processes above, the
radiation pattern of generated antenna is more and more close to the reference pattern.
Therefore the original aim is realized, which is Automatic Design of Planar Antennas
Using Genetic Algorithms and the NEC Simulation Package.
46
Bibliography
[1] Ch. Bach. ANTENNA BASICS –Basic Antenna Design Information, September
2003, available URL www.enocean.com. [Accessed on 25/08/09]
47
[9] Straw, R. Dean (2003). The ARRL Antenna Book, 20th Edition. Newington,
Connecticut, USA: pp. 944.
48
[20] R. L. Haupt, D. H. Werner, (2007) Genetic Algorithms in Electromagnetics
Published by John Wiley & Sons, Inc., Hoboken, New Jersey, Canada. pp 29.
[23] S.J Chen, Foundations of Genetic Algorithm.ppt, Taiwan public union university
49
Appendix A: Thesis Project Specification
Project background:
Project Plan:
Project outcomes:
The main objective for this project is to design a number of high-gain 2.4 GHz
microwave antennas which can be manufactured and tested with 802.11 radio
hardware to demonstrate that GA-based antenna designs work well in the real
50
world. Though this project, the student will be expected to develop practical skills
in programming with NEC Simulator, Qantenna, and Octave Octave tools.
Project tasks:
• Familiarise with the software NEC Simulator, Qantenna, and Octave Octave
• Modify bits2nec.m to support new antenna geometries
• Designing antenna for 2.4GHZ, a 3-dimensional reference pattern is to be
used rather than only a horizontal and vertical slice, allowing greater control
of the overall shape of the radiation pattern.
• A number of different sets of design constraints will be tested, including
two-dimensional planar patch arrays with various geometric shapes and
reflective backplanes, with an emphasis on ease of manufacture.
Project Resources
The following resources will be required to complete the project.
• A PC to be used for web server and programming and to dedicated personal
computer to test the design.
• Microsoft office is used for editing the document paper work
• NEC simulator: a software of calculating and simulating antennas structure
• Qantenna: FLOSS software used to viewing and analyzing antennas and
their 3D radiation patterns.
• Octave Octave: both a programming language and interpreter, which is used
to execute defined functions written in Octave code.
• A number of material is for being manufactured
51
Appendix B: Project Timelines
Week 1 2 3 4 5 6 7 8 9 10 11 12
Project proposal
Literature survey
Modify bits2nec.m
52
2nd session plan
1 2 3 4 5 6 7 8 9 10 11 12
Simulation
53
Appendix C:
54
55
Appendix D:
1. patch.pl
#!/usr/bin/perl -w
# If you want to make (say) a 4x4 patch array occupying 1m x 1m area, define the parameters below as
# Then run the program as ./patch.pl 010100100101010....1010 (a total of 16 zeros and ones).
$patches_x = 4;
$patches_y = 4;
$width = 1;
$height = 1;
$x0 = -$width / 2;
$y0 = -$height / 2;
$z = 0;
$n_horizontal = 3;
$n_vertical = 3;
$diameter = 0.001;
sub str2num {
my ($str) = @_;
56
$len = length $str;
return $num;
sub create_patch {
my $delta = 1e-7;
my ($x, $y);
print $fh "GW $n 21 $x " . ($y0 - $height / 2) . " $z $x " . ($y0 + $height / 2) . " $z
$diameter\n";
print $fh "GW $n 21 " . ($x0 - $width / 2) . " $y $z " . ($x0 + $width / 2) . " $y $z
$diameter\n";
# print "SP 0 1 " . ($x0 - $width / 2) . " " . ($y0 - $height / 2) . " 0 " . ($x0 + $width / 2) . " " . ($y0 -
# print "SC 0 1 " . ($x0 + $width / 2) . " " . ($y0 + $height / 2) . " 0\n";
$n++;
$ant = 0;
foreach (@ARGV) {
57
# Validate each argument: must be the right number of zeros and ones!
die (sprintf ("$0: error: argument '$_' should be %i characters long and only contain 0s and 1s\n",
# Split up the input string of zeros and ones into individual bits and put them in an array called @bits
$n = 1;
$ant++;
# Draw a wire from the centre of the patch to just beyond the edge of the antenna
$n++;
# Now print out common parts of the NEC file which are independent of the number and location of patches
print SIMF "GW $n 21 $x0 " . ($y0 - 0.1) . " $z " . ($x0 + $width) . " " . ($y0 - 0.1) . " $z
$diameter\n";
58
close SIMF;
2. crossover_shu
#!/usr/bin/perl -w
use POSIX;
$population_size = 100;
$bit_mutation_probability = 0.08;
$nbits = 16;
$iterations = 400;
# Generate a random number between 0 and 65535 (2^16) Store the individuals
# is called 'value'.
# Go through all individuals in the current population. Simulate and calculate MSE.
$str = "";
59
for ($j = 0; $j < $nbits; $j++) {
$str .= $population[$i]{'value'}[$j];
`patch.pl $str`;
$mse = `$str`;
chomp $mse;
$population[$i]{'mse'} = $mse;
$rank = 1;
$new_pop_size = 0;
$average_mse = 0;
foreach (@sorted) {
${$_}{'rank'} = $rank++;
60
# print STDERR "${$_}{'mse'}, copies = ${$_}{'copies'}\n";
$average_mse += ${$_}{'mse'};
$intermediate[$new_pop_size++] = ${$_}{'value'};
# foreach (@intermediate) {
# @code = @$_;
# foreach (@code) {
# print $_
# }
# print "\n";
# }
$average_mse /= $population_size;
$best_code .= $sorted[0]{'value'}[$i];
# Print out run number, average mse, best mse, worst mse, code of the best
$i = 0;
foreach (@intermediate) {
@partner1 = @$_;
# foreach (@partner1) {
# print $_
# }
# print "\n";
61
# foreach (@partner2) {
# print $_
# }
# print "\n";
# Now we have two individuals selected from this list; $_ and $partner. We
$partner2[$j]);
$i++;
# foreach (@new_population) {
# @code = @{${$_}{'value'}};
# foreach (@code) {
# print $_;
# }
# print "\n";
# }
# For each bit, there is a certain probability that the bit will be inverted
$new_population[$n]{'value'}[$i] = 1 - $new_population[$n]{'value'}[$i];
62
}
# foreach (@new_population) {
# @code = @{${$_}{'value'}};
# foreach (@code) {
# print $_;
# }
# print "\n";
# }
@population = @new_population;
$population_size = $new_pop_size;
3. calc_mse.m
#!/usr/bin/octave -qH
% an error message
if (nargin ~= 2)
exit (-1);
end
63
4. monitor_results.m
#!/bin/sh
# To make a shell program under Linux, you should create a text file which
# starts with a line that says #!/bin/sh ONLY. Then you can put the commands
# that you want to run in the text file. After you save the file, you need
# You only need to do this once. Now you can run your script as follows:
# ./nec2plot
# This program reads the output files generated by NEC, and extracts the
# to save the output. In octave or Matlab you can then read this file and
# plot it in polar coordinates - or manipulate the data in any way that you
# load results.dat
# To compute the mean squared error between two radiation patterns, run the
# NEC simulations for each, using a different filename each time, then load
# load vertical_reference.dat
# load vertical_test.dat
# How it works:
# Scan through the entire output file and find the line number which
64
# echo $1
if [ x$1 = x ] ; then
exit
fi
if [ ! -e $1 ] ; then
exit
fi
if [ ! -r $1 ] ; then
exit
fi
# grep -n prints out the line of text containing 'RADIATION PATTERNS' with a
# line number. cut -f 1 -d ':' splits up the input text around the ':'
# delimiter, and prints out the first field. The result is just the line
# We want to start five lines after that point, so we eliminate the text
LINE=`expr $LINE + 5`
# Now we take all text AFTER that line, and of that text, everything BEFORE
# the last 8 lines, and pipe the result to awk - in this case awk just
65