Solution to Homework Problems for April 12

Total Page:16

File Type:pdf, Size:1020Kb

Solution to Homework Problems for April 12

College of Engineering and Computer Science Mechanical Engineering Department Mechanical Engineering 692 Computational Fluid Dynamics Spring 2010 Number: 17535 Instructor: Larry Caretto Solution to Homework Problems for April 12

Equation 5.19 in the text is a set of five equations in five unknowns that can be simply solved by direct methods. The solution to the equations is given by equation 5.20 in the text. In this homework assignment, you will use this solution set to demonstrate the application of iterative solution techniques. Each problem below asks for the same information using three different iteration techniques. We can rewrite each equation set in the following form for iteration.

1.1 .45 9 1.1 n1  2  2  1 1.55 31 1.55 .55  .45 n1  0  1 3  55  .45 2 1 1 3 .55  .45 n1  0  2 4  55  .45 3 1 2 4 .55  .45 n1  0  3 5  55  .45 4 1 3 5 .55 11 n1  0  4  4 5 1.45 29 The n+1 superscript for the variables on the left side of the equation indicates that we are solving for the variables at the new iteration. The superscripts on the right side will change as we change the iteration method. 1. Use the Jacobi method, with initial guesses of zero for all the variables, to iterate on the solution. 0 0 0 0 0 Taking initial guesses equal to zero gives 1  2  3  4  5  0 as the initial guesses (the values for iteration zero). In the Jacobi method all the variables on the right hand side are taken as those of the previous iteration. Thus we can rewrite our general solution algorithm as follows for the Jacobi method. 9n 1.1 11n n1  2  n1  55n  .45n n1  55n  .45n n1  55n .45n n1  4 1 31 1.55 2 1 3 3 2 4 4 3 5 5 29 (a) Determine the residuals in each equation before any iterations are done. What is the maximum residual?

Jacaranda (Engineering) 3333 Mail Code Phone: 818.677.6448 E-mail: [email protected] 8348 Fax: 818.677.7062 April 12 homework solutions ME 695, L. S. Caretto, Spring 2010 Page 2

N The residuals in the set of linear equations  aij j  bi can be defined as follows: j1 N ri  bi   aij j . Note that we are concerned about the magnitude, not the sign of the j 1

N residuals so that the following definition would also be appropriate: ri   aij j  bi . j 1 Applying this equation for the residuals to our original set of equations gives the following results for the residual at any iteration, n. n n 2 n n r1  1.551 .452  1.1 1.11.551 .452 n n n n n n n r2  .551 12 .453  0  551  2 .453 n n n n n n n r3  .552 13 .454  0  552  3 .454 n n n n n n n r4  .553 14 .455  0  553  4 .455 n n n n n r5  .554 1.455  0  .554 1.455 0 0 0 0 0 For out initial guess that 1  2  3  4  5  0 , we can see that the residual for the first 1 equation is r1 = 1.1 and the remaining residuals are zero. We can write this set or residuals as the vector r0 = [1.1,0 0,0 0]T. The maximum residual is 1.1. (b) Take three iterations. At the end of these three iterations determine the following items: (i) the residual in each equation, (ii) the maximum residual, (iii) the ratio of the maximum residual just found to the maximum residual before the start of iterations, (iv) the maximum change in a variable, and (v) the maximum relative change in a variable. 0 0 0 0 0 Using the initial guesses that 1  2  3  4  5  0 in our iteration equations for the Jacobi method gives the following results for the first three iterations. 90 1.1 90 1.1 1  2     0.7097 1  .550  .450  .550 .450  0 1 31 1.55 31 1.55 2 1 3 110 110 1  .550  .450  .550 .450  0 1  .550  .450  .550 .450  0 1  4   0 3 2 4 4 3 5 5 29 29 91 1.1 90 1.1 2  2     0.7097 2  .551  .451  .550.7097 .450  0.3903 1 31 1.55 31 1.55 2 1 3 111 110 2  .551  .451  .550 .450  0 2  .551  .451  .550 .450  0 2  4   0 3 2 4 4 3 5 5 29 29 92 1.1 90.3903 1.1 3  2     0.8230 3  .552  .452  .550.7097 .450  0.3903 1 31 1.55 31 1.55 2 1 3 112 110 3  .552  .452  .550.3903 .450  0.2147 3  .552  .452  .550 .450  0 3  4   0 3 2 4 4 3 5 5 29 29 At the end of the third iteration the residuals are found from the residual equations. April 12 homework solutions ME 695, L. S. Caretto, Spring 2010 Page 3

3 3 3 r1 1.11.551 .452 1.11.550.8230.450.3903  0 3 3 3 3 r2  .551  2 .453  .550.8230 .3903.45.2147  0.1589 3 3 3 3 r3  .552  3 .454  .550.3903 0.2147.450  0 3 3 3 3 r4  553  4 .455  .550.2147 0.450  .1181 3 3 3 r5  .554 1.455  .5501.450  0 The maximum residual is seen by inspection to be 0.1589. Dividing this by the maximum residual of 1.1 before the iterations are started gives the maximum relative residual of 0.1589/1.1 = 0.1445. The changes and relative changes in the variables between the last two iterations are found as follows.

