Skip to content
alwinm edited this page May 15, 2023 · 10 revisions

This page describes Cholla data, and contains some brief examples of plotting, etc. The first part deals with finite-volume data (average values in a cell represented on a grid), the second part deals with particle outputs (i.e. star or dark matter particles).

By default, Cholla outputs files in the hdf5 format. A single hdf5 file will generally correspond to a single snapshot from a simulation (or a subset of the simulation domain for an MPI simulation). Information in the file is split between "attributes", which are header variables that describe the data, and "datasets", which hold the values of the simulation data itself.

Attributes

The following attributes are attached to all Cholla outputs:

  • 'gamma', the ratio of specific heats that the simulation was run with
  • 't', the time of the snapshot, in code units (usually kyr)
  • 'dims', a three dimensional attribute that gives the number of cells in the x, y, and z directions
  • 'n_step', the simulation step when the data was output

Additional attributes that are attached to newer Cholla outputs include:

  • 'dx', a three dimensional attribute that gives the x, y, and z dimensions of a cell, in code units,

and a series of "unit" attributes, that provide the conversion between whatever units the code was run in and cgs:

  • 'length_unit'
  • 'time_unit'
  • 'mass_unit'
  • 'density_unit'
  • 'velocity_unit'
  • 'energy_unit'

So, for example, if the code was run with a mass unit of one solar mass and a length unit of one kpc, and you have read the density into an array called 'd', multiplying d by the density unit would convert the density array to g/cm^3.

Datasets

Datasets contain the different fields that are evolved by the simulation. They are 1, 2, or 3 dimensional arrays, corresponding to the dimensionality of the simulation (and specified by the nx, ny, nz attributes, as described above). The following are the conserved variable fields that are always outputs for a hydrodynamic simulation (all output in code units):

  • 'density', the mass density in each cell (i.e. M_sun / kpc^3)
  • 'momentum_x', the x-momentum density
  • 'momentum_y', the y-momentum density
  • 'momentum_z', the z-momentum density
  • 'Energy', the total energy density

If Cholla is run with the dual energy flag ('DE'), the thermal energy field will also be present:

  • 'GasEnergy', the thermal energy density, equivalent to the total energy density minus the kinetic energy density.

If Cholla is run with the passive scalar flag ('SCALAR'), a number of scalar fields may also be present, e.g.:

  • 'scalar0', the density of the passive scalar

Slices, Projections, and Rotated Projections

For 3D simulations, Cholla can also be run with flags to output slices and projections of the data. (This can be useful for larges simulations if saving the full dataset is too costly to achieve a high time resolution for snapshots.) The relevant make flags are 'SLICES', 'PROJECTIONS', and 'ROTATED_PROJECTIONS'. All produce hdf5 files similar to full grid outputs, with the same header attributes. Datasets present in slices include all the conserved variables, as well as the thermal energy density and scalars, if the simulation was run with them. Three slices will be output: 'xy' slices (a slice along the z-midplane), 'xz' slices (and a slice along the y midplane), and 'yz' slices (a slice along the x midplane). Datasets in the hdf5 file are named according to which direction the slice was made. For example, datasets in a 'slice_xy' file will include:

  • 'd_xy', the mass density in cells along the z-midplane of the simulation
  • 'mx_xy'
  • 'my_xy'
  • 'mz_xy'
  • 'E_xy'
  • 'GE_xy' (if DE is on)
  • 'scalar_xy' (if SCALAR is on)

Projections are similar to slices in that they are 2 dimensional datasets, but are integrated along the relevant direction. Currently, Cholla outputs density projections, and density-weighted temperature projections (density times temperature for a given cell). Both are output in code units. So, for example, if the code was run with density units of M_sun/kpc^3, a density projection output will have units of M_sun / kpc^2 and a temperature projection will have units of M_sun K / kpc^2. The PROJECTIONS flag outputs xy and xz projections (integrated along the z and y axes, respectively). Datasets are called:

  • 'd_xy'
  • 'T_xy'
  • 'd_xz'
  • 'T_xz'

Rotated projections are similar, but are integrated along an axis specified by the input parameter file (see the relevant wiki page for details).

Particle data

Concatenation scripts

Under python_scripts are a variety of scripts useful for concatenating multi-rank inputs into a single file.

The following are provided as scripts meant to be copied out of the repo, edited, and run.

cat_dset_3D.py cat_particles.py cat_projection.py cat_rotated_projection.py cat_slice.py

As of PR #298, the following is provided to be used as an import.

cat.py To use this module, place it on your path. Then import cat and access the functions within. Example usage:

import cat
cat.hydro(0, '', '') # concatenates 0.h5.* in the current directory and outputs to 0.h5 in the current directory
cat.projection(1, 'raw_projection/', 'cat_projection/') # concatenates raw_projection/1_proj.h5.* and outputs to cat_projection/1_proj.h5
cat.slice(2, './', '') # concatenates 2_slice.h5.* to 2_slice.h5 in the current directory

# Loops from 0 to n and concatenates all the slices in the current directory if they have not already been concatenated.
import os 
i = 0
while True:
    if not os.path.isfile(str(i)+'_slice.h5.0'):
        break
    if not os.path.isfile(str(i)+'_slice.h5'):
        print(str(i)+'_slice.h5')
        cat.slice(i,'','')
        print(str(i)+'_slice.h5')
    i += 1
Clone this wiki locally