Re: IC files

From: Dimitry Ayzenberg <dayzenbe_at_andrew.cmu.edu>
Date: Tue, 15 Sep 2009 22:06:38 -0400

I'm actually using Ubuntu now. Gave up on getting it to work on Windows.
But that explains it to me really well. Thanks for the help.

Dimitry


On Tue, September 15, 2009 21:39, Scott Wales wrote:
>

> Hi Dimitry,
>
>
> The blocks should be big enough to hold the data for all particles.
> Gadget probably checks the block size is exactly that amount.
>
>
> The header must be 256 bytes (a struct with the correct format is
> defined in allvars.h), for the rest check the user's guide, for example the
> positions block should be 3*N*sizeof(float) bytes, where N is the sum of
> elements in header.npart.
>
> fprintf outputs text, to output binary data use fwrite (since you're on
> windows make sure to open the file as binary data).
>
> Scott
>
>
>
> On 16/09/2009, at 11:05 AM, Dimitry Ayzenberg wrote:
>
>
>>
>> I think I've pretty much got it under control. Thanks for the help.
>> I just
>> had a couple of questions.
>>
>> The blocks for the Iinitial condition file can be any size as long
>> as the block size before them contains what size they are? Or must they
>> all be the same, specific size? Or does just the header block have to be
>> that specific size, which is 256 bytes?
>>
>> Also, does just doing an fprintf in C put the Initial Condition file
>> in the right format? It seems to read as if it's just a text file. Is
>> there anything special I need to add so that it prints out in the right
>> format?
>>
>> Thanks,
>> Dimitry
>>
>>
>> On Mon, September 14, 2009 08:44, Jay Billings wrote:
>>
>>> If you have any problems, I can link you to some source code that
>>> should help you with the IO.
>>>
>>> Jay
>>>
>>>
>>>
>>> On Mon, Sep 14, 2009 at 8:25 AM, Dimitry Ayzenberg
>>> <dayzenbe_at_andrew.cmu.edu>wrote:
>>>
>>>
>>>
>>>>
>>>> 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
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------------
>>>>
>>>>
>>>>
>>>> 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
>>
>
>
>
>
> -----------------------------------------------------------
>
>
> 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-16 04:06:40

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