Generating initial conditions for GEAR by MUSIC¶
[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:
[ ]:
#!/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
[ ]:
#!/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:
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\)
- 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\)
- 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\)
- 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