Page 71 - Numerical Methods for Chemical Engineering
P. 71

60      1 Linear algebra



                   increase the number of grid points until you no longer see a significant effect upon the
                   solution.
                                                                       2
                   1.B.4. When solving by finite differences the Poisson equation, −∇ ϕ = f ,in d dimensions
                   on a regular hypercube grid of N points in each direction, the A matrix has the following
                   nonzero elements in each row (for  x j = 1),

                                                 m
                          A(k, k) = 2d  A(k, k ± N ) =−1  m = 0, 1, ..., d − 1       (1.277)
                   For 2-D, 3-D, and 4-D grids generate the resulting A matrix for various N (for higher d,you
                   might only be able to use very small N). For each d, plot as functions of N the numbers of
                   nonzero elements in A and in the Cholesky factor R. Show also the spy plots of A and R for
                   the largest N value considered for each d. Using cputime, plot as well the computational
                   time required to solve Aϕ = b, b being a vector of all ones, both by the “\” operator and by
                   Cholesky factorization. NOTE High dimension boundary value problems do indeed arise
                   in practice, especially when one is computing the positional and orientational distribution
                   of objects.
                   1.C.1. Consider the following boundary value problem involving two coupled fields gov-
                   erned by linear differential equations,
                               2
                                                   2
                              d ϕ                 d ψ
                            −     = 1 + ψ(x)    −     = ϕ(x)    on    0 ≤ x ≤ 1
                              dx 2                dx 2
                                                                                     (1.278)
                                      BC1    ϕ(0) = 0    ϕ(1) = 0
                                      BC2    ψ(0) = 0    ψ(1) = 0
                   We wish to solve this problem numerically using the method of finite differences for a
                   uniform grid of points x j , j = 1, 2,..., N, in the interior of the domain, as was done in
                   the flow example for a single field. We compute numerically the field values at each point,
                   ϕ(x j ) = ϕ j and ψ(x j ) = ψ j , by solving through elimination the resulting linear algebraic
                   system.
                     Which of the following ways of stacking the unknowns into a single vector do you
                   recommend using? Explain your reasoning.
                                               
                                             ϕ 1                   
                                                                 ϕ 1
                                               
                                             ϕ 2                 
                                                                 ψ 1 
                                               
                                            :                    
                                                              ϕ 2 
                                                      or                             (1.279)
                                            ϕ N                  
                                        x =               x =  ψ 2 
                                            ψ 1                  
                                                              : 
                                            ψ 2                  
                                                              ϕ N  
                                            : 
                                                                 ψ N
                                             ψ N
                   Write a MATLAB program to solve the boundary value problem and plot the solution.
   66   67   68   69   70   71   72   73   74   75   76