Hi Mark,

I'll try an answer your questions inline.

On Wed, Feb 24, 2016 at 5:44 AM, Mark Lundeberg <[email protected]> wrote:
> Hi all,
> I would like to calculate a steady state electrical conductivity problem, in
> a 2D system with position-dependent conductivity tensor. The conductivity
> tensor has all entries nonzero (even off-diagonal) and is antisymmetric
> (Hall effect), lacking real principal axes.
>
> As I understand according to the FAQ this should be possible since spatially
> varying tensor conductivities are supported:
>
> http://www.ctcms.nist.gov/fipy/documentation/FAQ.html

Right, it should work.

> However this still leaves open some questions in practice. I have a few
> questions which are related to each other:
>
>
> 1. Normally (isotropic case) it is best practice to input the diffusion
> coefficient as a FaceVariable. For an anisotropic problem, should I still
> input the rank-2 coefficient as a FaceVariable? I ask because in the FAQ
> linked above, a CellVariable is used.

I believe that FiPy will internally do a linear interpolation to a
FaceVariable from a CellVariable, if you want to have more control
over the calculation of the FaceVarialble (like at discontinuous
internal boundaries) then you might want to use your own custom
calculation for the FaceVariable.

> 2. I want to calculate the flux variable of this problem, which in this case
> is the electric current. To be precise, I want the flux internally used by
> FiPy, which in this case should be divergence-free because my PDE has no
> source terms. The goal is to get the face fluxes and use them to calculate a
> stream function ( https://en.wikipedia.org/wiki/Stream_function ), which
> only works for the divergence free case.
>
> Ideally I think this should work, no?

It's certainly possible to get the fluxes, but the stream function is
more difficult I think. I remember backing out the stream function for
plotting streamlines in previous work with FiPy, but I can't find the
blog posts I wrote about it.

> numerix.dot(conductivity_tensor, voltage.faceGrad)
> but it returns a rank-2 object! Even then, if I were to successfully
> calculate a rank-1 FaceVariable current, I want to be confident that its
> face-normal current is the true divergence-free current.

The following seems to work...

~~~~
import fipy as fp

mesh = fp.Grid2D(nx=3, ny=3)
conductivity_tensor = fp.FaceVariable(mesh=mesh, rank=2)
voltage = fp.CellVariable(mesh=mesh)

area_projections = fp.FaceVariable(mesh=mesh, rank=1)
area_projections[:] = mesh._orientedAreaProjections

print area_projections.dot(conductivity_tensor).dot(voltage.faceGrad).shape
~~~~

it gives a shape of (24,), which I think is what you want for the flux
through each face.

> 3. Can I trust the zero-flux boundary conditions to function in this case?

I believe that the variable constraints carry are taken into account
when you do the `faceGrad` op so yes. I think it will be evident that
something is wrong and in that case you can possibly zero out the
tensor coefficient on the boundary to implement zero flux. See some of
these answers for details on how to do that.

http://article.gmane.org/gmane.comp.python.fipy/1526/match=boundary+conditions
http://article.gmane.org/gmane.comp.python.fipy/852/match=boundary+conditions
http://article.gmane.org/gmane.comp.python.fipy/1800/match=boundary+conditions

> The answers aren't clear since the FiPy documentation doesn't say how tensor
> diffusions are actually implemented; it only covers the isotropic case. I
> understand there are some serious subtleties for nonrectangular meshes, and
> so to make it easy I'm going to stick to a square grid mesh.

That's reasonable. I believe that the anisotropic coefficient is
designed to work on an unstructured mesh, but always proceed with
caution creating small test cases as you go to confirm.

Good luck with it.

-- 
Daniel Wheeler
_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

Reply via email to