Skip to content

SaraZahoor/2LPTic

 
 

Repository files navigation

Warning I generated 2048^3 ICs (subsampled from a 3072^3) with this IC code and those simulations were wrong. However, 1024^3 simulations generated with this were fine. Presumably, something is wrong with (at least) the subsample fraction logic - do not use the subsampling features in this code -- i.e., set both GlassTileFacSampleNumerator and GlassTileFacSampleNumerator = 1.

Description

This repo contains 2LPT IC generation code from Roman Scoccimarro. Original code can be found here

Improvements

  1. The code has been updated with lots of checks about INT overflow and 64 bit ID overflows.
  2. Dependency on Numerical Recipes in C has been replaced with gsl
  3. This code can accept P(k) generated by CAMB (contribution from Greg Poole)
  4. Can generate consistent particle IDs across simulations of different resolutions (contribution from Greg Poole)

Note this version produces a header compatible with standard public Gadget2. In particular, the number of particles in excess of INT_MAX (~2e9) is stored in npartTotalHighWord in the header, rather than npartTotal[2].

Installation

Pre-requisites

  1. An MPI capable compiler mpicc
  2. Double precision MPI FFTW2 libraries (fftw2.1.5)
  3. gsl library

Compilation

  1. Setup the Makefile options according to the simulation IC. Default options are matched to running a single-species dark matter only cosmological simulation.
  2. Check the paths to MPI, FFTW and GSL libraries
  3. Typing make should generate the executable

Generating Consistent Particle IDs

If you are running convergence tests, then the particle IDs for the lower resolution simulation can be sampled from the particle IDs of the highest resolution simulation you want to compare to. The generated IDs will not be contiguous anymore but the particle in the same spatial location should get an identical ID as the particle in the hi-res simulation. Since the particle ID is essentially set by the hi-res simulation, the low-res simulation might require 64bit IDs just to store consistent IDs. The code will check at runtime if the generated particle IDs are too large to fit into 32bit integers (only relevant when USE_64BITID Makefile option is not set during compilation).

The implementation requires two integers, GlassTileFacSampleNumerator and GlassTileFacSampleDenom, to be specified in the parameter file. The final number of particles is set by choose GlassTileFacSampleNumerator particles out of GlassTileFacSampleDenom hi-res particles.

  • To generate a 1024^3 subsample from a 3072^3 hi-res, set Nmesh=3072, Nsample=1024, GlassTileFac=3072, GlassTileFacSampleNumerator=1 and GlassTileFacSampleDenom=3.
  • To generate a 2048^3 subsample from a 3072^3 hi-res, set Nmesh=3072, Nsample=2048, GlassTileFac=3072, GlassTileFacSampleNumerator=2 and GlassTileFacSampleDenom=3.

NOTE: The previous examples assume that there is only one particle in the glass file; if that is not your case, then reduce GlassTileFac by the number of particles in the glass file. Nparticles_in_glass_file * GlassTileFac should equal TotNumPart^(1/3) in the hi-res simulation.

Running

  1. Edit the parameter file. See example parameter file provided in example.params
  2. Launch the MPI process mpirun -np Ncpus ./2LPTic simulation.param (refer to your computing cluster documentation for submitting and running jobs)

Author

Author is Roman Scoccimarro (I think based on N-GenIC developed by Volker Springel). Current repo contains contribution from Greg Poole for the CAMB P(k) handling and consistent particle IDs generation.

Maintained by Manodeep Sinha. Any new bugs are probably my fault.

About

Roman Scoccimarro's 2LPTic code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 96.1%
  • Makefile 3.9%