{"id":18822362,"url":"https://github.com/zardoz89/nbodysim","last_synced_at":"2026-02-08T16:33:26.255Z","repository":{"id":6092203,"uuid":"7319159","full_name":"Zardoz89/nBodySim","owner":"Zardoz89","description":"N Body Simulator","archived":false,"fork":false,"pushed_at":"2020-02-14T09:52:09.000Z","size":37,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-30T13:06:40.627Z","etag":null,"topics":["d","n-body-simulator"],"latest_commit_sha":null,"homepage":null,"language":"D","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Zardoz89.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-12-25T17:19:32.000Z","updated_at":"2021-06-15T23:30:32.000Z","dependencies_parsed_at":"2022-08-27T12:42:26.354Z","dependency_job_id":null,"html_url":"https://github.com/Zardoz89/nBodySim","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Zardoz89/nBodySim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zardoz89%2FnBodySim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zardoz89%2FnBodySim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zardoz89%2FnBodySim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zardoz89%2FnBodySim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zardoz89","download_url":"https://codeload.github.com/Zardoz89/nBodySim/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zardoz89%2FnBodySim/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29236898,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-08T14:18:14.570Z","status":"ssl_error","status_checked_at":"2026-02-08T14:18:14.071Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["d","n-body-simulator"],"created_at":"2024-11-08T00:49:04.719Z","updated_at":"2026-02-08T16:33:26.240Z","avatar_url":"https://github.com/Zardoz89.png","language":"D","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nBodySim : N Body problem Simulator\n\nnBodySim is a small simulator programa capable of handling huge number of bodies (\u003e1000). It's capable of using multiple cores of a modern many-core CPU. For this, nBodySim is programed using D Language 2, using the std.parallelism library.\n\nThis software was compiled with gdc 4.6.3 and dmd 2.0.65,  and tested on some machines using Ubuntu x64 14.04, 12.04, 12.10 and Linux ROCKS 6.0 x64.\n\nTo build it, use DUB. So do a simple :\n\n    dub build=release\n\nIt will generate the program using parallel for. If you like  to compare with the serial version, you can launch dub with ```--configure=nBodySim-serial```\n\n## Usage\n    ./nBodySim [OPTION]...\n- -i, --input=FILE                  Input file with initial positions and velocity\n                                    of every body\n- -o, --output=FILE                 Output data file\n- -d, --deltat=NUM                  Delta of Time used in each step. By default is\n                                    86400 [s]\n- -n, --num=NUM                     Total number of steps. by default is 36500, that\n                                    with default DeltaT, is 100 years of simulation\n- --points=NUM                      Defines every few points that are written to\n                                    output file. 1 means that are used all points, 2\n                                    that 1/2 of the total points not are written. By\n                                    default is 4\n- -e, --epsilon=NUM                 Softening factor used that avoid NaNs and Inf in\n                                    calculations. By default is 1000 meters\n- --rand=NUM                        If not are using a input file, then generate NUM\n                                    random stellar mass bodies in a cube of 10 LY\n- --seed=NUM                        Set a seed for the random generator\n- --center=NUM                      Set the output coords relative to the entity NUM\n                                    Useful to centre around a particular entity,\n                                    like the Sun\n- -h, --help                        Show this help\n\n**Note** : If it is used without any option, will try to open ssolar.sim file\n\n### Examples\n- Execute a simulation of 100 years with a DeltaT of a 1 day of our solar system fixing the Sun in the (0,0,0) position\n        ```./nBodySim --input ssolar.sim --center 0 --output ssolar.out```\n- Execute a simulation of 10000 years with a DeltaT of 100 days of a ranmdon set of 500 stars\n        ```./nBodySim --rand 500 -d8640000 --output rand.out```\n\n## Output files\nFor the moment, nBodySim it's outputing files that are compatible with [GnuPlot](http://www.gnuplot.info/), where in a row we can found the position of *every* object in the simulation for a determinated moment ofthe simulation.\nIt's easy to plot hte data using 'splot' command of gnuplot, but be carefull about how many points (rows) are stored in the file, becasue GnuPlot can be easily swamped. I recomend using --points to skip points to be stored in the output file, and keep it easy to hnadle for the gnuplot at same tiem that allow to run long (big number of iterations).\n\n### View output on gnuplot\n\n View the output data of the simulation of our solar system\n\n```\nset zrange [-8e+12:8e12]\nset title \"Solar System : 100 years\"\nsplot \"ssolar.out\" u 1:2:3 t \"Sun\", \\\n\"ssolar.out\" u 4:5:6 w dots t \"Mercury\", \\\n\"ssolar.out\" u 7:8:9 w dots t \"Venus\", \\\n\"ssolar.out\" u 10:11:12 w dots t \"Earth\", \\\n\"ssolar.out\" u 13:14:15 w dots t \"Moon\", \\\n\"ssolar.out\" u 16:17:18 w dots t \"Mars\", \\\n\"ssolar.out\" u 19:20:21 w dots t \"Jupiter\", \\\n\"ssolar.out\" u 22:23:24 w dots t \"Saturn\", \\\n\"ssolar.out\" u 25:26:27 w dots t \"Uranus\", \\\n\"ssolar.out\" u 28:29:30 w dots t \"Neptune\", \\\n\"ssolar.out\" u 31:32:33 w dots t \"Ceres\", \\\n\"ssolar.out\" u 34:35:36 w dots t \"Pluto\", \\\n\"ssolar.out\" u 37:38:39 w dots t \"Haumea\", \\\n\"ssolar.out\" u 40:41:42 w dots t \"Makemake\", \\\n\"ssolar.out\" u 43:44:45 w dots t \"Eris\"\n```\n\n## TODO\n\n- Make a animated viewer of generated data.\n- Make a interactive mode that work with the viewer.\n- Add an option to use relative coords around the barycenter of the all system.\n- Implement collisions.\n- Add other output format that can carry more usefull information.\n- Add a way to do electroestatic simulations.\n- Add a way to use a arbitrary precision calculations (GMP).\n\n## Benchmark data\n\n### 10 iterations :\n\nFX-4100 quad core times :\n\n    Bodies : 1000\n    Serial = 573 ms\n    ParallelFor = 192 ms -\u003e SpeedUp = 2.98\n\n    Bodies : 3000\n    Serial = 5106 ms\n    ParallelFor = 1745 ms -\u003e SpeedUp = 2.92\n\n    Bodies : 10000\n    Serial = 57726 ms\n    ParallelFor = 20023 ms -\u003e SpeedUp = 2.88\n    ~72% of max teorical speedup\n\n\nOpteron 16-core times :\n\n    Bodies : 1000\n    Serial =  682 ms\n    ParallelFor = 67 ms -\u003e SpeedUp = 10,12\n\n    Bodies : 3000\n    Serial = 6083 ms\n    ParallelFor = 474 ms -\u003e SpeedUp = 12,83\n\n    Bodies : 10000\n    Serial = 69728: ms\n    ParallelFor = 5232 ms -\u003e SpeedUp = 13,32\n    ~83.25% of max teorical speedup\n\n\nFX-8370E overcloked at 3.6Ghz . dmd 2.090\n\n    Bodies : 1000\n    Serial = 119ms\n    ParallelFor = 19ms -\u003e SpeedUp = 6,26\n\n    Bodies : 3000\n    Serial = 1078ms\n    ParallelFor = 168ms -\u003e SpeedUp = 6,41\n\n    Bodies : 10000\n    Serial = 11945ms\n    ParallelFor = 1841ms -\u003e SpeedUp = 6,48\n\nR7 3700x\n\n    Bodies : 1000\n    Serial = 43ms\n    ParallelFor = 5ms\n\n    Bodies : 3000\n    Serial = 387ms\n    ParallelFor = 35ms\n\n    Bodies : 10000\n    Serial = 4320ms\n    ParallelFor = 376ms -\u003e SpeedUp = 11.48\n    ~71% of max teorical speedup\n\ni7-6700 4 core 8 threads\n\n    Bodies : 1000\n    Serial = 212ms\n    ParallelFor = 39ms \n\n    Bodies : 3000\n    Serial = 1868ms\n    ParallelFor = 354ms \n\n    Bodies : 10000\n    Serial = 20745ms\n    ParallelFor = 3761ms -\u003e SpeedUp = 5,52 \n    ~69% of max teorical speedup\n\n\n### With 1000 iterations :\n\nFX-4100 quad core times :\n\n    Bodies : 100\n    Serial = 571 ms\n    ParallelFor = 234 ms -\u003e SpeedUp = 2,44\n\n    Bodies : 1000\n    Serial = 57373 ms\n    ParallelFor = 19987 ms -\u003e SpeedUp = 2,87\n    ~71.75% of max teorical speedup\n\n\nOpteron 16-core times :\n\n    Bodies : 100\n    Serial = 676 ms\n    ParallelFor = 296 ms -\u003e SpeedUp = 2,28\n\n    Bodies : 1000\n    Serial = 67505 ms\n    ParallelFor = 5921 ms -\u003e SpeedUp = 11,40\n    ~71.25% of max teorical speedup\n\n\nFX-8370E overcloked at 3.6Ghz . dmd 2.090\n\n    Bodies : 100\n    Serial = 600ms\n    ParallelFor = 129ms -\u003e SpeedUp = 4,651\n\n    Bodies : 1000\n    Serial = 60063ms\n    ParallelFor = 9314ms -\u003e SpeedUp = 6,448\n    ~80% of max teorical speedup\n\n    Bodies : 3000\n    ParallelFor = 83770ms\n\nR7 3700x 8 core 16 threads\n\n    Bodies : 100\n    Serial = 220ms\n    ParallelFor = 42ms\n\n    Bodies : 1000\n    Serial = 21886ms\n    ParallelFor = 2087ms -\u003e SpeedUp = 10.48\n\ni7-6700 4 core 8 threads\n\n    Bodies : 100\n    Serial = 210ms \n    ParallelFor = 60ms \n\n    Bodies : 1000\n    Serial = 20706ms \n    ParallelFor = 3852ms -\u003e SpeedUp = 5.37\n    ~67% of max teorical speedup\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzardoz89%2Fnbodysim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzardoz89%2Fnbodysim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzardoz89%2Fnbodysim/lists"}