Dear all,
I was wondering if there is an error in getGrad() within FiPy. For testing I
solved a really simple 1D differential equation ending up with a linear slope.
The value which I get from getGrad() are ok for all cells, except the ones at
the boundaries, where they are off by a factor of 2. (Surely because the
gradient between the boundary and the cell center should be evaluated and half
the cell size should be used, instead of dx.)

The simple script is looking like:
# BEGIN
from fipy import *
mesh=Grid1D(nx=10,dx=.01)
T=CellVariable(mesh=mesh,value=300.)
eqX=DiffusionTerm(coeff=1.)==0.
valueRight=300.
valueLeft=400.
BCs = (FixedValue(faces=mesh.getFacesRight(), value=valueRight),
       FixedValue(faces=mesh.getFacesLeft(), value=valueLeft))
eqX.solve(var=T,
              boundaryConditions=BCs)
print T.getGrad().getValue()  
print T.getValue()   
############# END

The output is:
    [[ -500.         -1000.         -1000.          -999.99999998
  -1000.00000006  -999.99999983 -1000.00000035  -999.99999949
  -1000.00000049  -500.00000161]]
[ 395.          385.          375.          365.          355.          345.
  335.          324.99999999  315.00000001  304.99999998]   

Could this be corrected?

Regards
Burak 

_______________________________________________
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