FINDING WAVENUMBER IN A RECTENGULAR ...smimarog/Son1x.doc · Web viewThe finite difference...

39
FINDING WAVENUMBER IN A RECTANGULAR WAVEGUIDE BY FINITE DIFFERENCE METHODS SELİM MİMAROĞLU Hacettepe University Electrical and Electronics Engineering Department ELE 401-ELE 402 Final Project Report Instructor: Dr. Adnan Köksal

Transcript of FINDING WAVENUMBER IN A RECTENGULAR ...smimarog/Son1x.doc · Web viewThe finite difference...

FINDING WAVENUMBER IN A RECTANGULAR WAVEGUIDE BY FINITE DIFFERENCE

METHODS

SELİM MİMAROĞLU

Hacettepe UniversityElectrical and Electronics Engineering Department

ELE 401-ELE 402 Final Project ReportInstructor: Dr. Adnan Köksal

Fall, 1999

ABSTRACT

Finite Difference Methods is one of the most important methods for solving electromagnetic problems. It is easily understood, more frequently used, and more universally applicable than any other methods. The finite difference techniques are based upon approximations, which permit replacing differential equations, by finite difference equations. By using the Finite Difference Methods the wavenumber k is found. Firstly initial values for TE and TM waves are defined. 1 matrix is the initial value for TM and a ramp matrix is the initial value for the TM. SOR is used in these calculations in order to increase the speed of the calculation. k values are modified and again used in the equations and programs. Also E and H fields for TM and TE waves are found and compared with the analytical solutions.

LIST OF CONTENTS

ABSTRACT ii

LIST OF FIGURES iii

1. INTRODUCTION 1

2. FINITE DIFFERENCE METHODS 2

3. TM IN RECTANGULAR WAVEGUIDES 5

4. TE IN RECTANGULAR WAVEGUIDES 7

5. FD APPROACH 9

6. ACCURACY AND STABILITY OF FD SOLN. 12

7. RESULTS 16

LIST OF FIGURES

Figure Page

1.1 a-rectangular grid 1b-skew gridc-triangular gridd-circular grid

2.1 f(x) function 23.1 rectangular W.G. 55.1 discretized W.G. 106.1 error as a function of the mesh size 14

1. INTRODUCTION

The finite difference method (FDM) was first developed by A. Thom in the 1920s

under the title “the method of squares” to solve nonlinear hydrodynamic

equations. Since then, the method has found applications in solving different field

problems. The finite difference techniques are based upon approximations, which

permit replacing differential equations, by finite difference equations. These finite

difference approximations are algebraic in form; they relate the value of the

dependent variable at a point in the solution region to the values at some

neighbouring points.

Figure 1.1

(a) rectangular grid, (b) skew grid, (c) triangular grid, (d) circular grid.

Thus a finite difference solution basically involves three steps:

(1) Dividing the solution region into a grid of nodes.

(a) (b)

(c) (d)

(2) Approximating the given differential equation by finite difference equivalent

that relates the dependent variable at a point in the solution region to its values

at the neighbouring points.

(3) Solving the difference equations subject to the prescribed boundary conditions

and/or initial conditions.

The most commonly used grid patterns for two – dimensional problems are

shown in Fig. 1.1

2. FINITE DIFFERENCE METHODS

Given a function ƒ(x) shown in Fig.2, we can approximate its derivative,

slope or the tangent at P by the slope of arc PB, giving the forward – difference

formula,

Figure 2 .1

(2.1)

or the slope of the arc AP, yielding the backward – difference formula,

(2.2)

f(x)

A

P B

X0–x X0 X0+x x

(x0) = (x0 + x) – (x0) x

(x0) = (x0) – (x0 – x) x

or the slope of the arc AB, resulting in the central – difference formula,

(2.3)

We can also estimate the second derivative ƒ(x) at P as

(2.4)

Any approximation of a derivative in terms of values at a discrete set of points is

called finite difference approximation.

According to the well – known expansion, Taylor’s series approach

(2.5)

and

(2.6)

Upon adding these expansions,

(2.7)

where O(Δx)4 is the error introduced by truncating the series. Therefore, O(Δx) 4

represents terms that are not greater than (Δx)4 . Assuming that these terms are

negligible. Higher order finite difference approximations can be obtained by taking

more terms in Taylor series expansion. If the infinite Taylor series were retained, an

(x0 + x) = (x0) + x (x0) + (x)2

2!1 (x0) +

(x)3 3!1 (x0) + …..

(x0 – x) = (x0) – x (x0) + (x)2

2!1 (x0) – (x)3

3!1 (x0) + . .

(x0 + x) + (x0 – x) = 2(x0) + (x)2(x0) + O(x)4

(x0) = (x0 + x) – (x0 – x)2x

(x0) = ’(x0 + x/2) – ’(x0-x/2) x/2x/2Yx/2)x

= 1x

(x0 + x) – (x0)x

(x0) – (x0 – x) x–

(x0) =(x0 + x) – 2(x0) + (x0- x)(x)2

exact solution would be realized for the problem. However, for practical reasons, the

infinite series is usually truncated after the second-order term. This imposes an error,

which exists in all finite difference solutions.

To apply the difference method to find the solution of a function Φ(x,t), we

divide the solution region in the x – t plane into equal rectangles or meshes of

sides Δx and Δt .We let the coordinates (x,t) of a typical grid point or node be

and the value if Φ at P be

(2.8)

With this notation, the central difference approximations of the derivatives of Φ at

the (i,j)th node are obtaıned as follows

(2.9)

x = ix, i = 0, 1, 2, ...t = jt, j = 0, 1, 2, ...

ΦP = Φ(ix, jt) = Φ(i, j).

Φtt i,j = Φ(i, j + 1) – 2Φ(i, j) + Φ(i, j –1)(t)2

Φx i,j = Φ(i + 1, j) – Φ(i – 1, j)2x

,

Φt i,j = Φ(i, j + 1) – Φ(i, j – 1)2t

,

Φxx i,j = Φ(i + 1, j) – 2Φ(i, j) + Φ(i – 1, j)(x)2

,

3. TM IN RECTANGULAR WAVEGUIDES

TM Waves does not have a component of the magnetic field in the direction of

propogation;

The behavior of the TM wave can be analyzed by the equation:

b y

x a z Fig 3.1. Rectangular W.G.

E field in the z direction can be explained interms of x, y and z and z can be

expressed seperately,which we obtain;

Solve the second –order partial diff. equation:

Using the method of seperatation of variables;

both sides must equal a constant in order for the equation to hold for all values of

x and y.

The appropriate forms to be chosen must satisfy the boundary conditions.The

boundary condition is that : n.H=0 (on the surface)

When we apply the B.C. in the x direction

When we apply B.C. in the y direction

The solution is:

since

For the TMnm mode the cutoff frequency is :

And the cutoff wavelength is:

4.TE WAVES IN RECTANGULAR WAVEGUIDES

TE Wave must satisfy the following boundary conditions

.

When we apply the above conditions in the x-direction, the following results

are obtained:

When we apply the above conditions in the y direction, following results are

obtained:

General Solution for the TE wave:

If a>b the cutoff frequency is the lowest when m=1 and n=0

The corressponding cutoff wavelength is

5.FD APPROACH

The solution of waveguide problems is well suited for finite difference schemes

because the solution region closed. This amounts to solving the Helmholtz or

wave equation

(5.1)

where Φ = Ez for TM modes or Φ = Hz for TE modes, while k is the wave number

given by

(5.2)

The permittivity c of the dielectric medium can be real for a lossless medium or

complex for a lossy medium. We consider all fields to vary with time and axial

distance as exp j(t – z). In the eigenvalue problem of Eq. (5.1), both k and Φ

are to be determined. The cutoff wavelength is c = 2 / kc. For each value of the

cutoff wave number kc , there is a solution for the eigenfunction Φi , which

represents the field configuration of a propagating mode.

To apply the finite difference method, we discretize the cross section of the

waveguide by a suitable square mesh.

(5.3)

where Δx = Δy = h is the mesh size. Equation (5.3) applies to all the free or

interior nodes. At the boundary points, we apply Dirichlet condition (Φ = 0) for

the TM modes and Neumann condition (Φ/n = 0) for the TE modes. This

implies that at point A in Fig.5.1, for example,

(5.4)

2Φ + k2 Φ = 0

k2 = 2c – 2 5.

