1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| from pymatgen.core.surface import Slab, SlabGenerator, generate_all_slabs, Structure, Lattice, ReconstructionGenerator, get_symmetrically_distinct_miller_indices from pymatgen.core.structure import Structure from pymatgen.analysis.adsorption import * from pymatgen.ext.matproj import MPRester from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.io.vasp.inputs import Poscar from matplotlib import pyplot as plt import os
mpr = MPRester('Bw7HdCARiXvzEWJK') path = os.getcwd()
mp_id = "mp-153"
struct = mpr.get_structure_by_material_id(mp_id) struct = SpacegroupAnalyzer(struct).get_conventional_standard_structure()
formula = struct.composition.reduced_formula print("输入的结构是:{}".format(formula))
ls = get_symmetrically_distinct_miller_indices(struct, 1, return_hkil=False)
for i in ls: slab = SlabGenerator(struct, miller_index=i, min_slab_size=25,min_vacuum_size=15.0, lll_reduce=True, center_slab=True) for n, slabs in enumerate(slab.get_slabs(bonds=None, ftol=0.1, tol=0.1, max_broken_bonds=0, symmetrize=True, repair=False)): slabs.make_supercell([[2,0,0],[0,2,0],[0,0,1]]) name = str(i).split(',')[0][1]+str(i).split(',')[1][1]+str(i).split(',')[2][1] open(formula+'_'+name +'_' + str(n+1) + '.vasp', 'w').write(str(Poscar(slabs)))
|