AMath 483/583 — Lecture 27
Outline:
- Random walk solution of Poisson problem
- Using MPI with subroutines
- Python plus Fortran: f2py
Notes and Sample codes:
- Class notes: Random numbers
- Class notes: Poisson problem
- $UWHPSC/codes/mpi/quadrature
- $UWHPSC/codes/f2py
R.J. LeVeque, University of Washington AMath 483/583, Lecture 27
Notes:
R.J. LeVeque, University of Washington AMath 483/583, Lecture 27
Monte Carlo solution of Poisson problem
Suppose we want to compute an approximate solution to uxx + uyy = 0 with u given on boundary at a single point (x0, y0). Finite difference approach: Discretize domain and solve linear system for approximations Uij at all points on grid. Instead can take a random walk starting at (x0, y0) and evaluate u at the first boundary point the walk reaches. Do this N times and average all the values obtained. This average converges to u(x0, y0) with rate 1/ √ N.
R.J. LeVeque, University of Washington AMath 483/583, Lecture 27
Notes:
R.J. LeVeque, University of Washington AMath 483/583, Lecture 27
Monte Carlo solution of Laplace’s Equation
Laplace’s equation: uxx(x, y) + uyy(x, y) = 0 An exact solution: u(x, y) = x2 − y2 since uxx = 2, uyy = −2. Also Uij = x2
i − y2 j satisfies discrete equations exactly, since 1 ∆x2 (Ui−1,j − Uij + Ui+1,j) = 2, 1 ∆y2 (Ui,j−1 − Uij + Ui,j+1) = −2
R.J. LeVeque, University of Washington AMath 483/583, Lecture 27
Notes:
R.J. LeVeque, University of Washington AMath 483/583, Lecture 27