Comparison of Solving Electromagnetic Field - at www.asee

advertisement
Comparison of Solving Electromagnetic Field Problems with
a Computer Using MATLAB and Maple Software
Jeng-Nan Juang
Abstract
Solving electromagnetic field problems with Maple software was discussed in the ASEE-SE
Conference in April of 2000 [1]. Many schools are using their introductory engineering courses to
acquaint students with a variety of computer tools and languages. MATLAB has become the
technical computing environment of choice for many engineers and scientists. In industrial settings,
MATLAB is used for research and to solve practical engineering and mathematical problems.
Because the MATLAB computing environment is the one that a new engineer is the most likely to
encounter on a job, it is a good tool for an introduction to computing for engineering students.
The main purpose of this paper is to compare the use of MATLAB and Maple software to solve the
same problems for electromagnetic fields.
Introduction
Engineers and scientists use computers to solve a variety of problems, ranging from the evaluation of
a simple function to solving a system of nonlinear equations. Because MATLAB is a single
interactive system that integrates numeric computation, symbolic computation, and scientific
visualization, it has become the choice for the technical computing environment of many engineers
and scientists at this time.
In university environments, MATLAB has become the standard instructional tool for introductory
courses in applied linear algebra, as well as advanced courses in other fields. There are several
electrical engineering text books using MATLAB as the instructional tool [8], [9], [10], [11], [12], [13],
[14].
Theory and Formulas
The same theory and formulas from a previous paper, “Solving Electromagnetic Field Problems with
Maple Software,” [1] are used for this paper. The goal of this paper is to demonstrate applications of
MATLAB software to static electric fields problems. All the formulas and theory from Coulomb’s law,
electrical fields intensity, electric flux density, and Gauss’s law can be solved by MATLAB software.
2001 ASEE Southeast Section Conference
1
Solving Electromagnetic Field Problems
No special knowledge of the MATLAB software interface is required for simple problem-solving, but
it is important to type the expressions as they appear on these pages. Three problems from an
electromagnetic field textbook [3] have been done in MATLAB to show how it works.
Problem 1:
A charge Qo = 1 nC is located in free space at (a,0,0). Prepare a sketch of the magnitude of the
force on Qo, as a function of a (0  a  5 m), produced by two other charges, Q1 = 1 C at (0,1,0);
and Q2 =: (a) 1 C at (0,-1,0); (b) –1 C at (0,-1,0).
The general equation of Coulomb’s Law is given by the mathematical expression:

QQ 
F  1 2 2 aR
4 0 R
Where for this problem, Qo = 1 nC at P (a,0,0); Q1 = 1 C at (0,1,0)
(a) Q2 = 1 C at (0,-1,0),


R10  a,1,0 ,
R20  a,1,0 
And

Fo 
10 9
4 8.854 x10 12
 a,1,0 
a,1,0 

 2
1.5
1.5 
a 2  1 
 a  1




So

F0  8.99
a
2a
2

1
1.5

ax 
a
18a
2

1
1.5

ax
(b) Q2 = -1 C at (0,-1,0),

Fo  8.99
a
2
2

1
1.5

ay 
a
 18
2

1
1.5

ay
Using MATLAB to solve the problem:
Using Maple to solve the problem:
x = linspace(0,5)
y = (18.*x)./((x.^2+1).^1.5);
plot(x,y)
xlabel(‘a’), ylabel(‘F[a]’)
F[a]:=(18*a)/((a^2+1)^1.5);
plot(F[a], a = 0..5);
Fa : 18
a
(a  1)1.5
2
2001 ASEE Southeast Section Conference
2
7
6
5
F[a]
4
3
2
1
0
0
0.5
1
1.5
2
2.5
a
3
3.5
4
4.5
5
Using MATLAB
Using Maple
x = linspace(0,5)
F[b]:=(-18)/((a^2+1)^1.5);
y = (18)./((x.^2+1).^1.5);
plot(abc(F[b]), a=0..5);
plot(x,y)
xlabel(‘a’), ylabel(‘F[b]’)
Fb : 18
1
(a  1)1.5
2
18
16
14
12
F[b]
10
8
6
4
2
0
0
0.5
1
1.5
2
2.5
a
3
3.5
4
4.5
5
Using MATLAB
Using Maple
x = linspace(0,5)
plot(F[a],abs(F[b])], a = 0..5);
y = (18.*x)./((x.^2+1).^1.5);
z = (18)./((x.^2+1).^1.5);
plot(x,y,x,z)
18
16
14
12
10
8
6
4
2
0
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
Using MATLAB
Using Maple
2001 ASEE Southeast Section Conference
3
Problem 2:
Let E = (2x + 4y –3)ax + (4x – 2y)ay and: (a) find the equation of the direction line passing
through p(1,2,z); (b) sketch this direction line and show E at p.
The equation of a streamline is obtained by solving the differential equation.
Ey
Ex

