# Waveguide eigenmode weak-form (Comsol)

Maxwell equations are: $$\nabla \times \mathbf{E} = -\frac{\partial \mathbf{B}}{\partial t},\,\,\,\,\,\,\,\,\nabla \times \mathbf{H} = +\frac{\partial \mathbf{D}}{\partial t}$$

Subject to the transversality conditions $\nabla \cdot \mathbf{D}=0$ and $\nabla \cdot \mathbf{H}=0$.

For linear non-magnetic dispersionless medium, things simplify a lot.

For example, a 1D waveguide propagating in the $y$-direction with $E_z$ polarization obeys the following equation:

$$E_z''(x) + (k_0^2 \varepsilon(x) -\beta^2)E_z(x)=0,$$ where $k_0=2\pi/\lambda$ and $\beta$ is the propagation constant (related to the effective index).

To simulate this system in Comsol we need to put it into weak-form.

The general weak-form for the Master equation (as Joannopoulous calls it) is:

$$\nabla \times \mathbf E \cdot \nabla \times \mathbf{\bar E} = k_0^2 \varepsilon \mathbf{E} \cdot \mathbf{\bar E},$$ where the bar indicates the test-function and analogous to the $\mathbf H$ field. This expression is just a 'integration by parts'. For our 1D example the weak form is:

$$-E_z'(x)\bar{E}_z'(x) + (k_0^2 \varepsilon(x) -\beta^2)E_z(x)\bar{E}_z(x)=0$$

And can be easily implemented in Comsol.

For the full case where we have the fields propagating in the $z$-direction and the permittivity varies in the $xy$-plane I wasn't able to implement the weak-form due to the transversality condition.

I've tried different approaches such as: Solving for $H_z$ and replacing in the weak-form of the Master equation; I've tried solving for the 6 fields (no second derivatives) since the divergence condition is automatically satisfied; I've tried using constraints to obey the divergence condition. Nothing thus far has produced results, only garbage (spurious solutions).

I don't want to use the default ewfd for two main reasons: due to curl-curl elements, the first derivative of $H_z$ is not defined; and the H fields have lower element order.

Anyone has any idea on how can I implement this?