No description
  • Jupyter Notebook 86.5%
  • Python 13%
  • Shell 0.5%
Find a file
2026-02-15 17:22:54 +01:00
.forgejo/workflows feat: Add all acceleration and optimization from S. Trusov fork (#3) 2025-09-25 14:00:34 +00:00
LICENSES Add all license and copyright notices 2025-02-18 23:11:57 +01:00
notebooks fix: minor corrections to bullfrogs 2025-10-14 14:08:27 +02:00
regression Add reproducible density regression workflow 2026-02-15 17:21:18 +01:00
scripts Add zoom force comparison plotting script 2026-02-15 17:22:54 +01:00
src/borgjaxpm Tune quick-run defaults and expose optimal-q toggle 2026-02-15 17:21:12 +01:00
tests Tune quick-run defaults and expose optimal-q toggle 2026-02-15 17:21:12 +01:00
.gitignore Add reproducible density regression workflow 2026-02-15 17:21:18 +01:00
conftest.py Add PM tests, plots, and benchmark 2025-12-22 15:23:16 +01:00
LICENSE Initial commit 2025-02-10 06:31:43 +00:00
poetry.lock feat: Add all acceleration and optimization from S. Trusov fork (#3) 2025-09-25 14:00:34 +00:00
pyproject.toml fix: minor corrections to bullfrogs 2025-10-14 14:08:27 +02:00
README.md Add essential readme file 2025-02-19 09:01:23 +01:00
REUSE.toml Add all license and copyright notices 2025-02-18 23:11:57 +01:00
TESTING.md Add PM tests, plots, and benchmark 2025-12-22 15:23:16 +01:00

BorgJaxPM

BorgJaxPM is a Python module that integrates a dark matter N-body forward model, developed using JaxPM. This module leverages the JAX library for acceleration and automatic differentiation, providing efficient and scalable simulations for astrophysical research.

Features

  • Dark Matter N-body Simulations: Simulate the evolution of dark matter particles under gravitational interactions.
  • Accelerated Computations: Utilizes JAX for GPU acceleration and automatic differentiation.
  • Scalability: Designed to handle large-scale simulations with ease.
  • Ease of Integration: Seamlessly integrates with existing astrophysical research workflows.

Installation

BorgJaxPM is developed with Python-Poetry support. Follow these steps to install the software:

  1. Install Poetry: If you haven't already, install Poetry by following the instructions on the official Poetry website.

  2. Clone the Repository: Clone the BorgJaxPM repository from GitHub.

    git clone https://git.aquila-consortium.org/guilhem_lavaux/borgjaxpm
    cd borgjaxpm
    
  3. Install Dependencies: Use Poetry to install the required dependencies.

    poetry install
    
  4. Activate the Virtual Environment: Activate the virtual environment created by Poetry.

    poetry shell
    

Usage

Once installed, you can use BorgJaxPM in your Python scripts or Jupyter notebooks. Here is a basic example of how to use the module:

import borgjaxpm as bjax
import numpy as np
import aquila_borg as borg
import numpy as np
import matplotlib.pyplot as plt

# Set up the borg
pars = borg.cosmo.CosmologicalParameters()

pars.sigma8 = 0.8
pars.A_s = 0

# Setup simulation box
bx = borg.forward.BoxModel()

bx.L = 500, 500, 500
bx.N = 32,32,32
a_init = 0.1

# Create a simulation chain
chain = borg.forward.ChainForwardModel(bx)
chain @= borg.forward.model_lib.M_PRIMORDIAL(bx, opts=dict(a_final=1.0))
ic_step = borg.forward.model_lib.M_TRANSFER_EHU(bx)
chain @= ic_step
myjax = bjax.BorgJaxPM_v2(
    bx, a_init=a_init, integrator="leapfrog", num_steps=10, supersampling=1, forcesampling=1,
)
chain @= myjax

chain.setCosmoParams(pars)

x = np.random.randn(*bx.N)

# Create white noise
xh = np.fft.rfftn(x, norm='ortho')
delta_m = np.empty(chain.getOutputBoxModel().N)

# Run simulation
chain.forwardModel_v2(xh)
chain.getDensityFinal(delta_m)

# Plot the result
plt.title("BorgJaxPM")
plt.imshow(np.log(2+rho[:,16,:]),vmin=0,vmax=2,cmap=plt.cm.coolwarm)
plt.show()

License

BorgJaxPM is licensed under the CECILL-B license. This license is a permissive free software license initiated in France by INRIA, CEA, and CNRS. It allows for the reuse of the software code with limited obligations, primarily requiring attribution and compliance with French law. For more details, refer to the CECILL-B license agreement.