def _particle_specific_angular_momentum(field, data):
     """
     Calculate the angular of a particle velocity.  Returns a vector for each
     particle.
     """
     center = data.get_field_parameter('center')
     pos, vel, normal, bv = get_angular_momentum_components(ptype, data, spos, svel)
     L, r_vec, v_vec = modify_reference_frame(center, normal, P=pos, V=vel)
     # adding in the unit registry allows us to have a reference to the dataset
     # and thus we will always get the correct units after applying the cross product.
     return -ucross(r_vec, v_vec, registry=data.ds.unit_registry)
示例#2
0
 def _particle_specific_angular_momentum(field, data):
     """
     Calculate the angular of a particle velocity.  Returns a vector for each
     particle.
     """
     center = data.get_field_parameter('center')
     pos, vel, normal, bv = get_angular_momentum_components(ptype, data, spos, svel)
     L, r_vec, v_vec = modify_reference_frame(center, normal, P=pos, V=vel)
     # adding in the unit registry allows us to have a reference to the dataset
     # and thus we will always get the correct units after applying the cross product.
     return -ucross(r_vec, v_vec, registry=data.ds.unit_registry)
示例#3
0
    def _particle_position_relative(field, data):
        """The cartesian particle positions in a rotated reference frame

        Relative to the coordinate system defined by the *normal* vector and
        *center* field parameters.

        Note that the orientation of the x and y axes are arbitrary.
        """
        normal = data.get_field_parameter('normal')
        center = data.get_field_parameter('center')
        pos = data.ds.arr([data[ptype, spos % ax] for ax in "xyz"]).T
        L, pos = modify_reference_frame(center, normal, P=pos)
        return pos
    def _particle_position_relative(field, data):
        """The cartesian particle positions in a rotated reference frame

        Relative to the coordinate system defined by the *normal* vector and
        *center* field parameters.

        Note that the orientation of the x and y axes are arbitrary.
        """
        normal = data.get_field_parameter('normal')
        center = data.get_field_parameter('center')
        pos = data.ds.arr([data[ptype, spos % ax] for ax in "xyz"]).T
        L, pos = modify_reference_frame(center, normal, P=pos)
        return pos
    def _particle_velocity_relative(field, data):
        """The vector particle velocities in an arbitrary coordinate system

        Relative to the coordinate system defined by the *normal* vector,
        *bulk_velocity* vector and *center* field parameters.

        Note that the orientation of the x and y axes are arbitrary.
        """
        normal = data.get_field_parameter('normal')
        center = data.get_field_parameter('center')
        bv = data.get_field_parameter("bulk_velocity")
        vel = data.ds.arr([data[ptype, svel % ax] - bv[iax] for iax, ax in enumerate("xyz")]).T
        L, vel = modify_reference_frame(center, normal, V=vel)
        return vel
示例#6
0
    def _particle_velocity_relative(field, data):
        """The vector particle velocities in an arbitrary coordinate system

        Relative to the coordinate system defined by the *normal* vector,
        *bulk_velocity* vector and *center* field parameters.

        Note that the orientation of the x and y axes are arbitrary.
        """
        normal = data.get_field_parameter('normal')
        center = data.get_field_parameter('center')
        bv = data.get_field_parameter("bulk_velocity")
        vel = data.ds.arr([data[ptype, svel % ax] - bv[iax] for iax, ax in enumerate("xyz")]).T
        L, vel = modify_reference_frame(center, normal, V=vel)
        return vel
示例#7
0
def manual_jz(data, type="all", r_filter=None, AMR=True):

    # vx * y - yv * x
    #	if data.has_field_parameter("bulk_velocity"):
    #		data.field_data.pop((type, 'particle_position_relative_x'))
    #		data.field_data.pop((type, 'particle_position_relative_y'))
    #		data.field_data.pop((type, 'particle_velocity_relative_x'))
    #		data.field_data.pop((type, 'particle_velocity_relative_y'))

    if AMR == True and type == "gas":
        from yt.utilities.math_utils import modify_reference_frame
        from yt.units.yt_array import ucross

        if data.has_field_parameter("normal"):
            normal = data.get_field_parameter("normal")
        else:
            normal = data.ds.arr([0.0, 0.0, 1.0],
                                 "code_length")  # default to simulation axis
        bv = data.get_field_parameter("bulk_velocity")
        pos = data.ds.arr([data["%s" % ax] for ax in "xyz"]).T
        vel = data.ds.arr([
            data["gas", "velocity_%s" % ax] - bv[iax]
            for iax, ax in enumerate("xyz")
        ]).T
        center = data.get_field_parameter('center')
        L, r_vec, v_vec = modify_reference_frame(center, normal, P=pos, V=vel)
        ang_momentum = -ucross(r_vec, v_vec, registry=data.ds.unit_registry)
        jz = ang_momentum[:, "2"]
        if r_filter != None:
            jz = jz[r_filter]

    else:
        if r_filter != None:
            vrot = (data[type, "particle_position_relative_x"][r_filter] *
                    data[type, "particle_velocity_relative_y"][r_filter])
            vrot = vrot - (
                data[type, "particle_position_relative_y"][r_filter] *
                data[type, "particle_velocity_relative_x"][r_filter])
        else:
            vrot = (data[type, "particle_position_relative_x"] *
                    data[type, "particle_velocity_relative_y"])
            vrot = vrot - (data[type, "particle_position_relative_y"] *
                           data[type, "particle_velocity_relative_x"])

        jz = vrot
    return jz