Hi Andy,

On Feb 4, 2008, at 11:22 AM, asreeve wrote:

I'm a little confused about results I'm getting from getDivergence in a FiPy script.

I've created a triangular mesh with gmsh and extruded it with fipy. I'm solving a simple diffusion equation, with a diffusion coefficient that varies spatially, and running the model to a steady-state condition. In my current test, I'm just varying the diffusion coefficient assigned to a cell based on a uniform random distribution (from 0.5e-5 to 1.5e-5).

At the end to the simulation, I calculate the the diffusive fluxes across cell faces based on Fick's Law. To check for mass-balance errors, I calculate the divergence in the cells. As you know, the divergence under steady-state conditions should be zero (or a very tiny number). However, when I do this in FiPy the divergences are relatively large (about 1e-7).


I've also run (and commented out in the script) a scenario with a regular mesh and this seems to yield better results (internal cells with a divergence of 1.e-18). The equation also works fine if Diff doesn't very spatially.


I'll take a closer look at your script as soon as I have the chance, but in my own research just in the past few days, I've encountered some problems with the sign of .getFaceGrad(), specifically on GmshImporter2D meshes. Other meshes don't exhibit this problem, and other results of my calculations are completely consistent between simulations on Grid1D, Grid2D, and GmshImporter2D meshes, apparently unaffected by the sign error in this one function. In your 3D case, if the signs of Flux were /all/ flipped, then you should still get essentially zero divergence, but because of the way the mesh extruded, it would not surprise me to learn that the "in-plane" faces have opposite signs from the "end" faces, or something like that, which would result in imperfect canceling.

Definitely something we need to resolve; rest assured that I'm working on it (Daniel is goofing off in Old Blighty).



Am I calculating the diffusive flux correctly?

Looks fine to me.


Reply via email to