0

I am modeling electrical current through various structures with the help of FiPy. To do so, I solve Laplace's equation for the electrical potential. Then, I use Ohm's law to derive the field and with the help of the conductivity, I obtain the current density.

FiPy stores the potential as a cell-centered variable and its gradient as a face-centered variable which makes sense to me. I have two questions concerning face-centered variables:

  1. If I have a two- or three-dimensional problem, FiPy computes the gradient in all directions (ddx, ddy, ddz). The gradient is a FaceVariable which is always defined on the face between two cell centers. For a structured (quadrilateral) grid, only one of the derivates should be greater than zero since for any face, the position of the two cell-centers involved should only differ in one coordinate. In my simulations however, it occurs frequently that more than one of the derivates (ddx, ddy, ddz) is greater than zero, even for a structured grid.
    The manual gives the following explanation for the FaceGrad-Method: Return gradient(phi) as a rank-1 FaceVariable using differencing for the normal direction(second-order gradient).
    I do not see, how this differs from my understanding pointed out above.
    What makes it even more problematic: Whenever "too many" derivates are included, current does not seem to be conserved, even in the simplest structures I model...

  2. Is there a clever way to access the data stored in the face-centered variable? Let's assume I would want to compute the electrical current going through my modeled structure.
    As of right now, I save the data stored in the FaceVariable as a tsv-file. This yields a table with (x,y,z)-positions and (ddx, ddy, ddz)-values. I read the file and save the data into arrays to use it in Python. This seems counter-intuitive and really inconvenient. It would be a lot better to be able to access the FaceVariable along certain planes or at certain points.

lmr
  • 174
  • 2
  • 10
  • How are you determining current continuity? – jeguyer Feb 16 '18 at 17:16
  • I have two external faces where Dirichlet boundary conditions, i.e. the voltage is applied. I compute the total current going in through this boundary and the current going out through the other one. Sometimes these values differ by a few percent which should not be the case... (This goes for simple geometries like a 2d rectangle as well...) – lmr Feb 18 '18 at 20:57
  • How are you computing current? – jeguyer Feb 20 '18 at 13:28
  • Via Ohm's law. Conductivity x grad(potential) = current density – lmr Feb 20 '18 at 18:36
  • Precisely what expression are you using? As illustrated in the Jupyter notebook I referenced in my answer, there are consequences to each of the choices you might make in how you calculate this. – jeguyer Feb 21 '18 at 20:57
  • I am using faceGrad and I evaluate it on a boundary. From the Jupyter notebook, I get that with a conservative boundary condition, only the second term of the faceGrad-expression remains. Since this is a Gaussian gradient evaluated at a cell center, it explains why in certain cases, there might be a difference between the current going through two different boundaries... Thanks again ;) – lmr Feb 22 '18 at 08:18

1 Answers1

1
  1. The documentation does not make it clear, but .faceGrad includes tangential components which account for more than just the neighboring cell center values. Please see this Jupyter notebook for explicit expressions for the different types of gradients that FiPy can calculate (yes, this stuff should go into the documentation: #560).

  2. The value is accessible with myFaceVar.value and the coordinates with myFaceVar.mesh.faceCenters. FiPy is designed around unstructured meshes and so taking arbitrary slices is not trivial. CellVariable objects support interpolation by calling myCellVar((xs, ys, zs)), but FaceVariable objects do not. See this discussion.

jeguyer
  • 2,379
  • 1
  • 11
  • 15
  • That Jupyter notebook is a great resource. FiPy is partly well documented and partly poorly documented. Concerning 2.: I would have thought that it might be possible to access faceVariable data via the x,y,z coordinates since it is possible to export the data in this way. But then, I'll keep on exporting and reimporting. – lmr Feb 18 '18 at 20:54
  • But FiPy doesn't export data by accessing x,y,z coordinates. FiPy exports a table consisting of columns of x, y, z, and value. This is what I showed you how to get. – jeguyer Feb 20 '18 at 13:28