Tutorial: Rectangular Waveguide


 * Download the latest matlab file using gitweb: Rect_Waveguide.m
 * Simulation Time: ~ 5 min for a 5m long waveguide

We will cover in this tutorial:
 * setup a mode profile excitation,
 * create voltage and current probes using the mode profile,
 * calculate and plot the waveguide impedance and s-parameters.

Octave (Matlab) Simulation Script
To start the script within an empty environment, the first lines are:

Setup the simulation, starting with the units:

Next, specify the waveguide dimensions for WR42:

Specify the frequency range of interest: The last instruction gives the wavelength of the centre frequency in microns.

Define the waveguide TE mode:

Specify the mesh resolution as 30 cells per wavelength in all directions:

Initialize the FDTD structure:

Set the boundary conditions. The wave is propagating in the z-direction so the ends of the waveguide are terminated with perfectly-matched layers (PML or 3). The sidewalls of the waveguide are formed by the x and y extents of the simulation space using perfect electric conductor (PEC or 0) boundary conditions.

Now setup the CSXCAD mesh:

Now specify the waveguide ports. Port 1 is 11 cells from the bottom end of the waveguide and port 2 is 13 cells from the top end. Ports are in the form of a box with the excitation plane located at the start position and the voltage and current probes located at the stop position. The stop position specifies the reference plane for the port. Port 1 is active with an amplitude of 1 while the second port is passive (no excitation amplitude specified).

Define a dump box to capture time-domain E-field results:

Write the simulation model and execute the simulation:

Results
Here are the post-processing steps to calculate the s-parameters and waveguide impedance: Note that "uf" refers to the frequency-domain voltages, "if" refers to the frequency-domain currents, "inc" refers to incident, "ref" refers to reflected, and "tot" refers to total.

Plot the s-parameters:



Compare analytic and numerical wave-impedance:

Plot the field dumps: