# How to force potential boundary conditions in the Yee scheme for solving Maxwell's equations?

Assume that we have a 2D electromagnetic field (in the sense that: $E=(E_x,E_y,0)$, $B=(0,0,B_z)$, and all derivatives with respect to $z$ are $0$), and that we are considering a system made up of two walls at $x=-b$ and $x=b$, held at fixed potential $\phi(y)$, with a third wall at $y=0$ also held at a fixed potential $\phi(x)=1$. The current in our system is $\vec{j} \propto B \times E+\sigma E$.

Using the Yee scheme to solve the Maxwell equations for our system how do I force the fixed potential boundary equations at the walls? Is there another scheme more appropriate for these types of problems?

Interesting question. I would expect the Yee scheme to be indifferent to static (bias) fields induced by constant potentials.

In the electrostatic case, if you have a constant electric potential $\phi$, it induces a field $\vec E = \nabla \phi$. The update equation is (modulo constants) $\frac{d}{dt}\vec B = \nabla \times \vec E$. But since $\vec E$ is a gradient, it lies in the nullspace of curl, so $\frac{d}{dt}\vec B=\nabla \times \nabla \phi= \vec 0$ (that is, $\vec B$ doesn't vary in time).

The elegance of the Yee scheme (and other schemes drawn from Nedelec/Whitney-type elements) is that all of these identities are upheld faithfully after (spatial) discretization. In the discrete setting, your potential $\mathbf v$ will give rise to a static field $\mathbf e = \mathbf G \mathbf v$, where $\mathbf G$ is the sparse stencil induced by the signed vertex-to-edge adjacency. The (semi)discrete update equation is $\frac{d}{dt}\mathbf b = \mathbf C \mathbf e$, where C is the edge-to-facet adjacency. By construction, $\mathbf C \mathbf G = \mathbf 0$, so $\mathbf b$ doesn't vary in time, either. Note, incorporating the gauss law $\nabla \cdot \vec B=0$ basically forces trivial/null $\vec B$ as an initial condition, so when you read "$\vec B$ doesn't vary in time", what you should be really thinking is "$\vec B$ starts as zero and stays that way forever".

My point being, an electrostatic (gradient) field is basically ignored by the scheme, as the curl operator / $\mathbf C$-stencil doesn't "sense" or "measure" it.

All that said, some care is required when you (i) set initial conditions and (ii) incorporate sources, to make sure you do not "source" $\mathbf e$ and $\mathbf b$ in any way that's inconsistent with Maxwell's equations. You should consult literature, people have studied this sort of thing. In particular, that $\vec J$ source term is murky. Most codes I have worked upon use engineering-motivated sources like planewaves and lumped ports. I am not sure how to interpret the role of your volume source .. looks like poynting vector and ohmic conduction? The latter is normally accounted for by directly modifying the $\mathbf e$ updates in a "semi-implicit" fashion, not an explicit source. I don't know what the former term is trying to represent.

• Thanks for the reply. The Poynting vector term comes from assuming that in the frame where $E \mathbin{\|} B$, the velocity of charges is in the direction of the Lorentz boosted electric field, and then boosting back to the original frame. I'm not sure it is much of an issue, since I can still update $E$ semi-implicitly. Could you point me to some literature? Lastly, just to make sure I understood you correctly: if I set initial conditions properly, I do not need to worry about maintaining the potential boundary? – Ben Stokes Oct 5 '17 at 21:01
• If you're looking to model the movement of charged particles, you might want to look into methods beyond the Yee scheme, to "particle-in-cell" approaches. They are basically a fusion of Yee-like algorithm for E/B field updates, plus "pusher" phase to move particles about (due to the E field and the Lorentz force). The motion of the charged particle (a current, ofc) is coupled back into the Yee update as a source term, much like you are saying. That's about all I can say .. never worked on one of these personally, but it sounds more tailored to your problem. – rchilton1980 Oct 6 '17 at 0:38
• I am perhaps speaking beyond my experience, but yes, I think if you were to set initial conditions properly you would not need to expressly impress/maintain the boundary potential. I'd try basically just using a poisson solver, seeking the vertex potentials $\mathbf v$ such that $\mathbf G^T \mathbf G \mathbf v = 0$, subject to the boundary conditions you first prescribed. Once you have $\mathbf v$, I'd then postprocess $\mathbf e = \mathbf G \mathbf v$ and use it for initial conditions. I am not sure if this translates into the PIC environment. – rchilton1980 Oct 6 '17 at 0:47
• Ok, thanks. For now at least I won't need particle in cell, since I'm trying to check an analytical solution derived from simply taking $\rho=\nabla \cdot \vec{E}$, and $\vec{j} = \nabla \cdot \vec{E} \left( B \times E+\sigma E \right)$. I am having an issue where, even with a non-null $\vec{j}$, $\nabla \times \vec{E} = 0$ at all times. Is there a way to regularize my problem so that this doesn't happen? In any case, I'm marking this as solved, since my initial question has been solved. – Ben Stokes Oct 7 '17 at 12:00