n-body techniques for astrophysics: lecture 1 – general ...web.pd.astro.it/mapelli/nbody1.pdf ·...
TRANSCRIPT
Michela Mapelli
N-body techniques for astrophysics:
Lecture 1 – General Introduction
PhD School in Astrophysics, University of PadovaNovember 3-12, 2015
This course is NOT: a programming course, an advanced algorithm course
The aim of this course: to learn the basic concepts ofstate-of-the-art techniques of N-body simulations in astrophysics
At the end of the course you should be able to: - if you are an observer / a technologist, you should be able to critically read and understand a paper about simulations in your field (star clusters, galaxies..) or maybe even run some simple simulation;
- if you are a theorist / you already do simulations, you mightacquire experience in different fields (e.g. if you are a cosmologist, you will be able to run simulations of a star cluster)
The lectures: 7 lectures by me, last lecture by my collaborator Mario Spera
A few words about the course:
Address: Michela MapelliOsservatorio AstronomicoAla sud, secondo [email protected] 8293527
Lectures will be published at
http://web.pd.astro.it/mapelli/lectures.html
Note: fill in the course evaluation sheet. It is anonymous, it helps me improving the lectures
Disclaimer: This course is still in the beta version – sorry for the trouble!
ASK MANY QUESTIONS, it is important for you and me!!!!
A few words about the course:
The EXAM: → preferred option: choose one code (among those I present
or even others), choose a test simulation (e.g. a star cluster, a galaxy, a molecular cloud,...), run the test simulation, write a SHORT report on the simulation and discuss it with me
→ disaster option: choose a paper about N-body simulations and discuss it with me (if you really feel you cannot do the preferred option)
The resources: you can either use your laptop, or your facilities (if you have computer time), or the computers in aula informatica
BUT DON'T MESS WITH THE SYSTEM MANAGERS, PLS
- don't unplug cables- don't smash computers- don't use the computers for something not related to the course
A few words about the course:
OUTLINE of the LECTURES:
1. WHAT IS an N-Body SIMULATION? DefinitionsExamples of solvers: Euler, Leapfrog Computational complexityN-body units!!
2. DIRECT N-body for COLLISIONAL SYSTEMS DO WE NEED DIRECT N-BODY CODES?Hermite integrator schemeTime stepRegularizationStellar evolutionHardware: Grape – GPUsExample codes: STARLAB, HiGPUs, Archain, BSE
3. N-body methods for collisionless systems:SofteningTree codeParticle Mesh and Fast Multipole codesClusters of computersExample codes: ChanGa no gas
4. GAS:Equations of gasSmoothed-particle hydrodynamics (SPH) codesMesh codes/ Adaptive mesh refinement codes (AMR)Example codes: ChanGa with gas, RAMSES
5. OTHER PHYSICS:Radiative transferSNaeStar formation
6. INITIAL CONDITIONS:Random sampling of a distribution functionExamples
1. WHAT IS an N-Body SIMULATION?
??
1. WHAT IS an N-Body SIMULATION?
numerical integration of the forces acting on N particles for a time t
- astrophysics- fluid-dynamics- molecular dynamics- ...
WHAT IS an N-Body SIMULATION ** IN ASTROPHYSICS **?
numerical integration of the force of GRAVITY acting on N particles for a time t
1. WHAT IS an N-Body SIMULATION?
numerical integration of Newton equation
Or the equivalent system of 2xNxndim 1st ord. differential eqs
DOES IT HAVE ANALYTIC SOLUTION?
1. WHAT IS an N-Body SIMULATION?
- 1687: Newton finds the equation
- 1710: Bernoulli derives analytic solution for N=2
- 1885: a challenge was proposed to be answered before21st January 1889, in honor of the 60th birthday of King Oscar II of Sweden and Norway.
'Given a system of arbitrarily many mass points that attract each according to Newton’s law, under the assumption that no two points ever collide, try to find a representation of the coordinates of each point as a series in a variable that is some known function of time and for all of whose values the series converges uniformly.
NOBODY WON THE PRIZE
- 1991: Wang finds a convergent power series solution for a generic number of bodies. Mathematically correct, but too difficult and slow convergence
1. WHAT IS an N-Body SIMULATION?
- Analytic problem only for N=2 (and restricted N=3)
- gravity force does not fade off (even far away particle interact)→ calculation of system cannot be decomposed in smaller
pieces
A system of 2 x N x ndim differential equations with NO known analytic solution
→ FIND A NUMERICAL SOLUTION
WHAT WOULD YOU DO?
1. WHAT IS an N-Body SIMULATION?
TAYLOR EXPANSION
Predicting time t +∆twith info at time t
Truncation order gives error order
A 1st order method has ∆t order errorsA 2nd order method has ∆t2 order errorsA 3rd order method has ∆t3 order errors...
1. WHAT IS an N-Body SIMULATION?
EULER METHOD: Taylor expansion at 1st order
xi
t∆t
EXPLICIT SCHEME = depends only on quantitiesat time t (which we know)
xi(t), vi(t), ai(t)
1. WHAT IS an N-Body SIMULATION?
EULER METHOD: Taylor expansion at 1st order
xi
t∆t
EXPLICIT SCHEME = depends only on quantitiesat time t (which we know)
xi(t), vi(t), ai(t)
1. WHAT IS an N-Body SIMULATION?
LEAPFROG METHOD: The name comes from the leapfrog game
IDEA: evaluation of velocity and position jumps like little happy frogs within a timestep..
1. WHAT IS an N-Body SIMULATION?
LEAPFROG METHOD: same as Euler but evaluated in between a timestep
t t+∆t/2 t+∆t
x(t), v(t), a(t) v(t+∆t/2) x(t+∆t), v(t+∆t), a(t+∆t)x(t), v(t), a(t)
1. WHAT IS an N-Body SIMULATION?
LEAPFROG METHOD: same as Euler but evaluated in between a timestep
t t+∆t/2 t+∆t
x(t), v(t), a(t) v(t+∆t/2) x(t+∆t), v(t+∆t), a(t+∆t)x(t), v(t), a(t)
v(t) → v(t+∆t/2)
1. WHAT IS an N-Body SIMULATION?
LEAPFROG METHOD: same as Euler but evaluated in between a timestep
t t+∆t/2 t+∆t
x(t), v(t), a(t) v(t+∆t/2) x(t+∆t), v(t+∆t), a(t+∆t)x(t), v(t), a(t)
v(t) → v(t+∆t/2)
x(t) → x(t+∆t)
1. WHAT IS an N-Body SIMULATION?
LEAPFROG METHOD: same as Euler but evaluated in between a timestep
t t+∆t/2 t+∆t
x(t), v(t), a(t) v(t+∆t/2) x(t+∆t), v(t+∆t), a(t+∆t)x(t), v(t), a(t)
v(t) → v(t+∆t/2)
x(t) → x(t+∆t)
v(t+∆t/2) → v(t+∆t)
1. WHAT IS an N-Body SIMULATION?
LEAPFROG METHOD: same as Euler but evaluated in between a timestep
t t+∆t/2 t+∆t
x(t), v(t), a(t) v(t+∆t/2) x(t+∆t), v(t+∆t), a(t+∆t)x(t), v(t), a(t)
v(t) → v(t+∆t/2)
x(t) → x(t+∆t)
v(t+∆t/2) → v(t+∆t)
D
KK
Kick + Drift + Kick (KDK) scheme
1. WHAT IS an N-Body SIMULATION?
LEAPFROG METHOD: same as Euler but evaluated in between a timestep
t t+∆t/2 t+∆t
x(t), v(t), a(t) v(t+∆t/2) x(t+∆t), v(t+∆t), a(t+∆t)x(t), v(t), a(t)
1. WHAT IS an N-Body SIMULATION?
EULER LEAPFROG
EULER VS LEAPFROG METHOD a simple test: Both Euler and Leapfrog are 2d order methods, but..
Same initial conditions: integration of a Keplerian binary
1. WHAT IS an N-Body SIMULATION?
EULER VS LEAPFROG METHOD a simple test: Both Euler and Leapfrog are 2d order methods, but..
Same initial conditions: integration of a Keplerian binary
1. WHAT IS an N-Body SIMULATION?
EULER VS LEAPFROG METHOD a simple test: Both Euler and Leapfrog are 2d order methods, but..
A possible hint for the final exam: if you like programming, you can write a simple LEAPFROG code!!!!
1. WHAT IS an N-Body SIMULATION?
numerical integration of Newton equation for
- Analytic problem only for N=2 (and restricted N=3)
- gravity force does not fade off (even far away particle interact)→ calculation of system cannot be decomposed in smaller
pieces
SCALING of a NUMERICAL PROBLEM:
Numerical complexity:How many calculations I have to do for N-particles?
1. WHAT IS an N-Body SIMULATION?
SCALING of a NUMERICAL PROBLEM:
Numerical complexity:
How many calculations I have to do for N-particles
3 particles6 forcesN (N - 1)
1. WHAT IS an N-Body SIMULATION?
SCALING of a NUMERICAL PROBLEM:
Numerical complexity:
How many calculations I have to do for N-particles
4 particles12 forcesN (N - 1)
1. WHAT IS an N-Body SIMULATION?
SCALING of a NUMERICAL PROBLEM:
Numerical complexity:
How many calculations I have to do for N-particles
9 particles72 forcesN (N – 1)
COMPLEXITY GROWS as N^2 - VERY FAST !!!!
1. WHAT IS an N-Body SIMULATION?
SCALING of a NUMERICAL PROBLEM:
COMPLEXITY GROWS as N^2 - VERY FAST !!!!
- CAN I REDUCE COMPLEXITY?
YES, BUT IT IS NOT ALWAYS THE RIGHT CHOICE→ See direct vs indirect N-body LECTURE 2
- HOW CAN I REDUCE COMPLEXITY?E.G. with BARNES-HUT TREE METHODand/or with MULTIPOLE EXPANSION→ See LECTURE 3
1. WHAT IS an N-Body SIMULATION?
N-body UNITS:
MOST N-body codes work in N-body units
since Gravity is the main force, choose units so that G=1
1. WHAT IS an N-Body SIMULATION?
N-body UNITS:
N-body UNITS: