solving scale linear systems ( example system continued )

28
Solving Scale Linear Systems ( Example system continued ) Lecture 14 MA/CS 471 Fall 2003

Upload: raisie

Post on 09-Jan-2016

27 views

Category:

Documents


2 download

DESCRIPTION

Solving Scale Linear Systems ( Example system continued ). Lecture 14 MA/CS 471 Fall 2003. Today. We will discuss direct methods for a slightly larger loop current problem as introduced last time. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Solving Scale Linear Systems  ( Example system continued )

Solving Scale Linear Systems (Example system continued)

Lecture 14

MA/CS 471

Fall 2003

Page 2: Solving Scale Linear Systems  ( Example system continued )

Today

• We will discuss direct methods for a slightly larger loop current problem as introduced last time.

• Then we will look at a much larger problem and examine the memory/work requirements for direct methods.

Page 3: Solving Scale Linear Systems  ( Example system continued )

Note• It is important that at least one loop has a

resistor that lies only on that loop (i.e. at least one resistor lying on a wire not shared by two loops).

• Otherwise the entire circuit will short circuit around the boundary of the entire circuit..

• For example:

4

3

21

6

7

+-

1

1

2 3

45

89

4

3

21

6

7

+-

1

1

2 3

45

89

Page 4: Solving Scale Linear Systems  ( Example system continued )

Circuit Problem

Enlarged

Problem: Find the current running through each closed loop

1

4

3

2 1

5

6

7

30V +-

1

4

3

21

5

6

7

20V +-

1

4

3

21

5

6

7

10V +-

2 1

1

2 3

45

6

7

89

10

11

12

14

15

16

17

13

Page 5: Solving Scale Linear Systems  ( Example system continued )

Shortcut to Loop Current

MatrixTo obtain the n’th row of the Matrix:1) The diagonal entry is equal to

the sum of the resistances on the n’th loop

2) There is an off diagonal entry foreach neighbor of the loop which is equal to:a) –sum(resistances) on shared wire if loop currents are in opposite direction b) sum(resistances) on shared wire if loop currents are in the same direction

1

4

3

2 1

5

6

7

30V +-

1

4

3

21

5

6

7

20V +-

1

4

3

21

5

6

7

10V +-

2 1

1

2 3

45

6

7

89

10

11

12

14

15

16

17

13

Page 6: Solving Scale Linear Systems  ( Example system continued )

1

4

3

2 1

5

6

7

+-

1

4

3

21

5

6

7

+-

1

4

3

21

5

6

7

+-

2 1

1

2 3

45

6

7

89

10

11

12

14

15

16

17

1 7 2 0 0 3 0 1 0 0 0 0 0 0 0 0 0 0

2 2 7 1 0 0 0 0 0 0 4 0 0 0 0 0 0 0

3 0 1 12 0 0 0 0 0 0 0 0 0 0 0 6 0 0

4 0 0 0 13 7 0 0 6 0 0 0 0 0 0 0 0 0

5 3 0 0 7 14 0 0 0 4 0 0 0 0 0 0 0 0

6 0 0 0 0 0 13 0 0 0 0 0 0 0 0 0 7 6

7 1 0 0 0 0 0 7 0 0 1 3 2 0 0 0 0 0

8 0 0 0 6 0 0 0 12 1 0 0 0 0 0 0 0 0

9 0 0 0 0 4 0 0 1 7 0 0

10

11

12

13

14

15

16

17

0 0 0 0 0 0

0 0 0 0 0 0 1 0 0 6 0 0 0 2 0 3 0

0 4 0 0 0 0 3 0 0 0 14 0 0 0 7 0 0

0 0 0 0 0 0 2 0 0 0 0 7 0 0 0 4 1

0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0

0 0 0 0 0 0 0 0 0 2 0 0 1 3 0 0 0

0 0 6 0 0 0 0 0 0 0 7 0 0 0 13 0 0

0 0 0 0 0 7 0 0 0 3 0 4 0 0 0 14 0

0 0 0 0 0 6 0 0 0 0 0 1 0 0 0 0 12

13

Page 7: Solving Scale Linear Systems  ( Example system continued )

1 7 2 0 0 3 0 1 0 0 0 0 0 0 0 0 0 0

2 2 7 1 0 0 0 0 0 0 4 0 0 0 0 0 0 0

3 0 1 12 0 0 0 0 0 0 0 0 0 0 0 6 0 0

4 0 0 0 13 7 0 0 6 0 0 0 0 0 0 0 0 0

5 3 0 0 7 14 0 0 0 4 0 0 0 0 0 0 0 0

6 0 0 0 0 0 13 0 0 0 0 0 0 0 0 0 7 6

7 1 0 0 0 0 0 7 0 0 1 3 2 0 0 0 0 0

8 0 0 0 6 0 0 0 12 1 0 0 0 0 0 0 0 0

9 0 0 0 0 4 0 0 1 7 0 0

10

11

12

13

14

15

16

17

0 0 0 0 0 0

0 0 0 0 0 0 1 0 0 6 0 0 0 2 0 3 0

0 4 0 0 0 0 3 0 0 0 14 0 0 0 7 0 0

0 0 0 0 0 0 2 0 0 0 0 7 0 0 0 4 1

0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0

0 0 0 0 0 0 0 0 0 2 0 0 1 3 0 0 0

0 0 6 0 0 0 0 0 0 0 7 0 0 0 13 0 0

0 0 0 0 0 7 0 0 0 3 0 4 0 0 0 14 0

0 0 0 0 0 6 0 0 0 0 0 1 0 0 0 0 12

