Smoothed Particle Hydrodynamics a meshfree particle method for astrophysics · 2015-02-03 ·...

16
Computational Astrophysics Lecture 1: Introduction to numerical methods Lecture 2: The SPH formulation Lecture 3: Construction of SPH smoothing functions Lecture 4: SPH for general dynamic flow Lecture 5: N-body techniques Lecture 6: Numerical Implementation Project Work (5-6 weeks) David Hobbs Lund Observatory ASTM22

Transcript of Smoothed Particle Hydrodynamics a meshfree particle method for astrophysics · 2015-02-03 ·...

Page 1: Smoothed Particle Hydrodynamics a meshfree particle method for astrophysics · 2015-02-03 · Computational Astrophysics Lecture 1: Introduction to numerical methods Lecture 2: The

Computational Astrophysics

Lecture 1: Introduction to numerical methodsLecture 2: The SPH formulation

Lecture 3: Construction of SPH smoothing functionsLecture 4: SPH for general dynamic flow

Lecture 5: N-body techniques Lecture 6: Numerical Implementation

Project Work (5-6 weeks)

David Hobbs

Lund ObservatoryASTM22

Page 2: Smoothed Particle Hydrodynamics a meshfree particle method for astrophysics · 2015-02-03 · Computational Astrophysics Lecture 1: Introduction to numerical methods Lecture 2: The

Flying through the hot plasma atmosphere of a galaxy clusters visualizing temperature, reveling the richness of substructure and their dynamics during the formation of the largest gravitational bound objects in the universe. When falling into the cluster, the galaxies are losing their gaseous atmosphere (appearing in white), forming comet-like features of gas trails. Due to tidal forces these trails sometimes get deformed into arc-like structures.

Flying  through  galaxy  clusters

Authors: Klaus Dolag

Simulation Tool: Gadget 2 (SPH)

Visualization Tool: Splotch

Download video

Page 3: Smoothed Particle Hydrodynamics a meshfree particle method for astrophysics · 2015-02-03 · Computational Astrophysics Lecture 1: Introduction to numerical methods Lecture 2: The
Page 4: Smoothed Particle Hydrodynamics a meshfree particle method for astrophysics · 2015-02-03 · Computational Astrophysics Lecture 1: Introduction to numerical methods Lecture 2: The

IntroductionIn this lecture we review the properties of smoothing functions and present some common examples

A generalized approach to constructing smoothing functions is presented.

The approach uses an integral representation and Taylor series expansions.

Analytical smoothing functions are given.

Examples of widely used smoothing functions are derived.

Problems:

Derive a smoothing function

Construction of SPH smoothing functions

Page 5: Smoothed Particle Hydrodynamics a meshfree particle method for astrophysics · 2015-02-03 · Computational Astrophysics Lecture 1: Introduction to numerical methods Lecture 2: The

Smoothing function properties (1/2)

A central problem in meshfree methods is how to effectively construct smoothing functions, W, based on a set of particles scattered in an arbitrary manner.The SPH method uses an integral representation of the smoothing functionThe smoothing function (or kernel) is important as it

• determines the shape for the function approximation• defines the dimensions of the support domain• determines the accuracy of both the kernel and particle approximations

Different smoothing functions have been used in the literature.

Page 6: Smoothed Particle Hydrodynamics a meshfree particle method for astrophysics · 2015-02-03 · Computational Astrophysics Lecture 1: Introduction to numerical methods Lecture 2: The

Smoothing function properties (2/2)• The smoothing function must be normalized over its support domain

• The smoothing function are compactly supported (allows for sparse discrete matrices)

The dimensions are defined by the smoothing length h and the scaling factor κ

