Vous êtes sur la page 1sur 6

VectGUI: A MATLAB-Based Simulation Tool

Ozlem Ozgun and Levent Sevgi

he vector analysis graphical user


interface (VectGUI), a MATLABbased vector analysis visualization
tool, can be used as a supplementary tool
in the first course of electromagnetic education. The main purpose of this tool is
to provide various visual aids that assist
students in developing a mental image
of some fundamental concepts in vector calculus and curvilinear coordinate
systems. This tool is composed of seven
subtools: two designed for the dynamic
visualization of geometries in cylindrical
and spherical coordinates; two used to
display the scalar and vector fields; and
three designed to demonstrate the gradient, curl, and divergence fields.

Vector Analysis Tools


Teaching electromagnetics using novel
modeling and simulation approaches has long been discussed, mostly in
this magazine [1][6], including fundamental concepts and terms [7], [8].
Sevgi [9], [11] and Felsen et al. [10] discuss guided wave propagation via the
well-known SturmLiouville problem
and explain the connection between
Greens function and eigenvalue
problems. The finite-difference timedomain method has been discussed,
and MATLAB-based virtual tools and
codes have been shared with readers
[13][19]. Several antennas and propagation packages, from the very simple to
the most comprehensive tools, have also
been introduced [20][26]. Electromagnetic diffraction has been reviewed, and
novel virtual tools have been introduced
[27][29]. Virtual tools for teaching
advanced-level mathematical functions
and tools have also been reviewed with
useful packages [30], [31]. Some Javabased applets for multivariable calculus,
Digital Object Identifier 10.1109/MAP.2015.2463152
Date of publication: 21 August 2015

IEEE Antennas & Propagation Magazine

editors Note
This tutorial belongs to a simple MATLAB package that visualizes functions and
operators (e.g., gradient of scalar fields and divergence of vector fields) in the cylindrical
and spherical coordinate systems. These packages can be used in lectures such as vector
algebra, mathematical foundations of electromagnetics, and mathematical methods
in electromagnetics, together with the previous packages we introduced in this
column[1], [2].

References

[1] L. Sevgi and . Uluiik, A tutorial on the Bessel functions and numerical evaluations of Bessel integrals, IEEE Antennas Propagat. Mag., vol. 51, no. 6, pp. 222233, Dec. 2009.
[2] . Uluiik and L. Sevgi, A MATLAB-based visualization package for complex functions, and their mappings and integrals, IEEE Antennas Propagat. Mag., vol. 54, no. 1, pp. 243253, Feb. 2012.

Table 1. Differential Operations.


Operation

Notation

Transformation

Gradient

df = grad ^ f h

Divergence

d $ F = div ^F h

Curl

d # F = curl ^F h

Input: scalar field


Output: vector field
Input: vector field
Output: scalar field
Input: vector field
Output: vector field

including vector analysis, are available


through the Internet [32][34].
Vision plays a vital role in electromagnetics because it removes the obstacle in understanding and perception of
physical phenomena. New students often
think that electromagnetics is a difficult course because some mathematical and geometrical concepts, as well as
electromagnetic fields that are vector
functions of space and time, are abstract
and hard to visualize. Therefore, a wellestablished background on vector calculus and coordinate systems is essential
in developing a better conceptual understanding of electromagnetic phenomena.
Being motivated by this fact, this article
presents a basic tutorial on the visualization of some fundamental concepts in
the study of vector analysis. A MATLAB-based package (called VectGUI) is
introduced with graphical user interface
june 2015

(GUI) capabilities. As previously stated,


