Beispiel #1
0
def pmg_surfer(mpid='', vacuum=15, mat=None, max_index=1, min_slab_size=15):
    if mat == None:
        with MPRester() as mp:
            mat = mp.get_structure_by_material_id(mpid)
        if mpid == '':
            print('Provide structure')

    sg_mat = SpacegroupAnalyzer(mat)
    mat_cvn = sg_mat.get_conventional_standard_structure()
    mat_cvn.sort()
    indices = get_symmetrically_distinct_miller_indices(mat_cvn, max_index)
    #ase_atoms = AseAtomsAdaptor().get_atoms(mat_cvn)

    structures = []
    pos = Poscar(mat_cvn)
    try:
        pos.comment = str('sbulk') + str('@') + str('vac') + str(vacuum) + str(
            '@') + str('size') + str(min_slab_size)
    except:
        pass
    structures.append(pos)
    mat_cvn.to(fmt='poscar',
               filename=str('POSCAR-') + str('cvn') + str('.vasp'))
    for i in indices:
        slab = SlabGenerator(initial_structure=mat_cvn,
                             miller_index=i,
                             min_slab_size=min_slab_size,
                             min_vacuum_size=vacuum,
                             lll_reduce=False,
                             center_slab=True,
                             primitive=False).get_slab()
        normal_slab = slab.get_orthogonal_c_slab()
        slab_pymatgen = Poscar(normal_slab).structure
        #ase_slab.center(vacuum=vacuum, axis=2)
        #slab_pymatgen = AseAtomsAdaptor().get_structure(ase_slab)
        xy_size = min_slab_size
        dim1 = int((float(xy_size) /
                    float(max(abs(slab_pymatgen.lattice.matrix[0]))))) + 1
        dim2 = int(
            float(xy_size) /
            float(max(abs(slab_pymatgen.lattice.matrix[1])))) + 1
        slab_pymatgen.make_supercell([dim1, dim2, 1])
        slab_pymatgen.sort()
        surf_name = '_'.join(map(str, i))
        pos = Poscar(slab_pymatgen)
        try:
            pos.comment = str("Surf-") + str(surf_name) + str('@') + str(
                'vac') + str(vacuum) + str('@') + str('size') + str(
                    min_slab_size)
        except:
            pass
        pos.write_file(filename=str('POSCAR-') + str("Surf-") +
                       str(surf_name) + str('.vasp'))
        structures.append(pos)

    return structures
Beispiel #2
0
 def __init__(self,
              strt,
              hkl=[1, 1, 1],
              min_thick=10,
              min_vac=10,
              supercell=[1, 1, 1],
              name=None,
              adsorb_on_species=None,
              adatom_on_lig=None,
              ligand=None,
              displacement=1.0,
              surface_coverage=None,
              scell_nmax=10,
              coverage_tol=0.25,
              solvent=None,
              start_from_slab=False,
              validate_proximity=False,
              to_unit_cell=False,
              coords_are_cartesian=False,
              primitive=True,
              from_ase=False,
              lll_reduce=False,
              center_slab=True,
              max_normal_search=None,
              force_normalize=False,
              x_shift=0,
              y_shift=0,
              rot=[0, 0, 0]):
     self.from_ase = from_ase
     vac_extension = 0
     if ligand is not None:
         vac_extension = ligand.max_dist
     if isinstance(strt, Structure) and not isinstance(strt, Slab):
         self.min_vac = min_vac + vac_extension
         if self.from_ase:
             strt = get_ase_slab(strt,
                                 hkl=hkl,
                                 min_thick=min_thick,
                                 min_vac=min_vac + vac_extension)
         else:
             slab = SlabGenerator(strt,
                                  hkl,
                                  min_thick,
                                  min_vac + vac_extension,
                                  center_slab=center_slab,
                                  lll_reduce=lll_reduce,
                                  max_normal_search=max_normal_search,
                                  primitive=primitive).get_slab()
             if force_normalize:
                 strt = slab.get_orthogonal_c_slab()
             else:
                 strt = slab
         strt.make_supercell(supercell)
     else:
         self.min_vac = min_vac
     Slab.__init__(self,
                   strt.lattice,
                   strt.species_and_occu,
                   strt.frac_coords,
                   miller_index=strt.miller_index,
                   oriented_unit_cell=strt.oriented_unit_cell,
                   shift=strt.shift,
                   scale_factor=strt.scale_factor,
                   validate_proximity=validate_proximity,
                   to_unit_cell=to_unit_cell,
                   coords_are_cartesian=coords_are_cartesian,
                   site_properties=strt.site_properties,
                   energy=strt.energy)
     self.strt = strt
     self.name = name
     self.hkl = hkl
     self.min_thick = min_thick
     self.supercell = supercell
     self.ligand = ligand
     self.slab = strt
     self.displacement = displacement
     self.solvent = solvent
     self.surface_coverage = surface_coverage
     self.adsorb_on_species = adsorb_on_species
     self.adatom_on_lig = adatom_on_lig
     self.scell_nmax = scell_nmax
     self.coverage_tol = coverage_tol
     self.x_shift = x_shift
     self.y_shift = y_shift
     self.rot = rot
