def compute_effective_field(self, y): y.shape = (self.total_image_num, -1) for i in range(self.image_num): self.sim.spin[:] = y[i + 1][:] # self.sim.compute_effective_field(t=0) # Compute effective field, which is the gradient of # the energy in the NEB method (derivative with respect to # the generalised coordinates) h = self.sim.field # self.Heff[i + 1, :] = h[:] # Compute the total energy self.energy[i + 1] = self.sim.compute_energy() # Compute the 'distance' or difference between neighbouring states # around y[i+1]. This is used to compute the spring force # dm1 = compute_dm(y[i], y[i + 1]) dm2 = compute_dm(y[i + 1], y[i + 2]) self.springs[i] = self.spring * (dm2 - dm1) # Use the native NEB (C code) to compute the tangents according # to the improved NEB method, developed by Henkelman and Jonsson # at: Henkelman et al., Journal of Chemical Physics 113, 22 (2000) neb_clib.compute_tangents(y, self.energy, self.tangents, self.total_image_num, 3 * self.n) # native_neb.compute_springs(y,self.springs,self.spring) y.shape = (-1,)
def compute_effective_field(self, y): y.shape = (self.total_image_num, -1) for i in range(self.image_num): self.sim.spin[:] = y[i + 1][:] # self.sim.compute_effective_field(t=0) # Compute effective field, which is the gradient of # the energy in the NEB method (derivative with respect to # the generalised coordinates) h = self.sim.field # self.Heff[i + 1, :] = h[:] # Compute the total energy self.energy[i + 1] = self.sim.compute_energy() # Compute the 'distance' or difference between neighbouring states # around y[i+1]. This is used to compute the spring force # dm1 = compute_dm(y[i], y[i + 1]) dm2 = compute_dm(y[i + 1], y[i + 2]) self.springs[i] = self.spring * (dm2 - dm1) # Use the native NEB (C code) to compute the tangents according # to the improved NEB method, developed by Henkelman and Jonsson # at: Henkelman et al., Journal of Chemical Physics 113, 22 (2000) neb_clib.compute_tangents(y, self.energy, self.tangents, self.total_image_num, 3 * self.n) # native_neb.compute_springs(y,self.springs,self.spring) y.shape = (-1, ) gc.collect()
def compute_effective_field(self, y): """ Compute the effective field using Fidimag and the tangents using the NEB C code, according to the improved NEB method, developed by Henkelman and Jonsson # at: Henkelman et al., Journal of Chemical Physics 113, 22 (2000) y :: The array with all the spin components for every image, i.e. for a N images energy band and P spins system: [theta0_0, phi0_0, theta0_1, phi0_1, ... , theta0_P, phi0_P, theta1_0, phi1_0, ..., theta1_P, phi1_P, ... thetaN_0, phiN_0, ..., thetaN_P, phiN_P] """ # Every row has all the spin components of an image y.shape = (self.total_image_num, -1) for i in range(self.image_num): # Redefine the angles of the (i + 1)-th image # (see the corresponding function) check_boundary(y[i + 1]) # Set the simulation magnetisation to the (i+1)-th image # spin components self.sim.spin = spherical2cartesian(y[i + 1]) # Compute the effective field using Fidimag's methods. # (we use the time=0 since we are only using the simulation # object to get the field) # Remember that The effective field is the gradient of # the energy with respect to the generalised coordinates # i.e. the magnetisation self.sim.compute_effective_field(t=0) h = self.sim.field # Save the field components of the (i + 1)-th image # to the effective field array which is in spherical coords self.Heff[i + 1, :] = cartesian2spherical_field(h, y[i + 1]) # Compute and save the total energy for this image self.energy[i + 1] = self.sim.compute_energy() # Compute the 'distance' or difference between neighbouring states # around the y[i+1] image. This is used to compute the spring force dm1 = compute_dm(y[i], y[i + 1]) dm2 = compute_dm(y[i + 1], y[i + 2]) self.springs[i] = self.spring * (dm2 - dm1) # Compute tangents using the C library (this is also used for # cartesian coordinates, we set here the total number of spin # components for spherical coords) neb_clib.compute_tangents( y, self.energy, self.tangents, self.total_image_num, 2 * self.n) # Flatten y y.shape = (-1, )
def compute_effective_field(self, y): """ Compute the effective field using Fidimag and the tangents using the NEB C code, according to the improved NEB method, developed by Henkelman and Jonsson # at: Henkelman et al., Journal of Chemical Physics 113, 22 (2000) y :: The array with all the spin components for every image, i.e. for a N images energy band and P spins system: [theta0_0, phi0_0, theta0_1, phi0_1, ... , theta0_P, phi0_P, theta1_0, phi1_0, ..., theta1_P, phi1_P, ... thetaN_0, phiN_0, ..., thetaN_P, phiN_P] """ # Every row has all the spin components of an image y.shape = (self.total_image_num, -1) for i in range(self.image_num): # Redefine the angles of the (i + 1)-th image # (see the corresponding function) check_boundary(y[i + 1]) # Set the simulation magnetisation to the (i+1)-th image # spin components self.sim.spin = spherical2cartesian(y[i + 1]) # Compute the effective field using Fidimag's methods. # (we use the time=0 since we are only using the simulation # object to get the field) # Remember that The effective field is the gradient of # the energy with respect to the generalised coordinates # i.e. the magnetisation self.sim.compute_effective_field(t=0) h = self.sim.field # Save the field components of the (i + 1)-th image # to the effective field array which is in spherical coords self.Heff[i + 1, :] = cartesian2spherical_field(h, y[i + 1]) # Compute and save the total energy for this image self.energy[i + 1] = self.sim.compute_energy() # Compute the 'distance' or difference between neighbouring states # around the y[i+1] image. This is used to compute the spring force dm1 = compute_dm(y[i], y[i + 1]) dm2 = compute_dm(y[i + 1], y[i + 2]) self.springs[i] = self.spring * (dm2 - dm1) # Compute tangents using the C library (this is also used for # cartesian coordinates, we set here the total number of spin # components for spherical coords) neb_clib.compute_tangents(y, self.energy, self.tangents, self.total_image_num, 2 * self.n) # Flatten y y.shape = (-1, )