# Implementing a potential problem with a current condition

@raboynics, not sure I understand what you are saying. For a 1D problem, the current on a boundary will indeed determine the voltage, but for 2D problems, knowing the total current through an electrode is a scalar constraint and can only determine a voltage if the voltage is also a scalar. Thus for a 2D problem, we must assume in addition that the voltage along the boundary in question is constant. This is why specifying total current is insufficient information to alone determine the voltage on the boundary.

I wasn’t able to find any of the codes you referred to above. Can you send them to me or send me a link to them?

Well, yes and no. My ‘‘old’’ code used to apply a vanishing Dirichlet b.c. to one of the 2 surfaces, and a Neumann boundary term at another surface to specify the magnitude of the escaping current. What I obtained was the same input and output currents through the 2 surfaces, which was good, and is possibly enough for your case.

In my case it was not perfectly good because of thermoelectric effect, where I also apply conditions on temperature on those surfaces, while experimentally a known current passes. The real solution (i.e. what really happens physically) is that the voltage isn’t quite constant along the input and output surfaces in my case, this is why I went purely for Neumann b.c.s for the voltage, but I do have to specify b.c.s for the temperature, which is coupled to voltage. I am not in front of a computer, so it’s hard for me to dig my code from previous posts. But for example the MWE I posted less than 24 hours ago about.the curl would be such an example.
Look at my weak form part ‘‘F_V’’.

I just skimmed through the thread and not sure if I absorbed everything so apologies for repetition.

In the past, I used to have these floating electrodes (I=J=0). The straightforward solution in my knowledge is given here but as pointed out is not applicable in dolfinx yet due to lack of real elements.

As a workaround, I managed to do fine by replacing the electrode boundary with a thin shell of very high conductivity. While I had a J=0 (i.e. natural boundary) condition, I presume it should not break things if one wants to specify a different Neumann condition.

No guarantees that it works but I think it is worth a try. If it helps, it will probably be the best workaround. The problem remains linear and the additional film of electrode has uniform potential which does not require a fine mesh.

I agree that the problem is a lack of real elements in dolfinx. It might help to introduce a third electrode in the above problem on a subset of the upper boundary, because this will introduce an asymmetry in the current distribution on Gamma2. When you replace the electrode boundary Gamma2 with a thin shell of very high conductivity, are you imposing the condition J=0 pointwise (like a Neumann condition)? If so, that’s a problem, because the local current distribution on Gamma2 will be nonzero. Only its integral on Gamma2 vanishes for you. So where and how do you impose the constraint J=0? Can you do that at a single point in the shell?

Adding a thin shell of high conductivity does not impose anything on J by itself. The latter is done by the physics (i.e. weak form) and you have a choice whatever you like to do there. The thin shell only ensures that the potential has the right distribution as would actually be present in the metallic electrode given the geometrical interface with outside.

I worked with J = -\sigma \partial V/\partial n=0 (V is potential), which also happens to be the natural boundary condition of the weak form. You can define a different Neumann boundary condition following standard methods in dolfinx with whatever distribution of J you need on the boundary.

With that said, a point J appears to be tricky if the electrode itself is just a point. In that case I do not see how the shell can mimic the real geometry and so this approach will not work.

@sbhasen, you are right. If you only want to impose zero total current on the thin shell, then you can treat the exterior of the shell (that part that is not adjacent to the main domain) as insulating. However, this approach breaks down if you want to impose a nonzero total current on the electrode.

Right now I am trying to do another approach, but I’m not sure I can get this to work. As you noted, we are unable to use real elements, but why not define a separate interval [0,1] and use one linear element on this interval? Instead of a real element, this becomes a vector element of dimension 2, which is not that big an increase in matrix size. Now I will try to define the voltage as a constant on this separate interval and impose a total current condition on the boundary of the main domain to determine the voltage on the separate interval. My knowledge of FEniCSx is perhaps too primitive, and this might not work.

After trying this for a while, I am convinced that it won’t work, and I am abandoning it.

I’ve just revised my codes, and I believe that manually setting the input/output electric current is enough to fully determine the electrostatic potential (voltage), up to a constant, of course. You can find such a MWE code at Lost with boundary conditions in ME spaces Daniel. Let me know what you think.

I do get consistent results (Ohm’s law safisfied), when I integrate the current density over the input and output surfaces I do get the correct current I have set. And I do get the full electrostatics potential field figured out everywhere, including on the boundaries, and it is far from being constant in my case (mixed element, coupling with temperature).