Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
PHY 604: Computational Methods in Physics and Astrophysics II
PDEs
PHY 604: Computational Methods in Physics and Astrophysics II
On to PDEs...
● Next up: PDEs
– PDEs are at the heart of many physical systems
– We will study three classes of PDEs, represented by the wave/advection equation, the Poisson equation, and the diffusion equation
● Where do we stand?
● Differentiation:
– We saw how Taylor expansions give rise to difference formula with varying orders of accuracy
– These ideas will be at the heart of the spatial discretization we use with PDEs
● Interpolation:
– We will see the interpolation ideas again as we reconstruct our discretized data to find values at interfaces in our PDE discretizations
PHY 604: Computational Methods in Physics and Astrophysics II
On to PDEs...
● ODEs:
– A common procedure is to spatially discretize a PDE and then solve the result initial value ODE system using ODE methods—this is called the method of lines approach
● Linear algebra:
– We will have a choice of discretizing explicitly or implicitly. Implicit discretizations often result in a linear system to solve, using our linear algebra techniques
– We will see the iterative methods come into play when we consider the Poisson equation
● FFTs:
– As already motivated, FFTs can be used to transform a PDE into an algebraic equation in Fourier-space, enabling its easy solution. (Some restrictions apply)
PHY 604: Computational Methods in Physics and Astrophysics II
Introduction to PDEs
● Different types of PDEs require different solution methods
– Methodology matches the underlying behavior
● We will study the three main classes of PDEs:
– Hyperbolic
● e.g. the wave equation: ut - uxx = 0
● Characterized by real, distinct propagation speeds (for a system, the eigenvalues are real)
● Requires initial conditions and boundary conditions (on the upwind boundaries)
● Supports discontinuities, propagation of waves, etc.● The equations of compressible hydrodynamics form a hyperbolic system● The scalar linear advection equation will be our model for these methods
PHY 604: Computational Methods in Physics and Astrophysics II
The Sod problem from compressible hydrodynamics—here we see three characteristic waves that carry information propagating outward from an initial disturbance
PHY 604: Computational Methods in Physics and Astrophysics II
Introduction to PDEs
– Elliptic
● e.g. the Poisson equation: uxx + uyy = f
● No “speed” associated with propagating information—the solution responds instantaneously to the boundaries
● Requires boundary conditions on all sides● Solutions are smooth● Also arises in low-Mach number flow as a constraint on the velocities,
electrostatics, gravity, ...
PHY 604: Computational Methods in Physics and Astrophysics II
Introduction to PDEs
with u = 0 on the boundary.
This example comes from a simple python code on my website
PHY 604: Computational Methods in Physics and Astrophysics II
Introduction to PDEs
– Parabolic
● e.g. the diffusion equation: ut = uxx
● Inbetween hyperbolic and elliptic● Solution smooths out sharp features
PHY 604: Computational Methods in Physics and Astrophysics II
Introduction to PDEs
Diffusion of a Gaussian in one-dimension
PHY 604: Computational Methods in Physics and Astrophysics II
Introduction to PDEs
● Formally, these names come from a mathematical classification analogous to conic sections
– Written as:
– Hyperbolic if
– Parabolic if
– Elliptic if
(Wikiped
ia)
PHY 604: Computational Methods in Physics and Astrophysics II
Introduction to PDEs
● We can also discuss them in terms of initial value vs. boundary value problems
– Typical boundary conditions are
● Dirichlet (specify value at the boundary)● Neumann (specify the derivative normal to the boundary)● Periodic
● Many equations or systems are mixed types, e.g.
– Viscous flow (both hyperbolic + parabolic)
– Constrained flow (hyperbolic + elliptic)
PHY 604: Computational Methods in Physics and Astrophysics II
Discretization
● We need to discretize both space and time (or multiple space dimensions)
● There are many different types of spatial discretizations we can employ
– Finite difference
– Finite volume
– Finite element
– Spectral
– Particle methods (SPH)
● Each have their own strengths and weaknesses
● All but finite-element see wide use in astrophysics
PHY 604: Computational Methods in Physics and Astrophysics II
Spectral Methods
● Solution is expressed in terms of a superposition of globally-defined basis functions (Fourier series, Chebyshev, or Legendre functions)
● Solve for evolution of the weights in the superposition
● Ideally for smooth flow
– Doesn't handle discontinuities (e.g. shocks) well
● Wide application in turbulence studies
PHY 604: Computational Methods in Physics and Astrophysics II
Finite Elements
● Derivation similar to spectral—form inner product of function and basis functions
– In F-E, compact basis functions are used
● Popular in engineering—works well on irregular domains
Wikipedia
PHY 604: Computational Methods in Physics and Astrophysics II
Structured Grids
● Discretization on a series of logically Cartesian grids
– Allows for easy access to any element, avoiding indirect addressing on machines—maximizes cache performance
● Two popular approaches: finite-difference and finite-volume
– Underlying mathematical formulation differs
– Often can result in identical discretizations
PHY 604: Computational Methods in Physics and Astrophysics II
Finite Difference Approximation
● Function values are stored at discrete grid points
– Discrete values are simply:
– Replace derivatives in the PDE with discrete differences between neighboring grid points
– This is basically what we've already done with ODEs (think about the orbit problem)
PHY 604: Computational Methods in Physics and Astrophysics II
Finite Volume Approximation
● In the finite-volume approach, we store the average of the function value over an interval/zone
– Where:
– Note that half-integers are used to label the zone boundaries
– This discretization arises naturally when we model conservation laws in integral form
PHY 604: Computational Methods in Physics and Astrophysics II
Multiple Dimensions
● Either of these discretizations can be extended to multiple dimensions, using similar definitions
2-d finite-difference grid 2-d finite-volume grid
PHY 604: Computational Methods in Physics and Astrophysics II
Structured Adaptive Mesh Refinment
● Structured AMR uses a nested hierarchy of grids to focus resolution in regions of complex flow
PHY 604: Computational Methods in Physics and Astrophysics II
SPH
● No grid
● Represent mass distribution as a collection of particles
● Form continuous quantities by integrating over particles via a smoothing kernel
● Lagrangrian approach (more on that later...)
Two spherical mass distributions represented by a structured grid (a) and SPH particles (b). Note, there is a lot of unneeded resolution in the space between the spheres in the grid case.
(Stephen Oxley)
PHY 604: Computational Methods in Physics and Astrophysics II
Aside: Gravity Only
● Pure gravity simulations often employ an N-body technique
– Particles represent mass
– Accelerations are computed by computing the total gravitational force on each particle due to all other particles
– Position/velocity advanced via Newton's laws
● Not a PDE
● Direct calculation is N2, but we'll see later there is an N log N method
PHY 604: Computational Methods in Physics and Astrophysics II
Grid Basics
● It should not come as a surprise that the finer we make the grid, the more accurate our solution
● For time-dependent problems (like hyperbolic or parabolic equations), sometimes there is a relation between the size of the timestep we can take and the grid spacing
● Now when we talk about order-of-accuracy, we will need to discuss both the spatial and temporal accuracy