james_reinders
Software Programmer

Raise Your Hand and Ask: What’s an ‘N-Body Simulation’?

opinion
Mar 21, 20175 mins

istock 498578425
Credit: istock

Note: Most people don’t want to be the uncool one to raise their hand and ask a question, but in many cases we really should. These occasional ‘Raise Your Hand and Ask” posts highlight cool “buzzwords” you may have heard. My aim isn’t just to explain what they mean (that you can look up), but also why they matter.

What does “N-body” mean – and why should I care?

How do researchers evaluate potential cures for HIV and AIDS?

N-body simulations.

How do astrophysicists study the expansion of the universe, and the nature of dark matter?

N-body simulations.

How do scientists looking to enable controlled fusion study plasma physics?

N-body simulations.

N-body literally means “N” (some number) of “bodies” (objects).  A simulation of N bodies is a simulation of N objects and their interactions over time.  Keep in mind, each of the N bodiesare busy moving around. Therefore, each body has a direction, velocity, and perhaps a charge.  When we seek to simulate their movement over time, we will update the information regarding each body in each time step.  We need to consider what happens to each of the bodiesin each time step tofind where they are for the start of our next time step simulation.

17 1 istock

Four forces – not yet grandly unified

Bodies are subject to four “fundamental interactions”: strong nuclear, weak nuclear, electromagnetic, and gravitational.  The first two have forces only at incredibly short distances (subatomic). Gravitational interaction between masses, and the electromagnetic interaction between charges, are examples of long range forces. Long range forces decrease inversely as the square of the distance. In other words, twice the distance means one-quarter of the force.  Within tight quarters, we may need to consider all four forces. As we expand distance, we can start to consider only gravitational and electromagnetic. At very large distances, only gravitational forces matter because electromagnetic forces essentially cancel each other out on the scale of planets, stars, and galaxies.

Assuming we simulate the activity of our numerous (N) bodies, we could compute all pairwise forces by making N2 computations. This is an unacceptable amount of computation for reasonable numbers of objects, and therefore an interesting thing about “N-body simulations” becomes how to simplify our simulations to make them practical to compute.

Approximate by grouping into regions (close vs. far)

To get the best of both worlds, we can consider our bodies into regions, and do pairwise computations only on bodies within a single region. We can focus on the forces in close-range interactions within a region, and use a faster method based on a far-field approximation of longer-range forces, which is valid only between regions of the system that are well separated. Methods to speed up solving N-body problems fall into three categories: particle-mesh methods (best for uniformly spaced N bodies), tree-code methods (better suited than mesh when bodies are highly non-uniform such as stars in a galaxy), and fast multipole methods (FMM, also well suited for non-uniform distributions).

For cosmic simulations, where bodies are stars, planets, etc., the interactions are all gravitational in nature as the other forces do not matter.  Gravitational N-body simulations can be used to simulate celestial mechanics such as the expansion of the universe, or the orbits of planets and comets.

For molecular dynamics, fluid dynamics, and plasma physics, where bodies are molecules, atoms, or subatomic particles, forces other than gravitational need to be included, at least within a region where bodies are closest to one another.

Molecular dynamics can lead to cures

Simulations of molecular dynamics have great importance in the biochemistry and molecular biology fields. The simulations can involve the interactions of proteins, nucleic acids, membranes, virus, and drugs. Such simulations can help us understand diseases and evaluate potential cures. For instance, an anti-viral drug generally works by either interfering with replication (stopping a virus from unfolding) or blocking its movement in the body (making it unable to pass through cell membranes).  Simulations can help understand the potential effectiveness of such treatments when deployed within the complexities of a body.

N-body simulations – a key technique

For whatever reason, if you have a collection of objects interacting with each other, then you have an N-body problem. Concepts around how to simulate their interactions constitute a broad topic, which has received a lot of attention. Knowing that the broad topic is called “N-body simulations” is the first step to understanding how to tap into this richly studied and supported field.

If you want to dig a little deeper, here are some recommended readings:

Click here to download your free 30-day trial of Intel Parallel Studio XE

james_reinders
Software Programmer

James Reinders is a software programmer with a passion for Parallel Programming and Parallel Computer Architecture. He has contributed to the development of some of the world’s fastest computers, and the software tools that make that performance accessible for programmers. James has shared this passion in classes, webinars, articles and has authored eight books for software developers. James enjoyed 10,001 days working at Intel, and now continues to share his passion to help others “Think Parallel.”

More from this author