Figure 83 shows a 2-d resonant cavity consisting of a hollow, rectangular, perfectly
conducting channel of dimensions . Suppose that the walls
of the channel are aligned along the - and -axes.
We shall excite this cavity in a rather artificial manner
by imposing a -directed alternating current pattern of frequency ,
which has the same spatial structure as the mode in which we are interested. Let us calculate the electric
and magnetic field patterns excited within the cavity by such a current pattern.

Figure 83:A 2-d resonant cavity.

The electric and magnetic fields within the cavity can be written
, and
, respectively.
It follows from Maxwell's equations that

(268)

(269)

(270)

where is the velocity of light, , , and
. Note that the
above system of equations takes the form of three coupled advection equations with a source term.
The boundary conditions are that the tangential electric field and the normal
magnetic field must be zero at the conducting walls. It follows that

(271)

at all the walls (which are located at and ),

(272)

at , and

(273)

at . Finally, the normalized current pattern associated
with the (, ) mode takes the form

(274)

As usual, we discretize in time on the uniform grid
, for
.
Furthermore, in the -direction, we discretize on the uniform grid
, for
, where
.
Finally, in the -direction, we discretize on the uniform grid
, for
, where
. Adopting a Crank-Nicholson temporal differencing scheme
similar to that discussed in Sects. 7.4 and 7.6, Eqs. (268)-(270) yield

The routine listed below solves the 2-d wave equation in a resonant
cavity using the Crank-Nicholson scheme
discussed above. The routine first Fourier transforms , , , and
in both the - and -directions, takes
a time-step using Eqs. (285)-(287), and then reconstructs
, , and via an double inverse Fourier transform.

The numerical calculations discussed below were performed
using the above routine. The electromagnetic
fields , , and were all initialized to zero everywhere at .
Figure 84 shows the maximum
amplitude of versus the frequency, , for an driving
current distribution. It can
be seen that there is a clear resonance at .

Figure 84:Electromagnetic waves in a 2-d resonant cavity.
The maximum amplitude of
between and versus the driving frequency, .
Numerical calculation performed using , , , , ,
, and
.

Figures 85 and 86 illustrate the typical time variation
of , , and for a non-resonant and a resonant case, respectively.
For the non-resonant case, the traces take the form of interference patterns
between the directly driven response, which oscillates at the driving frequency ,
and the transient response, which oscillates at the natural frequency of the cavity.
Note that the transients never decay, since there is no dissipation in the present problem.
Incidentally, it is easily demonstrated that

(288)

Hence, it follows that
for
, which corresponds very well
to the resonant frequency found in Fig. 84.
For the resonant case, the traces take the form of waves of ever increasing amplitude
which oscillate at the
natural frequency .