# maxwellWaveguideBC

This module illustrates how to implement waveguide boundary conditions in Maxwell equations. So far it is done for 2D planar case in Cartezian and Axial (m = 0) cases. Waveguides modes and waveguides port are hardcoded.

## Problem

The module uses Maxwell equations written for $\mathbf{E}$ field in $\exp(-i \omega t)$ presentation: $curl curl \mathbf{E} = \frac{\omega^2}{c^2} \epsilon(x,y) \mathbf{E}$ (here: $\omega$ - is the frequency, $c$ - the speed of light, $\epsilon$ - dielectric permittivity; the CGS system of units is used).

This module illustrates how to set boundary condition so that there is two waveguide ports through one of which an input signal enters. That is it solves a simple waveguide scattering problem

## Variational form

Variational form is:

For waveguide ports the last term in the left hand side is written as:

Here C_s is the amplitude of mode $s$ and $\mathbf(E_s)$ - the s-th mode’s electric field. The $C_s$ in its turn is written as:

, here $\mathbf{H}$ and $\mathbf{H_s}$ are current and mode’s magnetic field which are found from Maxwell equations, $N_s$ is the norm.

Finally, the last term of the LHS side can be written in term of the direct product as:

that allows one to implement it by means of FreeFem++ tools without low-level matrix assembly (for the price of performance, of course).

## Algorithms

### 2D - Cartesian

Hardcoded TE modes. File `cartezian2D_TEmodes.idp`

:

Hardcoded TM modes. File `cartezian2D_TMmodes.idp`

Script for intermixing TM and TE modes. File `cartezian2D_modes.idp`

:

Finally, the main script:

### 2D - axial-symmetric

In the axial-symmetric case dimensionless norm and transversal wave numbers are read from file `modes_m=0.txt`

. If only TE or TM modes are required, just delete unnecessary raws. The first lines is the lines number. For the rest: the first column is Bessel funstion or Bessel function prime zeros, the second column is the mode type (TE or TM), the next is M=0, the last is the dimensionless norm. `modes_m=0.txt`

:

```
19
2.404825557695773 1 0 0.7793251491983979
3.8317059702075125 0 0 1.190818894252844
5.5200781102863115 1 0 1.763983488461943
7.0155866698156215 0 0 2.2165400124021
8.653727912911013 1 0 2.7590751389668657
10.173468135062722 0 0 3.226726175661221
11.791534439014281 1 0 3.7566997735908174
13.323691936314221 0 0 4.232168817077737
14.930917708487787 1 0 4.755305323217033
16.470630050877634 0 0 5.235551752495418
18.071063967910924 1 0 5.754389740203993
19.615858510468243 0 0 6.237857058819471
21.21163662987926 1 0 6.753743000677423
22.760084380592772 0 0 7.239528520160257
24.352471530749302 1 0 7.753262043197564
25.903672087618382 0 0 8.240795797022049
27.493479132040253 1 0 8.752890449018484
29.046828534916855 0 0 9.241789609116804
30.634606468431976 1 0 9.752594764648169
```

Hardcoded TE modes, file `axial2D_TEmodes.idp`

:

Hardcoded TM modes, file `axial2D_TMmodes.idp`

:

Script for intermixing TM and TE modes. File `axial2D_modes.idp`

:

Finally, the main script. Note that in 2D axial symmetric Maxwell equations (in axial cut) the variable $r E_{\phi}$ is used rather than $E_{\phi}$

## Validation

Following examples show reflectiveless transition of a waveguide mode traveling from one port (left) to an other (right).

### 2D, Cartezian

Left and right borders are waveguide ports. Input mode TE1

Mode TE1, abs(Ez) |
---|

Mode TE1, Re(Ez) |
---|

Left and right borders are waveguide ports. Input mode TM1

Mode TM1, abs(Ex) |
---|

Mode TM1, abs(Ey) |
---|

### 2D, axial-symmetric

Mode TE01, abs(Ephi) |
---|

Mode TE01, Re(Ephi) |
---|

Mode TM02, abs(Ez) |
---|

Mode TM02, abs(Er) |
---|