Coordinate Tools

pyHARM’s tools for dealing with coordinates are split into two files: pyHARM.coordinates, for dealing with continuous transformations between different coordinate systems in the Kerr metric, and pyHARM.grid for holding a Cartesian mesh of native coordinates, coupled with their local metric, connection coefficients, and transformation matrices back to some “base” coordinate system (currently must be Kerr-Schild coordinates)

Coordinate Systems

Coordinate systems are implemented as classes, each of which subclasses pyHARM.coordinates.CoordinateSystem and implements the methods it contains:

class pyHARM.coordinates.CoordinateSystem

Base class for representing coordinate systems Coordinate classes define, as functions of their native coordinates X:

  • r,th,phi in spherical Kerr-Schild coordinates (or just spherical coordinates in the case of Minkowski)
  • A transformation matrix, dxdX, for tensors from one system to the other
  • The forms and determinant of the metric, gcov, gcon, & gdet

Of these, most are derivable

cart_coord(x)

Return Cartesian Kerr-Schild coordinates of a point X in native coordinates

conn_func(x, delta=1e-05)

Calculate all connection coefficients \(\Gamma^{i}_{j, k}\). Returns a 3+N dimensional array conn[i,j,k,…]

gcon(gcov)

Return contravariant form of the metric, given the covariant form. As with all coordinate functions, the matrix/vector indices are first. Specifically, gcon_func expects exactly zero grid indices (i.e. a single 4x4 matrix) or two grid indices (i.e. 4x4xN1xN2).

gdet(gcov)

Return the negative root determinant of the metric \(\sqrt{-g}\), given the covariant form.

ks_coord(x)

Return Spherical Kerr-Schild coordinates of a point X in native coordinates

The coordinate systems currently supported are Minkowski (pyHARM.coordinates.Minkowski), Kerr-Schild (pyHARM.coordinates.KS), Modified Kerr-Schild (pyHARM.coordinates.MKS), and “Funky” Modified Kerr-Schild (pyHARM.coordinates.FMKS). The MKS and FMKS systems are used to concentrate zones toward the midplane, and to make zones near the pole larger, in order to preserve accuracy in simulations while maintaining a reasonable time step (which is driven by the Courant condition at the pole). Details on these coordinate systems can be found here.

The Grid Class

class pyHARM.grid.Grid(params, caches=True, cache_conn=True)

Holds all information about the (potentially a) grid of zones: size, shape, zones’ global locations, metric tensor

coord(i, j, k, loc=<Loci.CENT: 3>)

Get the position x of zone(s) i,j,k, in _native_ coordinates

If given lists of i,j,k, this returns x[NDIM,len(i),len(j),len(k)] via np.meshgrid(). Any index given as a single value is suppressed on output, down to x[NDIM]

All functions in coordinates.py which take coordinates “x” also accept a grid of the form this returns.

coord_all(loc=<Loci.CENT: 3>)

Like coord_bulk, but including ghost zones

coord_all_mesh()

Like coord_bulk_mesh, but including ghost zones

coord_bulk(loc=<Loci.CENT: 3>)

Return a 3D array of all position vectors X within the physical zones. See coord() for use.

coord_bulk_mesh()

Returns zone corners for plotting a variable in the bulk

dot(ucon, ucov)

Inner product along first index. Exists to make other code OpenCL-agnostic

dt_light()

Returns the light crossing time of the smallest zone in the grid

lower_grid(vcon, loc=<Loci.CENT: 3>)

Lower a grid of contravariant rank-1 tensors to covariant ones.

raise_grid(vcov, loc=<Loci.CENT: 3>)

Raise a grid of covariant rank-1 tensors to contravariant ones.

pyHARM.grid.make_some_grid(type, n1=128, n2=128, n3=128, a=0, hslope=0.3, r_in=None, r_out=50, params=None, caches=True, cache_conn=True)

Convenience function for generating grids with default parameters used at Illinois. Type should be one of ‘minkowski’, ‘mks’, ‘fmks’ Size and coordinate parameters are optional with somewhat reasonable defaults.