def test_geodesic_distance(): """ We will measure the distance between a spin in the +z direction and a spin at the -z direction. The great-circle distance (distance on the unit sphere) should be PI, since the perimeter is 2PI The other distance is between a spin in the [0, 1, 0] direction and another one in the [-1, 0, 0] direction. The arc length should be PI/2 """ # Degrees of freedom in Cartesian coordinates A = np.array([0, 0, 1.]) B = np.array([0, 0, -1.]) n_dofs_image = 3 # The material array only indicates the lattice/mesh sites where # there is material (mu_s or M_s larger than zero) material = np.array([1]).astype(np.int32) n_dofs_image_material = 3 d = nebm_geodesic.geodesic_distance(A, B, n_dofs_image, material, n_dofs_image_material ) assert np.abs(d - np.pi) < 1e-5 # The other two spins: A = np.array([0, 1, 0.]) B = np.array([-1, 0, 0.]) d = nebm_geodesic.geodesic_distance(A, B, n_dofs_image, material, n_dofs_image_material ) assert np.abs(d - np.pi * 0.5) < 1e-5
def compute_distances(self, A, B): """ Compute the distance between corresponding images of the bands A and B A B [ [image_0] [ [image_0] [image_1] - [image_1] ..self. ... ] ] """ A.shape = (-1, self.n_dofs_image) B.shape = (-1, self.n_dofs_image) distances = np.zeros(len(A)) for i in range(len(distances)): distances[i] = nebm_geodesic.geodesic_distance( A[i], B[i], self.n_dofs_image, self._material_int, self.n_dofs_image_material) A.shape = (-1) B.shape = (-1) return distances
def compute_distances(self, A, B): """ Compute the distance between corresponding images of the bands A and B A B [ [image_0] [ [image_0] [image_1] - [image_1] ..self. ... ] ] """ A.shape = (-1, self.n_dofs_image) B.shape = (-1, self.n_dofs_image) distances = np.zeros(len(A)) for i in range(len(distances)): distances[i] = nebm_geodesic.geodesic_distance(A[i], B[i], self.n_dofs_image, self._material_int, self.n_dofs_image_material ) A.shape = (-1) B.shape = (-1) return distances