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
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])
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
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)
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)
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)
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)
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"])
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
def _kinetic_energy_density(field, data): v = obtain_relative_velocity_vector(data) return 0.5 * data[ftype, "density"] * (v**2).sum(axis=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]