Φ(i + 1, j) + Φ(i – 1, j) + Φ(i, j + 1) + Φ(i, j – 1) – (4 – h2k2)Φ(i, j) = 0

ΦA = 0

for TM modes. At point A, Φ/n = 0 implies that ΦD = ΦE so that Eq. (5.1)

becomes

(5.5)

for TE modes. By applying Eq. (5.3) and either Eq. (5.4) or (5.5) to all mesh

points in the waveguide cross section, we obtain m simultaneous equations

involving the m unknowns (Φ1 , Φ2 , ... , Φm). These simultaneous equations may

be conveniently cast into the matrix equation

(5.6) or

(5.7)

Figure 5.1 .

where A is an m x m band matrix of known integer elements, l is an identity

matrix, Φ = (Φ1 , Φ2 , ... , Φm) is the eigenvector, and

(5.8)

is the eigenvalue. There are several ways to determining and the corresponding

Φ. We consider two of these options.

The first option is the direct method. Equation (5.6) and (5.7) can be satisfied

only if the determinant of (A – l) vanishes, ie.,

(5.9)

This result in a polynomial in , which can be solved for the various eigenvalues

. For each , we obtained the corresponding Φ from Eq. (5.3). This method

ΦB + ΦC + 2ΦD – (4 – h2k2) ΦA = 0

(A – I)Φ = 0

AΦ = Φ

A – I= 0

= (kh)2 = 22h

c

requires storing the relevant matrix elements and does not take advantage of the

fact that matrix A is sparse. In favor of the method is the fact that a computer

subroutine usually exists that solves the eigenvalue problem in Eq. (5.9) and that

determines all the eigenvalues of the matrix. These eigenvalues give the dominant

and higher modes of the waveguide, although accuracy deteriorates rapidly with

mode number.

The second option is the iterative method. In this case, the matrix elements are

usually generated rather than stored. We begin with Φ1 = Φ2 = ... = Φm = 1 for

TM we take these values randomly and a guessed value for k,. The field at the

(i,j)th node in the (k+1)th iteration is obtained from its known value in the kth

iteration using

(5.10)

where is the acceleration factor, 1 < < 2, and Rij is the residual at the (i,j)th

node given by

(5.11)

After three or four scans of the complete mesh using Eq. (10), the value of = h2

k2 should be update using Raleigh formula

(5.12)

The finite difference equivalent of Eq. (5.12) is

(5.13)

where Φs are the latest field values after three or four scans of the mesh and the

summation is carried out over all points in the mesh. The new value of k obtained

from Eq. (5.13) is now used in applying Eq. (5.10) over the mesh for another three

or four times to give more accurate field values, which are again substituted into

Rij = Φ(i, j) + Φ(i, j – 1) + Φ(i + 1, j) + Φ(i – 1, j) – (4 – h2k2)Φ(i, j)

(4 – h2k2)Rij

Φk+1(i, j) = Φk(i, j) +

k2 =i = 1j = 1

Φ(i, j) Φ(i + 1, j) + Φ(i – 1, j) + Φ(i, j + 1) + Φ(i, j – 1) – 4Φ(i, j)

h2 Φ2(i, j)i = 1j = 1

k2 =S

Φ2 ΦdS

SΦ2 dS

Eq. (5.13) to update k. This process is continued until the difference between

consecutive values of k is within a specified acceptable tolerance.

If the first option is to be applied, matrix A must first be found. To

obtained matrix A is not easy. If there are nx and ny divisions along the x and y

directions, the number of free nodes is

(5.14)

Each free node must be assigned two sets of numbers, one to correspond to m in

Φm and the other to correspond to (i,j) in Φ(i,j).

6.ACCURACY AND STABILITY OF FD SOLUTIONS

The question of accuracy and stability of numerical methods is extremely

important if solution is to be reliable and useful. Accuracy has to the with the

closeness of the approximate solution of exact solutions. Stability is the

requirement that the scheme does not increase the magnitude of the solution with

increase in time.

There are three sources of errors that are nearly unavoidable in numerical

solution of physical problems:

(1) modelling errors,

(2) truncation (or discretization) errors,

(3) round off errors.

Each of these error types will affect accuracy and therefore degrade the solution.

The modelling errors are due to several assumptions made in arriving at the

mathematical model. For example, a nonlinear system may be represented by a

