# Solution of algebraic equations

### From Thermal-FluidsPedia

To obtain the temperature distribution for one time step, it is necessary to solve the discretized algebraic equations for all grid points simultaneously. Direct solution of these equations (e.g., using Cramer’s rule) requires a large amount of computational time and storage. If the problem is linear, we only need to solve the set of linear algebraic equations once for every step. If, however, the problem is nonlinear, solving the algebraic equations once only gives us the temperature distribution based on the temporary coefficients of the algebraic equations and several iterations must be performed to get the temperature distribution for one time step. For this case, it is imperative to develop an efficient algorithm to solve the algebraic equations.
A simple but efficient algorithm – line-by-line method – that combines direct method (TDMA) and Gauss-Seidel iteration method will be discussed here (Patankar, 1980). We will demonstrate this method using a two-dimensional conduction problem. The discretized equation *a*_{P}*T*_{P} = *a*_{E}*T*_{E} + *a*_{W}*T*_{W} + *a*_{N}*T*_{N} + *a*_{S}*T*_{S} + *b* from numerical solution of multi-dimensional unsteady-state conduction can be rewritten as

where *i* = 1,2,...*M*,*j* = 1,2,...*N*. The line-by-line method can be performed either in the *x*- or *y*-direction. To apply this method in the *x*-direction, we can choose the *j*_{th} row to apply the TDMA [see Fig. 1(a)]. To do that, it is assumed that the temperature at the (*j* − 1)^{th} and (*j* + 1)^{th} row are known from the previous iteration. For the first iteration at the current time step, they can be taken as values at the previous time step. Equation (1) can then be rewritten as

where ~ represents the values from the previous iteration. If we treat all terms in the parentheses on the right hand of eq. (2) as the constant term, *d*_{i}, in eq. *a*_{i}*T*_{i} = *b*_{i}*T*_{i + 1} + *c*_{i}*T*_{i − 1} + *d*_{i},*i* = 1,2,...*M* from numerical solution of 1-D steady conduction, eq. (2) can be solved using TDMA to get *T*_{ij}, in the *j*_{th} row. We can perform this procedure from *j* = 1to*N* to get the temperature for the whole domain updated. This can also be done in the reverse direction from *j* = *N*to1. The information about the boundary conditions in the *x*-direction can be propagated into the entire domain, but the information on the boundary condition in the *y*-direction can only propagate one grid into the computational domain. To speed up the process, we can also choose the *i*_{th} column to update its temperature using TDMA [see Fig. 1(b)]. In this case, eq. (1) can then be rewritten as

which can be applied either from *i* = 1to*M* or *i* = *M*to1.
The line-by-line method is a combination of direct method (TDMA) and iteration method. Once we complete the procedure along the *x*- direction twice (from*j* = 1to*N* and then from *j* = *N*to1) and along the *y*-direction twice (from*i* = 1to*M* and then from *i* = *M*to1) – referred to as one iteration – the information from boundary conditions on all four sides can be propagated throughout the computational domain. The numerical practices by the authors and other researchers indicate that a converged solution can be obtained after two to four iterations.
The above line-by-line method can be easily extended to the case of three-dimensional heat conduction problem. While our discussion here is for solution of algebraic equations resulting from the discretization of the heat conduction problem, it can also be used to solve the discretized equations for convection problems.

## References

Faghri, A., Zhang, Y., and Howell, J. R., 2010, *Advanced Heat and Mass Transfer*, Global Digital Press, Columbia, MO.

Patankar, S.V., 1980, *Numerical Heat Transfer and Fluid Flow*, Hemisphere, Washington, DC.