Skip to main content

Stretched Equal Area Generator

Project description


A python implementation of the stretched equal area (SEA) algorithm for generating spherically symmetric arrangements of particles with accurate particle densities, e.g. for SPH initial conditions that precisely match an arbitrary density profile, as presented in Kegerreis et al. (2019), MNRAS 487:4, 5029-5040,

See also for making the initial profiles, placing particles with SEAGen, and modifications for spinning bodies.

Jacob Kegerreis (2020)
Josh Borrow

Visit to download the code including examples and for support.

This program has been tested for a wide range of cases but not exhaustively. If you find any bugs, potential improvements, or features worth adding, then please let us know!


  • The main program classes and functions.
  • Examples to demonstrate how to use the SEAGen module.
  •, setup.cfg,, Python package files.
  • LICENSE.txt GNU general public license v3+.

Basic Usage

  • See the doc strings in for all the details.
  • Create a single shell of particles and print their positions:
    import seagen
    N = 100
    r = 1
    particles = seagen.GenShell(N, r)
    print(particles.x, particles.y, particles.z)
  • Create a full sphere of particles on a simple density profile and print their positions and masses:
    import seagen
    import numpy as np
    N = 100000
    radii = np.arange(0.01, 10, 0.01)
    densities = np.ones(len(radii))     # e.g. constant density
    particles = seagen.GenSphere(N, radii, densities)
    print(particles.x, particles.y, particles.z, particles.m)
  • See for other working examples, e.g. an arbitrary density profile with multiple layers and extra temperature information.


  • PyPI: Automatically install the package with pip install seagen, see
  • Direct download: The single file can be imported and used without any extra installation, so you can just download this repository and place the file in a local directory or wherever your python will look for modules.


  • Python 3 (tested with 3.6.0).

Notation etc.

  • PEP8 is followed in most cases apart from some indentation alignment.
  • Arrays are explicitly labelled with a prefix A1_, or An_ for an n-dimensional array.
  • Particle is abbreviated to picle.

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

seagen-1.4.2.tar.gz (29.4 kB view hashes)

Uploaded source

Built Distribution

seagen-1.4.2-py3-none-any.whl (28.0 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page