linear PDE. Truncation errors arise from the fact that in numerical analysis, we

can deal only with a finite number of terms from processes, which are usually

nf = (nx – 1) (ny – 1).

described by infinite series. For example, in deriving finite difference schemes,

some higher-order terms in the Taylor series expansion were neglected, there by

introducing truncation error. Truncation errors may be reduced by using finer

meshes, that is, by reducing the mesh size h and time increment Δt. Alternatively,

truncation errors may be reduced by using a large number of terms in the series

expansion of derivatives, that is, by using higher-order approximations. However,

care must be exercised in applying higher-order approximations.

Roundoff errors reflect the fact that computations can be done only with a

finite precision on a computer. This unavoidable sources of errors is due to the

limited size of registers in the arithmetic unit of the computer. Round off errors

can be minimised by the use of double-precision arithmetic. The only way to

avoid round off errors completely is to code all operations using integer

arithmetic. This is hardly possible in most practical situations.

Although it has been noted that reducing the mesh size h will increase

accuracy, it is not possible to indefinitely reduce h. Decreasing the truncation

error by using a finer mesh may result in increasing the round off error due to the

increased number of arithmetic operations. A point is reached where the minimum

total error occurs for any particular algorithm using any given word length. This is

illustrated in Fig. 6.1. The concern about accuracy leads us to question whether

the finite difference solution can grow unbounded, a property termed the

instability of the difference scheme. A numerical algorithm is said to be stable if a

small error at any stage produces a smaller cumulative error. It is unstable

otherwise. The consequence of instability (producing unbounded solution) is

disastrous. To determine whether a finite difference scheme is stable, an error is

defined, n, which occurs at time step n, assuming that there is one independent

variable. We define the amplification of this error time step n+1 as

(6.1)

where g is known as the amplification factor. In more complex situations, Eq.

(6.1) becomes

n+1 = gn

[]n+1 = [G][]n

(6.2)

where [G] is the amplification matrix. For the stability of the difference scheme, it

is required that Eq. (6.1) satisfy.

or

(6.3) For the case in Eq. (6.2) determinant of [G] must vanish, ie.,

(6.4)One useful and simple method of finding a stability criterion for a

difference scheme is to construct a Fourier analysis of the difference equation and

thereby derive the amplification factor. This technique is known as Neumann’s

Method

(6.5)

where r = Δt/k(Δx)2. Let the solution be.

(6.6)

where k is the wave number. Since the differential equation is linear it is

approximated to

(6.7)

n+1 n

g 1

det[G] = 0

Φ n+1i = (1– 2r) + r( + )

Φ n

i Φ ni+1 Φ n

i–1

= An(t)ejkix , 0 x 1Φ ni

= A(t)ejkixΦ ni

error

Figure 6.1 mesh size h

round-off error

discretization error

total error

Substituting Eq. (6.7) into Eq. (6.5) gives

(6.8)or

Hence the amplification factor is

(6.9)

In order to satisfy Eq. (6.3),

Since this condition must hold for every wave number k, we take the maximum

value of the sine function so that

or

Of course, r = 0 implies Δt = 0, which is impractical. Thus

(6.10)

An+1ejkix = (1 – 2r) An+1ejkix + r(ejkx + e–jkx) Anejkix

An+1 = An[1 – 2r + 2coskx].

g = An+1

An = 1 – 2r + 2coskx

g = kx21 – 4r sin2

kx21 – 4r sin2 1

1 – 4r – 1 and r 0

12r and r 0

12r 0 <

7. RESULTS AND DISCUSSION

8.CONCLUSION

9. REFERENCES

1. Matthew N.O. Sadiku, Numerical Techniques in Electromagnetics, 1992, CRC

Press Boca Raton.

2. Robert E. Collin, Foundations For Microwave Engineering, 1992, McGraw-

Hill Singapore.

3. David K. Cheng, Field and Wave Electromagnetics, 1989, Addison-Wesley

Reading,Mass.

4. D. S. Jones, Methods in Electromagnetic Wave propogation, 1991, IEEE Press

New York.

10. APPENDICES

Algorithm of the program

S1: Enter inputs

S2: Calculate necessary parameters

S3: Calculate Matrix A using boundary values

S4: Calculate the summation matrices for new k value

S5: Enter the necessary values for n and m

