Skip to content

KristofferC/benchmark-leapfrog

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple N-Body with LeapFrog integrator

Implementation in C, Fortran, Go and Rust of a very simple N-Body simulator with 3 particles using a LeapFrog integrator. Presented in What can the programming language Rust do for astrophysics?, to appear in the Proceedings of the IAU Symposium 325 on Astroinformatics.

The code has evolved since publication, implementing several suggestion made by the Hacker News and Rust subreddit communities. The current times on a 1,6 GHz Intel Core i5 machine:

  • C: 2m53.504s
  • Fortran: 2m29.226s
  • Rust: 2m33.082s
  • Go: 3m22.032s

Output positions for the two particles after a one million year simulation:

[
    [0.00011259641961937496, 0.00011235312238407964, 0.00000982962683070781],
    [-2.986377308237493, 14588403.613911422, 1276320.0322206458]
]

The original article's conclusions are still valid for this simple user case, Rust can be as fast and precise as C or Fortran. Additionally, Rust characteristics ensures that scientific results are not affected by memory management issues and this is a great advantage for reliable scientific computation.

Compilation & execution

From each directory:

make clean
make
time target/optimized/leapfrog 

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 26.1%
  • Rust 24.5%
  • Makefile 23.4%
  • Go 15.7%
  • Fortran 10.3%