Programming assignment #1 Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.

Slides:



Advertisements
Similar presentations
M. Dumbser 1 / 23 Analisi Numerica Università degli Studi di Trento Dipartimento dIngegneria Civile ed Ambientale Dr.-Ing. Michael Dumbser Lecture on Numerical.
Advertisements

Partial Differential Equations
Computational Modeling for Engineering MECN 6040
Chapter 8 Elliptic Equation.
Geometric (Classical) MultiGrid. Hierarchy of graphs Apply grids in all scales: 2x2, 4x4, …, n 1/2 xn 1/2 Coarsening Interpolate and relax Solve the large.
Steepest Decent and Conjugate Gradients (CG). Solving of the linear equation system.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 19 Solution of Linear System of Equations - Iterative Methods.
ENGG 1801 Engineering Computing MATLAB Lecture 7: Tutorial Weeks Solution of nonlinear algebraic equations (II)
Geometric (Classical) MultiGrid. Linear scalar elliptic PDE (Brandt ~1971)  1 dimension Poisson equation  Discretize the continuum x0x0 x1x1 x2x2 xixi.
NAE C_S2001 FINAL PROJECT PRESENTATION LASIC ISMAR 04/12/01 INSTRUCTOR: PROF. GUTIERREZ.
Partial differential equations Function depends on two or more independent variables This is a very simple one - there are many more complicated ones.
Numerical Methods Due to the increasing complexities encountered in the development of modern technology, analytical solutions usually are not available.
Solving Scalar Linear Systems Iterative approach Lecture 15 MA/CS 471 Fall 2003.
Iterative Methods for Solving Linear Systems Leo Magallon & Morgan Ulloa.
Hyperbolic PDEs Numerical Methods for PDEs Spring 2007 Jim E. Jones.
CIS V/EE894R/ME894V A Case Study in Computational Science & Engineering HW 5 Repeat the HW associated with the FD LBI except that you will now use.
ME451 Kinematics and Dynamics of Machine Systems Numerical Solution of DAE IVP Newmark Method November 1, 2013 Radu Serban University of Wisconsin-Madison.
Lecture 22 MA471 Fall Advection Equation Recall the 2D advection equation: We will use a Runge-Kutta time integrator and spectral representation.
Scientific Computing Partial Differential Equations Poisson Equation.
Boundary Value Problems and Least Squares Minimization
1 EEE 431 Computational Methods in Electrodynamics Lecture 4 By Dr. Rasime Uyguroglu
1 Spring 2003 Prof. Tim Warburton MA557/MA578/CS557 Lecture 31.
6. Introduction to Spectral method. Finite difference method – approximate a function locally using lower order interpolating polynomials. Spectral method.
MA2213 Lecture 11 PDE. Topics Introduction p Poisson equation p Visualization of numerical results p Boundary conditions p.
Programming assignment #2 Solving a parabolic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.
Elliptic PDEs and the Finite Difference Method
Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.
Introduction Examples of differential equations and related problems Analytical versus numerical solutions Ideas of numerical representations of solutions.
Boundary Value Problems l Up to this point we have solved differential equations that have all of their initial conditions specified. l There is another.
Solution of Nonlinear Functions
MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo
Final Project Topics Numerical Methods for PDEs Spring 2007 Jim E. Jones.
Discretization Methods Chapter 2. Training Manual May 15, 2001 Inventory # Discretization Methods Topics Equations and The Goal Brief overview.
Elliptic PDEs and Solvers
Part 3 Chapter 12 Iterative Methods
ME451 Kinematics and Dynamics of Machine Systems Dynamics of Planar Systems December 9, 2010 Solving Index 3 DAEs using Newmark Method © Dan Negrut, 2010.
ME451 Kinematics and Dynamics of Machine Systems Newton-Raphson Method 4.5 October 28, 2010 © Dan Negrut, 2010 ME451, UW-Madison TexPoint fonts used in.
1 Spring 2003 Prof. Tim Warburton MA557/MA578/CS557 Lecture 32.
Programming assignment # 3 Numerical Methods for PDEs Spring 2007 Jim E. Jones.
Example application – Finite Volume Discretization Numerical Methods for PDEs Spring 2007 Jim E. Jones.
Relaxation Methods in the Solution of Partial Differential Equations
Part 8 - Chapter 29.
EEE 431 Computational Methods in Electrodynamics
Programming assignment #1. Solutions and Discussion
Gauss-Siedel Method.
Scientific Computing Lab
MultiGrid.
Lecture 19 MA471 Fall 2003.
Convergence in Computational Science
3.2 Solve Linear Systems Algebraically
Autar Kaw Benjamin Rigsby
Partial Differential Equations
ENGG 1801 Engineering Computing
Scientific Computing Lab
Scientific Computing Partial Differential Equations Implicit Solution of Heat Equation.
Linear Algebra Lecture 3.
Numerical Analysis Lecture13.
Elliptic Partial Differential Equations – Gauss-Seidel Method
6.5 Taylor Series Linearization
Problems with Gauss-Seidel
MATH-321 In One Slide MATH-321 & MATLAB Command.
Discrete Least Squares Approximation
Jacobi Project Salvatore Orlando.
Numerical Methods on Partial Differential Equation
Stencil Pattern ITCS 4/5145 Parallel computing, UNC-Charlotte, B. Wilkinson Oct 14, 2014 slides6b.ppt 1.
Programming assignment # 3 Numerical Methods for PDEs Spring 2007
Stencil Pattern ITCS 4/5145 Parallel computing, UNC-Charlotte, B. Wilkinson StencilPattern.ppt Oct 14,
Linear Algebra Lecture 16.
Home assignment #3 (1) (Total 3 problems) Due: 12 November 2018
Presentation transcript:

