Table of Contents

Name

snap - (fortran binary) format for N-body simulations - version 2

Synopsis

include ’snap.inc’

Description

SNAP is a (fortran-based) binary format used in Aguilar’s (3D) N-body simulations. It has a fixed sized header and a variable sized data part (this format has gone through some revisions, see "VERSION 1" below) The header defines the maximum number of particles, with information place holders for a number of individual sub-components (dubbed ‘‘galaxies’’).

Each ‘‘galaxy’’ can have different combinations of density profiles, velocity distributions and spatial shapes, the center of mass and velocity can be specified individually for each one.

Example

The disk and memory image of snap are very closely related. The following code sections explains the include file, and how to read/write a single snapshot.
    PARAMETER (Npmx = 50000)    !Maximum number of particles
    PARAMETER (Ngmx = 50)        !Maximum number of galaxies
    INTEGER iseed            !random number generator seed
    CHARACTER*72 comment        !general commentary for init. cond.
    INTEGER Np            !# of points in simulation
    INTEGER Ngals            !# of galaxies
    INTEGER nframe            !# of frame
    REAL time            !time for frame
    CHARACTER*72 cparam(Ngmx)    !galaxies’ character string array
    LOGICAL lparam(16,Ngmx)        !galaxies’ logical parameters array
    INTEGER iparam(12,Ngmx)        !galaxies’ integer parameters array
    REAL rparam(40,Ngmx)        !galaxies’ real parameters array
    INTEGER index(Npmx)        !array used to indicate unbound particles
    REAL lum(Npmx), m(Npmx), x(3,Npmx), v(3,Npmx)    !part. lum, mass, pos. & vel.
    COMMON /snapshot/ iseed,comment,Np,Ngals,nframe,time,
    *                  cparam,lparam,iparam,rparam,index,m,lum,x,v

The following snippet of code would have written the unformatted version of this SNAP data:
     open(99, file = snapfile // ’SNAP_u.dat ’, form=’unformatted’,status=’new’)
     write(99) iseed,comment,Np,Ngals,nframe,time,
                (cparam(i),i=1,Ngals),
                ((lparam(i,j),i=1,16),j=1,Ngals),
                ((iparam(i,j),i=1,12),j=1,Ngals),
                ((rparam(i,j),i=1,40),j=1,Ngals),
                (index(i),i=1,Np),(m(i),i=1,Np),
                (lum(i),i=1,Np),
                ((x(i,j),i=1,3),j=1,Np),((v(i,j),i=1,3),j=1,Np)

Reading this format is exactly the same. Note the convention that the filename has a fixed extension SNAP_u.dat for unformatted format, and the extension SNAP_f.dat for the formatted version. To convert between these two, see snapformat(1LAAC) .

The size of this data is 92 + 344*Ngals + 36*Np, assuming 4 bytes per REAL and INTEGER.

Global Information

PARAMETERS:

    Npmx:    Maximum number of particles
    Ngmx:    Maximum number of galaxies

CHARACTER VARIABLES:

    comment:    Commentary

INTEGER VARIABLES:

    iseed:        seed for random number generator
    Np:        Number of points in initial conditions
    ngals:        Number of galaxies
    nframe:         Frame number in a series of snapshots (1=first)
    time:          Time of the snapshot
    index(Npmx):    If (0), bound particle; if (1), unbound.

REAL VARIABLES:

    m(Npmx):    masses of individual particles
    lum(Npmx):    light to mass ratio for each particle
    x(3,Npmx):    spatial cartesian coordinates of particles
    v(3,Npmx):    cartesian velocity components of particles

Individual Galaxy Information:

In each of the following arrays, the index, or second index if a matrix, refers to the galaxy to which the information applies.

CHARACTER VARIABLES:

    cparam*72(Ngmx)    Comment

LOGICAL VARIABLES:

    lparam(16,Ngmx)
        i=1:    Equal masses for particles?
          2:    Non-spherical shape?
          3:    Rotation measured?
          4:    Softened velocities?
          5:    Principal axes aligned with frame of reference?
          6:    Unbound particles marked?
          7:    Density profile fitted?
          8-16:    Not used

INTEGER VARIABLES:

    iparam(12,Ngmx)
        i=1:    Number of points
          2:    Density profile code:
                1) constant density
                2) power-law
                3) isochrone
                4) Plummer
                5) Rood (modified Hubble)
                6) King
                7) de-Vaucouleurs
                8) Jaffe
                9) Hernquist
          3:    Velocity distribution:
                1) isotropic
                2) anisotropic (Opsikov-Merritt)
                3) Circular orbits
          4:    Mass function:
                1) equal masses
                2) power-law
          5:    Number of bound particles
          6-12:    Not used