Using Sparse Matrices in Matlab

Page 8: Solving Scale Linear Systems  ( Example system continued )

Run bigcircuit1) Create the list of non-zeros2) Convert the list to Matlab’s sparse matrix format3) Convert the sparse matrix to a full matrix (just for viewing)

Page 9: Solving Scale Linear Systems  ( Example system continued )

Counting the Non-Zeros with nnz

• We can use Matlab’s built in nnz function to find the number of non-zeros:

i.e. there are only 58 non-zero entries out of 17x17=289 possible

Page 10: Solving Scale Linear Systems  ( Example system continued )

Now We LU Factorize The Sparse Matrix

• Since there are only a few degrees of freedom we will use a direct method to factorize and solve the system.

• We can use the built in LU factorization of the matrix…

• i.e. find two matrices L & U such that A=LU where L is logically lower triangle and U is logically upper triangle..

Page 11: Solving Scale Linear Systems  ( Example system continued )

LU Factorization of Loop Current Matrix

Page 12: Solving Scale Linear Systems  ( Example system continued )

Solving The System

• Now we have factorized the system into A=LU we can solve in three stages.

1) Build the source vector, v

2) Solve y = L\v

3) Solve for the currents I = U\y

Page 13: Solving Scale Linear Systems  ( Example system continued )

1

4

3

2 1

5

6

7

+-

1

4

3

21

5

6

7

+-

1

4

3

21

5

6

7

+-

2 1

1

2 3

45

6

7

89

10

11

12

14

15

16

17

13

30V

20V

10V

Solving for the loop currents using an LU factorization

Page 14: Solving Scale Linear Systems  ( Example system continued )

1

4

3

2 1

5

6

7

+-

1

4

3

21

5

6

7

+-

1

4

3

21

5

6

7

+-

2 1

1

2 3

45

6

7

89

10

11

12

14

15

16

17

13

30V

20V

10V

Solving for the loop currents using an LU factorization

Page 15: Solving Scale Linear Systems  ( Example system continued )

Let’s Renumber

• Matlab has a built in routine symrcm which takes a symmetric matrix and returns a permutation array so that if we use this to permute the unknowns (by column and row swaps) the bandwidth of the matrix may be reduced…

Page 16: Solving Scale Linear Systems  ( Example system continued )

Renumbering with symrcm

Page 17: Solving Scale Linear Systems  ( Example system continued )

How Were The Loops Renumbered

• We can examine the permutation matrix:

• i.e. the old 13 cell becomes the new 1 cell

• 6->2, 14->3…

Page 18: Solving Scale Linear Systems  ( Example system continued )

1

4

3

2 1

5

6

7

+-

1

4

3

21

5

6

7

+-

1

4

3

21

5

6

7

+-

2 1

1

2 3

45

6

7

89

10

11

12

14

15

16

17

13

1

4

3

2 1

5

6

7

+-

1

4

3

21

5

6

7

+-

1

4

3

21

5

6

7

+-

2 1

13

12 10

1514

2

11

1716

7

9

8

3

6

4

5

1

Page 19: Solving Scale Linear Systems  ( Example system continued )

Let’s Figure Out the Sequence of

Shells in symrcm

1

4

3

2 1

5

6

7

+-

1

4

3

21

5

6

7

+-

1

4

3

21

5

6

7

+-

2 1

13

12 10

1514

2

11

1716

7

9

8

3

6

4

5

1

Level 1

Level 2

Level 3

Level 4

Level 5

Level 6

Page 20: Solving Scale Linear Systems  ( Example system continued )

Let’s Try LU Factorization of the Reordered Matrix

Page 21: Solving Scale Linear Systems  ( Example system continued )

Effect of Reordering

Before

After

Page 22: Solving Scale Linear Systems  ( Example system continued )

Notes• We could have also used Cholesky

factorization (since the loop current matrix is symmetric).

• Just by reordering unknowns we have changed the amount of fill in the L,U factors of the matrix.

• Changing the ordering of cells will not change the answer (beyond round off).

• However, we have reduced the amount of work required in the backsolves.

Page 23: Solving Scale Linear Systems  ( Example system continued )

Solving The Reordered System

Page 24: Solving Scale Linear Systems  ( Example system continued )

Comparing The Results• We can compare the results from solving using the

original matrix and using the reordered matrix:No reordering With reordering

Page 25: Solving Scale Linear Systems  ( Example system continued )

OK – Let’s Get Serious And Look At A Large Circuit Case

We can construct a random circuit:

Page 26: Solving Scale Linear Systems  ( Example system continued )

The Sparsity Pattern of a Loop Circuit Matrix for a Random Circuit (with 1000 closed loops)

Page 27: Solving Scale Linear Systems  ( Example system continued )

Notes

• For a more realistic circuit (i.e. with less random interconnects) the fill in the L & U matrices will be reduced more after reordering using RCM

Page 28: Solving Scale Linear Systems  ( Example system continued )

Lab Task• Construct a more realistic “random” circuit for an arbitrary N (i.e.

design a process which randomly grows a circuit). Use an interconnect of say 4 per cell on average.

• Time how long the LU factorization takes for N=10,100,1000,1e4,1e5,1e6,1e7,1e8and plot a graph of time v. N

• Calculate the number of non-zeros (i.e. how much memory is taken by the L & U matrices). Plot this as a function of N.

• Solve with a random source vector for N=10,100,…,1e6 and time how long the backsolves take and plot a graph of time v. N

• Perform a polynomial fit of the timings (estimate the polynomial growth rate with N)…

• USE SPARSE MATRICES!. You can use Cholesky if you wish.