# Implementing temperature depending viscosity in a finite-difference scheme

I have a little question that might be basic for some experts, but right now, its not clear for me. I want to implement temperature depending viscosity in a finite difference scheme (incompressible fluid). Therefore, I get for the viscous term

$\frac{\partial}{\partial x_j} \left( \nu \left(\frac{\partial u_i}{\partial x_j} + \frac{\partial u_j}{\partial x_i}\right) \right)$

Now, I equate this using the product rule (noting that $\nu$ is spatial variable):

$\frac{\partial \nu}{\partial x_j} \left( \frac{\partial u_i}{\partial x_j} + \frac{\partial u_i}{\partial x_j} \right) + \nu \left( \frac{\partial^2 u_i}{\partial x_j \partial x_j} + \frac{\partial^2 u_j}{\partial x_j \partial x_i} \right)$

Making use of Schwarz's theorem, I can switch the cross derivatives in the last term. Because of the incompressibility condition ($\frac{\partial u_i}{\partial x_i} = 0$), I expect the last term to vanish, i.e. ending up with

$\frac{\partial \nu}{\partial x_j} \left( \frac{\partial u_i}{\partial x_j} + \frac{\partial u_i}{\partial x_j} \right) + \nu \frac{\partial^2 u_i}{\partial x_j \partial x_j}$

My question now is rather simple: Is this correct?? I had some doubts since I remember some discussions that in case of temperature dependent viscosity one needs to implement cross-derivatives of the velocity field, and that these cross-derivatives are somehow tricky regarding the order of the numerical scheme. However, I don't need them here and this confuses me.

I would be happy if someone could help me.

Thanks Marius

• This is one of the many reasons that I use a finite element formulation where I can apply the divergence theorem to the first term and be done. – Bill Barth Jun 4 '16 at 14:35

I think there are two parts to your question.

The first part is the correctness of the analytic expression you've written. All of the expressions you've written, as far as I can tell, are correct.

The second part is the correctness (or better, favorableness) of the resulting finite difference discretization. It turns out that different resulting discretizations (e.g. the one you'd get from the first and last expressions) have different conservation properties.

As @Bill Barth suggested, a finite element, or finite volume, approach has nice conservation properties. You can read about different finite difference discretizations and their conservation properties here:

Vasilyev, O. V. High Order Finite Difference Schemes on Non-uniform Meshes with Good Conservation Properties. J. Comput. Phys. 157, 746–761 (2000).

Final conclusion

I suggest you use the first expression, as this will have nice conservation properties.