# Finite difference solver for the 2D Poisson's equation with an integral boundary condition

I wanted to attempt an implementation of a finite-difference-based solver for the 2D elctrostatic Poisson equation when metallic objects are present. Also, I hope to take as input, the location of charges and their magnitude.

For the sake of simplicity, I consider a rectangular domain, inside which I attempt to solve the equation.

Something like so

(The red dots denote charges)

I have the following three points that I wanted to get some advice on:

1) Condition at points on metallic objects:

For the objects (which could be shells or filled), I intend to use the fact that metals are equipotential. To bring this into a matrix equation, what I thought was this: given an object, pick a point in/on it as a reference, and set the potentials of all other points to be equal to the potential of this point.

I am a little lost as to what condition I should use for the point chosen as reference since the Laplace equation does not hold for it. Currently, I am assuming that the Laplace equation holds at these reference points. Is there an alternative way to convey that the object is equipotential?

2) Boundary condition:

I have studied some bit of surface integral equations; if I assume that the potential inside the domain is $$\phi_{1}$$, and outside, it is $$\phi_{2}$$, then the following boundary condition holds:

$$\oint_{S2}[\phi_{2}\nabla g(r,r')-g(r,r')\nabla\phi_{2}]\cdot\hat{n_{2}}dS= -\oint_{S1}[\phi_{2}\nabla g(r,r')-g(r,r')\nabla\phi_{2}]\cdot\hat{n_{1}}dS$$ if $$r'$$ is outside the region enclosed by the two surfaces and the r is inside it or on the boundary. The integration is done w.r.t to the variable $$r$$.

Here, $$g(r,r')$$ is Green's function for the 2D Poisson equation in free space, that is, it satisfies the equation

$$\nabla^{2}g(r,r') = \delta(\lvert r-r'\rvert)$$

For this problem, $$g(r,r') = \frac{1}{2\pi}log(\lvert r-r'\rvert)+C$$

(It is assumed that $$\phi_{1}$$ is zero outside the domain, and that $$\phi_{2}$$ is zero inside the domain. On the common boundary ($$S1$$), they have the same value)

$$\hat{n_{1}}$$ is the normal to the surface $$S_{1}$$ that points into the region outside the volume enclosed by $$S_{1}$$ and $$S_{2}$$.

However, I would appreciate any suggestions for alternative boundary conditions, since this integral makes my otherwise sparse matrix dense.

What I basically want to enforce through this integral is that there is no object or source or anything outside the boundary; i.e. the domain is an artificial limiting of the space under consideration.

Does anyone know of any boundary condition for electric potential that performs the same task, but is something like the Robin BC in electromagnetism?

3) Matrix solver:

Since this problem will generate a sufficiently large (but somewhat sparse) matrix, should I use a direct solver, or should I opt for an iterative solver? From some preliminary implementations I have done for this problem, the matrix is usually $$10000 \times 10000$$ or somewhere of that order; the integral condition makes the matrix dense.

I would greatly appreciate help on this, since I have spent a month on this problem. Also, I am averse to using FEM on this problem, since that is too cumbersome to implement.

In case anyone wants my code for the problem (I have written it in Fortran 2003), I can provide a Google Drive link for that.)

• Also, I welcome any comments on the way in which I have asked the question. This is my first post, so I hope to improve from any advice I get! Jan 25 at 18:50
• Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
– Community Bot
Jan 26 at 0:01
• I am thinking that for the conducting surfaces one should be able to impose the condition that the tangential derivative of Phi along the surface vanishes, and that would force the surface to be equipotential. The condition that there is electric charge inside a conducting surface would amount to an integral constraint expressing the Gauss theorem for this surface. Jan 27 at 3:11