Skip to main content

N-body simulator

Project description

gonzales

A 3D N-body simulator.

Project description

This project is a parallel N-body simulator, which includes a user interface for overview and animation of simulation results. The low level code is written in Cython and C, and the rest was developed with Python. Parallelization was achieved with OpenMP. The GUI is written using PyQt5.

Two main simulation types are available:

  • Brute-force simulation
  • Barnes-Hut simulation

For both cases, the simulator is collisionless, with a gravitational softening parameter which can be specified. Simulation results are written into HDF5 format.

Documentation

Documentation can be found here.

Requirements

  • Python 3, Pip
  • a C compiler

Installation

  • install from PyPi with pip install gonzales, preferably using a virtual environment. For more details, see the installation docs

After installing, you can do the following in order to verify everything is working correctly:

  • run one of the examples, like the Solar system simulation: python -m gonzales.examples.solar_system
  • run the default performance benchmark suite with import gonzales; gonzales.run_default_benchmark()
  • run the quick start snippet below

Quick start snippet

import gonzales as gnz
import numpy as np

# number of particles, gravitational constant and softening length
N = 10000
G, eps = 0.01, 1e-2

# initial conditions and masses
r = np.random.uniform(-1, 1, (N, 3))
v = np.zeros((N, 3))
m = np.ones(N)

# output file name
fn = 'results.hdf5'

# particle container
s = gnz.Space(r, v, m)

# Barnes-Hut simulation
sim = gnz.BHSimulation(s, fn, G, eps, 1000, np.zeros(3), 0.75)
sim.run(100, 0.01)

# Viewer for animation and results
gnz.run_viewer(fn)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gonzales-0.1.2.tar.gz (359.6 kB view details)

Uploaded Source

File details

Details for the file gonzales-0.1.2.tar.gz.

File metadata

  • Download URL: gonzales-0.1.2.tar.gz
  • Upload date:
  • Size: 359.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for gonzales-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5aac2f63b30f41b87996fa20b27e5dc00b9b1ebc66999e1d1bca7285d70d5a82
MD5 4cf44f39439eed52520b327f09650252
BLAKE2b-256 afebb7170f490f5a778265885305a1124e6afe7171937b33488ddf46586e155d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page