def test_cylindrical_coordinate_conversion(): normal = [0, 0, 1] real_r = [ 0.47021498, 0.75970506, 0.94676179, 0.96327853, 0.79516968, 0.96904193, 1.00437346, 1.3344104 ] real_theta = [-2.65224483, -0.23804243, -1.47641858, -1.46498842, -0.40172325, -0.4422801 , 0.95466734, -2.31085392] real_z = [-0.55774212, 0.64076921, -0.61774511, 0.16294352, 0.75728738, -0.57039201, 0.46759728, -0.38355343] calc_r = get_cyl_r(coords, normal) calc_theta = get_cyl_theta(coords, normal) calc_z = get_cyl_z(coords, normal) assert_array_almost_equal(calc_r, real_r) assert_array_almost_equal(calc_theta, real_theta) assert_array_almost_equal(calc_z, real_z) normal = [1, 0, 0] real_r = [ 0.59994016, 0.66533898, 1.12694569, 0.97165149, 0.81862843, 0.70524152, 0.94368441, 1.05738542] real_theta = [-1.94809584, 1.843405, -2.56143151, 2.97309903, 1.96037671, -2.1995016, 0.51841239, -2.77038877] real_z = [-0.41503037, 0.73828247, 0.08922066, 0.10173242, 0.73186508, 0.8757989 , 0.58040762, -0.89983356] calc_r = get_cyl_r(coords, normal) calc_theta = get_cyl_theta(coords, normal) calc_z = get_cyl_z(coords, normal) assert_array_almost_equal(calc_r, real_r) assert_array_almost_equal(calc_theta, real_theta) assert_array_almost_equal(calc_z, real_z)
def test_cylindrical_coordiante_conversion(): normal = [0, 0, 1] real_r = [ 0.47021498, 0.75970506, 0.94676179, 0.96327853, 0.79516968, 0.96904193, 1.00437346, 1.3344104 ] real_theta = [-2.65224483, -0.23804243, -1.47641858, -1.46498842, -0.40172325, -0.4422801 , 0.95466734, -2.31085392] real_z = [-0.55774212, 0.64076921, -0.61774511, 0.16294352, 0.75728738, -0.57039201, 0.46759728, -0.38355343] calc_r = get_cyl_r(coords, normal) calc_theta = get_cyl_theta(coords, normal) calc_z = get_cyl_z(coords, normal) assert_array_almost_equal(calc_r, real_r) assert_array_almost_equal(calc_theta, real_theta) assert_array_almost_equal(calc_z, real_z) normal = [1, 0, 0] real_r = [ 0.59994016, 0.66533898, 1.12694569, 0.97165149, 0.81862843, 0.70524152, 0.94368441, 1.05738542] real_theta = [-0.37729951, -2.86898397, -0.99063518, -1.73928995, -2.75201227, -0.62870527, 2.08920872, -1.19959244] real_z = [-0.41503037, 0.73828247, 0.08922066, 0.10173242, 0.73186508, 0.8757989 , 0.58040762, -0.89983356] calc_r = get_cyl_r(coords, normal) calc_theta = get_cyl_theta(coords, normal) calc_z = get_cyl_z(coords, normal) assert_array_almost_equal(calc_r, real_r) assert_array_almost_equal(calc_theta, real_theta) assert_array_almost_equal(calc_z, real_z)
def _particle_position_cylindrical_theta(field, data): """The cylindrical theta component of the particle positions Relative to the coordinate system defined by the *normal* vector and *center* field parameters. """ normal = data.get_field_parameter("normal") pos = data["relative_particle_position"].T return data.ds.arr(get_cyl_theta(pos, normal), "")
def _particle_position_cylindrical_theta(field, data): """The cylindrical theta component of the particle positions Relative to the coordinate system defined by the *normal* vector and *center* field parameters. """ normal = data.get_field_parameter("normal") center = data.get_field_parameter('center') pos = data.ds.arr([data[ptype, spos % ax] for ax in "xyz"]) pos = pos - np.reshape(center, (3, 1)) return data.ds.arr(get_cyl_theta(pos, normal), "")
def _particle_position_cylindrical_theta(field,data): """The cylindrical theta component of the particle positions Relative to the coordinate system defined by the *normal* vector and *center* field parameters. """ normal = data.get_field_parameter("normal") center = data.get_field_parameter('center') pos = data.ds.arr([data[ptype, spos % ax] for ax in "xyz"]) pos = pos - np.reshape(center, (3, 1)) return data.ds.arr(get_cyl_theta(pos, normal), "")
def _particle_velocity_cylindrical_theta(field, data): """The cylindrical theta 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 theta = get_cyl_theta(pos, normal) cylt = get_cyl_theta_component(vel, theta, normal) return cylt
def _cylindrical_theta(field, data): """The cylindrical z component of the positions of the mesh cells. theta is the azimuthal position angle in the plane perpendicular to the *normal* vector. Relative to the coordinate system defined by the *normal* vector and *center* field parameters. """ normal = data.get_field_parameter("normal") coords = get_periodic_rvec(data) return get_cyl_theta(coords, normal)
def _particle_velocity_cylindrical_theta(field, data): """The cylindrical theta 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"]) pos = pos - np.reshape(center, (3, 1)) vel = vel - np.reshape(bv, (3, 1)) theta = get_cyl_theta(pos, normal) cylt = get_cyl_theta_component(vel, theta, normal) return cylt
def _particle_velocity_cylindrical_theta(field, data): """The cylindrical theta 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"]) theta = get_cyl_theta(pos, normal) pos = pos - np.reshape(center, (3, 1)) vel = vel - np.reshape(bv, (3, 1)) cylt = get_cyl_theta_component(vel, theta, normal) return cylt
def test_cylindrical_coordinate_projections(): normal = [0, 0, 1] theta = get_cyl_theta(coords, normal) z = get_cyl_z(coords, normal) zero = np.tile(0, coords.shape[1]) # Purely radial field vecs = np.array([np.cos(theta), np.sin(theta), zero]) assert_array_almost_equal(zero, get_cyl_theta_component(vecs, theta, normal)) assert_array_almost_equal(zero, get_cyl_z_component(vecs, normal)) # Purely toroidal field vecs = np.array([-np.sin(theta), np.cos(theta), zero]) assert_array_almost_equal(zero, get_cyl_z_component(vecs, normal)) assert_array_almost_equal(zero, get_cyl_r_component(vecs, theta, normal)) # Purely z field vecs = np.array([zero, zero, z]) assert_array_almost_equal(zero, get_cyl_theta_component(vecs, theta, normal)) assert_array_almost_equal(zero, get_cyl_r_component(vecs, theta, normal))
def _cylindrical_theta(field, data): normal = data.get_field_parameter("normal") coords = get_periodic_rvec(data) return get_cyl_theta(coords, normal)