How to solve PDEs using  MATHEMATIA and MATLAB G. Y. Park, S. H. Lee and J.K. Lee Department of Electronic and Electrical ...
Contents <ul><li>Solving PDEs using MATHEMATICA </li></ul><ul><li>- FTCS method </li></ul><ul><li>- Lax method </li></ul><...
References <ul><li>Textbook </li></ul><ul><li>- ‘Numerical and Analytical Methods for Scientists and Engineers Using Mathe...
PDE (Partial Differential Equation) <ul><li>PDEs are used as mathematical models for phenomena in  </li></ul><ul><li>all b...
FTCS method for the heat equation FTCS ( Forward Euler in Time and Central difference in Space ) Heat equation in a slab P...
FTCS method for the heat equation Initial  conditions Plot FTCS
Stability of FTCS and CTCS FTCS is first-order accuracy in time and second-order accuracy in space. So small time steps ar...
Lax method Simple modification to the CTCS method In the differenced time derivative, The resulting difference equation is...
Crank Nicolson Algorithm ( Implicit Method ) BTCS ( Backward time, centered space ) method for heat equation ( This is sta...
Crank Nicolson Algorithm Initial  conditions Plot Crank-Nicolson scheme Exact solution
Crank Nicolson Algorithm Plasma Application Modeling POSTECH
Multiple Spatial Dimensions FTCS for 2D heat equation Courant condition for this scheme ( Other schemes such as CTCS and L...
Wave equation with nonuniform wave speed 2D wave equation Initial condition : Boundary condition : Wave speed : CTCS metho...
Wave equation with nonuniform wave speed Since evaluation of the nth timestep refers back to the n-2nd step,  for the firs...
Wave equation with nonuniform wave speed Plasma Application Modeling POSTECH
Wave equation with nonuniform wave speed Plasma Application Modeling POSTECH
2D Poisson’s equation Poisson’s equation Direct Solution for Poisson’s equation Centered-difference the spatial derivatives
Jacobi’s  method ( Relaxation method ) <ul><li>Direct solution can be difficult to program efficiently. </li></ul><ul><li>...
Jacobi method
Simultaneous OverRelaxation (SOR) The convergence of the Jacobi method is quite slow.  Furthermore, the larger the system,...
Simultaneous OverRelaxation (SOR)
O.V. Manuilenko MATLAB   The Language of Technical Computing MATLAB PDE Run:  dftcs.m >> dftcs dftcs - Program to solve th...
O.V. Manuilenko MATLAB   The Language of Technical Computing MATLAB PDE Run:  dftcs.m >> dftcs dftcs - Program to solve th...
O.V. Manuilenko MATLAB   The Language of Technical Computing MATLAB PDE Run:  neutrn.m >>  neutrn Program to solve the neu...
O.V. Manuilenko MATLAB   The Language of Technical Computing MATLAB PDE Run:  neutrn.m >>  neutrn Program to solve the neu...
O.V. Manuilenko MATLAB   The Language of Technical Computing MATLAB PDE Run:  advect.m >> advect advect - Program to solve...
O.V. Manuilenko MATLAB   The Language of Technical Computing MATLAB PDE Run:  advect.m >> advect advect - Program to solve...
O.V. Manuilenko MATLAB   The Language of Technical Computing MATLAB PDE Run:  relax.m >> relax relax - Program to solve th...
Upcoming SlideShare
Loading in …5
×

Finite DIfference Methods Mathematica

36,048
-1

Published on

Finite difference methods with introduction to Burgers Equation

Published in: Technology
5 Comments
14 Likes
Statistics
Notes
No Downloads
Views
Total Views
36,048
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
1,202
Comments
5
Likes
14
Embeds 0
No embeds

No notes for slide

Finite DIfference Methods Mathematica

  1. 1. How to solve PDEs using MATHEMATIA and MATLAB G. Y. Park, S. H. Lee and J.K. Lee Department of Electronic and Electrical Engineering, POSTECH 2006. 5. 17 Plasma Application Modeling POSTECH
  2. 2. Contents <ul><li>Solving PDEs using MATHEMATICA </li></ul><ul><li>- FTCS method </li></ul><ul><li>- Lax method </li></ul><ul><li>- Crank Nicolson method </li></ul><ul><li>- Jacobi’s method </li></ul><ul><li>- Simultaneous-over-relaxation (SOR) method </li></ul><ul><li>Solving PDEs using MATLAB </li></ul><ul><li>- Examples of PDEs </li></ul>Plasma Application Modeling POSTECH
  3. 3. References <ul><li>Textbook </li></ul><ul><li>- ‘Numerical and Analytical Methods for Scientists and Engineers Using Mathematica’, Daniel Dubin, Wiley, 2003 </li></ul><ul><li>- ‘Applied numerical methods in C’, S. Nakamura </li></ul>Plasma Application Modeling POSTECH
  4. 4. PDE (Partial Differential Equation) <ul><li>PDEs are used as mathematical models for phenomena in </li></ul><ul><li>all branches of engineering and science. </li></ul>Plasma Application Modeling POSTECH - Three Types of PDEs: 1) Elliptic:  Steady heat transfer, flow and diffusion 2) Parabolic:  Transient heat transfer, flow and diffusion 3) Hyperbolic:  Transient wave equation
  5. 5. FTCS method for the heat equation FTCS ( Forward Euler in Time and Central difference in Space ) Heat equation in a slab Plasma Application Modeling POSTECH
  6. 6. FTCS method for the heat equation Initial conditions Plot FTCS
  7. 7. Stability of FTCS and CTCS FTCS is first-order accuracy in time and second-order accuracy in space. So small time steps are required to achieve reasonable accuracy. CTCS method for heat equation (Both the time and space derivatives are center-differenced.) However, CTCS method is unstable for any time step size. ( unstable ) Plasma Application Modeling POSTECH Courant condition for FTCS
  8. 8. Lax method Simple modification to the CTCS method In the differenced time derivative, The resulting difference equation is ( Second-order accuracy in both time and space ) Plasma Application Modeling POSTECH Replacement by average value from surrounding grid points Courant condition for Lax method
  9. 9. Crank Nicolson Algorithm ( Implicit Method ) BTCS ( Backward time, centered space ) method for heat equation ( This is stable for any choice of time steps, however it is first-order accurate in time. ) Crank-Nicolson scheme for heat equation taking the average between time steps n-1 and n, ( This is stable for any choice of time steps and second-order accurate in time. ) Plasma Application Modeling POSTECH a set of coupled linear equations for
  10. 10. Crank Nicolson Algorithm Initial conditions Plot Crank-Nicolson scheme Exact solution
  11. 11. Crank Nicolson Algorithm Plasma Application Modeling POSTECH
  12. 12. Multiple Spatial Dimensions FTCS for 2D heat equation Courant condition for this scheme ( Other schemes such as CTCS and Lax can be easily extended to multiple dimensions. ) Plasma Application Modeling POSTECH
  13. 13. Wave equation with nonuniform wave speed 2D wave equation Initial condition : Boundary condition : Wave speed : CTCS method for the wave equation : Courant condition : Plasma Application Modeling POSTECH
  14. 14. Wave equation with nonuniform wave speed Since evaluation of the nth timestep refers back to the n-2nd step, for the first step, a trick is employed. Since initial velocity and value, Plasma Application Modeling POSTECH
  15. 15. Wave equation with nonuniform wave speed Plasma Application Modeling POSTECH
  16. 16. Wave equation with nonuniform wave speed Plasma Application Modeling POSTECH
  17. 17. 2D Poisson’s equation Poisson’s equation Direct Solution for Poisson’s equation Centered-difference the spatial derivatives
  18. 18. Jacobi’s method ( Relaxation method ) <ul><li>Direct solution can be difficult to program efficiently. </li></ul><ul><li>Relaxation methods are relatively simple to code, </li></ul><ul><li>however, they are not as fast as the direct methods. </li></ul><ul><li>Idea : </li></ul><ul><li>Poisson’s equation can be thought of as the equilibrium solution to the heat equation with source. </li></ul><ul><li>Starting with any initial condition, the heat equation solution will eventually relax to a solution of Poisson’s equation. </li></ul>FTCS (Maximum time step satisfying Courant condition)
  19. 19. Jacobi method
  20. 20. Simultaneous OverRelaxation (SOR) The convergence of the Jacobi method is quite slow. Furthermore, the larger the system, the slower the convergence. Simultaneous OverRelaxation (SOR) : the Jacobi method is modified in two ways, <ul><li>Improved values are used as soon as they become available. </li></ul><ul><li>Relaxation parameter ω tries to overshoot for going to the final result. </li></ul><ul><li>( 1< ω <2) </li></ul>Plasma Application Modeling POSTECH
  21. 21. Simultaneous OverRelaxation (SOR)
  22. 22. O.V. Manuilenko MATLAB The Language of Technical Computing MATLAB PDE Run: dftcs.m >> dftcs dftcs - Program to solve the diffusion equation using the Forward Time Centered Space scheme. Enter time step: 0.0001 Enter the number of grid points: 51 Solution is expected to be stable Plasma Application Modeling Group POSTECH
  23. 23. O.V. Manuilenko MATLAB The Language of Technical Computing MATLAB PDE Run: dftcs.m >> dftcs dftcs - Program to solve the diffusion equation using the Forward Time Centered Space scheme. Enter time step: 0.00015 Enter the number of grid points: 61 WARNING: Solution is expected to be unstable Plasma Application Modeling Group POSTECH
  24. 24. O.V. Manuilenko MATLAB The Language of Technical Computing MATLAB PDE Run: neutrn.m >> neutrn Program to solve the neutron diffusion equation using the FTCS. Enter time step: 0.0005 Enter the number of grid points: 61 Enter system length: 2 => System length is subcritical Solution is expected to be stable Enter number of time steps: 12000 Plasma Application Modeling Group POSTECH
  25. 25. O.V. Manuilenko MATLAB The Language of Technical Computing MATLAB PDE Run: neutrn.m >> neutrn Program to solve the neutron diffusion equation using the FTCS. Enter time step: 0.0005 Enter the number of grid points: 61 Enter system length: 4 => System length is supercritical Solution is expected to be stable Enter number of time steps: 12000 Plasma Application Modeling Group POSTECH
  26. 26. O.V. Manuilenko MATLAB The Language of Technical Computing MATLAB PDE Run: advect.m >> advect advect - Program to solve the advection equation using the various hyperbolic PDE schemes: FTCS, Lax, Lax-Wendorf Enter number of grid points: 50 Time for wave to move one grid spacing is 0.02 Enter time step: 0.002 Wave circles system in 500 steps Enter number of steps: 500 FTCS FTCS Plasma Application Modeling Group POSTECH
  27. 27. O.V. Manuilenko MATLAB The Language of Technical Computing MATLAB PDE Run: advect.m >> advect advect - Program to solve the advection equation using the various hyperbolic PDE schemes: FTCS, Lax, Lax-Wendorf Enter number of grid points: 50 Time for wave to move one grid spacing is 0.02 Enter time step: 0.02 Wave circles system in 50 steps Enter number of steps: 50 Lax Lax Plasma Application Modeling Group POSTECH
  28. 28. O.V. Manuilenko MATLAB The Language of Technical Computing MATLAB PDE Run: relax.m >> relax relax - Program to solve the Laplace equation using Jacobi, Gauss-Seidel and SOR methods on a square grid Enter number of grid points on a side: 50 Theoretical optimum omega = 1.88184 Enter desired omega: 1.8 Potential at y=L equals 1 Potential is zero on all other boundaries Desired fractional change = 0.0001 Plasma Application Modeling Group POSTECH
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×