def bulk(name, crystalstructure=None, primitive=False, **kwargs): """Return the standard conventional cell of a bulk structure created using ASE. Accepts all keyword arguments for the ase bulk generator. Parameters ---------- name : Atoms | str Chemical symbol or symbols as in 'MgO' or 'NaCl'. crystalstructure : str Must be one of sc, fcc, bcc, hcp, diamond, zincblende, rocksalt, cesiumchloride, fluorite or wurtzite. primitive : bool Return the primitive unit cell instead of the conventional standard cell. Returns ------- standardized_bulk : Gratoms object The conventional standard or primitive bulk structure. """ if isinstance(name, str): atoms = ase_bulk(name, crystalstructure, **kwargs) else: atoms = name standardized_bulk = utils.get_spglib_cell(atoms, primitive=primitive) return standardized_bulk
def surface(elements, size, crystal='fcc', miller=(1, 1, 1), termination=0, fixed=0, vacuum=10, **kwargs): """A helper function to return the surface associated with a given set of input parameters to the general surface generator. Parameters ---------- elements : str or object The atomic symbol to be passed to the as bulk builder function or an atoms object representing the bulk structure to use. size : list (3,) Number of time to expand the x, y, and z primitive cell. crystal : str The bulk crystal structure to pass to the ase bulk builder. miller : list (3,) or (4,) The miller index to cleave the surface structure from. If 4 values are used, assume Miller-Bravis convention. termination : int The index associated with a specific slab termination. fixed : int Number of layers to constrain. vacuum : float Angstroms of vacuum to add to the unit cell. Returns ------- slab : Gratoms object Return a slab generated from the specified bulk structure. """ if isinstance(elements, Atoms): atoms = elements else: atoms = ase_bulk(elements, crystal, cubic=True, **kwargs) gen = SlabGenerator(bulk=atoms, miller_index=miller, layers=size[-1], vacuum=vacuum, fixed=fixed, layer_type=kwargs.get('layer_type', 'trim'), attach_graph=kwargs.get('attach_graph', True), standardize_bulk=kwargs.get('standardize_bulk', True), tol=kwargs.get('tol', 1e-8)) if len(size) == 2: size = size[0] elif len(size) == 3: size = size[:2] slab = gen.get_slab(size=size, iterm=termination) return slab
return corners, corners_xy, np.concatenate([gpoints_xy, gvalues], axis=1) if __name__ == "__main__": from pprint import pprint if True: from ase.build import bulk as ase_bulk from ase.atoms import Atoms # input1 = bulk("Fe").repeat((1, 1, 1)) # atoms = Atoms(symbols=["Fe", "S"], scaled_positions=[[0.25, 0.25, 0.25], [0.75, 0.75, 0.75]], # cell=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]) atoms = ase_bulk("Fe") print(atoms.get_positions()) atom_map = {"Fe": {"radius": 1.3, "color_fill": "red"}, "S": {"radius": .5, "color_fill": "blue"}} dstruct, c_map = atoms_to_rdensity(atoms, cube_dims=(5, 5, 5), atom_map=atom_map) pprint(c_map) pprint(dstruct["elements"][0]["cell_vectors"]) print(dstruct["elements"][0]["centre"]) pprint(dstruct["elements"][0]["dcube"].tolist()) if False: from ase.build import bulk from ipyatomica.iron_sulfide_params import get_fes_bulk input2 = get_fes_bulk("mackinawite") print(input2) dstruct, c_map = atoms_to_rdensity(input2, cube_dims=(200, 200, 200))
def bulk(self, *args, **kwargs): return ase_to_pyiron(ase_bulk(*args, **kwargs))