Beispiel #1
0
 def compute_tangents(self, y):
     nebm_clib.compute_tangents(self.tangents, y, self.energies,
                                self.n_dofs_image, self.n_images)
     nebm_clib.project_images(self.tangents, y, self.n_images,
                              self.n_dofs_image)
     nebm_clib.normalise_images(self.tangents, self.n_images,
                                self.n_dofs_image)
Beispiel #2
0
    def nebm_step(self, y):

        self.compute_effective_field_and_energy(y)
        nebm_clib.project_images(self.gradientE, y, self.n_images,
                                 self.n_dofs_image)
        self.compute_tangents(y)
        self.compute_spring_force(y)

        nebm_clib.compute_effective_force(self.G, self.tangents,
                                          self.gradientE, self.spring_force,
                                          self._climbing_image, self.n_images,
                                          self.n_dofs_image)
Beispiel #3
0
    def string_method_step(self, y):

        # Use the projection mehtod from the NEBM C libs
        self.compute_effective_field_and_energy(y)
        nebm_clib.project_images(self.gradientE, y,
                                 self.n_images, self.n_dofs_image
                                 )

        # The string method only requires to update the images using the
        # gradient (steepest descent)

        # Is it necessary to rescale the effective field?
        # scale = np.tile(np.repeat(const.mu_0 * self.sim.Ms, 3), self.n_images)
        self.G[:] = -self.gradientE[:]
def test_project_images_into_image():
    """

    Project the vectors from an array of images a, into images

    The C library function does NOT calculate projections of extrema images,
    i.e. image 0 and N, thus we pad two extra arrays at the end and beginning
    of the arrays

    We construct array "a" made of 4 images, each having 3 vectors
    Then we construct array "images" with 4 images
    Then we project vectors from "a" into "images" and compare results

    """

    a = np.zeros(18 + 18, dtype=np.float)
    a[9:27] = np.arange(18, dtype=np.float)
    images = np.array([0., 0, 0, 0, 0, 0, 0, 0, 0,
                       0., 0, 1, 1, 0, 0, 0, 0, 1,
                       0., 1, 0, 0, 0, 1, 1, 1, 0,
                       0., 0, 0, 0, 0, 0, 0, 0, 0,
                       ])

    # Project array of images a, which is updated in the C library
    nebm_clib.project_images(a, images,
                            # num of images and num of dofs per image:
                            4, 9)

    # Here we do the projections manually -------------------------------------
    # Dot products for every vector
    a_dot_images = [2., 3., 8.,
                    10., 14., 15. + 16.]
    expected_res = np.zeros(18 + 18, dtype=np.float)
    # Projections:
    expected_res[9:12] = [0, 1, 2 - a_dot_images[0]]
    expected_res[12:15] = [3 - a_dot_images[1], 4, 5]
    expected_res[15:18] = [6, 7, 8 - a_dot_images[2]]
    # Second image
    expected_res[18:21] = [9, 10 - a_dot_images[3], 11]
    expected_res[21:24] = [12, 13, 14 - a_dot_images[4]]
    expected_res[24:27] = [15 - a_dot_images[5], 16 - a_dot_images[5], 17]
    # print(expected_res)
    # print(a)
    # -------------------------------------------------------------------------

    for i in range(36):
        assert a[i] == expected_res[i]
Beispiel #5
0
    def compute_tangents(self, y):
        """
        Calculation of tangents from the Geodesic NEBM, so we can use the
        interpolation methods for the energy band

        TODO: An alternative approximation of the band can be made with simple
        spline interpolations although the GNEBM interpolation has more
        information of the gradients
        """
        nebm_clib.compute_tangents(self.tangents, y, self.energies,
                                   self.n_dofs_image, self.n_images
                                   )
        nebm_clib.project_images(self.tangents, y,
                                 self.n_images, self.n_dofs_image
                                 )
        nebm_clib.normalise_images(self.tangents,
                                   self.n_images, self.n_dofs_image
                                   )