Fixed point iteration applied to Coolebrook-White

Fixed point iteration applied to Coolebrook-White

My first blog post is about the fixed point iteration method. A simple method to solve (implicit) equations iteratively. It is applied to the Colebrook-White equation and solved in a Python script and Excel.

Explicit and implicit functions

An explicit function of the form

(1)   \begin{equation*} y = f(x) \end{equation*}

can usually be solved directly. An implicit function of the form

(2)   \begin{equation*} y = f(x,y) \end{equation*}

may not be solved directly. This is because there is an implicitely defined relationship between the left and right side of the function. Therefore, these functions can be solved iteratively.

Friction factor using Coolebrook-White

The dimensionless friction factor is used to calculate the pressure loss due to friction. The Colebrook-White equation [1, p. 78] can be applied for turbulent flow (\approx 2300 in pipes) and at Reynolds number larger than 4000. The Darcy friction factor f using the Colebrook-White equation is calculated as follows:

(3)   \begin{equation*} \frac{1}{\sqrt{f}}= -2 \cdot \log_{10}\left(\frac{2.51}{Re \cdot \sqrt{f}} + \frac{k}{3.7 \cdot d}\right). \end{equation*}

Necessary Parameters:

  • Reynolds number Re
  • Pipe diameter d
  • Pipe surface roughness k
The friction factor f is on both sides of the equation (implicit dependency).

Solving the equation using Python

Basically, a solution of a previous calculation step is used to recalculate the equation. This is repeated, until it converges. This practically means, that the deviation between the current and the previous solution is lower than an accepted tolerance. There are two termination condition for the loop: the relative deviation to the previous result and a maximum amount of iterations.

Within Python you can solve this equation very easily using the following code.

  • To access basic mathematical operations e.g. log the dependency math is imported.
  • The input parameters are defined.
  • Afterwards, the fixed point iteration function is defined.
  • The Colebrook white equation is defined (Solved for f on the left side).
  • A initial guess value f_{guess} needs to be provided to start the iteration process.
  • The function is called.
#Author: johannes <>, last update: 2017-12-12
#License: MIT License (

import math

# Input parameter
k = 5e-5 #[m]
d = 0.05 #[m]
Re = 50000 #[-]

# Function for fixed point iteration
def fixedPoint(f, x0, rtol=1e-7, maxiter=50):
    e = 1
    it = 0
    while(e > rtol and it < maxiter):
        x = f(x0)
        e = math.fabs((x-x0)/math.fabs(x))
        x0 = x
        it = it + 1
    return x
# Colebrook-White equation for Darcy friction factor    
def fColebrookWhite(x):
   return 1/(-2*math.log10((2.51/(Re*math.sqrt(x))) + (k/(3.7*d))))**2
#Initial guess value
fGuess = 0.5
# Call function
fFriction = fixedPoint(fColebrookWhite, fGuess)

The solution of the friction factor from Python is f = 0.0240207840157.

Stop criteria

I used the relative deviation between the solutions as a stop criteria for the iterations. Hence, the relative deviation is calculated from:

(4)   \begin{equation*} e_{rel} \geq \frac{\norm{x_{k+1} - x_{k}}}{\norm{x_{k+1}}} \end{equation*}

Therefore, I changed the function fixedPoint to fixedPointRes.

#Author: johannes <>, last update: 2017-12-12
#License: MIT License (

import numpy as np
import matplotlib.pyplot as plt

def fixedPointRes(f, x0, rtol=1e-7, maxiter=50):

    it = 0
    e =np.array([1])
    iteration = np.array([0])
    while(it < maxiter and e[it] > rtol):
        x = f(x0)
        e= np.append(e,math.fabs((x-x0)/math.fabs(x)))
        iteration=np.append(iteration, it)
        x0 = x
        it = it + 1
    fig = plt.figure(1)
    fig = fig.add_subplot(111)
    plt.plot(iteration, e,'--', color='red', linewidth=2.0)
    fig.set(xlabel='Iteration', ylabel='Relative deviation')
    return x

The change of the relative deviation is plotted in the following figure.

Residuals of fixed point iteration

Solving the equation using Excel

In Excel the same input data needs to be provided. Again, the solution of the previous calculation step is used to recalculate it. This is repeated until a desired deviation from the previous step is achieved.

Fixed point iteration applied to Colebrook-White in Excel

The solution of the friction factor using Excel is f = 0.02402078.


There is a vast amount of methods to solve (implict) equations iteratively. In this post, a very basic one is presented to make the subject more accessible. The choice of the initial guess values has a strong impact on the number of iterations needed. For some equations it is not easy to find a suitable initial guess value.

Hints regarding Colebrook-White

  • You can find explicit equations which deliver similar results. So no iterations are needed. As a result, you can save computational costs.
  • Finally, don’t confuse Darcy and Fanning friction factor (f_{Darcy} = 4 \cdot f_{Fanning}).


[1] Rennels, D. C., Hudson H. M.: PIPE FLOW A Practical and Comprehensive Guide. John Wiley & Sons, 2012.

What did you think?

I’d like to hear what you think about this post.

Let me know by leaving a comment below.