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 in the following units:

  • Distance: parsecs (pc)
  • Mass: solar masses (M☉)
  • Time: megayears (Myr)

Future versions aim to support more flexible unit selection.


Installation

Using pip:

pip install pyPebble

Clone this repository and install manually:

git clone https://github.com/your-username/pypebble.git
cd pypebble
pip install -r requirements.txt
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 Bodies

system = Bodies(positions, velocities, masses)

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

system = Bodies().create_disc(
    n_particles=100,
    r_max=10,
    center=[0, 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
)

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.


Roadmap

  • Support for multiple unit systems
  • Additional initial condition generators (e.g., clusters, binary systems)
  • General Optimisations
  • Visualization improvements

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.0.0.tar.gz (5.1 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.0.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pypebble-0.0.0.tar.gz
Algorithm Hash digest
SHA256 0bd795d2290849b6f658cb5c9ee6184c8fdf46e46065005cee30dde1bdcf9667
MD5 b728cc6d08c8dda65eb612f7f3d26bb7
BLAKE2b-256 0fcf6fc9ecca48e34498ad473dce135050a2847a9916723ab18ca0656e0a371d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pypebble-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 24d43911994cb76bd07f678df485f6dce3929e90d4ee85d941dc58525dcf6b8e
MD5 15b8781c114d6d4c442f6d560fd7e9d2
BLAKE2b-256 dbf0f7370e09b6d8bd7e4decede7f5a095ab591dd80910d1929561443be11cb4

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