OnTheContrary
OnTheContrary

Reputation: 204

FiPy interior conducting boundary conditions

I am a newcomer to FiPy and I am solving the Poisson's equation for the potential inside a 3D volume. It works fine for surface boundary conditions but now I need to place a conductor inside. This will be a constant potential surface and I realize that you cannot use potential.constrain for interior surfaces.

The documentation suggests using an ImplicitSourceTerm along with a mask defining the surface, but it is not evident how this can be used to constrain the potential to be constant, or equivalently to constrain the electric field to be perpendicular to the surface. Is this possible?

Thanks for any help.

Upvotes: 1

Views: 591

Answers (1)

jeguyer
jeguyer

Reputation: 2484

The discussion at http://www.ctcms.nist.gov/fipy/documentation/USAGE.html#applying-internal-boundary-conditions describes exactly what you are trying to do. I think I know why it might not have worked for you, though. When declaring an ImplicitSourceTerm, FiPy has to be careful not to add negative values to the diagonal of the matrix, so it examines the signs of the coefficients of the ImplicitSourceTerm and compares them to the signs of the diagonal elements form the DiffusionTerm (and others) that have already been put in the matrix; if the signs are opposite, then FiPy treats those cells explicitly (puts everything on the RHS vector).

If you declare your equation (like I initially did) as

eq = (fp.DiffusionTerm(coeff=dielectric) + charge ==   
      conductor * largeValue * conductorPotential
      - fp.ImplicitSourceTerm(coeff=conductor * largeValue)

then everything about the conductor gets put on the RHS vector and the implicit solver never "sees" it. If you reverse the order of the last two terms, then conductor * largeValue gets put on the matrix diagonal and conductor * largeValue * conductorPotential gets put on the RHS and the solution for these cells becomes dominated by conductorPotential.

In short, what I'm saying is that it matters (to FiPy (in this case)) whether you say

V == conductorPotential

or

conductorPotential == V

I posted an IPython notebook at https://gist.github.com/guyer/a61d5adfa9a050eb970a

Upvotes: 2

Related Questions