this package includes seven subtools:
cylGUI and sphGUI plot geometries
in a dynamic manner by varying one
of the coordinate variables in cylindrical and spherical coordinates, respectively; sfieldGUI and vfieldGUI plot
user-defined scalar and vector fields,
respectively, in a two-dimensional (2-D)
Cartesian system; grad2dGUI and grad3dGUI plot and display the gradient of
a user-defined scalar field, together with
the field itself, in 2-D and three-dimensional (3-D) Cartesian systems, respectively; and, finally, curldivGUI plots and
displays the curl and divergence of a
user-defined vector field together with
the field itself in both 2-D and 3-D Cartesian systems. The MATLAB-based
VectGUI package can be downloaded
from http://www.ee.hacettepe.edu.
tr/~ozlem/.
113

Figure 1. The main window of the VectGUI package.

Basic Concepts
Measurable quantities in the study of
physical phenomena are named either
scalar or vector quantities. A scalar
(e.g., charge and current) is a quantity
that has only magnitude and can be
described by a single numeric value.
A vector (e.g., velocity, electric, and magnetic fields) is a quantity that has both
magnitude and direction. Both scalars
and vectors can be functions of position
and time. A spatial distribution of a quantity is named the field. If the quantity is a

vector (scalar), the field is called a vector


(scalar) field. Hence, scalar and vector
fields are the major players of electromagnetics. To describe the variations of these
quantities in space, a suitable coordinate
system is needed. Although the laws of
electromagnetism are valid in any coordinate system, a coordinate system provides a frame of reference and is chosen
based on the symmetry of the geometry
to ease its analysis. Therefore, the vector
analysis has three main ingredients: 1)
an orthogonal coordinate system (Carte-

Table 2. The subtools of the VectGUI package.


Tool Name

Description

cylGUI

Displays geometries in a cylindrical coordinate system by


changing one of the coordinate variables in a dynamic
manner.
Displays geometries in a spherical coordinate system by
changing one of the coordinate variables in a dynamic
manner.
Displays a user-defined scalar field in 2-D.
Displays a user-defined vector field in 2-D.
Displays a scalar field and its gradient field in 2-D.
Displays a scalar field and its gradient field in 3-D.
Displays a vector field and its curl and divergence fields in
2-D and 3-D.

sphGUI

sfieldGUI
vfieldGUI
grad2dGUI
grad3dGUI
curldivGUI

114

june 2015

sian, cylindrical, and spherical); 2) vector


