Re: IC files

From: Scott Wales <wales_at_physics.usyd.edu.au>
Date: Mon, 14 Sep 2009 15:10:56 +1000

Hi Dimitry,

Gadget initial condition files have the same format as snapshots. They
are binary files, so you'll have to write a program to actually do
anything with them. The file format is detailed in the user's guide,
but briefly the file consists of a series of blocks, each of which
consist of an int containing the block size, a binary blob of data and
then another int with the block size. Fortran will read the blocks
automatically with a unformatted read, for c use a function like

#include <assert.h>
#include <stdio.h>
void ReadGadgetBlock(FILE* gadgetfile, void ** data, size_t *
data_size){
        unsigned int block_size;
        size_t number_read;
        // Get the size of the block
        number_read = fread(&block_size,1,sizeof(block_size),gadgetfile);
        assert(number_read == 1);
        // Allocate space for the data
        *data_size = block_size;
        *data = realloc(*data,*data_size);
        // Read the data
        number_read = fread(*data,*data_size,1,gadgetfile);
        assert(number_read == *data_size);
        // Read the block footer
        number_read = fread(&block_size,1,sizeof(block_size),gadgetfile);
        assert(number_read == 1);
        assert(block_size == *data_size);
}

The contents of each block are detailed in the user's guide.

The initial conditions you'll use depends on what you're simulating.
For cosmological simulations try something like Edwin Sirko's ic
(needs some format conversion) or Crocce et al.'s 2lpt. They will
require input power spectra, found by something like cmbeasy or cmbfast.

Cheers,

Scott Wales

On 14/09/2009, at 2:40 PM, Dimitry Ayzenberg wrote:

>
> Can someone please tell me how to open and read the .dat files in
> the ICs
> folder? Also how to make initial condition files? I'm a little
> confused
> about how to do either.
>
> Thanks,
> Dimitry
>
>
>
>
> -----------------------------------------------------------
>
> If you wish to unsubscribe from this mailing, send mail to
> minimalist_at_MPA-Garching.MPG.de with a subject of: unsubscribe
> gadget-list
> A web-archive of this mailing list is available here:
> http://www.mpa-garching.mpg.de/gadget/gadget-list
Received on 2009-09-14 07:11:04

This archive was generated by hypermail 2.3.0 : 2023-01-10 10:01:31 CET