3 2 3 2 3 1  1  .8230  .7097  0.1133 1  1 1  0.1133 0.8230  0.1367 3 2 3 2 3 2  2  .3903.3903  0 2  2 2  0 0.3903  0 3 2 3 2 3 3  3  .2147  0  0.2147 3  3 3  0.2147 0.2147 1 3 2 3 2 3 4  4  0  0  0 4  4 4  0 0 3 2 3 2 3 5  5  0  0  0 5  5 5  0 0

By inspection the maximum residual of 0.2147 and the maximum relative residual of 1 both occur

for the variable3. 2. Use the Gauss-Seidel method, with initial guesses of zero for all the variables, to iterate on the solution. For the Gauss-Seidel method we use the most recent iteration values. This gives the following algorithm for the iterations.

9n 1.1 11n1 n1  2  n1  55n1  .45n n1  55n1  .45n n1  55n1  .45n n1  4 1 31 1.55 2 1 3 3 2 4 4 3 5 5 29 (a) Determine the residuals in each equation before any iterations are done. What is the maximum residual? With the same initial guesses, the initial set of residuals, before any iteration occurs, will be the same for all methods. Thus the initial residuals for the Gauss-Seidel method will be the same as those of the Jacobi method: r0 = [1.1,0 0,0 0]T. The maximum residual is 1.1. (b) Take three iterations. At the end of these three iterations determine the following items: (i) the residual in each equation, (ii) the maximum residual, (iii) the ratio of the maximum residual just found to the maximum residual before the start of iterations, (iv) the maximum change in a variable, and (v) the maximum relative change in a variable. 0 0 0 0 0 Using the initial guesses that 1  2  3  4  5  0 in our iteration equations for the Jacobi method gives the following results for the first three iterations. April 12 homework solutions ME 695, L. S. Caretto, Spring 2010 Page 4

90 1.1 90 1.1 1  2     0.7097 1  .551  .450  .550.7097 .450  0.3903 1 31 1.55 31 1.55 2 1 3 1 1 0 1 0 0 3  .552  .454  .550.3903 .450  0.2147 4  .553  .455  .550.2147 .450  0.1181 110 110.1181 1  4   0.04479 5 29 29 91 1.1 90.7097 1.1 2  2     0.8230 2  .552  .451  .550.8230 .450.2147  0.5493 1 31 1.55 31 1.55 2 1 3 2 2 1 2 2 1 3  .552  .454  .550.5793 .450.1181  0.3552 4  .553  .455  .550.3552 .450.04479  0.2155 112 110.2155 2  4   0.08175 5 29 29 92 1.1 90.5493 1.1 3  2     0.8691 3  .553  .452  .550.8991 .450.3552  0.6379 1 31 1.55 31 1.55 2 1 3 3 3 2 3 3 2 3  .552  .454  .550.6379 .450.2155  0.4478 4  .553  .455  .550.4478 .450.08175  0.2831 113 110.2831 3  4   0.1074 5 29 29 At the end of the third iteration the residuals are found from the residual equations. 3 3 3 r1 1.11.551 .452 1.11.550.8691.450.6379  0.03988 3 3 3 3 r2  .551  2 .453  .550.8691 0.6379.450.4478  0.04167 3 3 3 3 r3  .552  3 .454  .550.6379 0.4478.450.2831  0.03040 3 3 3 3 r4  553  4 .455  .550.4478 0.2831.450.1074  .01153 3 3 3 r5  .554 1.455  .550.2831.450.1074  0 The maximum residual is seen by inspection to be 0.04167. Dividing this by the maximum residual of 1.1 before the iterations are started gives the maximum relative residual of 0.04167/1.1 = 0.03788. The changes and relative changes in the variables between the last two iterations are found as follows.

3 2 3 2 3 1  1  0.8691 0.8230  0.0461 1  1 1  0.04613 0.8691  0.05304 3 2 3 2 3 2  2  0.6379  0.5493  0.0886 2  2 2  0.0886 0.6379  0.1389 3 2 3 2 3 3  3  0.4478  0.3552  0.0926 3  3 3  0.09267 0.4478  0.2068 3 2 3 2 3 4  4  0.2831 0.2155  0.0676 4  4 4  0.0676 0.2831  0.2388 3 2 3 2 3 5  5  0.1047  0.08175  0.0136 5  5 5  0.0136 0.2192

By inspection the maximum residual of 0.2388 occurs for 3 and the maximum relative residual of

0.2388 occurs for the variable4. 3. Use the successive over relaxation with a relaxation factor,  = 1.2 and initial guesses of zero for all the variables, to iterate on the solution. For successive overrelaxation (SOR), the general formula is that we take the old iteration value, n and add to this the difference between the Gauss-Seidel calculation of the new value, n+1,GS – April 12 homework solutions ME 695, L. S. Caretto, Spring 2010 Page 5

