Smoothed Particle Hydrodynamics a meshfree particle method...

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...

Page 1: Smoothed Particle Hydrodynamics a meshfree particle method ...david/teaching/SPH/notes/ComputationalAstrophy… · Computational Astrophysics Lecture 1: Introduction to numerical

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 ...david/teaching/SPH/notes/ComputationalAstrophy… · Computational Astrophysics Lecture 1: Introduction to numerical

This  movie  shows  the  dark  ma0er  distribu3on  in  the  universe  at  the  present  3me,  based  on  the  Millennium  Simula3on,  the  largest  N-­‐body  simula3on  carried  out  at  the  3me  (more  than  1010  par3cles).  

By  zooming  in  on  a  massive  cluster  of  galaxies,  the  movie  highlights  the  morphology  of  the  structure  on  different  scales,  and  the  large  dynamic  range  of  the  simula3on.  

The  zoom  extends  from  scales  of  several  Gpc  down  to  resolved  substructures  as  small  as  ~10  kpc.

Simula3ng  the  joint  evolu3on  of  quasars,  galaxies  and  their  large-­‐scale  distribu3on

Authors:  Volker  Springel,  Simon  D.  M.  White,  Adrian  Jenkins,  Carlos  S.  Frenk,  Naoki  Yoshida,  Liang  Gao,  Julio  Navarro,  Robert  Thacker,  Darren  Croton,  John  Helly,  John  A.  Peacock,  Shaun  Cole,  Peter  Thomas,  Hugh  Couchman,  August  Evrard,  Joerg  Colberg,  Frazer  Pearce  

Simula3on  Tool:  Gadget  2  (SPH)

Visualiza3on  Tool:  Splotch

Download  video

Page 3: Smoothed Particle Hydrodynamics a meshfree particle method ...david/teaching/SPH/notes/ComputationalAstrophy… · Computational Astrophysics Lecture 1: Introduction to numerical
Page 4: Smoothed Particle Hydrodynamics a meshfree particle method ...david/teaching/SPH/notes/ComputationalAstrophy… · Computational Astrophysics Lecture 1: Introduction to numerical

Introduction

In this lecture we introduce:

• the basic concepts of SPH

• the concepts of the support and influence domains

• Problems: how to derive SPH formulations

The formulation of SPH is usually divided into two main steps

• the kernel approximation (or integral representation)

• the discretized particle approximation

The SPH formulation

Page 5: Smoothed Particle Hydrodynamics a meshfree particle method ...david/teaching/SPH/notes/ComputationalAstrophy… · Computational Astrophysics Lecture 1: Introduction to numerical

BASIC CONCEPTS (1/2)

In the SPH method we use the following key ideas:1. The problem domain is represented by a set of arbitrarily distributed particles and

no connectivity of the particles is needed (i.e. meshfree).2. We use an integral representation for the field functions and introduce a kernel

approximation. It provides stability and has a smoothing effect.3. The kernel approximation is then further approximated using particles. This is

known as the particle approximation in SPH.• Done by replacing the integral and its derivatives with summations over all

corresponding values at the neighboring particles in a local domain called the support domain (compact support).

• Results in banded sparse matrices which can be solved efficiently

κh

Page 6: Smoothed Particle Hydrodynamics a meshfree particle method ...david/teaching/SPH/notes/ComputationalAstrophy… · Computational Astrophysics Lecture 1: Introduction to numerical

Basic concepts (2/2)

4. The particle approximation is performed at each time step, so particles depend on the current local distribution of particles (adaptive). Therefore, SPH naturally handles problems with large deformation.

5. The support domain must be sufficiently large and particles can be assigned mass and become physical material particles.

6. The particle approximations are performed on all field functions to produce a set of ODE's in discretized form with respect to time only (Lagrangian). Such equations are conceptually simpler than the Eulerian equivalent.

7. The ODE's are solved using an integration algorithm to achieve fast time stepping, and to obtain the time history of all the field variables for all the particles (dynamic).

κh

So our dynamical problem is meshfree, adaptive, stable, dynamic and Lagrangian.

The detailed formulation follows!

Page 7: Smoothed Particle Hydrodynamics a meshfree particle method ...david/teaching/SPH/notes/ComputationalAstrophy… · Computational Astrophysics Lecture 1: Introduction to numerical

Integral Representation of a field function (1st main step, part I)The concept of the integral representation (or kernel approximation) of a function f(x):