REAL VARIABLES:

    rparam(40,Ngmx):
        i=1:     pwr-law index, concentr., or 1D central vel. disp.
          2:    rt (total radius)
          3:    rh (half mass radius)
          4:    Mg (Mass of galaxy)
          5:    Ug (Potential energy of galaxy)
          6:    ro (core radius)
          7:    dens_o (central density)
          8:    ra (anisotropy radius)
          9:    (2T/U)tot (total virial ratio)
         10:    (2T/U)rot (virial ratio for rotation)
         11:    (X/Z) (major to minor axis ratio at 80% mass fract.)
         12:    (Y/Z) (interm. to minor axis ratio at 80% ......   )
         13-15:    (xo,yo,zo) (coordinates of center of galaxy)
         16-18:    (vxo,vyo,vzo) (vel. comp. of center of galaxy)
         19:    m1/<mi> (mass ratio of 1st part. to mean of others)
         20:    Mass function index
         21:    m_max/m_min (mass dynamical range)
         22:    e1i^2 (squared soft. length for 1-i interaction)
         23:    eij^2 (squared soft. length for i-j interaction)
         24:    T (Kinetic energy of galaxy)
         25:    E (Total energy of galaxy)
         26:    vrms (rms velocity of galaxy)
         27:    Tb (Kinetic energy of bound galaxy)
         28:    Ub (potential energy of bound galaxy)
         29:    Eb (total energy of bound galaxy)
         30:    Mbnd (mass of bound galaxy)
         31:    Tcm (kinetic energy of center of mass motion)
         32:    DE/E (fractional change in total energy)
          33:    DM/M (fractional change in mass)
         34-40:    Not used

Limitations

As defined by the PARAMETER statements, the maximum number of particles is Npmx [50000], with a maximum of Ngmx [50] galaxies allowed. These can be easily changed by changing their declared values. In addition, the length of the different param blocks is limited to 72 for character, 16 for logical, 12 for integer and 40 for real, each per galaxy. These are fixed and cannot be changed without violating this format.

Machine dependant FORTRAN binary format.

Bugs

ANSI Fortran doesn’t allow common blocks with characters mixed with real/integer/double precision.

See Also

fsnapio(3NEMO) , snapshot(5NEMO) , galmaker(1LAAC) , snapformat(1LAAC)

Files


usr/aguilar/galmaker    examples
snap.inc    The COMMON/SNAP/ definition

Version 1

The format that predated this version 2 we call version 1, and was derived from Josh Barnes /SNAPSHOT/ format he used in the early 80s. The following section explains his format:
    CHARACTER*72 comment        !general commentary for init. cond.
    INTEGER Np            !# of points in simulation
    REAL time            !time for frame
    INTEGER nframe            !# of frame
    REAL soften, m1, m2, mi,
         e12, e1i, eij, Vrms, Tcross,
         u, k, e
    REAL x(3,*),v(3,*)                !part. lum, mass, pos. & vel.
    COMMON /SNAPSHOT/ iseed,comment,Np,Ngals,nframe,time,
    *                  cparam,lparam,iparam,rparam,index,m,lum,x,v

The following snippet of code would have written the unformatted version of this SNAP data:
     open(99, file = snapfile // ’SNAP_u.dat ’, form=’unformatted’,status=’new’)
     write(99) iseed,comment,Np,Ngals,nframe,time,
                (cparam(i),i=1,Ngals),
                ((lparam(i,j),i=1,16),j=1,Ngals),
                ((iparam(i,j),i=1,12),j=1,Ngals),
                ((rparam(i,j),i=1,40),j=1,Ngals),
                (index(i),i=1,Np),(m(i),i=1,Np),
                (lum(i),i=1,Np),
                ((x(i,j),i=1,3),j=1,Np),((v(i,j),i=1,3),j=1,Np)

Reading this format is exactly the same. Note that the filename has a fixed extension SNAP_u.dat for unformatted format, and an extension SNAP_f.dat for the formatted version. To convert between these two, see snapformat(1LAAC) .

Author

Luis A. Aguilar

History


2/10/92      Created       Luis A. Aguilar            
21-nov-93    man5 created    PJT
14-jun-94    documented v1 and v2    PJT


Table of Contents