Install gizmo

Working /home/htanimur/lib

1, Install GNU Scientific Library

$ tar xvfz gsl-1.9.tar.gz
$ cd gsl-1.9
$ ./configure –prefix=/home/htanimur/lib/gsl/1.9
$ make
$ make install

2, Install FFTW

$ tar xvfz fftw-2.1.5.tar.gz
$ cd fftw-2.1.5

$ ./configure –prefix=/home/htanimur/lib/fftw/2.1.5/ –enable-mpi –enable-type-prefix
$ make
$ make install
$ make clean
$ ./configure –prefix=/home/htanimur/lib/fftw/2.1.5/ –enable-mpi –enable-type-prefix –enable-float
$ make
$ make install

 

3, Install HDF5

$ tar xvfz hdf5-1.10.1.tar.gz
$ cd hdf5-1.10.1
$ ./configure –prefix=/home/htanimur/lib/hdf5/1.10.1
$ make
$ make install

4, Install Gizmo 

$ unzip phopkins-gizmo-public-542a79b1459e.zip
$ mv phopkins-gizmo-public-542a79b1459e gizmo

“Makefile.systype” file defines the systype you want to use (I choose SYSTYPE=”Wheeler”)

$ set GSL_HOME
export GSL_HOME=/home/htanimur/lib/gsl/1.9
export FFTW2_HOME=/home/htanimur/lib/fftw/2.1.5
export HDF5_HOME=/home/htanimur/lib/hdf5/1.10.1

set LD_LIBRARY_PATH in /home/htanimur/.bashrc

export LD_LIBRARY_PATH=”$LD_LIBRARY_PATH:/home/htanimur/lib/hdf5/1.10.1/lib”

$ make

Advertisements

Run Gadget-2

(Work at ~/ana/Sim/run1)

1, Copy necessary files

$ cd ~/ana/Sim/run1
$ cp ~/lib/N-GenIC/dummy_glass.dat .
$ cp ~/lib/N-GenIC/ics.param .
$ cp ~/lib/Gadget-2.0.7/Gadget2/parameterfiles/lcdm_gas.param .

2, Edit ics.param

——————————————————-
Nmesh 128
Nsample 128
Box 60.0 % Periodic box size of simulation
FileBase ics % Base-filename of output files
OutputDir ./ICs/ % Directory for output
GlassFile dummy_glass.dat
TileFac 8

Omega 0.3
OmegaLambda 0.7
OmegaBaryon 0.0
HubbleParam 0.7
Redshift 99 % Starting redshift
Sigma8 0.8

SphereMode 1
WhichSpectrum 0
FileWithInputSpectrum input_spectrum.txt
InputSpectrum_UnitLength_in_cm 3.085678e24
ReNormalizeInputSpectrum 1
ShapeGamma 0.21 % only needed for Efstathiou power spectrum
PrimordialIndex 1.0

Seed 123456 % seed for IC-generator
NumFilesWrittenInParallel 1 % limits the number of files that are

UnitLength_in_cm 3.085678e24 % defines length unit of output (in cm/h)
UnitMass_in_g 1.989e43 % defines mass unit of output (in g/cm)
UnitVelocity_in_cm_per_s 1e5 % defines velocity unit of output (in cm/sec)
——————————————————-

3, Run N-GenIC

$ mkdir ICs
$ N-GenIC ics.param

4, Make output timestamp

(gmktimesteps.py)
——————————————————-
#!/usr/bin/env python
”’
Create a liste of cosmological timesteps in the form of parameter a.

”’

from optparse import OptionParser
import sys
import numpy as np

def parse_options():
usage = “usage: %prog [options]”
parser = OptionParser(usage=usage)

parser.add_option(“-p”, action=”store”, dest=”p”, type=’int’, default=5, metavar=” INT”, help=”precision value”)
parser.add_option(“-v”, action=”store_true”, dest=”verbose”, default = 0, help=”verbose mode”)

(options, args) = parser.parse_args()
files = args
return files,options

##########################################
#
# MAIN
#
##########################################

# get options
files,options = parse_options()

p = options.p
verbose = options.verbose

da = 1./(2.**p)
a = 0
outtimes = np.zeros(0)

while 1:

a = a + da
z = 1./a – 1.0

if z < 0:
break

