def add_relaxed_step(self, a, find_neighbors=None, perform_parametrization=None): """ After a candidate is relaxed it must be marked as such. As well add the possible neighbor list and parametrization parameters to screen candidates before relaxation (default not in use) """ # test that raw_score can be extracted try: a.info['key_value_pairs']['raw_score'] except KeyError: print("raw_score not put in atoms.info['key_value_pairs']") gaid = a.info['confid'] if 'generation' not in a.info['key_value_pairs']: g = self.get_generation_number() a.info['key_value_pairs']['generation'] = g if find_neighbors is not None: enable_parametrization_methods(a) a.set_neighbor_list(find_neighbors(a)) if perform_parametrization is not None: a.set_parametrization(perform_parametrization(a)) relax_id = self.c.write(a, gaid=gaid, relaxed=1, key_value_pairs=a.info['key_value_pairs'], data=a.info['data']) a.info['relax_id'] = relax_id
def get_angles_distribution(atoms, ang_grid=9): """ Method to get the distribution of bond angles in bins (default 9) with bonds defined from the get_neighbor_list(). """ from math import pi enable_parametrization_methods(atoms) conn = atoms.get_neighbor_list() if conn is None: conn = get_neighborlist(atoms) bins = [0] * ang_grid for atom in atoms: for i in conn[atom.index]: for j in conn[atom.index]: if j != i: a = atoms.get_angle([i, atom.index, j]) * 180 / pi for k in range(ang_grid): if (k + 1) * 180. / ang_grid > a > k * 180. / ang_grid: bins[k] += 1 # Removing dobbelt counting for i in range(ang_grid): bins[i] /= 2. return bins
def get_atoms_connections(atoms, max_conn=5): """ This method returns a list of the numbers of atoms with X number of neighbors. The method utilizes the neighbor list and hence inherit the restrictions for neighbors. """ enable_parametrization_methods(atoms) conn = atoms.get_neighbor_list() if conn is None: conn = get_neighborlist(atoms) no_of_conn = [0] * max_conn for i in range(len(atoms)): no_of_conn[min(len(conn[i]), max_conn - 1)] += 1 return no_of_conn
def get_rings(atoms, rings=[5, 6, 7]): """ This method return a list of the number of atoms involved in rings in the structures. It uses the neighbor list hence inherit the restriction used for neighbors. """ enable_parametrization_methods(atoms) conn = atoms.get_neighbor_list() if conn is None: conn = get_neighborlist(atoms) no_of_loops = [0] * 8 for s1 in range(len(atoms)): for s2 in conn[s1]: v12 = [s1] + [s2] for s3 in [s for s in conn[s2] if s not in v12]: v13 = v12 + [s3] if s1 in conn[s3]: no_of_loops[3] += 1 for s4 in [s for s in conn[s3] if s not in v13]: v14 = v13 + [s4] if s1 in conn[s4]: no_of_loops[4] += 1 for s5 in [s for s in conn[s4] if s not in v14]: v15 = v14 + [s5] if s1 in conn[s5]: no_of_loops[5] += 1 for s6 in [s for s in conn[s5] if s not in v15]: v16 = v15 + [s6] if s1 in conn[s6]: no_of_loops[6] += 1 for s7 in [s for s in conn[s6] if s not in v16]: # v17 = v16 + [s7] if s1 in conn[s7]: no_of_loops[7] += 1 to_return = [] for ring in rings: to_return.append(no_of_loops[ring]) return to_return
not pbs_run.enough_jobs_running()): a = da.get_an_unrelaxed_candidate() pbs_run.relax(a) # create the population population = Population(data_connection=da, population_size=population_size, comparator=comp) # create the regression expression for estimating the energy all_trajs = da.get_all_relaxed_candidates() sampled_points = [] sampled_energies = [] for conf in all_trajs: enable_parametrization_methods(conf) no_of_conn = list(conf.get_parametrization()) if no_of_conn not in sampled_points: sampled_points.append(no_of_conn) sampled_energies.append(conf.get_potential_energy()) sampled_points = np.array(sampled_points) sampled_energies = np.array(sampled_energies) if len(sampled_points) > 0 and len(sampled_energies) >= len(sampled_points[0]): weights = np.linalg.lstsq(sampled_points, sampled_energies)[0] else: weights = None # Submit new candidates until enough are running while (not pbs_run.enough_jobs_running() and