dy
dx

4x  2 y
2x  4 y  3
4 xdx  2 ydx  2 xdy  4 ydy  3dy
And by integrating
2 x 2  2 y 2  2 xy  3 y  c1 ,
Here
x  1, y  2
2  8  4  6  c1 , c1  4
So the streamline equation is:
2x2 – 2xy – 2y2 + 3y +4 = 0
solve(%,y)

1
3 1
1
3 1
x 
20 x 2  12 x  41, x  
20 x 2  12 x  41
2
4 4
2
4 4
1
3 1
y :  x  
20 x 2  12 x  41
2
4 4
Solving by MATLAB:
x = linspace(-4, 4)
y = -(1./2).*x+(3./4)+(1./4)
.*sqrt(20.*x.^2-12.*x+41);
plot(x,y)
xlabel(‘x’), ylabel(‘y’)
Solving by Maple:
y = -1/2*x+3/4+1/4
*sqrt(20*x^2-12*x+41);
plot(y,x = -4..4);
1
3 1
y :  x  
20 x 2  12 x  41
2
4 4
2001 ASEE Southeast Section Conference
4
8
7
6
y
5
4
3
2
-4
-3
-2
-1
0
x
1
2
3
4
Using MATLAB
Using Maple
Problem 3:
Identical 1-C point charges are located in free space at (0,0,1) and (0,0,-1). Prepare a plot
showing  E vs. z along the line x = 0, y = 2, for  z  10.
Using the formula for Electric Field Intensity:


Qa R
E
4 o R 2
So

EP 
10 6
4 (8.854) x10 12
 (0,2, z  1)
(0,2, z  1) 



2 1.5
[4  ( z  1) 2 ]1.5 
[4  ( z  1) ]
And


1
1
E y  17,980

2 1.5
2 1.5 
[4  ( z  1) ] 
[4  ( z  1) ]


z 1
z 1
E z  8990

2 1.5
2 1.5 
[4  ( z  1) ] 
[4  ( z  1) ]
Absolute Value for E is:

E  E z2  E y2
E  y  : 17980
E  z  : 8990
1
1
 17980
2 1.5
(4  ( z  1) )
(4  ( z  1) 2 )1.5
z 1
z 1
 8990
2 1.5
(4  ( z  1) )
(4  ( z  1) 2 )1.5
2
2







1
1
z 1
z 1



E : sqrt  17980

17980

8990

8990

(4  ( z  1) 2 )1.5
(4  ( z  1) 2 )1.5  
(4  ( z  1) 2 )1.5
(4  ( z  1) 2 )1.5  



