GravHopper
"They told me computers could only do arithmetic." -- Grace Hopper
Gravitational N-body simulation code written by Jeremy Bailin.
Named in honour of pioneering computer scientist Grace Hopper. Doubly appropriate because it uses a leapfrog integrator.
This is a simple Python-interface code for performing gravitational N-body simulations. It combines a simple Python interface for ease of use with a C backend for speed, and has the following features:
- Choice of Barnes-Hut tree or direct summation algorithm.
- Ability to include external potentials from galpy, gala, or user-supplied functions.
- Ability to return output as pynbody snapshots.
- Functions that generate equilibrium or near-equilibrium initial conditions (ICs) for several density profiles (Plummer, Hernquist, exponential disk), along with the ability to create ICs from galpy distribution function objects or pynbody snapshots.
- Utility functions for plotting snapshots and making movies.
For now, it uses a constant uniform timestep and constant uniform Plummer softening.
Requirements:
- Astropy
- NumPy, SciPy, Matplotlib
- C compiler
- To use galpy, gala, or pynbody interface functions, they will need to be installed.
- Saving movies requires ffmpeg.
For example, this will create a Plummer sphere with 2000 particles, run it for a few dynamical times, and plot the particle positions before and after to show that it is in equilibrium:
from gravhopper import Simulation, IC
from astropy import units as u
import matplotlib.pyplot as plt
# Create Plummer initial conditions.
Plummer_IC = IC.Plummer(N=2000, b=1*u.pc, totmass=1e6*u.Msun)
# Create a new simulation with a time step of 0.005 Myr and a softening of 0.05 pc.
sim = Simulation(dt=0.005*u.Myr, eps=0.05*u.pc)
# Add the Plummer model to the simulation
sim.add_IC(Plummer_IC)
# Run for 400 time steps
sim.run(400)
# Plot the x-y positions at the beginning and end.
fig = plt.figure(figsize=(12,4))
ax1 = fig.add_subplot(121, aspect=1.0)
ax2 = fig.add_subplot(122, aspect=1.0)
sim.plot_particles(snap='IC', unit=u.pc, xlim=[-10,10], ylim=[-10,10], ax=ax1)
sim.plot_particles(snap='final', unit=u.pc, xlim=[-10,10], ylim=[-10,10], ax=ax2)
To make a movie of the whole evolution of the simulation:
# Make and save a movie of the simulation running
sim.movie_particles('Plummer_sim.mp4', unit=u.pc, xlim=[-10,10], ylim=[-10,10])
Installation
Option 1: Pip
If all goes well, you should be able to install GravHopper simply with:
pip install gravhopper
Option 2: Install from source
To install directly from the current source:
- Clone or download the git repository
git clone https://github.com/jbailinua/gravhopper.git
- Go into the gravhopper directory and build the code.
cd gravhopper
python setup.py build_ext --inplace
- Copy the gravhopper subdirectory to wherever you want to use it.
Release files for gravhopper 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gravhopper-1.0.6.tar.gz | 22.1 kB | Details |
Built distributions (wheels)
Total release size: 414.0 kB
Release files / gravhopper-1.0.6.tar.gz
| Download URL | gravhopper-1.0.6.tar.gz |
|---|---|
| Size | 22.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db8281edd22af0886dd7eeb90a482c52a26ba29b9fb72b4d96aeae478c2ac73d
|
|
BLAKE2b-256 checksum How to use checksums |
a88aa4dd07f0d6d31211b10ab1b029290864ef38217273b1c66f1bc2f0f24a04
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
|
Release files / gravhopper-1.0.6-cp39-cp39-win_amd64.whl
| Download URL | gravhopper-1.0.6-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 26.7 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
3a377b42a385def2338bd7e723cd496818821f3430435ffc57cbb7c209bb249e
|
|
BLAKE2b-256 checksum How to use checksums |
60be54b4fd820b3598b13395c60379b9ab5081b4dd18a73df6e99945e6ec1d93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
|
Release files / gravhopper-1.0.6-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
| Download URL | gravhopper-1.0.6-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl |
|---|---|
| Size | 47.0 kB |
| Tags | CPython 3.9 Linux glibc 2.12+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
4bc9f1bc9e5ce71335bb4d581bd47506c16fb9d28efc1925232074eeddc07135
|
|
BLAKE2b-256 checksum How to use checksums |
633af0d114e0d7decad9c00fd4b39c1089a87b39cb4eaf609eec54920c80fe01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
|
Release files / gravhopper-1.0.6-cp39-cp39-macosx_10_9_x86_64.whl
| Download URL | gravhopper-1.0.6-cp39-cp39-macosx_10_9_x86_64.whl |
|---|---|
| Size | 24.1 kB |
| Tags | CPython 3.9 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
a801692a43dee9d2a63de2eb66b1ff747028ea8f4511890d2f29f2b1aa299525
|
|
BLAKE2b-256 checksum How to use checksums |
7dab13fcedd5993c7220d4d9deb5730930cc6462a4d81b9d6f8a885a25790670
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
|
Release files / gravhopper-1.0.6-cp38-cp38-win_amd64.whl
| Download URL | gravhopper-1.0.6-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 26.7 kB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
937b94cb458b39ab7a44a572ecbc9c5003c8960f6aa5b09b9ad1691c5b728c65
|
|
BLAKE2b-256 checksum How to use checksums |
68807557c47520e749667004c50d1aab21a7258fada7facaef222f7fd4e6ff95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
|
Release files / gravhopper-1.0.6-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
| Download URL | gravhopper-1.0.6-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl |
|---|---|
| Size | 48.2 kB |
| Tags | CPython 3.8 Linux glibc 2.12+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
10253ce051a92a7d6282fc227a373924c8a68b2b53ed67d7bfd42a72c8570619
|
|
BLAKE2b-256 checksum How to use checksums |
324cd55f7356ebe41646f581a9ce673fedbf9d8e784c5e4d88beccfc9551b1ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
|
Release files / gravhopper-1.0.6-cp38-cp38-macosx_10_9_x86_64.whl
| Download URL | gravhopper-1.0.6-cp38-cp38-macosx_10_9_x86_64.whl |
|---|---|
| Size | 24.1 kB |
| Tags | CPython 3.8 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
ba83a0cf5c064f0a6477fe40eae80bb87ef8be7c9511d9e7f0107452aa403646
|
|
BLAKE2b-256 checksum How to use checksums |
99af52599f47916b728024d0d377a49a9d84c91ab4fb536d201d6626d24b9854
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
|
Release files / gravhopper-1.0.6-cp37-cp37m-win_amd64.whl
| Download URL | gravhopper-1.0.6-cp37-cp37m-win_amd64.whl |
|---|---|
| Size | 26.6 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5e5f2c10b7dcb7f0ce7631418938ff4576927d8f2eedfe54bed411f6bcb05519
|
|
BLAKE2b-256 checksum How to use checksums |
0e48827f9b159965b9906c74e1d03e60c78e9582561fa9df2e5ea134abaed581
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
|
Release files / gravhopper-1.0.6-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
| Download URL | gravhopper-1.0.6-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl |
|---|---|
| Size | 47.4 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
dc3bbb152a2acef783b3dc0d0c9ed521aaee579e2608bd2f83834f97c18a5cf6
|
|
BLAKE2b-256 checksum How to use checksums |
22a90da56f5b7c526eb22c87e1c9116550313c6722d9e0d358001368fc9228c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
|
Release files / gravhopper-1.0.6-cp37-cp37m-macosx_10_9_x86_64.whl
| Download URL | gravhopper-1.0.6-cp37-cp37m-macosx_10_9_x86_64.whl |
|---|---|
| Size | 24.1 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
151d47ec80bd743590ef1ae5a536ae79f566d9d04161c0f52d75a3fd0e6fa26c
|
|
BLAKE2b-256 checksum How to use checksums |
c632c2a91a5e63864c0779da946fc60ba41818e08e362a6308536d59203b3a42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
|
Release files / gravhopper-1.0.6-cp36-cp36m-win_amd64.whl
| Download URL | gravhopper-1.0.6-cp36-cp36m-win_amd64.whl |
|---|---|
| Size | 26.6 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
3bb2ad474599e460c2d7538b01368441df0b0ee5b540c57c0b59291fb831a8be
|
|
BLAKE2b-256 checksum How to use checksums |
42ddfcfdba638d2fdbb18b163d21829c55024a14ac6ec7473ec3f874841d15bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
|
Release files / gravhopper-1.0.6-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
| Download URL | gravhopper-1.0.6-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl |
|---|---|
| Size | 46.5 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
b8a64e95bd64da87edd141b128f2a6e3f4ef8668fd412f166054a9264b3c014d
|
|
BLAKE2b-256 checksum How to use checksums |
bd457fa9e3b6869ad850f0225134dec84f6cd10046e781f99d0311808c91d123
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
|
Release files / gravhopper-1.0.6-cp36-cp36m-macosx_10_9_x86_64.whl
| Download URL | gravhopper-1.0.6-cp36-cp36m-macosx_10_9_x86_64.whl |
|---|---|
| Size | 24.1 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
538d29229281d45188e06fdb68c32c41912d7dd4d4958d652b6109e2b7b3b2b7
|
|
BLAKE2b-256 checksum How to use checksums |
b1ddf480eb469e9f60f53d60c7d1b1b3a69fe85817325eca57198570ee670054
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
|