NETWORKS

Consider the H-shaped network of water pipes in the figure below.  The problem is to find the rate
of flow in certain of the pipes given the flow rate in others.  To do this we arbitrarily assign an arrow and a letter to each pipe.  The letter represents the flow rate and is positive if the flow is in the direction of the arrow.  In our example, there are five flow rates: a, b, c, d and e.  The numbers are labels for the nodes:  exits and entrances of the network as well as places where pipes join.
              1             2
             |  |         |  | 
           a |\/|         |\/| b
             |\/|    c    |\/| 
             |\/|_________|\/|
             |   \ \ \ \ \   |
             | 3 /_/_/_/_/ 4 |
             |  |         |  |
             |\/|         |\/|
           d |\/|         |\/| e
             |  |         |\/|
              5             6
The net inflow of fluid at each node must balance the net outflow, for otherwise fluid would accumulate
there.  Equations which express this conservation of fluid law for our example are:
                 a = c + d   (fluid flowing into Node 3 = fluid flowing out)
             b + c = e              (Node 4)


Suppose we know the fluid flows at the top of the network - for example, suppose a is 10 and b is 12.
Then we have

             d = 10 - c    and      e = 12 + c.
Thus if we know one additional flow rate, we can determine the others.  For example, if the flow in the
cross-connection is c = 2, then the flow rates in the bottom part of the network are d = 8 and e = 14.
If, on the other hand, c = 13, then d = -3 and e = 25,  so there is a backflow along the lower left pipe.

If we know about pressures and resistances in the network, we can easily say more about the flow.  The basic law is

                              
                                                Pressure = Resistance x Flow Rate

We can determine the resistance of a segment of pipe experimentally.  Set up a one unit pressure drop across the pipe segment and then measure the flow rate.  Assume that these measurements have been made (or that resistances have been computed using information about the diameter, length and roughness of the pipe) and that the results are as indicated in the table below:
     -------- Path ---------- Resistance ---------
                a                 1
                b                 2
                c                 5
                d                 1
                e                 1
      ---------------------------------------------
If we measure some of the pressure drops across the network, then we get additional equations from the  following principle:
                                   The pressure drop from node A to node B equals the sum of the
                             pressure  drops along the segments of any path from node A to node B

To see how this works, suppose that the pressure drop from node 1 to node 5 is 40 units and the pressure drop from node 2 to node 6 is 39 units.  Also, assume that the pressure at node 1 equals that at node 2.  Since the pressure drop along each segment is the resistance times the flow rate, we get an equation for each path from the top of the network to the bottom:
              Path ad:   40 = a + d
              Path ace:  30 = a + 5c + e
              Path be:   30 = 2b + e
The path bcd gives the equation 40 = 2b - 5c + d, but this equation is just a combination of the three we already have, so we don't gain or lose anything by including it.  (Start with the equation for path ad.  Use path ace to eliminate a from the equation.  Then use path be to eliminate e.)

The pressure drop equations above, combined with the conservation laws yield five equations in five unknowns:

           a     -  c  - d      = 0
               b +  c      - e  = 0
          a            + d      = 40
          a      + 5c      + e  = 30
              2b           + e  = 30


If the equations are independent (and they are) they will determine all five flow rates.  This 5x5 system could easily be solved by hand, but we will use it to illustrate how to solve a linear system in MATLAB.
We could set up the augmented matrix of this system and have MATLAB do gaussian elimination:

     >> M = [ 1  0  -1  -1   0   0;
              0  1   1   0  -1   0;
              1  0   0   1   0   40;
              1  0   5   0   1   30;
              0  2   0   0   1   30 ]
      >> rref(M)
Alternatively, we could view this system in the form Ax = b, define the coefficient matrix A and the vector b in MATLAB and use the backslash operator to solve for the flow rates:
 
      >> A = [1  0  -1  -1   0; 0  1   1   0  -1;
              1  0   0   1   0; 1  0   5   0   1;
              0  2   0   0   1]
      >> b = [ 0; 0; 40; 30; 30]
      >> x = A\b
Remark:  Numerically the backslash  method is more efficient so with large matrices it is preferred.  The backslash operator  in MATLAB uses the LU decomposition of the matrix A to solve the system.  The LU decomposition is computed essentially by transforming A into an upper triangular matrix U via elementary row operations  (thus starting in the same way as solving by finding the row reduced echelon form for A).  Simultaneously this sequence of row operations is used to construct a lower triangular matrix L with the property that A = LU.  This system can be easily solved by back-substitution and forward-substitution.  When working with systems with thousands of equations, it becomes essential to consider the efficiency of the method, taking advantage of any shortcut that reduces the number of numerical calculations needed to solve.

Consider the network described in the figure below:
 

                            1
                          |  | 
                          |\/| a
                     b    |\/| 
              ____________|  |
             |     / /       |
             | 3 __\_\____  2|
             |  |         |  |
             |\/|         |\/|
           c |\/|         |\/| h
             |  |_________|  |
             |     \ \       |
             | 4 __/_/____  5|
             |  |    i    |  |
             |\/|         |\/|
           d |  |         |  | g
             |\/|         |\/|
             |  |_________|  |
             | 7   / /     6 |
             |   __\_\_______|
             |  |    f
             |\/|
           e |\/|
             |  |
               8
Exercise 1  Find the flow rates in the network, assuming that all the resistances are 1 and the pressure drop from top to bottom is also 1.

Exercise 2  Find the flow rates assuming that all the resistances are 1 and the pressure drop from top to bottom is now 2.

Exercise 3  Find the flow rates assuming that the resistance of edge b is 1/2 instead of 1 and the pressure drop is 1.

Exercise 4  Suppose we turn off the resistance in our network - that is, set them to 0 to describe a superfluid (like liquid helium near absolute zero).  Suppose further that the flow in the top and out the bottom is zero.  Describe all possible fluid flows, both mathematically and physically.