def __init__(self, images=None): self.covalent_radii = covalent_radii.copy() self.config = read_defaults() self.atom_scale = self.config['radii_scale'] if images is None: images = [Atoms()] self.initialize(images)
def get_element_radii(self): """Return mapping of element atomic number to atom radii.""" if self.config.element_radii == "ase": return ase_covalent_radii.copy() if self.config.element_radii == "vesta": data = load_data_file("vesta_element_data.json") return data["radius"] raise ValueError(self.config.element_radii)
def __init__(self, atoms_list, element_radii=None, radii_scale=0.89): """Initialise the atom images. Parameters ---------- atoms_list : list[ase.Atoms] element_radii : list[float] radii for each atomic number (default to ase covalent) radii_scale : float scale all atomic_radii """ if element_radii: self.covalent_radii = np.array(element_radii, dtype=float) else: self.covalent_radii = default_covalent_radii.copy() # In the base class, self.config is set, but it is only used for radii scale # self.config = get_default_settings() # self.atom_scale = self.config["radii_scale"] self.atom_scale = radii_scale self.initialize(atoms_list)
# creates: atomic_radii.png # encoding: utf-8 import numpy as np import matplotlib.pyplot as plt from ase.data.vdw import vdw_radii as vdw1 from ase.data.vdw_alvarez import vdw_radii as vdw2 from ase.data import covalent_radii, chemical_symbols plt.grid(ls=':') c1 = covalent_radii.copy() c1[c1 < 0.2001] = np.nan # Remove 'false' values which are all 0.2 plt.plot(vdw2, marker='.', label='vdw_radii [ase.data.vdw_alvarez]') plt.plot(vdw1, marker='.', label='vdw_radii [ase.data.vdw]') plt.plot(c1, marker='.', label='covalent_radii [ase.data]') nobles = [2, 10, 18, 36, 54, 86] plt.xticks(nobles, [chemical_symbols[Z] for Z in nobles]) plt.xlabel('Z') plt.ylabel(u'radius [Å]') plt.legend(loc='best') plt.savefig('atomic_radii.png')
import time from collections import defaultdict import numpy as np from scipy.optimize import differential_evolution as DE from ase import Atoms from ase.data import covalent_radii, atomic_numbers from ase.units import Bohr, Ha from gpaw import GPAW, PW, setup_paths, Mixer, ConvergenceError from gpaw.atom.generator2 import generate # , DatasetGenerationError from gpaw.atom.aeatom import AllElectronAtom from gpaw.atom.atompaw import AtomPAW from gpaw.setup import create_setup my_covalent_radii = covalent_radii.copy() for e in ['Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr']: # missing radii my_covalent_radii[atomic_numbers[e]] = 1.7 my_radii = { 1: 0.41, 2: 1.46, 3: 1.47, 4: 1.08, 5: 0.83, 6: 0.75, 7: 0.67, 8: 0.68, 9: 0.7, 10: 1.63, 11: 1.7,
def get_neighbors(atoms, points=None, cutoff_matrix=None): """Returns the neighboring atoms within a specified cutoff matrix criteria for requested points. Use of the cutoff matrix provides more fine-tuned control over the interaction parameters. Parameters: ----------- atoms : atoms object Atoms object to return. points : list (N,) or None Points to locate neighboring points of. If not provided, all atom points in the atoms-object will be used. cutoff_matrix : ndarray (96, 96) or None A matrix of interaction distances for the first 96 elements of the periodic table. These interactions are separated into individual i, j interactions. If None, defaults from ASE will be used. Returns: -------- neighbors : dict Keys of each point and an array of each neighboring atoms index. """ if cutoff_matrix is None: r = radii.copy() # TODO: Develop an SVM to parameterize this for me # Will need reliable training data for an supervised approach metals = [ [47, 1.1], # Ag [79, 1.2], # Au [29, 1.1], # Cu [77, 1.1], # Ir [46, 1.1], # Pd [78, 1.2], # Pt [45, 1.1], # Rh ] adsorbates = [[1, 1.0], [6, 1.0], [7, 1.0], [8, 1.0], [16, 1.0]] for i, f in metals: r[i] *= f for i, f in adsorbates: r[i] *= f cutoff_matrix = np.zeros((96, 96)) for i in range(96): for j in range(96): cutoff_matrix[i][j] = r[i] + r[j] cutoff_matrix[j][i] = r[i] + r[j] rcmax = cutoff_matrix.max() an = atoms.get_atomic_numbers() positions = atoms.get_positions() pbc = atoms.get_pbc() cell = atoms.get_cell() icell = np.linalg.pinv(cell) scaled = np.dot(positions, icell) scaled0 = scaled.copy() N = [] for i in range(3): if pbc[i]: scaled0[:, i] %= 1.0 v = icell[:, i] h = 1 / np.sqrt(np.dot(v, v)) n = int(2 * rcmax / h) + 1 else: n = 0 N.append(n) offsets = (scaled0 - scaled).round().astype(int) positions0 = atoms.positions + np.dot(offsets, cell) natoms = len(atoms) indices = np.arange(natoms) if points is None: points = indices cutoffs = np.zeros(natoms) neighbors = {a: np.empty(0, int) for a in points} for n1 in range(-N[0], N[0] + 1): for n2 in range(-N[1], N[1] + 1): for n3 in range(-N[2], N[2] + 1): displacement = np.dot((n1, n2, n3), cell) for a in points: for b in range(natoms): cutoffs[b] = cutoff_matrix[an[a]][an[b]] d = positions0 + displacement - positions0[a] i = indices[(d**2).sum(1) < (cutoffs)**2] if a in i: i = np.delete(i, np.where(i == a)[0]) neighbors[a] = np.concatenate((neighbors[a], i)) return neighbors
def __init__(self): self.update({'covalent_radii': covalent_radii.copy()})
def __init__(self, images=None): self.covalent_radii = covalent_radii.copy() self.config = read_defaults() self.atom_scale = self.config['radii_scale'] if images is not None: self.initialize(images)
def __init__(self): self.update({ 'covalent_radii': covalent_radii.copy(), 'radicals': radicals, })