Exemplo n.º 1
0
def create_hkl_surface(lattice,
                       hkl,
                       layers,
                       vacuum=1.0,
                       center=False,
                       pbc=True):
    """
    Use ase.build.surface to build a surface with surface normal (hkl).

    Args:
        lattice (pyiron.atomistics.structure.atoms.Atoms/str): bulk Atoms
            instance or str, e.g. "Fe", from which to build the surface
        hkl (list): miller indices of surface to be created
        layers (int): # of atomic layers in the surface
        vacuum (float): vacuum spacing
        center (bool): shift all positions to center the surface
            in the cell

    Returns:
        pyiron.atomistics.structure.atoms.Atoms instance: Required surface
    """
    # https://gitlab.com/ase/ase/blob/master/ase/lattice/surface.py
    s.publication_add(publication_ase())

    surface = ase_surf(lattice, hkl, layers)
    z_max = np.max(surface.positions[:, 2])
    surface.cell[2, 2] = z_max + vacuum
    if center:
        surface.positions += 0.5 * surface.cell[2] - [0, 0, z_max / 2]
    surface.pbc = pbc
    return ase_to_pyiron(surface)
    def db_entry(self):
        """
        Generate the initial database entry

        Returns:
            (dict): db_dict
        """
        db_dict = super(InteractiveWrapper, self).db_entry()
        if self.structure:
            if isinstance(self.structure, PAtoms):
                parent_structure = self.structure.get_parent_basis()
            else:
                parent_structure = ase_to_pyiron(
                    self.structure).get_parent_basis()
            db_dict["ChemicalFormula"] = parent_structure.get_chemical_formula(
            )
        return db_dict
Exemplo n.º 3
0
def create_ase_bulk(
    name,
    crystalstructure=None,
    a=None,
    c=None,
    covera=None,
    u=None,
    orthorhombic=False,
    cubic=False,
):
    """
    Creating bulk systems using ASE bulk module. Crystal structure and lattice constant(s) will be guessed if not
    provided.

    name (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.
    a (float): Lattice constant.
    c (float): Lattice constant.
    c_over_a (float): c/a ratio used for hcp.  Default is ideal ratio: sqrt(8/3).
    u (float): Internal coordinate for Wurtzite structure.
    orthorhombic (bool): Construct orthorhombic unit cell instead of primitive cell which is the default.
    cubic (bool): Construct cubic unit cell if possible.

    Returns:

        pyiron.atomistics.structure.atoms.Atoms: Required bulk structure
    """
    s.publication_add(publication_ase())
    return ase_to_pyiron(
        bulk(
            name=name,
            crystalstructure=crystalstructure,
            a=a,
            c=c,
            covera=covera,
            u=u,
            orthorhombic=orthorhombic,
            cubic=cubic,
        ))
Exemplo n.º 4
0
    def poly_fit(self, fit_order=3, vol_erg_dic=None):
        self._set_fit_module(vol_erg_dic=vol_erg_dic)
        fit_dict = self.fit_module.fit_polynomial(fit_order=fit_order)
        if fit_dict is None:
            self._logger.warning("Minimum could not be found!")
        else:
            self.input["fit_type"] = fit_dict["fit_type"]
            self.input["fit_order"] = fit_dict["fit_order"]
            with self.project_hdf5.open("input") as hdf5_input:
                self.input.to_hdf(hdf5_input)
            with self.project_hdf5.open("output") as hdf5:
                hdf5["equilibrium_energy"] = fit_dict["energy_eq"]
                hdf5["equilibrium_volume"] = fit_dict["volume_eq"]
                hdf5["equilibrium_bulk_modulus"] = fit_dict["bulkmodul_eq"]
                hdf5["equilibrium_b_prime"] = fit_dict["b_prime_eq"]

            with self._hdf5.open("output") as hdf5:
                structure = self.get_structure(iteration_step=-1)
                if not isinstance(structure, Atoms):
                    structure = ase_to_pyiron(structure)
                structure.to_hdf(hdf5)

            self.fit_dict = fit_dict
        return fit_dict
Exemplo n.º 5
0
def pymatgen_to_pyiron(structure):
    return ase_to_pyiron(AseAtomsAdaptor.get_atoms(structure))
 def _final_struct_to_hdf(self):
     with self._hdf5.open("output") as hdf5:
         structure = self.get_structure(iteration_step=-1)
         if not isinstance(structure, Atoms):
             structure = ase_to_pyiron(structure)
         structure.to_hdf(hdf5)
Exemplo n.º 7
0
def create_surface(element,
                   surface_type,
                   size=(1, 1, 1),
                   vacuum=1.0,
                   center=False,
                   pbc=True,
                   **kwargs):
    """
    Generate a surface based on the ase.build.surface module.

    Args:
        element (str): Element name
        surface_type (str): The string specifying the surface type generators available through ase (fcc111,
        hcp0001 etc.)
        size (tuple): Size of the surface
        vacuum (float): Length of vacuum layer added to the surface along the z direction
        center (bool): Tells if the surface layers have to be at the center or at one end along the z-direction
        pbc (list/numpy.ndarray): List of booleans specifying the periodic boundary conditions along all three
                                  directions.
        **kwargs: Additional, arguments you would normally pass to the structure generator like 'a', 'b',
        'orthogonal' etc.

    Returns:
        pyiron.atomistics.structure.atoms.Atoms instance: Required surface

    """
    # https://gitlab.com/ase/ase/blob/master/ase/lattice/surface.py
    if pbc is None:
        pbc = True
    s.publication_add(publication_ase())
    for surface_class in [
            add_adsorbate,
            add_vacuum,
            bcc100,
            bcc110,
            bcc111,
            diamond100,
            diamond111,
            fcc100,
            fcc110,
            fcc111,
            fcc211,
            hcp0001,
            hcp10m10,
            mx2,
            hcp0001_root,
            fcc111_root,
            bcc111_root,
            root_surface,
            root_surface_analysis,
            ase_surf,
    ]:
        if surface_type == surface_class.__name__:
            surface_type = surface_class
            break
    if isinstance(surface_type, types.FunctionType):
        if center:
            surface = surface_type(symbol=element,
                                   size=size,
                                   vacuum=vacuum,
                                   **kwargs)
        else:
            surface = surface_type(symbol=element, size=size, **kwargs)
            z_max = np.max(surface.positions[:, 2])
            surface.cell[2, 2] = z_max + vacuum
        surface.pbc = pbc
        return ase_to_pyiron(surface)
    else:
        return None