Download presentation
Presentation is loading. Please wait.
Published byAnastasia Fowler Modified over 9 years ago
1
Scientific Computing Partial Differential Equations Poisson Equation
2
Partial Differential Equations Our study of PDE’s has focused on linear, second-order equations The following general form of such PDE’s can be classified by B 2 - 4AC (Variables – x and y/t)
3
Partial Differential Equations B 2 -4AC Category Example < 0 EllipticLaplace equation (steady state with 2 spatial dimensions) = 0 ParabolicHeat conduction equation (time variable with one spatial dimension) >0HyperbolicWave equation (time-variable with one spatial dimension)
4
Multi-dimensional Heat Equation Consider an object in which the temperature is a function of more than just the x-direction. Then the heat conduction equation can be written: – 2-D: – 3-D:
5
2-D Steady State The Steady State solution for the Heat Equation requires that the temperature reaches an equilibrium distribution, that is we have Then, This is called Laplace’s Equation or the Potential Equation.
6
The Laplace Equation Models a variety of problems involving the potential of an unknown variable u(x,y) The solution of this equation is used in thermodynamics (steady state of heat flow), fluid flow (finding potential function), and other problems where we are calculating the potential of some quantity.
7
The Poisson Equation Models a variety of problems involving the potential of an unknown variable u(x,y) where the right side of the equality is non-zero. For example, in calculations involving an Electric Field.
8
Electric Potential The electric field is related to the charge density by the divergence relationship: (Gauss’s Law) The electric field is related to the electric potential by a gradient relationship Therefore the potential is related to the charge density by Poisson's equation In a charge-free region of space, this becomes Laplace's equation Note: is called the Laplacian operator = sum of 2 nd partials
9
Poisson’s equation: Example Show that the 2D potential distribution satisfies the Poisson’s equation Let’s evaluate the Laplacian operator: Thus,
10
Poisson vs Potential Laplace’s Equation or Potential Equation: Poisson Equation:
11
Solution Method Both the Laplace and Poisson Equations involve calculating the Laplacian Operator. We will approximate this sum of derivatives based on a grid in x and y and centered finite differences:
12
Solution Method Here h = Δx and k = Δy (i,j) (i+1,j) (i-1,j) (i,j+1) (i,j-1)
13
Solution Method Thus, for the Poisson Equation For the Potential (Laplace) equation we have
14
Solution Method The equation is valid at all interior points of the grid. What about the boundary?
15
Boundary Conditions Simplest boundary conditions specify value of u(x,y) on each of the fours sides of the region (grid) 0 ≤ x ≤ 1, 0 ≤ y ≤ 1
16
Solution Method If we assume h = k, we get for the Poisson Equation (putting lower i, j terms first) For the Potential (Laplace) equation we have
17
Solution Method If we negate the Poisson equation and re-write we get: Consider the interior node equations for j=1:
18
Solution Method If we let Then, we can write the equations on the previous slide as where
19
Solution Method Now, consider the interior node equations for j=2:
20
Solution Method If we let Then, we can write the equations on the previous slide as
21
Solution Method Similarly, for j=3,4,…,n-2 we can write the equations as where
22
Solution Method Now, consider the interior node equations for j=n-1:
23
Solution Method If we let Then, we can write the equations on the previous slide as
24
Solution Method If we let Then, we can write the entire (grid interior) system of equations as:
25
Solution Method
26
The matrix A is sparse, block-tridiagonal (for the way we set up the vector for u), symmetric, and positive definite (x t A x > 0 for all x). Also, A is a (n-1) 2 x (n-1) 2 matrix.
27
Solution Method Since A is positive definite, the eigenvalues of A will be positive, so A is invertible. The solution exists as Now, this solution is not ideal, as it is computationally expensive to find the inverse of A. We could instead use Gaussian Elimination or LU factorization to solve for u, but this is not optimal, as A has a lot of zeroes, so we are wasting operations.
28
Iterative Solution Method It turns out (no proof) that our iterative methods from earlier in the course work well for this system. Review: The iterative methods we looked at to solve Ax=B were: – Jacobi Method – Gauss-Seidel Method – SOR (Successive Over-Relaxation)
29
Jacobi Iterative Formula Jacobi Iteration: D=diagonal of A. x (k+1) = D -1 (B + (D-A) x (k) ) Element-wise, this is
30
Jacobi Iterative Formula In our case the x vector is and x i k+1 corresponds to solving for the diagonal terms in Ax=B, thus in our case of the Jacobi equation becomes Now, after adding back the terms from the vector b, we get
31
Jacobi Iterative Formula So, we initialize u i,j 0 on the boundary of the grid, and set the interior values to some start values, say u ij = 1, then use the Jacobi iteration formula repeatedly to converge to the solution, keeping tabs on the error in our approximation.
32
Matlab Implementation function [x y u] = explicitPoisson(f, f0, f1, g0, g1, n) %Explicit solution of wave equation % Constants and vectors h = 1/n; x = 0:h:n*h; y = 0:h:n*h; % Initial guess at u is u=1 for all x,y u = ones(n+1,n+1); % Boundary conditions u(1:n+1, 1) = f0(x); u(1:n+1, n+1) = f1(x); u(1, 1:n+1) = g0(y); u(n+1, 1:n+1) = g1(y); % unew = next iterate, err will measure the error from % one iteration to next unew = u; err= unew-u;
33
Matlab Implementation % Iterative procedure epsilon = 1e-4; % tolerance for convergence imax = 1000; % maximum number of iterations allowed k = 1; % initial index value for iteration % Calculation loop while k<= imax for i = 2:n for j = 2:n unew(i,j)=(-h^2*f(i,j) + u(i-1,j)+u(i+1,j) +u(i,j-1)+u(i,j+1))/4.0; err(i,j) = abs(unew(i,j)-u(i,j)); end; u = unew; k = k + 1; errmax = max(max(err)); if errmax < epsilon u = u'; mesh(x,y,u); fprintf('Convergence for %i iterations.\n',k); return; end; end
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.