On Tue, Feb 18, 2014 at 6:04 PM, Caleb Hattingh
<[email protected]> wrote:
> On 19 February 2014 02:25, Daniel Wheeler <[email protected]> wrote:

> And this continues all the way down into the bottom right-hand
> corner such that J[nx,nx] * dx^2 is again -3.   I found this by using
> perturbation (forward differencing) to calculate the Jacobian
> numerically.  Of course, once I saw the pattern it became obvious
> that I was being a bit silly, and I then set up a finite differencing
> algebraic scheme to check the diagonal (and off-diagonal) entries \
> then it makes perfect sense why this should be so.

Right, the perturbation of the linear diffusion equation is just the
diffusion equation.

> Question: why are the J elements for CV[zero] and CV[nx]
> equal to "-3"?

It depends on the boundary condition. If you have natural boundary
conditions, the values should be -1, but with fixed value, the values
are -3. This is because the distance to the edge is dx / 2.

> I'm missing something very simple probably.  How is the
> discretization for the diffusion term set up (numerically) at the
> boundaries?  I did not find this yet in the FiPy manual.

For natural boundary conditions (fixed flux of 0, Neumann type),
nothing is added to the matrix for the boundary. The left and right
matrix values should then be -1. For fixed value (Dirichlet), the
distance to the edge is dx / 2, so the entry in the matrix is -2 + -1
= -3.

You do have to be careful when deriving the correction equations for
Newton steps. Boundary conditions (what is the correct boundary
condition for the correction value), multiplying through by the cell
volumes as well as using the correct residual can all bite you. It's
sometimes not apparent that you've made a mistake because the solution
will often converge anyway.

-- 
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