S6: Calculate analytical solution

S7: Draw FD solution

S8: Draw Analytical solution

S9: Draw the difference between analytical and FD solutions

Computer Programs

Program1

%TE MODE WAVEGUIDE PROBLEMclear all;a=input('enter the number of rows =');b=input('enter the number of coloumns =');w=input('enter the acceleration number 1<w<2 =');h=input('enter hx=hy=')%A=randn(a,b);for i=1:a for j=1:b A(i,j)=-b/2+0.5+j; endendB=A;k=80;f=0;p=1;c=4-h^2*k^2;y=a*hx=b*hwhile p>0.01 & f<1000 for i=1:a for j=1:b if i==1 & j==1; A(i,j)=(2*A(i,j+1)+2*A(i+1,j))/c; elseif i==1 & j~=b & j~=1; A(i,j)=(A(i,j-1)+A(i,j+1)+2*A(i+1,j))/c; elseif i==1 & j==b; A(i,j)=(2*A(i,j-1)+2*A(i+1,j))/c; elseif j==1 & i~=a & i~=1; A(i,j)=(A(i-1,j)+A(i+1,j)+2*A(i,j+1))/c; elseif i==a & j==1; A(i,j)=(2*A(i-1,j)+2*A(i,j+1))/c; elseif i==a & j~=1 & j~=b; A(i,j)=(A(i,j-1)+A(i,j+1)+2*A(i-1,j))/c; elseif i==a & j==b; A(i,j)=(2*A(i,j-1)+2*A(i-1,j))/c; elseif j==b & i~=1 & i~=a; A(i,j)=(2*A(i,j-1)+A(i-1,j)+A(i+1,j))/c; else A(i,j)=(A(i,j-1)+A(i,j+1)+A(i-1,j)+A(i+1,j))/c; end end end A=(1-w)*B+w*A; B=A; for i=1:a for j=1:b if i==1 & j==1; Z(i,j)=2*A(i,j)*(A(i,j+1)+A(i+1,j)); elseif i==1 & j~=b & j~=1; Z(i,j)=A(i,j)*(A(i,j-1)+A(i,j+1)+2*A(i+1,j)); elseif i==1 & j==b; Z(i,j)=2*A(i,j)*(A(i,j-1)+A(i+1,j)); elseif j==1 & i~=a & i~=1; Z(i,j)=A(i,j)*(A(i-1,j)+A(i+1,j)+2*A(i,j+1));

elseif i==a & j==1; Z(i,j)=2*A(i,j)*(A(i-1,j)+A(i,j+1)); elseif i==a & j~=1 & j~=b; Z(i,j)=A(i,j)*(A(i,j-1)+A(i,j+1)+2*A(i-1,j)); elseif i==a & j==b; Z(i,j)=2*A(i,j)*(A(i,j-1)+A(i-1,j)); elseif j==b & i~=1 & i~=a; Z(i,j)=A(i,j)*(2*A(i,j-1)+A(i-1,j)+A(i+1,j)); else Z(i,j)=A(i,j)*(A(i,j-1)+A(i,j+1)+A(i-1,j)+A(i+1,j)); end Y(i,j)=A(i,j)*A(i,j); end end f=f+1; c=(sum(sum(Z)))/(sum(sum(Y))); t=(sqrt(4-c))/h; p=abs((t-k)/t); k=t; end A=normalize(A); f,k kc(x,y) n=input('enter n = '); m=input('enter m = '); for i=1:a for j=1:b G(i,j)=cos(n*pi*h*(j-1)/x)*cos(m*pi*h*(i-1)/y); end end for i=1:a for j=1:b H(i,j)=abs(A(a+1-i,b+1-j)-G(i,j)); E(i,j)=A(a+1-i,b+1-j); end end figure(1); imagesc(E) colormap(gray) title('numerical solution of te') pause figure(2); imagesc(G) colormap(gray) title('TE Analytical Solution ') pause

figure(3); imagesc(H) colormap(gray)

pause yy=(1:a); xx=(1:b); figure(4) mesh(xx,yy,G) pause figure(5) mesh(xx,yy,E) pause figure(6) mesh(xx,yy,H) pause figure(7) subplot(2,2,1), mesh(xx,yy,G) title('Analytical TE Solution') subplot(2,2,2), mesh(xx,yy,E) title('Numerical TE Solution') subplot(2,2,3), mesh(xx,yy,H) title('Difference')

