def update(self, cluster: Cluster, step: int) -> None: super().update(cluster=cluster, step=step) cluster.minimum = False cluster = self.database.insert_cluster(cluster) worker_pool = Pool(processes=self.n_processes) minima = Pool.map(self.quench(cluster), [cluster for i in range(self.n_quench)]) for _ in range(self.n_quench): minimum = self.quench(cluster) minimum.step = step minimum = self.database.insert_cluster(minimum) minima.append(minimum) self.results_dict[cluster] = Counter(minima)
def minimize(self, cluster: Cluster) -> Cluster: self.step_size = self.initial_step step = 0 _ = cluster.get_particle_positions() # n_coords = len(_[1]) self.coords = _[0] np.random.shuffle(self.coords) last_energy = self.pot.get_energy(cluster) converged = False while step <= self.max_steps and not converged: converged = True step += 1 for idx in range(len(self.coords)): self._take_step(self.coords[idx]) cluster.set_particle_positions((self.coords, _[1], _[2])) new_energy = self.pot.get_energy(cluster) # print(new_energy, last_energy) dE = new_energy - last_energy last_energy = new_energy self.update() if abs(dE) >= self.convergence_gradient: converged = False # print(f"Exiting in {step} steps") # for i in self.coords: # print("Cl " + " ".join([str(a) for a in i])) cluster.minimum = True return cluster