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 _cylindrical_radius(field, data): """The cylindrical radius component of the positions of the mesh cells. 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 data.ds.arr(get_cyl_r(coords, normal), "code_length").in_cgs()
def _particle_position_cylindrical_radius(field, data): """The cylindrical radius 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_r(pos, normal), 'code_length')
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 _cylindrical_r(field, data): normal = data.get_field_parameter("normal") coords = get_periodic_rvec(data) return data.ds.arr(get_cyl_r(coords, normal), "code_length").in_cgs()