n times the relaxation factor, . That is, n+1 = n + (n+1,GS – n) = n+1,GS + (1 – )n. Applying this general result to each of the Gauss-Seidel iteration equations above gives the following results for our SOR iterations. The first equation in each line below is for a general relaxation factor, , and the second equation is for the specific value of  = 1.2 for this problem.

 9n 1.1   9n 1.1  n1   2    1  n  1.2 2    0.2n 1     1   1  31 1.55   31 1.55  n1 n1 n n n1 n n 2  .551  .453  1 2  1.2.551  .453  0.22 n1 n1 n n n1 n n 3  .552  .454  1 3  1.2.552  .454  0.23 n1 n1 n n n1 n n 4  .553  .455  1 4  1.2.553  .455  0.24 11n1 11n1 n1   4  1 n  1.2 4  0.2n 5 29 5 29 5 (a) Determine the residuals in each equation before any iterations are done. What is the maximum residual? As noted in the solutions for the Gauss-Seidel iterations, the initial set of residuals, before any iteration occurs, will be the same for all methods, using the same initial guesses. Thus the initial residuals for the SOR method will be the same as those in the two previous methods: r0 = [1.1,0 0,0 0]T. The maximum residual is 1.1. (b) Take three iterations. At the end of these three iterations determine the following items: (i) the residual in each equation, (ii) the maximum residual, (iii) the ratio of the maximum residual just found to the maximum residual before the start of iterations, (iv) the maximum change in a variable, and (v) the maximum relative change in a variable. Using the iterations equations above, the first three iterations are done as follows.

 90 1.1   90 1.1  1  1.2 2    0.20  1.2   0.2 0  0.8516 1   1      31 1.55   31 1.55  1 1 0 0 2  1.2.551  .453  0.22  1.2.550.8516 .450 0.20  0.5621 1 1 0 0 3  1.2.552  .454  0.23  1.2.550.5621 .450 0.20  0.3710 1 1 0 0 4  1.2.553  .455  0.24  1.2.550.3710 .450 0.20  0.2448 111 110.2448 1  1.2 4  0.20  1.2  0.20  0.1114 5 29 5 29

 91 1.1   90.5621 1.1  2  1.2 2    0.21  1.2   0.2 0.8516  0.8771 1   1      31 1.55   31 1.55  2 2 1 1 2  1.2.551  .453  0.22  1.2.550.8771 .450.3710 0.20.5621  0.6668 2 2 1 0 3  1.2.552  .454  0.23  1.2.550.6668 .450.2448 0.20  0.4981 1 2 1 0 4  1.2.553  .455  0.24  1.2.550.4981 .450.1114 0.20  0.3400 112 110.3400 2  1.2 4  0.20  1.2  0.20  0.1325 5 29 5 29 April 12 homework solutions ME 695, L. S. Caretto, Spring 2010 Page 6

 92 1.1   90.6668 1.1  3  1.2 2    0.21  1.2   0.2 0.8516  0.9085 1   1      31 1.55   31 1.55  2 2 1 1 2  1.2.551  .453  0.22  1.2.550.9085 .450.4981 0.20.5621  0.7352 2 2 1 0 3  1.2.552  .454  0.23  1.2.550.7352 .450.3400 0.20  0.5692 1 2 1 0 4  1.2.553  .455  0.24  1.2.550.5692 .450.1325 0.20  0.3792 112 110.3792 2  1.2 4  0.20  1.2  0.20  0.1461 5 29 5 29 At the end of the third iteration the residuals are found from the residual equations. 3 3 3 r1 1.11.551 .452 1.11.550.9085.450.7352  0.02268 3 3 3 3 r2  .551  2 .453  .550.9085 0.7352.450.5692  0.03976 3 3 3 3 r3  .552  3 .454  .550.7352 0.5692.450.3792  0.005811 3 3 3 3 r4  553  4 .455  .550.5692 0.3792.450.1325  .000393 3 3 3 r5  .554 1.455  .550.37921.450.1325  0.003302 The maximum residual is seen by inspection to be 0.02268. Dividing this by the maximum residual of 1.1 before the iterations are started gives the maximum relative residual of 0.02268/1.1 = 0.02062. The changes and relative changes in the variables between the last two iterations are found as follows.

3 2 3 2 3 1  1  0.9085  0.8771  0.0314 1  1 1  0.0314 0.9085  0.03456 3 2 3 2 3 2  2  0.7352  0.6668  0.0684 2  2 2  0.0684 0.7352  0.0.09304 3 2 3 2 3 3  3  0.5692  0.4981  0.0711 3  3 3  0.0711 0.5692  0.1249 3 2 3 2 3 4  4  0.3792  0.3400  0.0392 4  4 4  0.0392 0.3792  0.1034 3 2 3 2 3 5  5  0.1461 0.1325  0.0136 5  5 5  0.0136 0.1461  0.09309

By inspection the maximum residual of 0.0711 and the maximum relative residual of 0.1249 both occur for the variable3. Comment on the results We see that the residuals at the end of iteration three and the change in the variables at the end of iteration three all decrease as the iteration method moves from Jacobi to Gauss-Seidel to successive overrelaxation (SOR). This confirms the notion that the convergence rate for these three methods goes from Jacobi as being the slowest to SOR being the fastest with Gauss-Seidel in between.

Recommended publications