Generating initial conditions for GEAR by MUSIC

\(\textbf{MUSIC}\):
MUSIC (MUlti-Scale Initial Conditions), generates cosmological initial conditions for high-resolution “zoom” cosmological simulations like Gear. Users guide and a detailed description of the method is provided by author,Oliver Hahn, https://www-n.oca.eu/ohahn/MUSIC/.
\(\textbf{Generating initial conditions for Gear by MUSIC}\):
The configuration file in MUSIC contains general setup for the simulation box, cosmological parameters and the transfer function, the random seeds and the behavior of the random number generator.
In the cosmology section of MUSIC configuration file, standard plug-ins for the transfer functions are as following:
-BBKS
-eisenstein
-CAMB
In case of using CAMB, one can either set cosmological parameters and desired ranges of scales in each step or generate a initila parameter file and run camb.
[2]:
import sys, platform, os
from matplotlib import pyplot as plt
import numpy as np
import camb
[ ]:
#First set up parameters for CAMB
pars = camb.CAMBparams()
pars.set_cosmology(H0=67.5, ombh2=0.022, omch2=0.122)
pars.set_dark_energy() #re-set defaults
pars.InitPower.set_params(As=2.215e-9, ns=0.965)
#Now get matter power spectra and sigma8 at redshift 0 and 0.8 and 4.0
pars.set_matter_power(redshifts=[0.0, 0.8, 4.0], nonlinear=False, kmax=1e3)
#Linear spectra
results = camb.get_results(pars)
#Calculate results for specified parameters and return CAMBdata instance for getting results.
kh, z, pk = results.get_matter_power_spectrum(minkh=1e-4, maxkh=1e3, npoints = 200)
#kh, z, PK, where kz an z are arrays of k/h and z respectively, and PK[i,j] is value at z[i], k/h[j]
#in pk two rows for two redshifts and 200 columns for 200 kh
Note: redshifts have been re-sorted (earliest first)

Or by running CAMB on initial parameter file

[ ]:
data=np.loadtxt("my_test.dat")

k = data[:,0]
Pk = data[:,1]

plt.loglog(k, Pk, label="normal", color="b")

plt.xlabel(r"$k\,\rm{Mpc}$")
plt.ylabel(r"$P(k)$");
plt.legend();

Either CAMB or other transfer functions are used it should be specified in the Transfer plug-in of configuration file. In case of using CAMB, The filename of the additional option transfer_file has to indicate the file from which the tabulated transfer function shall be read.

After generating the configuration file, in order to run MUSIC you need to specify the path/name of this configuration file:

module add clastro
module add music
./MUSIC my_ics.conf
Using multiple threads is also possible by:
export OMP_NUM_THREADS=4
[ ]:
#!/bin/bash
#SBATCH -c 4            # Number of tasks
#SBATCH -J my_test      # Name of the job
#SBATCH -p s1           # Partition

module add clastro
module add music


# For OpenMP parellel jobs
export OMP_NUM_THREADS=4
srun -c 4 MUSIC my_ics.conf

# For MPI jobs
#srun -c 4 exe conf
In MUSIC the name and path as well as the format of the output file can be set in configuration file by using output plug-ins. Considering the format gadget as one of the standard plug-ins of MUSIC has been chosen, in order to have the output in the GEAR format, a python script can be used:
module add python
./gad2gear.py my_ics.dat my_ics_gear.dat
[ ]:
#!/usr/bin/env python3


from pNbody import *

file1 = sys.argv[1]
file2 = sys.argv[2]


nb = Nbody(file1,ftype='gadget')

nb.tpe = where(nb.tpe==1,2,nb.tpe)

nb.init()
nb.rename(file2)
nb.write()

In GEAR, name and path of the initial condition file generated by MUSIC shall be specified in InitCondFile plug-in of parameter file.

Note: cosmological parameters of camb, music and gear should be adjusted.

Check cosmological parameters of each file

Reference: Plank13+WP bestfti:

\(\Omega_bh^2= 0.022032\)
\(\Omega_ch^2 = 0.12038\)
\(n_s = 0.9603\)
\(A_s = 2.215e-9\)
\(\Omega_L = 0.6817\)
\(\Omega_m = 0.3183\)
\(\sigma_8=0.8347\)
\(H0 = 67.04\)
\(Y_{He} = 0.247695\)
  1. matter power spectrum with considering magnetic filed \(\Omega_bh^2 = 0.022032\) \(\Omega_ch^2 = 0.12038\) \(n_s = 0.9619\) \(A_s = 2.215e-9\) \(\sigma_8=0.8347\) \(h=0.6704\)

  2. matter power spectrum without considering magnetic field
    \(\Omega_bh^2 = 0.022\)
    \(\Omega_ch^2 = 0.12\)
    \(n_s = 0.9619\)
    \(A_s = 2.215e-9\)
    \(\Omega_L = 0.683132\)
    \(\Omega_m = 0.316868\)
    \(\sigma_8=0.8347\)
    \(h=0.6704\)
    \(Y_{He} = 0.24\)
    \(H0 = 70\)
  3. music configuration file
    \(\Omega_m = 0.315\)
    \(\Omega_L = 0.685\)
    \(\Omega_b= 0.0486\)
    \(H0 = 67.3\)
    \(\sigma_8 = 0.829\)
    \(n_s = 0.9603\)
    \(Y_{He} = 0.248\)
  4. gear parameters
    \(\Omega_m = 0.315\)
    \(\Omega_L = 0.685\)
    \(\Omega_b= 0.0486\)
    \(h = 0.673\)

After generating parameter file, the last step would be running Gear!

[ ]:
#!/bin/bash
#SBATCH -n 4            # Number of tasks
#SBATCH -J my_test      # Name of the job
#SBATCH -p s1           # Partition


module add clastro
module add spack
module add gcc
module add gear


srun --mpi=pmi2 ./src/Gear params 0