Skip to main content

Semi-analytical dark matter halo generator for astrophysics

Project description

HaloFactory - Semi-analytical dark matter halo generators

Last commit Workflow Status MIT License PyPI

In astrophysics, it is known that dark matter halos building blocks of the Universe's large-scale structures. Given their significance in theoretical and numerical studies of galaxy formation, it is imperative to generate halo catalogs not only following closely to structure formation theory but also being efficient in computation.

This repository presents a comprehensive collection of semi-analytical methods that facilitate the generation of halo catalogs and their corresponding merger trees. These methods are either purely theoretical or calibrate by numerical simulations. Building upon this repository, we intend to publish another repository dedicated to "semi-analytical galaxy formation models", which will utilize the halo-to-galaxy connection to populate halos with galaxies.

It is important to note that this package is currently in the process of being developed and is subject to structural modifications and functional expansions. The documentation is currently empty, and the testing does not encompass the entire source tree. We will continue to work towards completing these aspects.

Dependencies:

  • Python>=3.9.
  • pyhipp>=0.0.2, scipy, numpy.

To install halofactory and automatically handle the dependencies, use PyPI:

pip install halofactory

Interesting Features

Halo Density Profile. HaloFactory predefines a set of density profiles for halos. For example, the following codes defines an NFW profile instance:

>>> from halofactory.profile import NFWProfile
>>> profile = NFWProfile(mass = 1.0e2, rs = 10.0)
>>> profile

{'type': 'NFWProfile',
 '_meta': {'mass': 100.0, 'rin': 0.0001, 'xin': 1e-05, 'rvir': 150.0, ... },
 '_us': {'u_l': '3.085677581491367e+19 m', 'u_t': '3.085677581491367e+16 s',
         'u_m': '1.988409870698051e+40 kg', ...}}

The printed message includes the metainfo (mass, virial radius, etc.) of the halo, as well as the unit system in use.

To find information of the profile at given radii, for example, the density, write:

>>> profile.rho([1., 2., 3.])

array([0.03583832, 0.01505707, 0.00855313])

To sample from the profile and thus create a set of particles used as input for N-body simulation, define a sampler such as the Eddington Inversion sampler:

>>> from halofactory.initial_condition import EddInv
>>> sampler = EddInv(profile)
>>> sampler

{'type': 'EddInv',
 '_profile': {'type': 'NFWProfile', ...},
 '_rng': <pyhipp.stats.random.Rng object at 0x15092bc90>,
 '_meta': {'mass': 100.00000000000001, 'Et': 0.0, 'm_hi': 1.0, ...}}

The message indicates the method of the sampler, the input profile, the random number generator, and various of metadata.

To generate a sample, e.g., 1000 particles, write:

>>> sample = sampler.get(1000)
>>> sample.pos, sample.vel, sample.mass

(array([[-27.04020173,  60.70242802,  -6.84922322], ...]),
 array([[  12.7955374 , -114.31584255,   30.89851955],...]),
 0.10000000000000002)

The returned sample instance contains positions, velocities and mass of the sampled particles.

More is coming ...

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

halofactory-0.0.2.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

halofactory-0.0.2-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file halofactory-0.0.2.tar.gz.

File metadata

  • Download URL: halofactory-0.0.2.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for halofactory-0.0.2.tar.gz
Algorithm Hash digest
SHA256 d7d07c16acc72ff40079c5e1e5d568edd93e19093ad6db7111ff480c5dd96a89
MD5 5e95f8e35608c3b466515ac9fe5de618
BLAKE2b-256 08461d3b95b92ff1f1a2cc94246d7e500005ae673e4cfa8534b6d217b627ce91

See more details on using hashes here.

File details

Details for the file halofactory-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: halofactory-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for halofactory-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d2b72a1e5fdc4ddf0ef7efe0f78782484608128cb1733cbda076302d50b7ccac
MD5 3d03f473cf6dc2edd470e6644233a253
BLAKE2b-256 a07be393459fd7488dadf4a7ef6044f218111d933957579a362a428880dd4764

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