# nBody
### A GPU-accelerated N-body particle simulator and animator
Create 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!
## Features
Easy to use – and fast – nBody can simulate:
Gravitational acceleration
Coulomb interactions
Particle collisions
nBody is highly optimized:
GPU acceleration available via [`cupy`](https://cupy.chainer.org “cuPY”)
CPU multiprocessing with [`numpy`](https://numpy.org/ “NumPy”)
Energy conservation via the velocity-verlet algorithm
Animated [`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”).
## Quick-Start
Using `numpy` arrays, you will need:
- An initial position array `x` with shape `(N,p)`
N is the number of particles
p is the number of dimensions
An initial velocity array `v` with shape `(N,p)`
An array of masses `m```with shape ```(N,)`
An array of charges `q` with shape `(N,)`
An array of radii `r` with shape `(N,)`
A possible configuration is as follows:
import numpy as np x = np.random.normal(0, 10, (N,p)) # Positions v = np.random.normal(0, 2, (N,p)) # Velocities m = np.random.normal(8, 1, (N, )) # Masses q = np.random.normal(0, 1E-6, (N, )) # Charges r = np.random.normal(1, 0.1, (N, )) # Radii
m[m < 0] = np.abs(m[m < 0]) m[m == 0] = 1E-3
Next, 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.
from nbody import * S = spheres(x, v, m, q, r)
After selecting a simulation runtime `T` and (optional) time-step `dt`, use the `solve` method to calculate the particles’ trajectories.
S.solve(T, dt)
If 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`.
animate(S, “quick_start”)
If 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.
Once 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`.
save(S, “quick_start”)
Metadata
Release files for nbody 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nbody-0.0.4.tar.gz | 18.0 kB | Without provenance | Details for nbody-0.0.4.tar.gz |
Release files / nbody-0.0.4.tar.gz
| Download URL | nbody-0.0.4.tar.gz |
|---|---|
| Size | 18.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c9dfb5076b6b734c344e20642460b3401d71bf1ee6594c3e173ef31acbc30924
|
|
BLAKE2b-256 checksum How to use checksums |
022e0813eaf2ff8386a2fd328d3f8367b6880e44b4b6b1603066fd21e6da6dc3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.8
|
Security for nbody 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.