2001 ASEE Southeast Section Conference
5
Solving by MATLAB:
x = linspace(0,10);
y = sqrt([(17980./(4+(x-1).^2).^1.5)+(17980./(4+(x+1).^2).^1.5)].^2+[((8990.*(x-1))./(4+(x1).^1.5)+((8990.*(x+1))./(4+(x+1).^2).^1.5).^2);
plot(x,y)
xlabel(‘z’), ylabel(‘E(z)’)
3500
3000
2500
E(z)
2000
1500
1000
500
0
0
1
2
3
4
5
z
6
7
8
9
10
Using MATLAB
Using Maple
Using Maple to solve the problem:
Restart;
E(y):=17980*(1/(4+(z-1)^2)^1.5)+17980*(1/(4+(z+1)^2)^1.5);
E  y  : 17980
1
1
 17980
2 1.5
(4  ( z  1) )
(4  ( z  1) 2 )1.5
E(z):=8990*((z-1)/(4+(z-1)^2)^1.5)+8990*((z+1)/(4+(z+1)^2)^1.5);
E  z  : 8990
z 1
z 1
 8990
2 1.5
(4  ( z  1) )
(4  ( z  1) 2 )1.5
E:=((E(y))^2+(E(z))^2)^(1/2);
2
2







1
1
z 1
z 1



E : sqrt  17980

17980

8990

8990

(4  ( z  1) 2 )1.5
(4  ( z  1) 2 )1.5  
(4  ( z  1) 2 )1.5
(4  ( z  1) 2 )1.5  



Plot(E,Z=0..10)
2001 ASEE Southeast Section Conference
6
Conclusion
The main purpose of this paper is to compare Maple and MATLAB software for solving
homework problems for Electromagnetic Fields. From the results of the preceding problems,
there are no major differences between using MATLAB or Maple for this application. Both have
short, easy, equation entry. Both produce clear plots and basic plotting of equations. Both
enhance understanding of electromagnetic concepts. There are a few differences to consider,
however. Maple shows the equation that has been processed, which allows students to make sure
they have the correct solutions; MATLAB does not. MATLAB has simulation (or toolboxes)
while Maple has symbolic algebra. The importance of these two differences depends on what the
purpose for the application is. For instance, MATLAB can perform simulation for Transfer
function as follows:
1
s2 +2s+3
Step
Transfer Fcn
Step: Apply any value to Transfer Function
Scope
Scope: Show the graph of Transfer Function
It is more convenient for engineering students to do the calculation and see the results from the
graph through the MATLAB simulation. The final consideration is the difference in cost. Maple
student versions cost $50 each. Each MATLAB student version costs $99; however, to this
initial cost one must add $30 for the control tool kit, $30 for the DSP tool kit, and $60 for any
other tool kit. Our students must pay more than $250 for the completed student version of
MATLAB. Only 25 copies of MATLAB software are installed in our building for students to use.
When dealing with students, one should keep their financial obligations in mind.
2001 ASEE Southeast Section Conference
7
References
[1] Jeng-Nan Juang, (2000) Solving Electromagnetic Field Problems with Maple Software, ASEE
Southeast Section Conference Proceedings (April, 2000).
[2] DuBroff, Richard E., Stanley V. Marshall, and Gabriel G. Skitek (1996) Electromagnetic Concepts
and Applications, Prentice-Hall Inc., New Jersey.
[3] Hayt, William H., Jr. (1989) Engineering Electromagnetics, McGraw-Hill Inc., New York.
[4] Barrow, David, Art Belmonte, Al Boggess, Jack Bryant, Tom Kiffe, Jeff Morgan, Maury Rahe,
Kirby Smith, and Mike Stecher (1998) Solving Differential Equations with Maple V, Brooks/Cole
Publishing Company, Pacific Grove, CA.
[5] Heal, K. M., M. L. Hansen, and K. M. Rickard (1998) Maple V Learning Guide, Waterloo Maple
Inc., Canada.
[6] Delores M. Etter (1996) Introduction to Matlab for Engineers and Scientists
[7] User’s Guide for Microsoft Windows (1994) Matlab High-Performance Numeric Computation and
Visualization Software.
[8] Clayton R. Paul [2001] Fundamentals of Electric Circuit Analysis.
[9] Young W. Kwon, Hyochoong Bang [1997] The Finite Element Method, Using MATLAB.
[10] Frederick/Chow [1995] Feedback Control Problems, Using MATLAB and The Control System
Toolbox.
[11] Mark Beale, Howard Demuth [1994] Fuzzy Systems Toolbox, For Use With MATLAB.
[12] Theodore E. Djaferis [2000] Automatic Control, The Power of Feedback.
[13] Fred Taylor, Jon Mellott [1998] Hands-On Digital Signal Processing.
[14] Charles L. Phillips, John M. Parr [1999] Signals, Systems, and Transforms.
Jeng-Nan Juang
Dr. Juang received the B.S. degree in Electrical Engineering in 1975 from National Taiwan Ocean
University, Keelung, Taiwan. The M.S. and Ph.D. degree in 1978 and 1986, respectively, from
Tennessee Technological University, TN.
Dr. Juang has been a faculty member of the Electrical & Computer Engineering at Mercer
University since 1987. He served as the head of the Engineering Department at Roane State
Community College before he came to Mercer (1980-1987). Dr. Juang has also been serving as
Faculty Advisor for the Mercer University NSPE student chapter since 1994. .
2001 ASEE Southeast Section Conference
8
Download