1
$\begingroup$

This is a follow up to this question. I have a nonlinear BVP on $x=0$ to $L$:
$$ (T^2)\frac{\partial^2 T}{\partial x^2} + T \left( \frac{\partial T}{\partial x}\right)^2 + Q = 0 $$
to which I apply a finite difference discretization. The parameter $Q$ is a constant.There is a Dirichlet boundary condition at $x = 0$ and Robin at $x = L$: $$ (T^2)\frac{\partial T_L}{\partial x} = h(T-T_{\infty}) $$ Where $h$ is a physical constant and $T_{\infty}$ is the ambient temperature. My approach is similar to this using the ghost cell method. I sub-divide the grid into $N$ grid points with subscript indices $0,\ldots,N$ and discretize the Robin bc as follows: $$ (T_N^2)\frac{T_{N+1} - T_{N-1}}{2\Delta x} = h(T_N - T_{\infty}) $$ where $T_{N+1}$ extends beyond the grid to the "ghost cell." Re-arranging: $$ T_{N+1} = \frac{2\Delta xh}{T_N^2}(T_N-T_{\infty}) + T_{N-1} $$ Discretization of the BVP at grid point $N$ (right boundary, $x = L$) yields a nonlinear algebraic equation in function of $T_{N-1},\, T_N,\,T_{N+1}$. I can eliminate $T_{N+1}$ using the discretized Robin bc.

I can use Newton iteration to solve this system and it will work. The equation, however, is complicated and likewise is the Jacobian. Making a mistake when computing the derivatives or even programming seems likely.

My Question: Is there a better or more commonly used way of handling this Robin boundary condition than the ghost cell method (like some sort or linearization of the bc)?

Thanks for any help.

$\endgroup$
1
$\begingroup$

I don't know that it's "better", but you could use one-sided boundary conditions instead.

Variants of Newton's method (e.g., Newton's method, quasi-Newton methods) will take the nonlinear boundary condition and solve a linearized version at each (Newton nonlinear solve) iteration. In that sense, the boundary condition will be linearized; cruder linearizations about a nominal point will probably be less accurate unless the nonlinearity is extremely weak. For example, in your problem, if $|h| \ll 1$ is very small, then you could effectively treat your Robin condition as a Neumann condition.

The equation, however, is complicated and likewise is the Jacobian. Making a mistake when computing the derivatives or even programming seems likely.

Working with indices is definitely challenging, and it is easy to make mistakes. Consider using a computer algebra system (e.g., Sage, SymPy, Mathematica, Maple) to calculate derivatives and limit math errors. In interpreted languages, take advantage of language features that allow you to minimize using indices (for instance, in MATLAB, using arrays and slicing to vectorize your code); writing your code this way sometimes has the added benefit of making it faster (in MATLAB and Python with NumPy, for instance).

That said, I feel that learning to work with indices is an important skill you have to develop. If you have to program in a low-level language, working with indices is unavoidable. In further studies of computational mathematics, indicial notation is not only common, but expected.

This problem is a single PDE in 1-D with cubic nonlinearities. Computational science is rife with more complicated PDEs (e.g., multi-dimensional, coupled systems of PDEs, higher-order or transcendental nonlinearities). It's worth practicing on simpler problems like this one, and learning methods to manage the bookkeeping. It's also worth learning about the method of manufactured solutions so that you can test your discretization and be more confident that you obtain the proper solution and the proper order of convergence of your discretization method. If you test your methods, you can detect programming and derivation errors more easily, and tackle more complicated problems with confidence.

$\endgroup$
  • $\begingroup$ This answer is extremely helpful. I saw another ScicompSE answer where the problem was linearized around a point, as you mentioned, but it seems there are no "shortcuts" for implementing the bc. I will check my work with a computer algebra system and implement this using indices in order to practice. I am relatively new to Numerical Analysis and you have given me some great guidance. I appreciate your time. $\endgroup$ – coffeecake Dec 19 '14 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.