# Double sweep method - General case

Consider a reach having n computational cross sections. The system to be solved is then:

• St. Venant’s equations at every interval located between two computational cross sections, at every time instant t,
• upstream and downstream boundary conditions.

Discretization transforms the reach into a series of n computational cross sections connected to each other by the two linear equations  and . One then has 2(n-1) linear equations in DQ and DZ. The two missing equations for the system resolution are provided by the upstream and downstream boundary conditions, that are linearized at each time step.

Upstream boundary condition:

R1.DQ1 + S1.DZ1 = T1

In the case of a Q(t) relation, one has:

R1 = 1, S1 = 0 and T1 = Q(t+Dt) - Q(t)

Downstream boundary condition:

R’n.DQn + S’n.DZn = T’n, with:

= a, R’n = 1, S’n = -a, T’n = 0

A linear system with 2.n equations has to be solved. Instead of inverting the system matrix, the double sweep method is employed.

A11.DQi + A12.DZi = B11.DQj + B12.DZj + B13

A21.DQi + A22.DZi = B21.DQj + B22.DZj + B23

Let us write:

DEN = A11.A22 - A21.A12

DEN is different from zero, because the two equations are linearly independent.

DEN.DQi = (B11.A22 - B21.A12).DQj
+ (B12.A22 - B22.A12).DZj
+ B13.A22 - B23.A12

DEN.DZi = (B21.A11 - B11.A21).DQj
+ (B22.A11 - B12.A21).DZj
+ B23.A11 - B13.A21



with:

A =

B =

C =

D =

E =

F =

Let us examine the linear system for three computational cross sections:

R1S1DQ1T11-D1-E1DZ1F11-A1-B1 .DQ2 =C11-D2-E2DZ2F21-A2-B2DQ3C2R’3S’3DZ3T’3

First sweep:

The first upstream-downstream sweep gives:

R1S1DQ1T11-D1-E1DZ1F1R2S2 .DQ2 =T21-D2-E2DZ2F2R3S3DQ3T3R’3S’3DZ3T’3

For two consecutive sections i and j:

Ri.DQi + Si.DZi = Ti

Ri.(Ai.DQj + Bi.DZj + Ci)

+ Si.(Di.DQj + Ei.DZj + Fi) = Ti

R*j.DQj + S*j.DZj = T*j

with:
R*j = Ri.Ai + Si.Di
S*j = Ri.Bi + Si.Ei
T*j = Ti - Ri.Ci - Si.Fi

The coefficients R*j, S*j and T*j are set by normalizing, in order to avoid the propagation of numerical error.

Rj = etc.

One then has:

Rj.DQj + Sj.DZj = Tj

which is the upstream impedance relation.

At the downstream boundary condition:

which gives us DQn and DZn:

DQn =

DZn =

Then one goes up the second sweep.

Second sweep:

This sweep allows to calculate the DQ and DZ in each computational cross section using the equations .