if verbose:
print “a = %12.10f z = %12.8f”%(a,z)
else:
print “%12.10f”%(a)

outtimes = np.append(outtimes,[a])

np.savetxt(‘outputs.txt’, outtimes, fmt=”%12.10f”)
——————————————————-

5, Edit lcdm_gas.param

(lcdm_gas.param)
——————————————————-
% Relevant files

InitCondFile ICs/ics
OutputDir snap/

EnergyFile energy.txt
InfoFile info.txt
TimingsFile timings.txt
CpuFile cpu.txt

RestartFile restart
SnapshotFileBase snapshot
OutputListFilename outputs.txt

% CPU time -limit

TimeLimitCPU 36000 % = 10 hours
ResubmitOn 0
ResubmitCommand my-scriptfile

% Code options

ICFormat 1
SnapFormat 1
ComovingIntegrationOn 1

TypeOfTimestepCriterion 0
OutputListOn 1
PeriodicBoundariesOn 1

% Caracteristics of run

TimeBegin 0.01 % z=99, Begin of the simulation
TimeMax 1.0

Omega0 0.3
OmegaLambda 0.7
OmegaBaryon 0.0
HubbleParam 0.7
BoxSize 60.0

% Output frequency

TimeBetSnapshot 0.5
TimeOfFirstSnapshot 0

CpuTimeBetRestartFile 14400.0 ; here in seconds
TimeBetStatistics 0.05

NumFilesPerSnapshot 1
NumFilesWrittenInParallel 1

% Accuracy of time integration

ErrTolIntAccuracy 0.025
MaxRMSDisplacementFac 0.2
CourantFac 0.15

MaxSizeTimestep 0.01
MinSizeTimestep 0.0

% Tree algorithm, force accuracy, domain update frequency

ErrTolTheta 0.5
TypeOfOpeningCriterion 1
ErrTolForceAcc 0.005
TreeDomainUpdateFrequency 0.1

% Further parameters of SPH

DesNumNgb 33
MaxNumNgbDeviation 2
ArtBulkViscConst 0.8
InitGasTemp 1000.0 % always ignored if set to 0
MinGasTemp 50.0

% Memory allocation

PartAllocFactor 1.6
TreeAllocFactor 0.8
BufferSize 30 % in MByte

% System of units

UnitLength_in_cm 3.085678e24 ; 1.0 kpc -> 1 Mpc
UnitMass_in_g 1.989e43 ; 1.0e10 solar masses
UnitVelocity_in_cm_per_s 1e5 ; 1 km/sec
GravityConstantInternal 0

% Softening lengths

MinGasHsmlFractional 0.25

SofteningGas 0.05
SofteningHalo 0.05
SofteningDisk 0
SofteningBulge 0
SofteningStars 0
SofteningBndry 0

SofteningGasMaxPhys 0.05
SofteningHaloMaxPhys 0.05
SofteningDiskMaxPhys 0
SofteningBulgeMaxPhys 0
SofteningStarsMaxPhys 0
SofteningBndryMaxPhys 0
——————————————————-

6,  Run gadget-2

$ mkdir snap
$ mpirun -np 8 Gadget2 lcdm_gas.param &

(Reference)
http://www.ast.cam.ac.uk/~puchwein/NumCosmo_lect_2016/
http://obswww.unige.ch/lastro/misc/TP4/doc/rst/Exercices/Ex05.html
https://wwwmpa.mpa-garching.mpg.de/gadget/html/parameterfile.html

 

Read simulation output and perform analysis

(Work at ~/ana/Sim/ana1)

  • Halo / sub-halo finding (e.g. with the Rockstar code)
  • halo mass functions
  • creating maps / images

1, Install rockstar (FoF group finder)

