Skip to main content

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 ...

Metadata

Release files for halofactory 0.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 halofactory 0.0.2
File Size Uploaded
halofactory-0.0.2.tar.gz 10.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for halofactory 0.0.2
File Interpreter ABI Platform
halofactory-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 20.7 kB

Release files / halofactory-0.0.2.tar.gz

Download URL halofactory-0.0.2.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d7d07c16acc72ff40079c5e1e5d568edd93e19093ad6db7111ff480c5dd96a89
BLAKE2b-256 checksum
How to use checksums
08461d3b95b92ff1f1a2cc94246d7e500005ae673e4cfa8534b6d217b627ce91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / halofactory-0.0.2-py3-none-any.whl

Download URL halofactory-0.0.2-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d2b72a1e5fdc4ddf0ef7efe0f78782484608128cb1733cbda076302d50b7ccac
BLAKE2b-256 checksum
How to use checksums
a07be393459fd7488dadf4a7ef6044f218111d933957579a362a428880dd4764
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

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