All Projects → GabrielSCabrera → nBody

GabrielSCabrera / nBody

Licence: GPL-3.0 License
GPU-accelerated N-Body particle simulator with visualizer.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to nBody

negative-mass-simulator
Negative Mass N-body Simulation Codes
Stars: ✭ 57 (+103.57%)
Mutual labels:  simulations, nbody-simulation, nbody-gravity-simulation
N-body-numerical-simulation
Script written in Python to integrate the equations of motion of N particles interacting with each other gravitationally. The script computes the equations of motion and use scipy.integrate to integrate them. Then it uses matplotlib to visualize the solution.
Stars: ✭ 40 (+42.86%)
Mutual labels:  nbody, nbody-simulation, nbody-gravity-simulation
Barnes-Hut-Simulator
A C++ implementation of the Barnes-Hut-Algorithm.
Stars: ✭ 51 (+82.14%)
Mutual labels:  nbody-simulation, nbody-gravity-simulation
Newtonian-Particle-Simulator
C# OpenGL Particle Simulation, GPU accelerated
Stars: ✭ 131 (+367.86%)
Mutual labels:  particles, particle-system
Konfetti
Celebrate more with this lightweight confetti particle system 🎊
Stars: ✭ 2,278 (+8035.71%)
Mutual labels:  particles, particle-system
ParticleGround-Portfolio
A minimalistic particle theme landing page template. ⚛️
Stars: ✭ 335 (+1096.43%)
Mutual labels:  particles-animations, particles
Proton
Javascript particle animation library
Stars: ✭ 1,958 (+6892.86%)
Mutual labels:  particles, particle-system
sparkler
Modular Macro-powered Particle System for haxe
Stars: ✭ 16 (-42.86%)
Mutual labels:  particles, particle-system
mini-nbody
A simple gravitational N-body simulation in less than 100 lines of C code, with CUDA optimizations.
Stars: ✭ 73 (+160.71%)
Mutual labels:  cuda, nbody
nbody-simulation
a simulation of a dynamical system of particles
Stars: ✭ 23 (-17.86%)
Mutual labels:  nbody, nbody-simulation
HiSpatialCluster
Clustering spatial points with algorithm of Fast Search, high performace computing implements of CUDA or parallel in CPU, and runnable implements on python standalone or arcgis.
Stars: ✭ 31 (+10.71%)
Mutual labels:  cuda
SuperParticles
Amazing CPU-friendly particle network animations
Stars: ✭ 32 (+14.29%)
Mutual labels:  particles
ParticleLib
Multiversion spigot library supporting all particles and their data (1.8-1.18.2)
Stars: ✭ 156 (+457.14%)
Mutual labels:  particles
gpubootcamp
This repository consists for gpu bootcamp material for HPC and AI
Stars: ✭ 227 (+710.71%)
Mutual labels:  cuda
dbcsr
DBCSR: Distributed Block Compressed Sparse Row matrix library
Stars: ✭ 65 (+132.14%)
Mutual labels:  cuda
gproshan
geometry processing and shape analysis framework
Stars: ✭ 48 (+71.43%)
Mutual labels:  cuda
euler2d kokkos
Simple 2d finite volume solver for Euler equations using c++ kokkos library
Stars: ✭ 27 (-3.57%)
Mutual labels:  cuda
Galaxia-Runtime
Galaxy generator for Unity 3D, with Custom Particle Distributors, DirectX 11 Particles and Highly customization, curve driven Generation.
Stars: ✭ 36 (+28.57%)
Mutual labels:  particles
ONNX-Runtime-with-TensorRT-and-OpenVINO
Docker scripts for building ONNX Runtime with TensorRT and OpenVINO in manylinux environment
Stars: ✭ 15 (-46.43%)
Mutual labels:  cuda
k-means
Code accompanying my blog post on k-means in Python, C++ and CUDA
Stars: ✭ 56 (+100%)
Mutual labels:  cuda

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
  • CPU multiprocessing with numpy
  • Energy conservation via the velocity-verlet algorithm

Animated matplotlib visualizations included for 2-D simulations. 3-D animations are also supported through the use of vpython.

Quick-Start

The package can be installed with the python package installer:

python -m pip install nbody

Using numpy arrays, you will need:

  • An initial position array x0 with shape (N,p)
    • N is the number of particles
    • p is the number of dimensions

All other arguments are optional:

  • An initial velocity array v0 with shape (N,p)
  • An initial angular velocity array w0 (supported for 2-D and 3-D systems only)
    • In 2-D, with shape (N,1)
    • In 3-D, with shape (N,3)
  • An array of masses mwith shape (N,1)
  • An array of charges q with shape (N,1)
  • An array of radii r with shape (N,1)

A possible configuration is as follows:

import numpy as np
x0 = np.random.normal(0, 10,   (N,p)) # Positions
v0 = np.random.normal(0, 2,    (N,p)) # Velocities
w0 = np.random.normal(0, 1,    (N,1)) # Angular Velocities (not yet implemented)
m  = np.random.normal(8, 1,    (N,1)) # Masses
q  = np.random.normal(0, 1E-6, (N,1)) # Charges
r  = np.random.normal(1, 0.1,  (N,1)) # Radii

m[m < 0] = np.abs(m[m < 0])
m[m == 0] = 1E-3

r[r < 0] = np.abs(r[r < 0])
r[r == 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.

import nbody as nb
S = nb.spheres(x0 = x0, v0 = v0, w0 = w0, m = m, q = q, r = r)

After selecting a simulation runtime T and (optional) time-step dt, use the solve method to calculate the particles' trajectories.

T = 1      # Total simulation runtime
dt = 1E-3  # Simulation time-step
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.

nb.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.

nb.save(S, "quick_start")
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].