Program 2

%TM MODE WAVEGUIDE PROBLEM

a=input('enter the number of rows =');b=input('enter the number of coloumns =');w=input('enter the acceleration number 1<w<2 =');A=ones(a,b);B=ones(a,b);Z=zeros(a,b);Y=zeros(a,b);h=input('enter hx=hy =')y=a*hx=b*hk=1;f=0;p=1;c=4-h^2*k^2;while p>0.01 & f<1000 for i=1:a for j=1:b if i==1 & j==1; A(i,j)=(A(i,j+1)+A(i+1,j))/c; elseif i==1 & j~=b & j~=1; A(i,j)=(A(i,j-1)+A(i,j+1)+A(i+1,j))/c; elseif i==1 & j==b; A(i,j)=(A(i,j-1)+A(i+1,j))/c; elseif j==1 & i~=a & i~=1; A(i,j)=(A(i-1,j)+A(i+1,j)+A(i,j+1))/c; elseif i==a & j==1; A(i,j)=(A(i-1,j)+A(i,j+1))/c; elseif i==a & j~=1 & j~=b; A(i,j)=(A(i,j-1)+A(i,j+1)+A(i-1,j))/c; elseif i==a & j==b; A(i,j)=(A(i,j-1)+A(i-1,j))/c; elseif j==b & i~=1 & i~=a; A(i,j)=(A(i,j-1)+A(i-1,j)+A(i+1,j))/c; else A(i,j)=(A(i,j-1)+A(i,j+1)+A(i-1,j)+A(i+1,j))/c; end end end A=(1-w)*B+w*A; B=A; for i=1:a for j=1:b if i==1 & j==1; Z(i,j)=A(i,j)*(A(i,j+1)+A(i+1,j)); elseif i==1 & j~=b & j~=1; Z(i,j)=A(i,j)*(A(i,j-1)+A(i,j+1)+A(i+1,j)); elseif i==1 & j==b; Z(i,j)=A(i,j)*(A(i,j-1)+A(i+1,j)); elseif j==1 & i~=a & i~=1; Z(i,j)=A(i,j)*(A(i-1,j)+A(i+1,j)+A(i,j+1)); elseif i==a & j==1; Z(i,j)=A(i,j)*(A(i-1,j)+A(i,j+1)); elseif i==a & j~=1 & j~=b; Z(i,j)=A(i,j)*(A(i,j-1)+A(i,j+1)+A(i-1,j)); elseif i==a & j==b; Z(i,j)=A(i,j)*(A(i,j-1)+A(i-1,j)); elseif j==b & i~=1 & i~=a; Z(i,j)=A(i,j)*(A(i,j-1)+A(i-1,j)+A(i+1,j)); else Z(i,j)=A(i,j)*(A(i,j-1)+A(i,j+1)+A(i-1,j)+A(i+1,j));

end Y(i,j)=A(i,j)*A(i,j); end end f=f+1; c=(sum(sum(Z)))/(sum(sum(Y))); t=sqrt(4-c)/h; p=abs((t-k)/t); k=t; end A=normalize(A);

f,k kc(x,y) n=input('enter n = '); m=input('enter m = '); for i=1:a for j=1:b G(i,j)=sin(n*pi*h*(j)/x)*sin(m*pi*h*(i)/y); D(i,j)=abs(A(a+1-i,b+1-j)-G(i,j)); E(i,j)=A(a+1-i,b+1-j); end end figure(1); imagesc(E) colormap(gray) title('numerical solution TM’) pause figure(2); imagesc(D); colormap(gray); title('error in TM,error of k=%0.95'); pause figure(3); imagesc(G); colormap(gray); title('analytic sol. of TM,n=1,m=1,kc=211'); pause yy=(1:a); xx=(1:b); figure(4) mesh(xx,yy,G) pause figure(5) mesh(xx,yy,E) pause figure(6) mesh(xx,yy,D) pause figure(7) subplot(2,2,1), mesh(xx,yy,G) title('Analytical TM Solution') subplot(2,2,2), mesh(xx,yy,E) title('Numerical TM Solution')

subplot(2,2,3), mesh(xx,yy,D) title('Difference')