I think I'll try that out. I can't seem to open it properly in Fortran.
Thanks,
Dimitry
On Mon, September 14, 2009 07:25, Jay Billings wrote:
> Dimitry,
>
>
> It is also rather trivial to "invert" the read_snapshot.c file found in
> the "Analysis" directory. One benefit of doing it like this is that you
> have both read and write routines for Gadget2.
>
> Jay
>
>
> On Mon, Sep 14, 2009 at 1:19 AM, Dimitry Ayzenberg
> <dayzenbe_at_andrew.cmu.edu>wrote:
>
>
>>
>> Thank you very much. That helps a lot. I'm actually using Gadget to try
>> to do planet formation simulations, so I'll probably mess with the
>> initial conditions on my own. Just needed to know how to actually access
>> them.
>>
>> Dimitry
>>
>>
>>
>> On Mon, September 14, 2009 01:10, Scott Wales wrote:
>>
>>>
>>
>>> 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
>>>>
>>>>
>>>
>>>
>>>
>>>
>>> -----------------------------------------------------------
>>>
>>>
>>>
>>> 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
>>>
>>>
>>>
>>>
>>
>>
>> --
>> Dimitry Ayzenberg
>> Carnegie Mellon University
>> Physics - Class of 2012
>> Cell:(732)-425-4534
>> Email: dayzenbe_at_andrew.cmu.edu
>>
>>
>>
>>
>>
>> -----------------------------------------------------------
>>
>>
>> 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
>>
>>
>
--
Dimitry Ayzenberg
Carnegie Mellon University
Physics - Class of 2012
Cell:(732)-425-4534
Email: dayzenbe_at_andrew.cmu.edu
Received on 2009-09-14 14:25:35