Source code for asap3.setup.nanocrystalline.nanocrystalline

from ase.lattice.cubic import FaceCenteredCubic
from .helpers import create_atoms
import numpy as np


[docs] def make_nanocrystal(size, centres, rotations, min_dist=2.0, unit=None, symbol=None, latticeconstant=None): """Create a nanocrystalline sample. Either the ``unit`` or the ``symbol`` parameter must be specified. Parameters ---------- size : float or sequence of float Size of the system in Angstrom, either a single number or three numbers. centres : numpy.ndarray Positions of the grains, in scaled coordinates. rotations : numpy.ndarray Rotation matrices for the grains. min_dist : float, optional If two atoms are closer than this distance, one of them is removed. The default is 2.0. unit : ase.Atoms, optional A unit cell for building the crystals. It MUST be orthorhombic. symbol : str or int, optional If ``unit`` is ``None``, an FCC crystal of this element is used. latticeconstant : float, optional If ``symbol`` is specified, this overrides the default lattice constant. Returns ------- ase.Atoms The nanocrystalline sample. """ assert type(size) == float or type(size) == list if type(size) == float: size = np.array([size, size, size]) elif type(size) == list: size = np.array(size) assert size.shape == (3,) assert len(centres) == len(rotations) centres *= size if unit is None: unit = FaceCenteredCubic(symbol=symbol, size=(1,1,1), pbc=True, latticeconstant=latticeconstant) return create_atoms(centres, rotations, unit, size, min_dist)