Пример #1
0
        def _magnetic_field_toroidal(field, data):
            normal = data.get_field_parameter("normal")

            Bfields = ustack([
                data[ftype, "relative_magnetic_field_x"],
                data[ftype, "relative_magnetic_field_y"],
                data[ftype, "relative_magnetic_field_z"],
            ])

            phi = data["index", "spherical_phi"]
            return get_sph_phi_component(Bfields, phi, normal)
def test_spherical_coordinate_projections():
    normal = [0, 0, 1]
    theta = get_sph_theta(coords, normal)
    phi = get_sph_phi(coords, normal)
    zero = np.tile(0,coords.shape[1])

    # Purely radial field
    vecs = np.array([np.sin(theta)*np.cos(phi), np.sin(theta)*np.sin(phi), np.cos(theta)])
    assert_array_almost_equal(zero, get_sph_theta_component(vecs, theta, phi, normal))
    assert_array_almost_equal(zero, get_sph_phi_component(vecs, phi, normal))

    # Purely toroidal field
    vecs = np.array([-np.sin(phi), np.cos(phi), zero])
    assert_array_almost_equal(zero, get_sph_theta_component(vecs, theta, phi, normal))
    assert_array_almost_equal(zero, get_sph_r_component(vecs, theta, phi, normal))

    # Purely poloidal field
    vecs = np.array([np.cos(theta)*np.cos(phi), np.cos(theta)*np.sin(phi), -np.sin(theta)])
    assert_array_almost_equal(zero, get_sph_phi_component(vecs, phi, normal))
    assert_array_almost_equal(zero, get_sph_r_component(vecs, theta, phi, normal))
Пример #3
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)
Пример #4
0
 def _magnetic_field_toroidal(field,data):
     normal = data.get_field_parameter("normal")
     d = data[ftype,'magnetic_field_x']
     Bfields = data.ds.arr(
                 [data[ftype,'magnetic_field_x'],
                  data[ftype,'magnetic_field_y'],
                  data[ftype,'magnetic_field_z']],
                  d.units)
     
     phi = data["index", 'spherical_phi']
     return get_sph_phi_component(Bfields, phi, normal)
    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_rv_vec(data, (xn, yn, zn),
                                "bulk_%s" % basename)
        phi = resize_vector(data["index", "spherical_phi"], vectors)
        return get_sph_phi_component(vectors, phi, normal)
Пример #6
0
    def _particle_velocity_spherical_phi(field, data):
        """The spherical phi component of the particle velocities

        Relative to the coordinate system defined by the *normal* vector,
        *bulk_velocity* vector and *center* field parameters.
        """
        normal = data.get_field_parameter("normal")
        pos = data["relative_particle_position"].T
        vel = data["relative_particle_velocity"].T
        phi = get_sph_phi(pos, normal)
        sphp = get_sph_phi_component(vel, phi, normal)
        return sphp
Пример #7
0
    def _particle_velocity_spherical_phi(field, data):
        """The spherical phi component of the particle velocities

        Relative to the coordinate system defined by the *normal* vector,
        *bulk_velocity* vector and *center* field parameters.
        """
        normal = data.get_field_parameter('normal')
        center = data.get_field_parameter('center')
        bv = data.get_field_parameter("bulk_velocity")
        pos = data.ds.arr([data[ptype, spos % ax] for ax in "xyz"])
        vel = data.ds.arr([data[ptype, svel % ax] for ax in "xyz"])
        phi = get_sph_phi(pos, normal)
        pos = pos - np.reshape(center, (3, 1))
        vel = vel - np.reshape(bv, (3, 1))
        sphp = get_sph_phi_component(vel, phi, normal)
        return sphp
    def _particle_velocity_spherical_phi(field, data):
        """The spherical phi component of the particle velocities

        Relative to the coordinate system defined by the *normal* vector,
        *bulk_velocity* vector and *center* field parameters.
        """
        normal = data.get_field_parameter('normal')
        center = data.get_field_parameter('center')
        bv = data.get_field_parameter("bulk_velocity")
        pos = data.ds.arr([data[ptype, spos % ax] for ax in "xyz"])
        vel = data.ds.arr([data[ptype, svel % ax] for ax in "xyz"])
        phi = get_sph_phi(pos, normal)
        pos = pos - np.reshape(center, (3, 1))
        vel = vel - np.reshape(bv, (3, 1))
        sphp = get_sph_phi_component(vel, phi, normal)
        return sphp
Пример #9
0
 def _particle_spherical_position_phi(field, data):
     """
     Phi component of the particles' position vectors in spherical coords
     on the provided field parameters for 'normal', 'center', and 
     'bulk_velocity', 
     """
     normal = data.get_field_parameter('normal')
     center = data.get_field_parameter('center')
     bv = data.get_field_parameter("bulk_velocity")
     pos = spos
     pos = YTArray([data[ptype, pos % ax] for ax in "xyz"])
     theta = get_sph_theta(pos, center)
     phi = get_sph_phi(pos, center)
     pos = pos - np.reshape(center, (3, 1))
     sphp = get_sph_phi_component(pos, phi, normal)
     return sphp