Programming assignment #1 Solving an elliptic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones

The Problem Taken from Burden and Faires, Numerical Analysis, Ch12

The Problem PDE Boundary Conditions

Finite difference discretization based on Taylor’s approximation. (2,2) Equation for each grid point (x,y) Error in approximation is determined by the mesh size h. Difference between differential solution and algebraic solution goes to zero as h does. (1,1)

Solving the linear system Last lecture we did a simple example, solving the linear system in MATLAB This involved a one-dimensional ordering the nine interior unknowns. If the system is large, an iterative solver may be faster than the direct methods in MATLAB

Two dimensional ordering of the grid points (x=2.0,y=2.0) (i=8,j=8) Physical Space Index Space (x=1.0,y=1.0) (i=0,j=0)

Two dimensional ordering of the grid points (x=2.0,y=2.0) (i=8,j=8) (x=1.25,y=1.375) (i=2,j=3) (x=1.0,y=1.0) (i=0,j=0)

Two dimensional ordering of the grid points (x=2.0,y=2.0) (i=8,j=8) (x=1.0+i*h,y=1.0+j*h) (i,j) h=1/n, n=8 (x=1.0,y=1.0) (i=0,j=0)

Finite difference discretization based on Taylor’s approximation. Equation for each grid point (x,y)

Solving the linear system using Gauss-Seidel method Begin with an initial guess for the unknown u’s. If you don’t have anything better, guess u=0 at all unknown grid points. Do Gauss-Seidel iterations Loop over unknown grid points Change the u value at the current grid point to satisfy the equation in A for this grid point Check to see if the u-values are close enough to the true solution of the linear system. If they are STOP; otherwise, do another Gauss-Seidel iteration.

Loop over grid points: Lexicalgraphic ordering 1

Loop over grid points 1 2

Loop over grid points 1 2 3

Loop over grid points for j=1,n-1 for i=1,n-1 8 1 2 3 4 5 6 7

Gauss-Seidel update at point (I,J) Change u at i,j to satisfy its equation

Gauss-Seidel update at point (I,J) Change u at i,j to satisfy its equation Note: With this simple equation, there is no need to store A. Its mostly zeros anyway.

When to stop? We’re looking for the solution u* so that After completing a Gauss-Seidel iteration, we have an approximate solution u. One computable measure of the quality of the approximation is its residual.

When to stop? Stop when the residual is small enough, i.e. Think of r as a vector with (n-1)x(n-1) entries, one for each interior point. You can choose the norm, one choice is the infinity norm. For an vector with m components, the infinity norm is:

How good is the answer? After we iterate far enough to meet the stopping criterion, we have our approximate solution ugs. The difference between the true algebraic solution and our approximate solution is called the algebraic error.

How good is the answer? What we presumably really care about is the solution to the PDE, upde. The difference between the true PDE solution and the true algebraic solution is called the discretization error.

How good is the answer? What we presumably really care about is the solution to the PDE, upde. The difference between the true PDE solution and the true algebraic solution is called the discretization error. Interpret upde as a vector. The true PDE solution evaluated at each grid point.

How good is the answer? What we presumably really care about is the solution to the PDE, upde. The total error is the difference between the true PDE solution and our approximate solution.

How good is the answer? What we presumably really care about is the solution to the PDE, upde. The error is the difference between the true PDE solution and our approximate solution. The total error is the sum of the discretization error and the algebraic error.

How good is the answer? What we presumably really care about is the solution to the PDE, upde. The error is the difference between the true PDE solution and our approximate solution. We can make ed smaller by making h smaller, and thus using a finer mesh with more grid points.

How good is the answer? What we presumably really care about is the solution to the PDE, upde. The error is the difference between the true PDE solution and our approximate solution. We can make ea smaller by making tol smaller, and thus doing more Gauss Seidel iterations.

The Problem PDE solution

Assignment #1 Due Jan. 29 Code up the finite difference method using Gauss-Seidel to solve the linear system as discussed in these slides. You need to be able to run different problem sizes, so write your code with h (or n) as an input argument. You should also include the Gauss-Seidel stopping criterion tol as an input argument. You can write it for general right hand side and boundary conditions, or hard code the specific example. Do not store the A matrix. Verify that your code is working – do a small problem for which you know the answer.

Assignment #1 Due Jan. 29 Run your code for the example problem. Experiment by varying h and tol to see how they effect the number of iterations required and the infinity norm of the final, total error. Pick at least 3 values of h and 3 values of tol. I suggest h=.1,.05,.025 and tol=10e-2,10e-3,10e-4 this makes 9 runs total. Make table that includes the number of Gauss-Seidel iterations required for each run. Make table that includes the infinity norm of the final, total error for each run.

Assignment #1 Due Jan. 29 From your table of results, answer these questions: For fixed tolerance, how does the number of iterations depend on h? If h is halved does the number of iterations go up or down? By what factor? How does the error depend on h? If h is halved does the error go up or down? By what factor?