{"id":17632738,"url":"https://github.com/gabrielscabrera/nbody","last_synced_at":"2025-04-30T14:44:37.324Z","repository":{"id":57445146,"uuid":"221446750","full_name":"GabrielSCabrera/nBody","owner":"GabrielSCabrera","description":"GPU-accelerated N-Body particle simulator with visualizer.","archived":false,"fork":false,"pushed_at":"2024-03-31T14:11:02.000Z","size":150611,"stargazers_count":38,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T17:11:12.144Z","etag":null,"topics":["cuda","cuda-support","nbody","nbody-gravity","nbody-gravity-simulation","nbody-sim","nbody-simulation","nbody-simulations","particle-system","particles","particles-animations","simulations","sphere"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/GabrielSCabrera.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-13T11:46:48.000Z","updated_at":"2025-03-09T00:34:10.000Z","dependencies_parsed_at":"2024-10-23T07:19:03.509Z","dependency_job_id":"53263590-35db-486c-a69b-20a9f7becd29","html_url":"https://github.com/GabrielSCabrera/nBody","commit_stats":{"total_commits":50,"total_committers":2,"mean_commits":25.0,"dds":"0.020000000000000018","last_synced_commit":"054565242381cbb603f5bb5a3d0f118a8f999ab3"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielSCabrera%2FnBody","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielSCabrera%2FnBody/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielSCabrera%2FnBody/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielSCabrera%2FnBody/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GabrielSCabrera","download_url":"https://codeload.github.com/GabrielSCabrera/nBody/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251723360,"owners_count":21633147,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cuda","cuda-support","nbody","nbody-gravity","nbody-gravity-simulation","nbody-sim","nbody-simulation","nbody-simulations","particle-system","particles","particles-animations","simulations","sphere"],"created_at":"2024-10-23T01:45:27.078Z","updated_at":"2025-04-30T14:44:37.302Z","avatar_url":"https://github.com/GabrielSCabrera.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nBody\n\n### A GPU-accelerated N-body particle simulator and animator\n\nCreate complex particle simulations the easy way: a high-level package for designing and simulating large-scale particle interactions. Let **nBody** do the hard work for you!\n\n## Features\n\nEasy to use – and fast – **nBody** can simulate:\n\n* Gravitational acceleration\n* Coulomb interactions\n* Particle collisions\n\n**nBody** is highly optimized:\n\n* GPU acceleration available via [```cupy```](https://cupy.chainer.org \"cuPY\")\n* CPU multiprocessing with [```numpy```](https://numpy.org/ \"NumPy\")\n* Energy conservation via the *velocity-verlet* algorithm\n\nAnimated [```matplotlib```](https://matplotlib.org/ \"Matplotlib\") visualizations included for 2-D simulations. 3-D animations are also supported through the use of [```vpython```](https://vpython.org/ \"VPython\").\n\n## Quick-Start\n\nThe package can be installed with the *python package installer*:\n\n    python -m pip install nbody\n\nUsing ```numpy``` arrays, you will need:\n\n* An initial position array ```x0``` with shape ```(N,p)```\n    * *N* is the number of *particles*\n    * *p* is the number of *dimensions*\n    \nAll other arguments are optional:\n\n* An initial velocity array ```v0``` with shape ```(N,p)```\n* An initial angular velocity array ```w0``` (supported for 2-D and 3-D systems *only*)\n    * In 2-D, with shape ```(N,1)``` \n    * In 3-D, with shape ```(N,3)```\n* An array of masses ```m```with shape ```(N,1)```\n* An array of charges ```q``` with shape ```(N,1)```\n* An array of radii ```r``` with shape ```(N,1)```\n\nA possible configuration is as follows:\n\n    import numpy as np\n    x0 = np.random.normal(0, 10,   (N,p)) # Positions\n    v0 = np.random.normal(0, 2,    (N,p)) # Velocities\n    w0 = np.random.normal(0, 1,    (N,1)) # Angular Velocities (not yet implemented)\n    m  = np.random.normal(8, 1,    (N,1)) # Masses\n    q  = np.random.normal(0, 1E-6, (N,1)) # Charges\n    r  = np.random.normal(1, 0.1,  (N,1)) # Radii\n\n    m[m \u003c 0] = np.abs(m[m \u003c 0])\n    m[m == 0] = 1E-3\n    \n    r[r \u003c 0] = np.abs(r[r \u003c 0])\n    r[r == 0] = 1E-3\n\nNext, pass these arrays in the given order to the ```spheres``` function, so as to create a new instance ```S``` of class ```System``` with the above conditions.\n\n    import nbody as nb\n    S = nb.spheres(x0 = x0, v0 = v0, w0 = w0, m = m, q = q, r = r)\n\nAfter selecting a simulation runtime ```T``` and (optional) time-step ```dt```, use the ```solve``` method to calculate the particles' trajectories.\n    \n    T = 1      # Total simulation runtime\n    dt = 1E-3  # Simulation time-step\n    S.solve(T, dt)\n\nIf the system is 2-D such that ```p == 2```, an animation can be created and saved to file; here, the filename ```quick_start``` is chosen, and will produce a file ```animations/quick_start.mp4```.  \n\n    nb.animate(S, \"quick_start\")\n\nIf the system is 3-D such that ```p == 3```, animations can be created but not saved to file – simply omit the string argument shown above, and no warnings will be raised.\n\nOnce the ```solve``` method has been called, it is also possible to save the ```System``` instance to file; in this case, the data will be saved to a directory ```saved/quick_start```.\n\n    nb.save(S, \"quick_start\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabrielscabrera%2Fnbody","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgabrielscabrera%2Fnbody","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabrielscabrera%2Fnbody/lists"}