Beispiel #1
0
 def _specific_angular_momentum_z(field, data):
     xv, yv, zv = obtain_relative_velocity_vector(data)
     rv = obtain_position_vector(data)
     units = rv.units
     rv = np.rollaxis(rv, 0, len(rv.shape))
     rv = data.ds.arr(rv, units=units)
     return rv[..., 0] * yv - rv[..., 1] * xv
Beispiel #2
0
 def _specific_angular_momentum_y(field, data):
     xv, yv, zv = obtain_relative_velocity_vector(data)
     rv = obtain_position_vector(data)
     units = rv.units
     rv = np.rollaxis(rv, 0, len(rv.shape))
     rv = data.ds.arr(rv, input_units=units)
     return -(xv * rv[..., 2] - zv * rv[..., 0])
Beispiel #3
0
    def _relative_particle_velocity(field, data):
        """The vector particle velocities in an arbitrary coordinate system

        Relative to the coordinate system defined by the *bulk_velocity*
        vector field parameter.

        Note that the orientation of the x and y axes are arbitrary.
        """
        field_names = [(ptype, f"particle_velocity_{ax}") for ax in "xyz"]
        return obtain_relative_velocity_vector(data, field_names=field_names).T
Beispiel #4
0
        def _cylindrical_z_component(field, data):
            """The cylindrical z component of the vector field

            Relative to the coordinate system defined by the *normal* vector,
            *center*, and *bulk_* field parameters.
            """
            normal = data.get_field_parameter("normal")
            vectors = obtain_relative_velocity_vector(data, (xn, yn, zn),
                                                      f"bulk_{basename}")
            return get_cyl_z_component(vectors, normal)
Beispiel #5
0
        def _spherical_phi_component(field, data):
            """The spherical phi component of the vector field

            Relative to the coordinate system defined by the *normal* vector,
            *center*, and *bulk_* field parameters.
            """
            normal = data.get_field_parameter("normal")
            vectors = obtain_relative_velocity_vector(data, (xn, yn, zn),
                                                      f"bulk_{basename}")
            phi = data["index", "spherical_phi"]
            return get_sph_phi_component(vectors, phi, normal)
Beispiel #6
0
        def _cylindrical_radius_component(field, data):
            """The cylindrical radius component of the vector field

            Relative to the coordinate system defined by the *normal* vector,
            *center*, and *bulk_* field parameters.
            """
            normal = data.get_field_parameter("normal")
            vectors = obtain_relative_velocity_vector(data, (xn, yn, zn),
                                                      "bulk_%s" % basename)
            theta = data["index", 'cylindrical_theta']
            return get_cyl_r_component(vectors, theta, normal)
Beispiel #7
0
        def _cylindrical_theta_component(field, data):
            """The cylindrical theta component of the vector field

            Relative to the coordinate system defined by the *normal* vector,
            *center*, and *bulk_* field parameters.
            """
            normal = data.get_field_parameter("normal")
            vectors = obtain_relative_velocity_vector(data, (xn, yn, zn),
                                                      f"bulk_{basename}")
            theta = data["index", "cylindrical_theta"].copy()
            theta = np.tile(theta, (3, ) + (1, ) * len(theta.shape))
            return get_cyl_theta_component(vectors, theta, normal)
Beispiel #8
0
def test_obtain_relative_velocity_vector():
    ds = fake_random_ds(64,
                        nprocs=8,
                        fields=_fields,
                        negative=[False, True, True, True])

    dd = ds.all_data()

    vels = obtain_relative_velocity_vector(dd)

    assert_array_equal(vels[0, :], dd["velocity_x"])
    assert_array_equal(vels[1, :], dd["velocity_y"])
    assert_array_equal(vels[2, :], dd["velocity_z"])
Beispiel #9
0
        def _spherical_radius_component(field, data):
            """The spherical radius component of the vector field

            Relative to the coordinate system defined by the *normal* vector,
            *center*, and *bulk_* field parameters.
            """
            normal = data.get_field_parameter("normal")
            vectors = obtain_relative_velocity_vector(data, (xn, yn, zn),
                                                      f"bulk_{basename}")
            theta = data["index", "spherical_theta"]
            phi = data["index", "spherical_phi"]
            rv = get_sph_r_component(vectors, theta, phi, normal)
            # Now, anywhere that radius is in fact zero, we want to zero out our
            # return values.
            rv[np.isnan(theta)] = 0.0
            return rv
Beispiel #10
0
 def _kinetic_energy_density(field, data):
     v = obtain_relative_velocity_vector(data)
     return 0.5 * data[ftype, "density"] * (v**2).sum(axis=0)
Beispiel #11
0
 def _specific_angular_momentum_z(field, data):
     xv, yv, zv = obtain_relative_velocity_vector(data)
     rv = obtain_position_vector(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]