Beispiel #3
0
 def __init__(self, strt, hkl=[1, 1, 1], min_thick=10, min_vac=10,
              supercell=[1, 1, 1], name=None, adsorb_on_species=None,
              adatom_on_lig=None, ligand=None, displacement=1.0,
              surface_coverage=None, scell_nmax=10,
              coverage_tol=0.25, solvent=None,
              start_from_slab=False, validate_proximity=False,
              to_unit_cell=False, coords_are_cartesian=False,
              primitive=True, from_ase=False,
              lll_reduce=False, center_slab=True,
              max_normal_search=None, force_normalize=False,
              x_shift=0, y_shift=0, rot=[0, 0, 0]):
     self.from_ase = from_ase
     vac_extension = 0
     if ligand is not None:
         vac_extension = ligand.max_dist
     if isinstance(strt, Structure) and not isinstance(strt, Slab):
         self.min_vac = min_vac + vac_extension
         if self.from_ase:
             strt = get_ase_slab(strt,
                                 hkl=hkl,
                                 min_thick=min_thick,
                                 min_vac=min_vac + vac_extension)
         else:
             slab = SlabGenerator(strt, hkl, min_thick,
                                  min_vac + vac_extension,
                                  center_slab=center_slab,
                                  lll_reduce=lll_reduce,
                                  max_normal_search=max_normal_search,
                                  primitive=primitive).get_slab()
             if force_normalize:
                 strt = slab.get_orthogonal_c_slab()
             else:
                 strt = slab
         strt.make_supercell(supercell)
     else:
         self.min_vac = min_vac
     Slab.__init__(self, strt.lattice, strt.species_and_occu,
                   strt.frac_coords,
                   miller_index=strt.miller_index,
                   oriented_unit_cell=strt.oriented_unit_cell,
                   shift=strt.shift, scale_factor=strt.scale_factor,
                   validate_proximity=validate_proximity,
                   to_unit_cell=to_unit_cell,
                   coords_are_cartesian=coords_are_cartesian,
                   site_properties=strt.site_properties,
                   energy=strt.energy)
     self.strt = strt
     self.name = name
     self.hkl = hkl
     self.min_thick = min_thick
     self.supercell = supercell
     self.ligand = ligand
     self.slab = strt
     self.displacement = displacement
     self.solvent = solvent
     self.surface_coverage = surface_coverage
     self.adsorb_on_species = adsorb_on_species
     self.adatom_on_lig = adatom_on_lig
     self.scell_nmax = scell_nmax
     self.coverage_tol = coverage_tol
     self.x_shift = x_shift
     self.y_shift = y_shift
     self.rot = rot
Beispiel #4
0
def pmg_surfer(vacuum=15,
               mat=None,
               max_index=1,
               min_slab_size=15,
               write_file=True):
    """
    Pymatgen surface builder for a Poscar

    Args:
        vacuum: vacuum region
        mat: Structure object
        max_index: maximum miller index
        min_slab_size: minimum slab size

    Returns:
           structures: list of surface Structure objects
    """

    if mat == None:
        print("Provide structure")

    sg_mat = SpacegroupAnalyzer(mat)
    mat_cvn = sg_mat.get_conventional_standard_structure()
    mat_cvn.sort()
    indices = get_symmetrically_distinct_miller_indices(mat_cvn, max_index)

    structures = []
    pos = Poscar(mat_cvn)
    try:
        pos.comment = (str("sbulk") + str("@") + str("vac") + str(vacuum) +
                       str("@") + str("size") + str(min_slab_size))
    except:
        pass
    structures.append(pos)
    if write_file == True:
        mat_cvn.to(fmt="poscar",
                   filename=str("POSCAR-") + str("cvn") + str(".vasp"))
    for i in indices:
        slab = SlabGenerator(
            initial_structure=mat_cvn,
            miller_index=i,
            min_slab_size=min_slab_size,
            min_vacuum_size=vacuum,
            lll_reduce=False,
            center_slab=True,
            primitive=False,
        ).get_slab()
        normal_slab = slab.get_orthogonal_c_slab()
        slab_pymatgen = Poscar(normal_slab).structure
        xy_size = min_slab_size
        dim1 = (int((float(xy_size) /
                     float(max(abs(slab_pymatgen.lattice.matrix[0]))))) + 1)
        dim2 = (int(
            float(xy_size) / float(max(abs(slab_pymatgen.lattice.matrix[1]))))
                + 1)
        slab_pymatgen.make_supercell([dim1, dim2, 1])
        slab_pymatgen.sort()
        surf_name = "_".join(map(str, i))
        pos = Poscar(slab_pymatgen)
        try:
            pos.comment = (str("Surf-") + str(surf_name) + str("@") +
                           str("vac") + str(vacuum) + str("@") + str("size") +
                           str(min_slab_size))
        except:
            pass
        if write_file == True:
            pos.write_file(filename=str("POSCAR-") + str("Surf-") +
                           str(surf_name) + str(".vasp"))
        structures.append(pos)

    return structures