where f is a function of the position vector x, and δ(x - x') is the Dirac delta function

and Ω is the volume of the integral that contains x. This is exact as long as f(x) is defined and continuous in Ω. Replace delta by a smoothing function W(x - x',h):

where W is the smoothing kernel function or smoothing function or kernel for short. The smoothing length, h, defines the influence area of W. Note, the relationship is approximate, that’s why we say kernel approximation.

(kernel approximation)

Page 8: Smoothed Particle Hydrodynamics a meshfree particle method ...david/teaching/SPH/notes/ComputationalAstrophy… · Computational Astrophysics Lecture 1: Introduction to numerical

κh

This approximation is usually written with angle brackets as

The smoothing function is chosen to be an even function and it satisfies a number of conditions. Firstly, the normalization (or unity) condition:

Secondly, the Delta function is recovered as the smoothing length approaches zero

(1)

The third condition is the compact condition

Where κ is a constant and defines the non-zero area of the smoothing function called the support domain. This condition localizes the support domain of the smoothing function. The kernel approximation is of 2nd order accuracy if W is an even function.

Page 9: Smoothed Particle Hydrodynamics a meshfree particle method ...david/teaching/SPH/notes/ComputationalAstrophy… · Computational Astrophysics Lecture 1: Introduction to numerical

Mesh-free computational fluid dynamics, NUI Galway.

κh

We can show this by expanding f(x') around x using a Taylor series. From:

where r are the higher order residuals. If W is an even function

so

We neglect the residuals r which are of second order. If we had not used an even function for W then the error in the approximation could be larger.

Page 10: Smoothed Particle Hydrodynamics a meshfree particle method ...david/teaching/SPH/notes/ComputationalAstrophy… · Computational Astrophysics Lecture 1: Introduction to numerical

Integral Representation of the derivative of a field function (1st main step, part II)The approximation for the spatial derivative ∇⋅f(x) is obtained by simply substituting f(x) with ∇⋅f(x) in equation (1).

Where the divergence in the integral is on the primed coordinate. Using the product rule ∇⋅[AB] = ∇⋅AB + A∇⋅B

Using this identity above

The first integral on the RHS can be converted using the divergence theorem into an integral over the surface S of the domain of the integration Ω.

where n is the unit vector normal to the surface.

Page 11: Smoothed Particle Hydrodynamics a meshfree particle method ...david/teaching/SPH/notes/ComputationalAstrophy… · Computational Astrophysics Lecture 1: Introduction to numerical

Since the smoothing function W is compact the surface integral is just zero and vanishes.Note: this assumes the support domain does not overlap the problem boundary as this would be non-zero.So for points whose support domain is inside the problem domain we have

(2)

The spatial gradient of the field function can be calculated from the field function and the derivatives of the smoothing function W, rather than from the derivatives of the field function themselves.

Page 12: Smoothed Particle Hydrodynamics a meshfree particle method ...david/teaching/SPH/notes/ComputationalAstrophy… · Computational Astrophysics Lecture 1: Introduction to numerical

Particle approximation (2nd main step)Objects are represented by a finite number of particles that carry mass and occupy individual spaces. Done by applying a particle approximation, where the integrals (1) and (2) can be converted into forms with summation over all the particles in the support domain.

If the infinitesimal volume dx' at the location of particle j is replaced by the finite volume of the particle ΔVj that is related to the mass of particles mj by:

Where density ρj is the mass per unit volume of the particle j(=1,2,3,…,N) in which N is the number of particles j. The SPH representation for f(x) can be written in the particle approximation as

or

(Particle approximation)

Particle approximation for the spatial derivative:

Page 13: Smoothed Particle Hydrodynamics a meshfree particle method ...david/teaching/SPH/notes/ComputationalAstrophy… · Computational Astrophysics Lecture 1: Introduction to numerical

The particle approximations are normally written as: (note that the negative sign can be removed)

The value of the function at particle i is approximated by using the average of the function at all particles in the support domain weighted by the smoothing function

Similarly for the gradient of the function.

The use of particle summation to approximate the integrals makes SPH simple and easy to implement.

The particle approximation introduces mass and density into the equations.

A simple way to calculate density in SPH is by summation density:

Note the Wij has units of inverse volume.

Page 14: Smoothed Particle Hydrodynamics a meshfree particle method ...david/teaching/SPH/notes/ComputationalAstrophy… · Computational Astrophysics Lecture 1: Introduction to numerical

Support domain and influence domain

• The support domain is where all points inside this domain are used to determine the information at point x.

• The influence domain is defined as the domain where a node (or particle in SPH) exerts its influence.

Dimensions and shapes of support domains for different points

The influence domain is associated with a node in meshfree methods and the support domain with any field point x.As SPH is a particle method that approximates field variables only on particles (or nodes) the support and influence domains are the same.

For SPH the smoothing length h multiplied by the factor κ determines the support domain.

As can be partially seen from the figure the smoothing length can vary both spatially and temporally.

Page 15: Smoothed Particle Hydrodynamics a meshfree particle method ...david/teaching/SPH/notes/ComputationalAstrophy… · Computational Astrophysics Lecture 1: Introduction to numerical

Concluding remarks

SPH is a particle based meshfree approach. There is no connectivity between the particles and only an initial particle distribution is needed.The SPH approximation consists of a kernel approximation in the continuum domain and a particle approximation in the support domain at the current time step.In the next lecture we will consider how to construct the smoothing functions introduced here.

Page 16: Smoothed Particle Hydrodynamics a meshfree particle method ...david/teaching/SPH/notes/ComputationalAstrophy… · Computational Astrophysics Lecture 1: Introduction to numerical

Problems: How to derive SPH formulations1) Using the product rule and the following vector derivative identity

show that the following two identities hold

2) Substitute these two identities into the kernel approximation

and apply the result of the particle approximation procedure to each gradient term to obtain the following results

The above results are rather desirable as the field function appears in the form of paired particles. These expressions are more useful in practice, produce a symmetric central force between particles, conserve linear and angular momentum and allow consistent energy equations to be constructed. This is the form used by Monaghan (1992) ref. [5].

∇⋅fρ

⎝ ⎜

⎠ ⎟ =

ρ∇ ⋅ f − f ⋅ ∇ρρ2