Skip to main content

Multi purpose N-body sim

Project description

PyPebble: An N-Body Simulation Toolkit

PyPebble is a Python model to handle N-body problems, specifically geared towards gravitational simulations (with more features planned for the future). This code is still under development. Currently, inputs and outputs are configured to use the following units:

  • Distance: parsecs
  • Mass: solar masses
  • Time: megayears

Installation

Using pip:

pip install pyPebble

Clone this repository and then install manually with:

pip install -e .

Usage

Creating a System

You can define the properties of particles directly by passing arrays of positions, velocities, and masses:

from pypebble import Pebbles

system = Pebbles(positions, velocities, masses)

Alternatively, you can create a disc of particles using the built-in generator:

system = Pebbles().create_disc(
    n_particles=100,
    r_max=10,
    center=[0, 0],
    ang_vel=0.05,
    v_sigma=None,
    total_mass=None,
    particle_mass=None,
    distribution="uniform"
)

Setting up the Simulation

With a system defined, initialize the simulation using setup:

simulation = system.setup(
    softening=1e-2,
    bounds=20,
    smooth_len=10,
    t_start=0,
    t_finish=50,
    nsteps=1000,
    Enable_GPU=True,
    save_output=None
)

Live Animation

simulation.start_animation()

Running the Simulation

Run with:

simulation.run()

The simulation currently saves output data (time, position, velocity, and mass) to an .h5 file. Future improvements will include better ways to run and visualize simulations.


To do

  • Support for multiple unit systems
  • Additional initial condition generators
  • General Optimisations
  • GUI
  • Energy conservation checks
  • Multiprocessing option for simulation
  • Multithreading for writing to file
  • Allow simulations beyond a 2D plane
  • Realistic velocity and density distributions

License

MIT License.

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

pypebble-0.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pypebble-0.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file pypebble-0.1.0.tar.gz.

File metadata

  • Download URL: pypebble-0.1.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for pypebble-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c640494ebdca061d1433adf5440f4fcf3f2b4ef53e9e23941d8bb35ba9d14471
MD5 a8e5ff650025899b051bdabaa5b31578
BLAKE2b-256 a576f6edf941690778fc3008b397769e0911165c8c327ca76e60f065b0cd56aa

See more details on using hashes here.

File details

Details for the file pypebble-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pypebble-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for pypebble-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e998168b8eabd7777b34e798602f301eef44ba597e4be9087be794a849de93ab
MD5 4fc2b4e833171dc0c1f5af60c3842524
BLAKE2b-256 155ebb73ae8636db13bd89925941deb78c8f6fa15ae85683f8b2b18ff74bb35c

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