$ cd ~/ana/Sim/ana1
$ git clone https://bitbucket.org/gfcstanford/rockstar.git
(Or download rockstar files from https://bitbucket.org/gfcstanford/rockstar/downloads/)
$ cd rockstar
$ make

2, Change the parameter file for Rockstar (quickstart.cfg)

$ cp rockstar/quickstart.cfg .
specify force resolution, for our 128^3 run with 0.05 Mpc/h softening
FORCE_RES = 0.001 -> FORCE_RES = 0.05

3, run Rockstar

$ ./rockstar/rockstar -c quickstart.cfg ../run1/snap/snapshot_032
Rockstar produces halo catalog (halos_0.0.ascii, halos_0.0.bin) and rockstar.cfg.

4, Download analysis software (http://www.ast.cam.ac.uk/~puchwein/postprocess.zip)

$ unzip postprocess.zip

5, Edit plot_mass_func.py

halocat = loadtxt(“../rockstar/halos_0.0.ascii”)
-> halocat = loadtxt(“halos_0.0.ascii”)

6, Run “ipython plot_mass_func.py”

mass_func_128.png

7, Edit plot_particles.py

filename = “../run1/snap/snapshot_032”
halocat = loadtxt(“halos_0.0.ascii”)

#ax.plot(pos[:,0], pos[:,1], marker=”,”, linestyle=”none”, c=”blue”) # plot particle positions
-> ax.plot(pos[:,0], pos[:,1], marker=”o”, linestyle=”none”, c=”blue”, ms=0.005) # plot part

#ind = where(m200c > 3.0e13)[0] # select massive halos > 3e13 Msun / h
-> ind = where(m200c > 1.0e12)[0] # select massive halos > 3e13 Msun / h

#ax.plot(x[ind], y[ind], marker=”o”, linestyle=”none”, c=”red”) # plot halo positions
-> ax.plot(x[ind], y[ind], marker=”o”, linestyle=”none”, c=”red”, ms=0.5) # plot halo positions

8, Run “ipython plot_particles.py”

halo-positions.png

9, you can use readsnap.py to read the Gadget snapshot files

> import readsnap as rs
> header = rs.snapshot_header(“../run1/snap/snapshot_032”) # reads snapshot headerprint header.massarr
> mass = rs.read_block(“../run1/snap/snapshot_032″,”MASS”,parttype=1) # reads mass for particles of type 1, using block names should work for both format 1 and 2 snapshots
> print “mass for”, mass.size, “particles read”
> print mass[0:10]

 

(Reference)
https://www.ast.cam.ac.uk/~puchwein/NumCosmo_lect_2016/

 

 

 

 

Install Gadget-2

1, Install GNU Scientific Library

$ tar xvfz gsl-1.9.tar.gz
$ cd gsl-1.9
$ ./configure –prefix=/home/htanimur/lib/gsl/1.9
$ make
$ make install

2, Install FFTW

$ tar xvfz fftw-2.1.5.tar.gz
$ cd fftw-2.1.5

$ ./configure –prefix=/home/htanimur/lib/fftw/2.1.5/ –enable-mpi –enable-type-prefix
$ make
$ make install
$ make clean
$ ./configure –prefix=/home/htanimur/lib/fftw/2.1.5/ –enable-mpi –enable-type-prefix –enable-float
$ make
$ make install

3, Install MPI

$ tar xvfz mpich-3.0.2.tar.gz
$ cd mpich-3.0.2
$ ./configure –prefix=/home/htanimur/lib/mpich/3.0.2
$ make
$ make install

4, Install HDF5 (if you want)

$ tar xvfz hdf5-1.6.9.tar.gz
$ cd hdf5-1.6.9
$ ./configure –prefix=/home/htanimur/lib/hdf5/1.6.9
$ make
$ make install

5, Install Gadget-2.0.7 

(1) Changing Makefile

< OPT += -DPMGRID=128
> OPT += -DPMGRID=256

< OPT += -DHAVE_HDF5
< #OPT += -DOUTPUTPOTENTIAL
< #OPT += -DOUTPUTACCELERATION
> #OPT += -DHAVE_HDF5
> OPT += -DOUTPUTPOTENTIAL
> OPT += -DOUTPUTACCELERATION

< #OPT += -DCOMPUTE_POTENTIAL_ENERGY
> OPT += -DCOMPUTE_POTENTIAL_ENERGY

< ifeq ($(SYSTYPE),”MPA”)
< CC = mpicc
< OPTIMIZE = -O3 -Wall
< GSL_INCL = -I/usr/common/pdsoft/include
< GSL_LIBS = -L/usr/common/pdsoft/lib -Wl,”-R /usr/common/pdsoft/lib”
< FFTW_INCL=
< FFTW_LIBS=
< MPICHLIB =
< HDF5INCL =
< HDF5LIB = -lhdf5 -lz
< endif

> ifeq ($(SYSTYPE),”MPA”)
> CC = mpicc
> OPTIMIZE = -O3 -Wall
> GSL_INCL = -I/home/htanimur/lib/gsl/1.9/include
> GSL_LIBS = -L/home/htanimur/lib/gsl/1.9/lib
> FFTW_INCL= -I/home/htanimur/lib/fftw/2.1.5/include
> FFTW_LIBS= -L/home/htanimur/lib/fftw/2.1.5/lib
> MPICHLIB = -L/home/htanimur/lib/mpich/3.0.2/lib
> HDF5INCL = -I/home/htanimur/lib/hdf5/1.6.9/include
> HDF5LIB = -L/home/htanimur/lib/hdf5/1.6.9/lib -lhdf5 -lz
> endif

(2) Make

6, Install n-genic.tar.gz 

(1) Changing Makefile

< SYSTYPE=”OPA-Cluster64-Gnu”
> #SYSTYPE=”OPA-Cluster64-Gnu”
> SYSTYPE=”MPA”

> ifeq ($(SYSTYPE),”MPA”)
> CC = mpicc
> OPTIMIZE = -Wall
> GSL_INCL = -I/home/htanimur/lib/gsl/1.9/include
> GSL_LIBS = -L/home/htanimur/lib/gsl/1.9/lib
> FFTW_INCL= -I/home/htanimur/lib/fftw/2.1.5/include
> FFTW_LIBS= -L/home/htanimur/lib/fftw/2.1.5/lib
> MPICHLIB = -L/home/htanimur/lib/mpich/3.0.2/lib
> endif

(2) make

7, Make Gadget2 and N-GenIC executable in any directory

(1) Copy Gadget2 and N-GenIC to ~/bin directory

$ mkdir /home/htanimur/bin
$ cp lib/N-GenIC/N-GenIC bin/
$ cp lib/Gadget-2.0.7/Gadget2/Gadget2 bin/

(2) Add /home/htanimur/bin in $PATH

(.bashrc)
export PATH=$PATH:~/bin

(3) source .bashrc

 

(Reference)
For install,
http://www.hpcadvisorycouncil.com/pdf/GADGET-2_Best_Practices.pdf
https://snatverk.blogspot.fr/2013/02/nbody-simulations-with-gadget2.html
https://astrobites.org/2011/04/02/installing-and-running-gadget-2/
http://www-kn.sp.u-tokai.ac.jp/~yamamoto/sakaguchi/gadget-2.html

For Gadget2 Makefile
http://obswww.unige.ch/lastro/misc/TP4/doc/rst/Exercices/Ex05.html

Grammer

– You need 2 options 

if [ $# -ne 2 ]; then
echo “Num of input option is $# ” 1>&2
echo “Need 2 options” 1>&2
exit 1
fi

– for loop

for (( i=0; i<20; i++ ))
do
imin=`echo “scale=1; $i * 5 ” | bc`
imax=`echo “scale=1; ($i+1) * 5 ” | bc`
echo $imin $imax
done

Cosmology theory

–  why the angular diameter distance starts to decrease after a certain redshift (around z = 1.5)?

The angular diameter of something is the angular diameter it had when the light was emitted and started on its way to us.

Because pure expansion does not change angles. If you think diagrammatically, the lightrays are not spread apart or squinched together by expansion. They are just stretched out longer.

But the angular-size distance is just based on the angular diameter of some standard ruler (like a 100 thousand lightyear galaxy), and since the angle spread of the incoming light does not change the angular size distance equals the instantaneous proper distance to the object measured on the day when the light was emitted.

And that is smaller than the presentday distance by a factor of z+1.

So think about this example: the matter that emitted the CMB which we are now detecting is now about 45 billion LY from us. But the redshift of that ancient light is z = 1090. So the distances have increased by a factor of z+1 = 1091. Not to be too fussy, distances have increased by a factor of 1100. So when the light was emitted, that matter was only about 41 million LY from our matter! When the ancient light was emitted, the matter was much much closer

Reference:
https://www.physicsforums.com/threads/angular-diameter-distance.501108/
https://forum.cosmoquest.org/showthread.php?103185-angular-diameter-distance