Exemplo n.º 1
0
def get_periodic_rvec(data):
    coords = obtain_rvec(data)
    if sum(data.ds.periodicity) == 0: return coords
    le = data.ds.domain_left_edge.in_units("code_length").d
    dw = data.ds.domain_width.in_units("code_length").d
    for i in range(coords.shape[0]):
        if not data.ds.periodicity[i]: continue
        coords[i, ...] -= le[i]
        #figure out which measure is less
        mins = np.argmin([
            np.abs(np.mod(coords[i, ...], dw[i])),
            np.abs(np.mod(coords[i, ...], -dw[i]))
        ],
                         axis=0)
        temp_coords = np.mod(coords[i, ...], dw[i])

        #Where second measure is better, updating temporary coords
        ii = mins == 1
        temp_coords[ii] = np.mod(coords[i, ...], -dw[i])[ii]

        # Putting the temporary coords into the actual storage
        coords[i, ...] = temp_coords

        coords[i, ...] + le[i]

    return coords
Exemplo n.º 2
0
def get_periodic_rvec(data):
    coords = obtain_rvec(data)
    if sum(data.ds.periodicity) == 0: return coords
    le = data.ds.domain_left_edge.in_units("code_length").d
    dw = data.ds.domain_width.in_units("code_length").d
    for i in range(coords.shape[0]):
        if not data.ds.periodicity[i]: continue
        coords[i, ...] -= le[i]
        coords[i, ...] = np.min([
            np.abs(np.mod(coords[i, ...], dw[i])),
            np.abs(np.mod(coords[i, ...], -dw[i]))
        ],
                                axis=0)
        coords[i, ...] += le[i]
    return coords
def get_periodic_rvec(data):
    coords = obtain_rvec(data)
    if sum(data.ds.periodicity) == 0: return coords
    le = data.ds.domain_left_edge.in_units("code_length").d
    dw = data.ds.domain_width.in_units("code_length").d
    for i in range(coords.shape[0]):
        if not data.ds.periodicity[i]: continue
        coords[i, ...] -= le[i]
        #figure out which measure is less
        mins = np.argmin([np.abs(np.mod(coords[i, ...],  dw[i])),
                         np.abs(np.mod(coords[i, ...], -dw[i]))],
                         axis=0)
        temp_coords = np.mod(coords[i, ...], dw[i])

        #Where second measure is better, updating temporary coords
        ii = mins==1
        temp_coords[ii] = np.mod(coords[i, ...], -dw[i])[ii]

        # Putting the temporary coords into the actual storage
        coords[i, ...] = temp_coords

        coords[i, ...] + le[i]

    return coords
Exemplo n.º 4
0
 def _specific_angular_momentum_z(field, data):
     xv, yv, zv = obtain_velocities(data, ftype)
     rv = obtain_rvec(data)
     rv = np.rollaxis(rv, 0, len(rv.shape))
     rv = data.ds.arr(rv, input_units=data["index", "x"].units)
     return xv * rv[..., 1] - yv * rv[..., 0]
 def _specific_angular_momentum_z(field, data):
     xv, yv, zv = obtain_velocities(data, ftype)
     rv = obtain_rvec(data)
     rv = np.rollaxis(rv, 0, len(rv.shape))
     rv = data.ds.arr(rv, input_units = data["index", "x"].units)
     return xv * rv[...,1] - yv * rv[...,0]