Download Hyperion Manual Release 0.9.7 Thomas Robitaille

Transcript
Hyperion Manual, Release 0.9.7
from hyperion.importers.sph import construct_octree
octree = construct_octree(x, y, z, dx, dy, dz, px, py, pz, sigma, mass)
The arguments are:
• the center of the octree grid (x, y, z, which should be floating-point values)
• the half-width of the octree grid (dx, dy, dz, which should be floating-point values)
• the positions of the particles (px, py, pz, which should be 1-d Numpy arrays)
• the sigmas of the Gaussian kernel (sigma, which should be a 1-d Numpy array)
• the masses of the particles (mass, which should be a 1-d Numpy array)
Note that only Gaussian kernels are supported at this time. All values should be given in cgs. The function returns an
OctreeGrid object. This can then be used to set the geometry and the density grid:
m.set_grid(octree)
m.add_density_grid(octree['density'][0], dust_file)
A criterion can be specified to halt the refinement of cells. By default, cells are no longer refined if they contain
two or fewer particles. This can be changed by passing a custom function to construct_octree using the
stopping_criterion argument. The function passed should take ten arguments, which are x, y, z, dx, dy,
dz for the current cell, and the positions and sigmas px, py, pz, and sigma for the particles in the cell. The function
should return False if the cell should be refined further, and True otherwise. For example, the default function can
be written as:
def DEFAULT_STOPPING_CRITERION(x, y, z, dx, dy, dz, px, py, pz, sigma):
return len(px) <= 2
In addition, the construct_octree function can take a n_levels argument to indicate the maximum number
of levels of refinement to allow.
Writing and Reading Octree grids to disk
Computing an Octree can be a computationally expensive operation, so once it has been computed, you can write it
out to disk using:
import h5py
f = h5py.File('my_octree_grid.hdf5', 'w')
octree.write(f)
f.close()
You can then read it into a separate script (e.g. the script setting up the actual model) using:
import h5py
from hyperion.grid import OctreeGrid
f = h5py.File('my_octree_grid.hdf5', 'r')
octree = OctreeGrid()
octree.read(f)
f.close()
4.1.5 AMR Grids
AMR grids are specified by nested objects in the Python, with a layout described in Coordinate grids and physical
quantities. These objects can be built in several ways:
92
Chapter 4. Advanced