3

I am trying to write a code to solve a nonlinear BVP using the Finite Difference Method. The BVP is:
$(T^2)\frac{\partial^2 T}{\partial x^2} + T \left( \frac{\partial T}{\partial x}\right)^2 + Q = 0$
The boundary conditions are Dirichlet at $x = 0$ and Robin at $x = L$. The parameter $Q$ is a constant.

My (probably naive) approach is as follows:

  1. Use second-order accurate approximations for the first and second derivatives.
  2. Use the discretized form to generate a system of coupled equations for the spatial points.
  3. Construct a linear system of the form $\mathbf{A}\mathbf{x} = \mathbf{b}$, where $\mathbf{x}$ is a vector of $T$ at each spatial point $x_0, \ldots, x_L$, $\mathbf{A}$ is a matrix of the coefficients of $T$ arising from the discretization, and $\mathbf{b}$ is a solution vector including the source term $Q$.
  4. Solve the linear system for $\mathbf{x}$ somehow, I have not gotten this far.

I really don't know what to do about the nonlinearity. My first problem arises with the squared first derivative. If I apply the finite difference approximation to the first derivative, I get:
$T_i\left(\frac{T_{i+1} - T_{i-1}}{2\Delta x} \right)^2$
Developing the above term yields:
$T_i \left(\frac{T_{i+1}^2-2T_{i+1}T_{i-1}+T_{i-1}^2}{4 \Delta x^2} \right)$

I don't know how to handle this term. I need to linearize something at some point (before or after discretization?) but I am not sure how. And say I figure out a way to handle the squared first derivative, I don't know how to deal with the $T_i$ in front of it.

My question is: how do you discretize and then linearize (or vice-versa) these nonlinear terms?

Thank you for your time. Please let me know if I should elucidate anything.

coffeecake
  • 77
  • 2
  • 10
  • Your math expanding the square is a bit wonky :-) – Wolfgang Bangerth Dec 11 '14 at 03:01
  • 1
    In brief: discretize first. Then you have a nonlinear system of algebraic equations, which you can solve using standard methods. – Geoff Oxberry Dec 11 '14 at 05:02
  • @WolfgangBangerth thanks for catching that. Not sure what I was doing. – coffeecake Dec 12 '14 at 19:05
  • @GeoffOxberry thanks for your comment. That puts me on the right track. I am not familiar with the "standard" methods... any suggestions/starting points? Thanks for your help. – coffeecake Dec 12 '14 at 19:06
  • In order, you probably want to try: Newton's method, quasi-Newton methods, and then things like nonlinear fixed point schemes (e.g., nonlinear CG, nonlinear GMRES). – Geoff Oxberry Dec 12 '14 at 20:26
  • @GeoffOxberry I appreciate your help with this. – coffeecake Dec 12 '14 at 21:39
  • you were trying to solve a nonlinear problem with a linear mindset...look into Newton-Raphson method or its modified versions. – Warrior4just Dec 28 '14 at 09:30
  • @coffeecake, Hi, sorry in advance for any inconvenience since this is not an answer to your problem (since you seem to have solved it, eventually), but I am very very interested in knowing from which situation your problem arise. Could you please explain precisely in which context (configuration,asumptions,...) you have derived such a differential equation? Tank you very much for your reply. Cheers. –  Nov 25 '15 at 16:38
  • @SnowyOwl -- Unfortunately this problem was nothing more than an exercise. I do not know if such an equation actually represents some physical scenario. Sorry. – coffeecake Nov 30 '15 at 16:49

1 Answers1

1

Thanks to the help in the comments I solved the problem. I divided the spatial domain into $N$ grid points and discretized the PDE (without any sort of linearization), which resulted in $N-1$ nonlinear algebraic equations (as Geoff suggested) for the temperature at each grid point.

Then I employed Newton's method (again, as suggested by Geoff):

  1. Implement boundary conditions on the $N-1$ equations
  2. Develop a physically reasonable initial guess $F(x_0)$
  3. Compute the Jacobian of the $N-1$ equations, resulting in an $N-1 \times N-1$ tri-diagonal matrix
  4. Perform Newton iteration to solve for $\Delta T$

The method converged quickly and I am left with the correct temperature distribution.

Thanks for the help with this problem.

coffeecake
  • 77
  • 2
  • 10