algebra (addition, subtraction, and multiplication of vectors); and 3) vector calculus
(differentiation and integration of vectors).
Among them, the curvilinear coordinate
systems and the concepts of gradient,
divergence, and curl, which are based on
the del differential operator, are sometimes hard to visualize and comprehend.
In a 3-D coordinate system, a point
is defined at the intersection of three
surfaces, which can be denoted by u 1 =
constant, u 2 = constant, a n d u 3 =
constant surfaces. When these three
surfaces are mutually orthogonal, we
have an orthogonal coordinate system.
In the Cartesian coordinate system
^ x, y, z, h u 1 = x, u 2 = y, and u 3 = z;
in the cylindrical coordinate system
^ r, {, z h, u 1 = r, u 2 = { and u 3 = z;
and in the spherical coordinate system
^ R, i, { h, u 1 = R, u 2 = i, and u 3 = {.
Here, r is the radial distance of the point
from the z-axis, R is the radial distance
from the origin, { is the rotation angle
around the z-axis and is between 60, 2r@,
and i is the angle formed with the zaxis and is between 60, r@ . In addition,
r = constant surface defines the surface of a circular cylinder with radius r,
R = constant surface defines the surface
of a sphere with radius R, { = constant
surface defines a semi-infinite plane, and
i = constant surface defines a cone surface. The identification of such surfaces is
important especially in defining the differential quantities (i.e., the differential
length, surface, and volume elements) that
are used in the evaluation of line, surface,
and volume integrals.
Vector calculus deals with various differential operators defined in scalar and
vector fields. These operators are usually expressed in terms of the del operator ^d h that is also known as the nabla
operator. The del operator is defined in a
general coordinate system as follows:

2 (.) t 1 2 (.)
d = at u1 1
+ a u2
h 2 2u 2
h 1 2u 1

(.)
2
1
,
+ at u3
h 3 2u 3

(1)

where ^ u 1, u 2, u 3 h are the coordinate variables, at u i, ^ i = 1, 2, 3 h is the


base vector pointing in the direction
of increasing u i, and h i is the metric
IEEE Antennas & Propagation Magazine

coefficient to convert the differential


change in the coordinate variable ^du i h
into a differential change in length
^dl i h . If the coordinate variable is in
length, the metric coefficient becomes
unity. The metric coefficients, in three
coordinate variables, are defined as follows: h 1 = 1, h 2 = 1, h 3 = 1 (Cartesian);
h 1 = 1, h 2 = r, h 3 = 1 (cylindrical); and
h 1 = 1, h 2 = R, h 3 = R sin i (spherical).
The three most important differential
operations are listed in Table 1. The gradient operator applies to a scalar field and
returns a vector field. Its direction shows
the direction of maximum increase of
function, and its magnitude gives the rate
of increase (or slope) along this maximal
direction. In other words, it measures the
direction and rate of change in a scalar
field. In a general coordinate system, the
gradient of a scalar field f ^ u 1, u 2, u 3 h is
defined as follows:

2f
2f
df = at u1 1
+ at u2 1
h 2 2u 2
h 1 2u 1

2f
+ at u3 1
,
h 3 2u 3

(a)

(b)

(c)

(d)

Figure 2. The cylGUI window: (a) the r-constant surfaces, (b) the {-constant
surfaces, (c) the z-constant surfaces, and (d) the formed geometry.

(2)

which, in a Cartesian coordinate system, is


df = at x

2f
2f
2f
.(3)
+ at y
+ at z
2x
2y
2z

The divergence operator acts on


a vector field and yields a scalar field
or quantity. It measures how much
the vector field spreads out (or diverges) from the point of interest, i.e., the
magnitude of a source or sink of a
vector field at a given point. It represents the net outward flux of the vector field from an infinitesimal volume
around the given point. In a general
coordinate system, the divergence of
a vector field F ^ u 1, u 2, u 3 h = at u1 Fu1
^ u 1, u 2, u 3 h + at u 2 Fu 2 ^ u 1, u 2, u 3 h + at u 3 Fu 3
Fu3 ^ u 1, u 2, u 3 h is defined as

1 ; 2 ^ h 2 h 3 Fu1 h
h1 h2 h3
2u 1
2 ^ h 3 h 1 Fu2 h 2 ^ h 1 h 2 Fu3 h
E,
+
+

2u 2
2u 3
(4)
d $ F =

which, in a Cartesian coordinate system,


becomes

d$F=

2Fx 2Fy 2Fz


.(5)
+
+
2x
2y
2z

IEEE Antennas & Propagation Magazine

(a)

(b)

(c)

(d)

Figure 3. The sphGUI window: (a) the R-constant surfaces, (b) the i-constant
surfaces, (c) the {-constant surfaces, and (d) the formed geometry.
The curl operator applies to a vector
field and returns a vector field. It measures how much the vector field rotates
(curls) around a point of interest. It is
a measure of the strength of a vortex
source. Its magnitude represents the
maximum circulation of a vector field
within an infinitesimal area around
the given point, and its direction is
normal to the area in the sense of the
june 2015

right-hand rule. In a general coordinate


system, the divergence of a vector field
F is defined as
h 1 at u1 h 2 at u2 h 3 at u3
2
2
2 ,
1
d # F =
h 1 h 2 h 3 2u 1 2u 2 2 u 3
h 1 Fu1 h 2 Fu2 h 3 Fu3
(6)
which, in Cartesian coordinate system,
becomes
115

at x at y at z
d # F = 2 2 2 .(7)
2x 2y 2z
Fx Fy Fz

VectGUI Package
VectGUI is a MATLAB-based tool
for visualizing some fundamental
concepts in vector analysis. The main
window of the package is shown in
Figure 1. The package includes seven
subtools, which are summarized in
Table 2. When the user clicks one of
the subtools in the main window, a
new window is opened corresponding
to the clicked subtool. Each subtool in
Table 2 is described below.
The cylGUI tool (Figure 2) is
designed to display geometries in a
cylindrical coordinate system. The
user enters the ranges of each coordinates ^r, {, z h . Once one of the plot
buttons is clicked, the corresponding
variable is sampled by a number of
samples between the lower and upper
limits, and the geometry is dynamically
formed by drawing constant surfaces
at every 0.1 s. For example, as shown
in Figure 2(a), if the button Plot by
varying r is clicked, five r- constant
surfaces are plotted corresponding
to r = 0, r = 0.5, r = 1, r = 1.5, and
r = 2 surfaces at every 0.1 s. Similarly,
the geometry is formed by varying {
and z variables in Figure 2(b) and (c),
respectively. If the number of samples is
increased, the geometry is well formed,
as shown in Figure 2(d).
The sphGUI tool (Figure 3) is
designed to display geometries in a
spherical coordinate system by varying
one of the coordinate variables ^ R, i, { h .
This is similar to the cylGUI tool.
The sfieldGUI tool (Figure 4) is
designed to display the contour and
surface plots of a scalar field in a 2-D
Cartesian system. The function is symbolically entered by the user. The ranges
of the function and the number of points
along the x and y axes are also provided
by the user.
The vfieldGUI tool (Figure 5)
is designed to plot a vector field in a
2-D Cartesian system. The scalar
components of the vector field (i.e., Fx
and Fy ) are entered symbolically by the

Figure 4. The sfieldGUI window (scalar field plotter).

Figure 5. The vfieldGUI window (vector field plotter).


116

june 2015

IEEE Antennas & Propagation Magazine

Figure 6. The grad2dGUI window (2-D gradient field plotter).

Figure 7. The grad3dGUI window (3-D gradient field plotter).

Figure 8. The curldivGUI window (curl and divergence plotter).

user. The ranges of the function and


the number of points along the axes are
defined by the user.
The grad2dGUI tool (Figure 6) is
designed to plot the gradient field of a
scalar field in a 2-D Cartesian system.
The field itself might also be plotted.
The scalar field is symbolically entered
by the user, together with its ranges.
The components of the gradient vector
are also displayed symbolically.
The grad3dGUI tool (Figure 7) is
designed to plot the gradient field of
a scalar field in a 3-D Cartesian system. This tool is similar to the grad2dGUI tool.
IEEE Antennas & Propagation Magazine

The curldivGUI tool (Figure 8) is


designed to plot the divergence and
curl of a vector field in a 2-D or 3-D
Cartesian system. The components
of the vector field are symbolically
entered by the user. The expressions for
curl and divergence are also displayed
symbolically.

Conclusions
A MATLAB-based simulation package, VectGUI, has been developed for
vector analysis. The intent is to develop
a better conceptual understanding of
curvilinear coordinate systems, scalar
and vector fields, gradient, curl, and
june 2015

divergence. The tool may be used in


undergraduate electromagnetics courses and, perhaps, in other disciplines
that use vector analysis.

Author Information
Ozlem Ozgun (ozgunozlem@gmail.
com; ozlem@ee.hacettepe.edu.tr) is
with the Electrical and Electronics
Engineering Department, Hacettepe
University, Beytepe, Ankara, Turkey.
Levent Sevgi (ls@leventsevgi.net;
levent.sevgi@okan.edu.tr) is with the
Electrical and Electronics Engineering
Department, Okan University, Akfirat,
Tuzla, Istanbul, Turkey.
117

References

[1] L. Sevgi and C. Goknar, An intelligent balance between numerical and physical experimentation, IEEE Potentials Mag., vol. 23, no. 4, pp.
4044, Oct./Nov. 2004.
[2] L. B. Felsen and L. Sevgi, Electromagnetic
engineering in the 21st century: Challenges and
perspectives, ELEKTRIK, Turk. J. Electr. Eng.
Comput. Sci., vol. 10, no. 2, pp. 131145, Feb.
2002.
[3] L. Sevgi, A new electromagnetic engineering
program and teaching via virtual tools, Progr.
Electromagn. Res. B (EWS 2006 Special Issue),
vol. 6, pp. 205224, 2008.
[4] L. Sevgi, Teaching electromagnetic modeling and simulation as a graduate-level course,
IEEE Antennas Propagat. Mag., vol. 54, no. 5, pp.
261269, Oct. 2012.
[5] L. Sevgi, Complex Electromagnetic Problems
and Numerical Simulation Approaches. Hoboken,
NJ: IEEE PressJohn Wiley, 2003.
[6] L. Sevgi, Electromagnetic Modeling and Simulation. Hoboken, NJ: IEEE PressJohn Wiley,
2014.
[7] L. Sevgi, Innumeracy: The meaning of the
numbers we use, IEEE Antennas Propagat.
Mag., vol. 49, no. 2, pp. 195190, Apr. 2007.
[8] L. Sevgi, Numerical fourier transforms DFT
and FFT, IEEE Antennas Propagat. Mag., vol.
49, no. 3, pp. 238243, June 2007.
[9] L. Sevgi, Guided waves and transverse fields:
Transverse to what? IEEE Antennas Propagat.
Mag., vol. 50, no. 6, pp. 221225, Dec. 2008.
[10] L. B. Felsen, F. Akleman, and L. Sevgi,
Wave propagation inside a two-dimensional
perfectly conducting parallel plate waveguide:
Hybrid ray-mode techniques and their visualizations, IEEE Antennas Propagat. Mag., vol. 46,
no. 6, pp. 6989, Dec. 2004.
[11] L. Sevgi, Sturm-Liouville equation: The
bridge between eigenvalue and Greens function
problems, ELEKTRIK, Turk. J. Electr. Eng. Comput. Sci., vol. 14, no. 2, pp. 293311, June 2006.
[12] L. Sevgi, Guided waves and eigenvalue
extraction from propagation characteristics,
IEEE Antennas Propagat. Mag., vol. 50, no. 2, pp.
222234, Apr. 2008.

IMAGE LICENSED BY GRAPHIC STOCK

118

[13] L. Sevgi and . Uluisik, A MATLAB-based


transmission line virtual tool: Finite-difference
time-domain reflectometer, IEEE Antennas Propagat. Mag., vol. 48, no. 1, pp. 141145, Feb. 2006.
[14] G. akr, M. akr, and L. Sevgi, A multipurpose FDTD-based two dimensional electromagnetic virtual tool, IEEE Antennas Propagat.
Mag., vol. 48, no. 4, pp. 142151, Aug. 2006.
[15] M. akr, G. akr, and L. Sevgi, A two-dimensional FDTD-based virtual metamaterialWave
interaction visualization tool, IEEE Antennas Propagat. Mag., vol. 50, no. 3, pp. 166175, June 2008.
[16] G. Toroglu and L. Sevgi, FDTD MATLAB
codes for the first and second order electromagnetic models, IEEE Antennas Propagat. Mag.,
vol. 56, no. 2, pp. 221239, Apr. 2014.
[17] A. Pekmezci and L. Sevgi, FDTD based
metamaterial modeling, IEEE Antennas Propagat. Mag., vol. 56, no. 5, pp. 289303, Oct. 2014.
[18] G. akr, M. akr, and L. Sevgi, A novel
virtual FDTD-based microstrip circuit design and
analysis tool, IEEE Antennas Propagat. Mag.,
vol. 48, no. 6, pp. 161173, Dec. 2006.
[19] G. akr, M. akr, and L. Sevgi, Radar
cross section modeling and simulation: Part IIA
novel FDTD-based RCS prediction virtual tool,
IEEE Antennas Propagat. Mag., vol. 50, no. 2, pp.
8194, Apr. 2008.
[20] L. Sevgi, A ray shooting visualization MATLAB package for 2D groundwave propagation
simulations, IEEE Antennas Propagat. Mag., vol.
46, no. 4, pp. 140145, Aug. 2004.
[21] L. Sevgi and . Uluisik, A MATLAB-based
visualization package for planar arrays of isotropic
radiators, IEEE Antennas Propagat. Mag., vol.
47, no. 1, pp. 156163, Feb. 2005.
[22] L. Sevgi, . Uluisik, and F. Akleman, A
MATLAB-based two-dimensional parabolic
equation radiowave propagation package, IEEE
Antennas Propagat. Mag., vol. 47, no. 4, pp. 164
175, Aug. 2005.
[23] F. Akleman and L. Sevgi, A novel MoM- and
SSPE-based groundwave propagation field strength
prediction simulator, IEEE Antennas Propagat.
Mag., vol. 49, no. 5, pp. 6982, Oct. 2007.
[24] O. Ozgun, G. Apaydin, M. Kuzuoglu, and
L. Sevgi, PETOOL: MATLAB-based one-way

We want
to hear
from you!

and two-way split step parabolic equation tool


for radiowave propagation over variable terrain,
Comput. Phys. Commun., vol. 182, no. 12, pp.
26382654, 2011.
[25] L. Sevgi, A mixed-path groundwave field
strength prediction virtual tool for digital radio
broadcast systems in medium and short wave
bands, IEEE Antennas Propagat. Mag., vol. 48,
no. 4, pp. 1927, Aug. 2006.
[26] G. Apaydin and L. Sevgi, Numerical investigations of and path loss predictions for surface wave propagation over sea paths including
hilly island transitions, IEEE Trans. Antennas
Propag., vol. 58, no. 4, pp. 13021314, Apr. 2010.
[27] F. Hacveliog lu, L. Sevgi, and P. Y. Ufimtsev,
Electromagnetic wave scattering from a wedge
with perfectly reflecting boundaries: Analysis of
asymptotic techniques, IEEE Antennas Propagat. Mag., vol. 53, no. 3, pp. 232253, June 2011.
[28] F. Hacveliog lu, M. A. Uslu, and L. Sevgi, A
MATLAB-based simulator for the electromagnetic wave scattering from a wedge with perfectly
reflecting boundaries, IEEE Antennas Propagat.
Mag., vol. 53, no. 6, pp. 234243, Dec. 2011.
[29] M. A. Uslu and L. Sevgi, MATLAB-based
virtual wedge scattering tool for the comparison
of high frequency asymptotics and FDTD method, Int. J. Appl. Comput. Electromagn., vol. 27,
no. 9, pp. 697705, Sept. 2012.
[30] L. Sevgi and . Uluisik, A tutorial on the
bessel functions and numerical evaluations of
bessel integrals, IEEE Antennas Propagat. Mag.,
vol. 51, no. 6, pp. 222233, Dec. 2009.
[31] . Uluisik and L. Sevgi, A MATLAB-based
visualization package for complex functions, and
their mappings and integrals, IEEE Antennas Propagat. Mag., vol. 54, no. 1, pp. 243253, Feb. 2012.
[32] (2015, May 8). Multivariable calculus.
[Online]. Available: https://multivariablecalculus.
wordpress.com/video-demonstrations/
[33] (2015, May 8). Math applets for calculus
at SLU. [Online]. Available: http://www.slu.edu/
classes/maymk/MathApplets-SLU.html
[34] (2015, May 8). Exploring multivariable calculus. [Online]. Available: http://web.monroecc.
edu/calcNSF/

Do you like what youre reading?


Your feedback is important.
Let us knowsend the editor-in-chief an e-mail!
june 2015

IEEE Antennas & Propagation Magazine

Vous aimerez peut-être aussi