• W(x - x') ≥ 0 for any point at x' within the support domain of the particle x, i.e. positive, to be physically meaningful

• The smoothing function should monotonically decrease with distance to represent decreasing interaction

• The smoothing function should satisfy the Dirac delta function as h approaches zero

• Even function, i.e. symmetric to ensure inverse interactions have the same strength• Should be sufficiently smooth to ensure that it and it’s derivatives achieve reasonable

accuracy

Page 7: Smoothed Particle Hydrodynamics a meshfree particle method for astrophysics · 2015-02-03 · Computational Astrophysics Lecture 1: Introduction to numerical methods Lecture 2: The

where αd is 5/(4h), 5/(πh2) and 105/(16πh3) in 1-, 2- and 3-D respectively to satisfy the unity condition. R is the relative distance between two points

and r is the distance between the two points.

Common smoothing functions (1/3)The original SPH paper by Lucy ref. [7] used a bell shaped smoothing function

Page 8: Smoothed Particle Hydrodynamics a meshfree particle method for astrophysics · 2015-02-03 · Computational Astrophysics Lecture 1: Introduction to numerical methods Lecture 2: The

Monaghan ref. [5] assumed a Gaussian smoothing function for the best physical fit to non-spherical stars, where αd is 1/(π(1/2)h), 1/(πh2) and 1/(π(3/2)h3) in 1-, 2- and 3-D respectively.

Common smoothing functions (2/3)

This is a very stable choice but not very compact as it approaches zero very slowly (=> computationally expensive).

Page 9: Smoothed Particle Hydrodynamics a meshfree particle method for astrophysics · 2015-02-03 · Computational Astrophysics Lecture 1: Introduction to numerical methods Lecture 2: The

Common smoothing functions (2/3)

where αd is 1/h, 15/(7πh2) and 3/(2πh3) in 1-, 2- and 3-D respectively. It resembles a Gaussian function but is more compact. However, splines are piecewise and the second derivative can be less smooth and more complex

Other smoothing functions also exist but how are they constructed?

The most widely used smoothing function is the cubic spline known as a B-spline function

Page 10: Smoothed Particle Hydrodynamics a meshfree particle method for astrophysics · 2015-02-03 · Computational Astrophysics Lecture 1: Introduction to numerical methods Lecture 2: The

Constructing smoothing functions (1/2)The smoothing function is assumed to be a polynomial depending only on the relative distance between the points.We assume the following form in the support domain with an influence width of κh.

If the ith order derivative of the smoothing function at R=0 exists then the 1st derivative must vanish (see diagram).

W (R) = a0 + a1R + a2R2 + ...

" W (R) = 0+ a1 + 2a2R + ..." " W (R) = 0+ 0+ 2a2 + ...

Substituting W into the constraints, the coefficients a0, a2, …,an can be calculated.

W'(R) must pass through zero at R=0 for an even symmetric function.

If W'(0)=0 then a1 must be equal to zero and in general a2!=0. Thus, W''(R) can only exist if a1 = 0. This rule holds more generally for higher orders but normally in SPH we are interested only in the 1st and 2nd derivatives. In general for W''(R) to exist:

Page 11: Smoothed Particle Hydrodynamics a meshfree particle method for astrophysics · 2015-02-03 · Computational Astrophysics Lecture 1: Introduction to numerical methods Lecture 2: The

Constructing smoothing functions (2/2)

Other issuesWhen using some higher order approximations the smoothing functions are not necessarily positive in the whole support domain, which may result un unphysical solutions, e.g. negative density or energy.The central peak of the smoothing function determines how much the particle itself contributes to the approximation.The highest order of accuracy of the kernel approximation is 2nd order so the moment M2 can be used as a rough indicator of the accuracy.

The smaller M2 is the better the approximation as a positive smoothing function with a large central peak will have a smaller M2 i.e. Dirac delta like.

Page 12: Smoothed Particle Hydrodynamics a meshfree particle method for astrophysics · 2015-02-03 · Computational Astrophysics Lecture 1: Introduction to numerical methods Lecture 2: The

Likewise in 2-D and 3D respectively we have:

2πr is the length of circle's circumference and 4πr2 is the surface area of sphereAgain, solve each together with the compact condition to obtain values for a0 and a2.

with αd is 3/(4h), 2/(πh2), and 15/(8πh3) in 1-, 2-, and 3-D respectively. Please check these results yourself.

Example 1: Dome-shaped quadratic smoothing functionIf the smoothing function is quadratic in R and the scaling factor κ=1, then we have the following form:

Using the normalization condition in 1-D

From the compact property we have: which leads to

Solving the linear equations gives a0=3/(4h) and a2=-3/(4h).So the the quadratic kernel in 1-D is where α1=3/(4h).

Page 13: Smoothed Particle Hydrodynamics a meshfree particle method for astrophysics · 2015-02-03 · Computational Astrophysics Lecture 1: Introduction to numerical methods Lecture 2: The

W (R, h) = (a0 + a2R2 + a3R

3 + a4R4)

= (a0 + a2(r

h)2 + a3(

r

h)3 + a4(

r

h)4)

Example 2: Quartic smoothing functionThe original quartic smoothing function used by Lucy (1977) ref. [7] is constructed with κ=1 as follows:

With four unknown coefficients so four equations are necessary.

From the compact constraint

Using the unity condition in 1-, 2- and 3-D respectively we have

Solving for each dimension with the compact constraint gives

with αd equal 5/(4h), 5/(πh2), and 105/(16πh3) in 1-, 2-, and 3-D respectively. Please check these results yourself.

Page 14: Smoothed Particle Hydrodynamics a meshfree particle method for astrophysics · 2015-02-03 · Computational Astrophysics Lecture 1: Introduction to numerical methods Lecture 2: The
Page 15: Smoothed Particle Hydrodynamics a meshfree particle method for astrophysics · 2015-02-03 · Computational Astrophysics Lecture 1: Introduction to numerical methods Lecture 2: The

Summary of smoothing functionsSmoothing functions determine the shape, effective support domain and accuracy of the approximation.

Taylor series expansions can be used to derive conditions for the kernel approximation.

These conditions can then be used to systematically construct smoothing functions.

A few important points are listed below:

• The use of partially negative smoothing functions in SPH can lead to unphysical results for hydrodynamical problems where density or energy are used

• The center peak value of the smoothing function plays an important role in determining the accuracy of the SPH kernel approximation

• Piecewise construction of smoothing functions are among the most popular and can provide greater flexibility and accuracy

Page 16: Smoothed Particle Hydrodynamics a meshfree particle method for astrophysics · 2015-02-03 · Computational Astrophysics Lecture 1: Introduction to numerical methods Lecture 2: The

Problem: Construct the piecewise cubic smoothing functionThe piecewise cubic smoothing function is the most widely used smoothing function in SPH to date. It is defined with connection point R=1 and κ=2 as

The compact constraints are more complex here as the first and second derivatives at the connection points should be continuous also. Given this compact and continuous constraint as

and in 1-D the unity condition is (note that we add the pieces together here):

which simplifies to

Solving these two equations gives b1= -2/(3h) and b2=1/(6h). 1) Check that this is correct.2) Continue the derivation for the 2-D and 3-D cases and express the final results as W(R,h) = αd( ? ) where αd equals 1/h, 15/(7πh2), and 3/(2πh3) in 1-, 2-, and 3-D respectively.3) Plot your results in 1-D, 2-D and 3-D for the smoothing function and its partial derivatives (use matlab).