sph vs lagrange

download sph vs lagrange

of 32

Transcript of sph vs lagrange

  • 8/7/2019 sph vs lagrange

    1/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Lagrangian methods and SmoothedParticle Hydrodynamics (SPH)

  • 8/7/2019 sph vs lagrange

    2/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Eulerian Grid Methods

    The methods covered so far inthis course use an Euleriangrid:

    Prescribed coordinates

    In `lab frame' Fluid elements flow

    through grid zones

  • 8/7/2019 sph vs lagrange

    3/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Eulerian Grid Methods

    This is probably the standardapproach to solving theequations of fluid motions inmost disciplines.

    Many decades of research intosolution techniques

    Extremely sophisticated, high-order accuracy methods

    Can accurately describe verycomplex phenomena.

  • 8/7/2019 sph vs lagrange

    4/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Eulerian Grid Methods

    However, simplestpossible dynamics faressurprisingly poorly

    Even high-ordermethods are quitediffusive whenadvection over a largenumber of grid cells isnecessary

  • 8/7/2019 sph vs lagrange

    5/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Eulerian Grid Methods

    This is fundamental to how

    Eulerian grid codes work.

    Can be ameliorated but not fixed.

    Once some of a quantity enters agrid cell its contribution is spread

    throughout domain through someaveraging procedure.

    Higher order methods do this to alesser degree than lower-order

    methods, but the effect remains.Occurs for any evolved quantity.

    ``Numerical diffusion''

  • 8/7/2019 sph vs lagrange

    6/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Advection-Dominated Flows

    There are many systems in

    astrophysics which aredominated by large-scaleadvection of fluid

    Eulerian grid is not necessarilythe most natural approach in

    these systems

    Cosmology: evolution isdominated by large scale fallingof material onto local density

    enhancements

  • 8/7/2019 sph vs lagrange

    7/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Advection-Dominated Flows

    There are many systems in

    astrophysics which aredominated by large-scaleadvection of fluid

    Eulerian grid is not necessarilythe most natural approach in

    these systems

    Accretion disks: Flow isdominated by differentialKeplarian rotation around

    central object

  • 8/7/2019 sph vs lagrange

    8/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    1D Lagrangian Formulation

    Lagrangian formulation

    given in lecture 4No fluxes `through' fluid

    element interfaces, asno transport through

    interfaces*

    Typically implemented ona staggered grid:

    No purely advective fluxes!

    *

    absent other physics like dissipative transport

    vi-1

    p,ei

    vi+1

    p,ei-1

    vi

  • 8/7/2019 sph vs lagrange

    9/32

  • 8/7/2019 sph vs lagrange

    10/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    1D Lagrangian Formulation

    Huge benefit: openboundaries mesh canexpand as necessary

    And, of course, nonumerical diffusion frompurely moving fluidaround

  • 8/7/2019 sph vs lagrange

    11/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    1D Lagrangian Formulation

    These advantages make1d lagrangian gridmethods a naturalchoice for applicationssuch as stellar evolution

    Typically use `masscoordinates' evenoutside of numerical

    context

  • 8/7/2019 sph vs lagrange

    12/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Multi-D Lagrangian Gridding

    Works extremely well in

    1d.

    In multidimensions,more complexitypossible in geometry

    Even differentialrotation / shear canlead to disasterously

    tangled meshes.More complex motions

    almost hopeless

  • 8/7/2019 sph vs lagrange

    13/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Multi-D Lagrangian GriddingCan deal with this

    problem byremeshing every sooften

    Remeshing can be a

    very expensive step(choosing an optimalnew mesh for a set ofpoints is difficult)

    Loss of main benefit ofLagrangian method diffusive (as fluid`moves through'remeshing)

  • 8/7/2019 sph vs lagrange

    14/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Grid is a way of assigningneighbors to structure localinteractions.

    If can determine localneighbors without discretizing

    on a grid can avoid the issueswith tangling/remapping

    Astrophysics has a long (>60yr) history with one gridlessmethod gravitational N-bodycalculations

    Gridless methods

  • 8/7/2019 sph vs lagrange

    15/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    It is clearly true that one can

    write the density field in adomain as integral over infinitenumber of point particles:

    N-body calculationapproximates this by using afinite number of particles

    N-body calculation

    http://www.physics.drexel.edu/~steve/n-body.html

  • 8/7/2019 sph vs lagrange

    16/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Smoothed Particle Hydrodynamics

    For hydrodynamics, interactions need to be local

    Quantities stored at N `free' particles

    If infinite number of particles, any hydrodynamicquantity A could be defined as

    Finite number of particles quantities must be

    smoothed over some finite smoothing length h

  • 8/7/2019 sph vs lagrange

    17/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Properties of smoothing function W(r,h)

    In small h limit, goes to delta function (usually) symmetric about r=0

    Compact support W is exactly zero outside ofsome finite radius around the particle

    Cubic spline is typical choice

  • 8/7/2019 sph vs lagrange

    18/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    SPH `Discretization' Error

    Even in this limit, smoothed quantity has errorO(h2) [Why?]

    Very difficult (likely impossible) to have robust,stable smoothing with higher order accuracy.

    With finite number of particles,

  • 8/7/2019 sph vs lagrange

    19/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    SPH `Discretization' Error

    Taylor expand this around particle `a's position,and define W

    ab= W(r

    a r

    b,h)

    Even for constant function (say, A = 1), not

    guaranteed exact; must divide by first term, egdo SPH interpolation of A / SPH interpolation of 1.

  • 8/7/2019 sph vs lagrange

    20/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    SPH `Discretization' Error

    Error comes from discretization finite number of particles

    No guarantee that there will beenough particles well enoughdistributed so that

    although corrections can be made

    This problem is much worse forderivatives; numericalderivatives of `noisy' data known

    hard problem.

  • 8/7/2019 sph vs lagrange

    21/32

  • 8/7/2019 sph vs lagrange

    22/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Lagrangian Formulation

    Can now express other equations in terms ofLagrangian, Hamiltonian dynamics

    Lagrangian for Hydrodynamics is

    from Euler-Lagrange equations, get eqn of motion

  • 8/7/2019 sph vs lagrange

    23/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Momentum Equation

    Note symmetry; contribution to momentum ofparticle a from b equal and opposite to b from a

    Conserves momentum exactly

    This form of gradient of pressure has somediscreteness inaccuracies, but the symmetry ismuch more important

  • 8/7/2019 sph vs lagrange

    24/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Energy Equation

    Similarly, Hamiltonian can be written

    implying a specific energy equation

    again, note symmetry.

    Because of troubles with internal energy evolutionin high-speed flows, some SPH practitionersevolve entropy rather than energy; applies to gridcodes too.

  • 8/7/2019 sph vs lagrange

    25/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Setting Initial Conditions in an SPH code

    Unlike grid code (ICs are set everywhere in

    domain), have to sample (typically randomly) thedensity profile and put particles there

    If under-resolving the density profile is a problem,some caution is necessary; fluctuations causedby particle placement can be a problem. Mayhave to relax initial conditions.

    Cosmology: extreme care needed --- any initial

    fluctuations in density become large scalestructure! Specialized techniques.

  • 8/7/2019 sph vs lagrange

    26/32

  • 8/7/2019 sph vs lagrange

    27/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Time Evolution

    i li i l i

  • 8/7/2019 sph vs lagrange

    28/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Visualization/Analysis

    Grid code: output is a complete description of

    hydrodynamic states throughout domain.

    Easy to visualize, analyze many instantaneousquantities much harder to examine histories offluid elements.

    SPH: Opposite problem; can see what happens toany one fluid parcel immediately, but need someanalysis tools even just to make a picture of what

    the domain looks like

    Vi li i /A l i

  • 8/7/2019 sph vs lagrange

    29/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Visualization/Analysis

    Create a grid, use SPH interpolation tofind quantities at each point on grid

    Complications

  • 8/7/2019 sph vs lagrange

    30/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    Complications(Things I really should talk about but don't

    have time) Need artificial viscosity to handle shocks

    Real world necessities variable timesteps andsmoothing lengths complicate or break some of

    SPHs nice qualities There are a variety of techniques for finding

    neighbors within some distance h ; one commontechnique, using tree searches, integrates very

    nicely with using the same tree for gravitationalN-body solving, making SPH + treecode gravity avery natural match.

    SPH G id C d

  • 8/7/2019 sph vs lagrange

    31/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    SPH vs Grid Codes Handes open, free

    boundaries muchbetter

    Much less diffusion forbulk motion

    Automatically resolveshigh density region

    No need to wastecomputation on empty

    space

    Couples naturally to N-body gravity

    Very robust

    Poor at dealing with

    shocks Low-order spatial

    accuracy

    Derivatives harder,

    making some physics(MHD) harder

    More caution requiredwith initial conditions

    Hard to followinteresting dynamicsin low-density regions

    Too robust?

    SPH

  • 8/7/2019 sph vs lagrange

    32/32

    Computation in Astrophysics Seminar(Spring 2006)L. J. Dursi

    SPH resources

    References:

    Price (2005) astro-ph/0507472: Thesis chapter,very good review

    Codes

    GADGET-2: Robust, widely-used SPH code http://www.mpa-garching.mpg.de/gadget/

    StarCrash:

    http://www.astro.northwestern.edu/StarCrash/ SuperSPHplot: visualization tool

    http://www.astro.ex.ac.uk/people/dprice/supersphplot/

    http://www.mpa-garching.mpg.de/gadget/http://www.astro.ex.ac.uk/people/dprice/supersphplot/http://www.astro.ex.ac.uk/people/dprice/supersphplot/http://www.mpa-garching.mpg.de/gadget/