def test_points_ne_query_points(self): x_max = 2.5 y_max = 2.5 n_x = 10 n_y = 10 n_t = 4 lattice_size = 10 box = freud.box.Box.square(lattice_size * 5) points, query_points = util.make_alternating_lattice( lattice_size, 0.01, 2) orientations = np.array([0] * len(points)) query_orientations = np.array([0] * len(query_points)) r_max = np.sqrt(x_max**2 + y_max**2) test_set = util.make_raw_query_nlist_test_set(box, points, query_points, "ball", r_max, 0, False) for nq, neighbors in test_set: pmft = freud.pmft.PMFTXYT(x_max, y_max, (n_x, n_y, n_t)) pmft.compute(nq, orientations, query_points, query_orientations, neighbors=neighbors) # when rotated slightly, for each ref point, each quadrant # (corresponding to two consecutive bins) should contain 3 points. for i in range(n_t): assert np.count_nonzero(np.isinf(pmft.pmft[..., i]) == 0) == 3 assert len(np.unique(pmft.pmft)) == 2
def test_ref_points_ne_points(self): lattice_size = 10 # big box to ignore periodicity box = freud.box.Box.square(lattice_size*5) angle = np.pi/30 ref_points, points = util.make_alternating_lattice(lattice_size, angle) # actually not used rmax = 1.6 k = 0 n = 12 n_bins_t = 30 n_bins_p = 2 bod = freud.environment.BondOrder(rmax=rmax, k=k, n=n, n_bins_t=n_bins_t, n_bins_p=n_bins_p) # orientations are not used in bod mode ref_orientations = np.array([[1, 0, 0, 0]]*len(ref_points)) orientations = np.array([[1, 0, 0, 0]]*len(points)) bod.compute(box, ref_points, ref_orientations, points, orientations) # we want to make sure that we get 12 nonzero places, so we can test # whether we are not considering neighbors between ref_points self.assertEqual(np.count_nonzero(bod.bond_order), 12) self.assertEqual(len(np.unique(bod.bond_order)), 2)
def test_points_ne_query_points(self): r_max = 2.3 nbins = 10 lattice_size = 10 box = freud.box.Box.square(lattice_size * 5) points, query_points = util.make_alternating_lattice( lattice_size, 0.01, 2) orientations = np.array([0] * len(points)) query_orientations = np.array([0] * len(query_points)) test_set = util.make_raw_query_nlist_test_set(box, points, query_points, "ball", r_max, 0, False) for nq, neighbors in test_set: pmft = freud.pmft.PMFTR12(r_max, nbins) pmft.compute(nq, orientations, query_points, query_orientations, neighbors=neighbors) assert np.count_nonzero(np.isinf(pmft.pmft) == 0) == 12 assert len(np.unique(pmft.pmft)) == 3
def test_points_ne_query_points(self): lattice_size = 10 # big box to ignore periodicity box = freud.box.Box.square(lattice_size * 5) angle = np.pi / 30 query_points, points = util.make_alternating_lattice(lattice_size, angle) r_max = 1.6 num_neighbors = 12 n_bins_theta = 30 n_bins_phi = 2 test_set = util.make_raw_query_nlist_test_set( box, points, query_points, "nearest", r_max, num_neighbors, False ) for nq, neighbors in test_set: bod = freud.environment.BondOrder(bins=(n_bins_theta, n_bins_phi)) # orientations are not used in bod mode orientations = np.array([[1, 0, 0, 0]] * len(points)) query_orientations = np.array([[1, 0, 0, 0]] * len(query_points)) bod.compute( nq, orientations, query_points, query_orientations, neighbors=neighbors ) # we want to make sure that we get 12 nonzero places, so we can # test whether we are not considering neighbors between points assert np.count_nonzero(bod.bond_order) == 12 assert len(np.unique(bod.bond_order)) == 2
def test_alternating_points(self): lattice_size = 10 # big box to ignore periodicity box = freud.box.Box.square(lattice_size * 5) query_points, points = util.make_alternating_lattice(lattice_size) r_max = 1.6 num_neighbors = 12 test_set = util.make_raw_query_nlist_test_set( box, points, query_points, "nearest", r_max, num_neighbors, False ) nlist = test_set[-1][1] for nq, neighbors in test_set: if not isinstance(nq, freud.locality.NeighborQuery): continue check_nlist = nq.query(query_points, neighbors).toNeighborList() assert nlist_equal(nlist, check_nlist)
def test_ref_points_ne_points(self): r_max = 2.3 n_r = 10 n_t1 = 10 n_t2 = 10 pmft = freud.pmft.PMFTR12(r_max, n_r, n_t1, n_t2) lattice_size = 10 box = freud.box.Box.square(lattice_size * 5) ref_points, points = util.make_alternating_lattice( lattice_size, 0.01, 2) ref_orientations = np.array([0] * len(ref_points)) orientations = np.array([0] * len(points)) pmft.compute(box, ref_points, ref_orientations, points, orientations) self.assertEqual(np.count_nonzero(np.isinf(pmft.PMFT) == 0), 12) self.assertEqual(len(np.unique(pmft.PMFT)), 3)
def test_points_ne_query_points(self): x_max = 2.5 y_max = 2.5 nbins = 20 lattice_size = 10 box = freud.box.Box.square(lattice_size * 5) points, query_points = util.make_alternating_lattice( lattice_size, 0.01, 2) query_orientations = np.array([0] * len(query_points)) r_max = np.sqrt(x_max**2 + y_max**2) test_set = util.make_raw_query_nlist_test_set(box, points, query_points, 'ball', r_max, 0, False) for nq, neighbors in test_set: pmft = freud.pmft.PMFTXY(x_max, y_max, nbins) pmft.compute(nq, query_orientations, query_points, neighbors) self.assertEqual(np.count_nonzero(np.isinf(pmft.pmft) == 0), 12) self.assertEqual(len(np.unique(pmft.pmft)), 2)
def test_ref_points_ne_points(self): x_max = 2.5 y_max = 2.5 n_x = 10 n_y = 10 n_t = 4 pmft = freud.pmft.PMFTXYT(x_max, y_max, n_x, n_y, n_t) lattice_size = 10 box = freud.box.Box.square(lattice_size * 5) ref_points, points = util.make_alternating_lattice( lattice_size, 0.01, 2) ref_orientations = np.array([0] * len(ref_points)) orientations = np.array([0] * len(points)) pmft.compute(box, ref_points, ref_orientations, points, orientations) # when rotated slightly, for each ref point, each quadrant # (corresponding to two consecutive bins) should contain 3 points. for i in range(n_t): self.assertEqual(np.count_nonzero(np.isinf(pmft.PMFT[i]) == 0), 3) self.assertEqual(len(np.unique(pmft.PMFT)), 2)