Skip to main content

wendy

A one-dimensional gravitational N-body code.

Overview

wendy solves the one-dimensional gravitational N-body problem to machine precision with an efficient algorithm [O(log N) / particle-collision]. Alternatively, it can solve the problem with approximate integration, but with exact forces.

Author

Jo Bovy (University of Toronto): bovy - at - astro - dot - utoronto - dot - ca

Installation

Install the latest release using

pip install wendy

or clone/fork/download the repository and install using

sudo python setup.py install

or locally using

python setup.py install --user

The behavior of the parallel sorting algorithm used when setting sort='parallel' in the approximate version of the N-body code (approx=True) is controlled by a few compilation-time variables: PARALLEL_SERIAL_SORT_SWITCH, which sets the length of an array below which the serial sort is used, PARALLEL_SERIAL_MERGE_SWITCH, which sets the length of an array below which a serial merge is used (as part of the mergesort sorting algorithm used), and PARALLEL_SORT_NUM_THREADS, the number of threads used in the parallel sorting algorithm. By default, these are set to PARALLEL_SERIAL_MERGE_SWITCH=10000, PARALLEL_SERIAL_MERGE_SWITCH=50000, and PARALLEL_SORT_NUM_THREADS=32, which appear to work well. Significant speed-ups can be obtained by optimizing these for your system and specific problem. They can be set to different values by running, e.g.,

export CFLAGS="$CFLAGS -D PARALLEL_SERIAL_SORT_SWITCH=10 -D PARALLEL_SERIAL_MERGE_SWITCH=10 -D PARALLEL_SORT_NUM_THREADS=2"

before compiling the code (if you are trying to change them, make sure to force a re-compilation by removing the build/ directory).

Usage

Use wendy.nbody to initialize a generator object for initial (x,v) with masses m. The generator then returns the state of the system at equally-spaced time intervals:

g= wendy.nbody(x,v,m,0.05) # delta t = 0.05
next_x, next_v= next(g) # at t=0.05
next_x, next_v= next(g) # at t=0.10
...

The generator initialization with wendy.nbody has options to (a) solve the problem exactly or not using approx=, (b) include an external harmonic oscillator potential omega^2 x^2 / 2 with omega= (both for exact and approximate solutions), and (c) include an arbitrary external force F(x,t) (using ext_force=, only for the approximate solution).

Examples

  • Phase mixing and violent relaxation in one dimension: example notebook (run locally to see movies, or view on nbviewer)

  • Adiabatic vs. non-adiabatic energy injection for an exponential disk: example notebook (run locally to see movies, or view on nbviewer)

Metadata

Release files for wendy 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wendy 0.2
File Size Uploaded Provenance
wendy-0.2.tar.gz 30.8 kB Without provenance Details

Release files / wendy-0.2.tar.gz

Download URL wendy-0.2.tar.gz
Size 30.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f3fa0b9a40637f8745864e6f37a9ce8e89dada913816189465ee2c020ed096e2
BLAKE2b-256 checksum
How to use checksums
f4d8703513aefa5e2c63e91d88e834af502a2d9d65f624d55cd47a9a0a5b944c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.7.3

Security for wendy 0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page