Thanks to visit codestin.com
Credit goes to github.com

Skip to content

QuickStart

Oliver Hahn edited this page Oct 21, 2025 · 2 revisions

Quick Start Guide

This guide will get you from zero to running monofonIC in about 30 minutes. You'll generate initial conditions for a small cosmological simulation using default settings. Thanks to Lukas Winkler for the inspiration on this quick start format! See his excellent SWIFT quick start guide.

Prerequisites

System Requirements

  • Linux or macOS operating system
  • C++14 compatible compiler (GCC 7+, Clang 5+, or Intel C++)
  • CMake 3.9 or newer

Required Dependencies

Ubuntu/Debian:

sudo apt update
sudo apt install build-essential cmake git \
  libfftw3-dev libfftw3-mpi-dev \
  libgsl-dev \
  libhdf5-dev libhdf5-mpi-dev \
  libopenmpi-dev \
  pkg-config

macOS (Homebrew):

brew install cmake git fftw gsl hdf5 open-mpi pkg-config gcc

Note: On macOS, use GNU compilers instead of Apple Clang (see Building MUSIC2 for details).

5-Step Workflow

1. Clone the Repository

git clone https://github.com/cosmo-sims/monofonIC.git
cd monofonIC

2. Build monofonIC

mkdir build
cd build
cmake ..
make -j4

This creates the monofonIC executable in the build/ directory. Compilation takes 2-5 minutes.

Troubleshooting: If CMake can't find libraries, specify paths manually:

FFTW3_ROOT=/path/to/fftw HDF5_ROOT=/path/to/hdf5 cmake ..

3. Configure Your Simulation

Edit the example configuration file:

cd ..  # back to monofonIC root directory
cp example.conf quickstart.conf
nano quickstart.conf  # or use your preferred editor

Make these changes to quickstart.conf:

  1. Enable SWIFT output (around line 154):

    [output]
    format          = SWIFT
    filename        = ics_swift.hdf5
    UseLongids      = true
  2. Set thread count (around line 125):

    [execution]
    NumThreads      = 4  # adjust to your CPU core count
  3. Verify cosmology settings (around line 39): The example file uses Planck 2018 parameters and CLASS for the transfer function - this is fine for a quick test.

Save and exit.

4. Generate Initial Conditions

./build/monofonIC quickstart.conf

5. Verify the Output

Check that the file was created:

ls -lh ics_swift.hdf5

Inspect the HDF5 structure (optional but recommended):

# Install h5glance if not already available
pip install h5glance

# View file structure
h5glance ics_swift.hdf5

Expected structure:

ics_swift.hdf5
├── Header (metadata: box size, particle counts, cosmology)
├── PartType1 (dark matter particles)
│   ├── Coordinates [2097152 × 3]
│   ├── Velocities [2097152 × 3]
│   ├── Masses [2097152]
│   └── ParticleIDs [2097152]

What You Just Created

You've generated initial conditions for:

  • Simulation type: Dark matter only (no baryons)
  • Box size: 300 Mpc/h (comoving)
  • Particle count: 128³ = 2,097,152 particles
  • Starting redshift: z = 24
  • Perturbation order: 3LPT (third-order Lagrangian perturbation theory)
  • Cosmology: Planck 2018 (EE+BAO+SN)

Next Steps

Run a Simulation

To actually evolve these initial conditions forward in time, you need a simulation code. See the excellent guide:

Customize Your Initial Conditions

Now that you have the basics working, explore:

Learn More

Get Help


Have fun generating cosmological initial conditions with monofonIC!

Clone this wiki locally