/nbodyzip

A lossy compressor of dark matter-only N-body simulation data

Primary LanguageC++Apache License 2.0Apache-2.0

nbodyzip

A lossy compressor of dark matter-only N-body simulation data

Installation and usage

To compile the source code,

g++ -std=c++17 -o nbodyzip main.cpp

To use nbodyzip,

./nbodyzip [input_format] [output_format] [input_file] [output_file]

The input/output format can be one of tipsy, posvel, and zip.

For example, to compress a pkdgrav3 snapshot, run

./nbodyzip tipsy zip snapshot.xxxxx snapshot.xxxxx.nz

To decompress, run

./nbodyzip zip tipsy snapshot.xxxxx.nz snapshot.xxxxx.2

Input/output formats

tipsy

nbodyzip supports tipsy files that contains only dark matter particles and the number of particles along each dimension should be a power of two.

posvel

is a binary format (system-dependent endianness) defined in nbodyzip. It contains a 32-byte header, an array of particle positions, and an array of particle velocities.

  • Header: scale factor (fp64), number of particles (ui64), particle mass (fp64), and softening length (fp64, in units of mean particle distance);
  • Positions: x1, y1, z1, ..., xn, yn, zn (ui32 numbers representing coordinates between 0 and 1)
  • Velocites: vx1, vy1, vz1, ..., vxn, vyn, vzn (fp32)

zip

is a binary format (system-dependent endianness) defined in nbodyzip that efficiently stores simulation data. For a 10243 simulation, the absolute errors of x, y, and z coordinates are less than 2-22, 2-22, and 2-21; the absolute error of vi is 1.5×10-5(1+(vi/vscale)), with vscale being the rms of vi.