本文整理汇总了Python中pymatgen.core.surface.SlabGenerator类的典型用法代码示例。如果您正苦于以下问题:Python SlabGenerator类的具体用法?Python SlabGenerator怎么用?Python SlabGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SlabGenerator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: apply_transformation
def apply_transformation(self, structure):
sg = SlabGenerator(structure, self.miller_index, self.min_slab_size,
self.min_vacuum_size, self.lll_reduce,
self.center_slab, self.primitive,
self.max_normal_search)
slab = sg.get_slab(self.shift, self.tol)
return slab
开发者ID:matk86,项目名称:pymatgen,代码行数:7,代码来源:advanced_transformations.py
示例2: test_normal_search
def test_normal_search(self):
fcc = Structure.from_spacegroup("Fm-3m", Lattice.cubic(3), ["Fe"],
[[0, 0, 0]])
for miller in [(1, 0, 0), (1, 1, 0), (1, 1, 1), (2, 1, 1)]:
gen = SlabGenerator(fcc, miller, 10, 10)
gen_normal = SlabGenerator(fcc, miller, 10, 10,
max_normal_search=max(miller))
slab = gen_normal.get_slab()
self.assertAlmostEqual(slab.lattice.alpha, 90)
self.assertAlmostEqual(slab.lattice.beta, 90)
self.assertGreaterEqual(len(gen_normal.oriented_unit_cell),
len(gen.oriented_unit_cell))
graphite = self.get_structure("Graphite")
for miller in [(1, 0, 0), (1, 1, 0), (0, 0, 1), (2, 1, 1)]:
gen = SlabGenerator(graphite, miller, 10, 10)
gen_normal = SlabGenerator(graphite, miller, 10, 10,
max_normal_search=max(miller))
self.assertGreaterEqual(len(gen_normal.oriented_unit_cell),
len(gen.oriented_unit_cell))
sc = Structure(Lattice.hexagonal(3.32, 5.15), ["Sc", "Sc"],
[[1/3, 2/3, 0.25], [2/3, 1/3, 0.75]])
gen = SlabGenerator(sc, (1, 1, 1), 10, 10, max_normal_search=1)
self.assertAlmostEqual(gen.oriented_unit_cell.lattice.angles[1], 90)
开发者ID:tallakahath,项目名称:pymatgen,代码行数:25,代码来源:test_surface.py
示例3: generate_slabs
def generate_slabs(self, film_millers, substrate_millers):
"""
Generates the film/substrate slab combinations for a set of given
miller indicies
Args:
film_millers(array): all miller indices to generate slabs for
film
substrate_millers(array): all miller indicies to generate slabs
for substrate
"""
for f in film_millers:
film_slab = SlabGenerator(self.film, f, 20, 15,
primitive=False).get_slab()
film_vectors = reduce_vectors(film_slab.lattice_vectors()[0],
film_slab.lattice_vectors()[1])
film_area = vec_area(*film_vectors)
for s in substrate_millers:
substrate_slab = SlabGenerator(self.substrate, s, 20, 15,
primitive=False).get_slab()
substrate_vectors = reduce_vectors(
substrate_slab.lattice_vectors()[0],
substrate_slab.lattice_vectors()[1])
substrate_area = vec_area(*substrate_vectors)
yield [film_area, substrate_area, film_vectors,
substrate_vectors, f, s]
开发者ID:jwyoon89,项目名称:pymatgen,代码行数:29,代码来源:substrate_analyzer.py
示例4: test_surface_sites_and_symmetry
def test_surface_sites_and_symmetry(self):
# test if surfaces are equivalent by using
# Laue symmetry and surface site equivalence
for bool in [True, False]:
# We will also set the slab to be centered and
# off centered in order to test the center of mass
slabgen = SlabGenerator(self.agfcc, (3, 1, 0), 10, 10,
center_slab=bool)
slab = slabgen.get_slabs()[0]
surf_sites_dict = slab.get_surface_sites()
self.assertEqual(len(surf_sites_dict["top"]),
len(surf_sites_dict["bottom"]))
total_surf_sites = sum([len(surf_sites_dict[key])
for key in surf_sites_dict.keys()])
self.assertTrue(slab.is_symmetric())
self.assertEqual(total_surf_sites / 2, 4)
self.assertTrue(slab.have_equivalent_surfaces())
# Test if the ratio of surface sites per area is
# constant, ie are the surface energies the same
r1 = total_surf_sites / (2 * slab.surface_area)
slabgen = SlabGenerator(self.agfcc, (3, 1, 0), 10, 10,
primitive=False)
slab = slabgen.get_slabs()[0]
surf_sites_dict = slab.get_surface_sites()
total_surf_sites = sum([len(surf_sites_dict[key])
for key in surf_sites_dict.keys()])
r2 = total_surf_sites / (2 * slab.surface_area)
self.assertArrayEqual(r1, r2)
开发者ID:gmatteo,项目名称:pymatgen,代码行数:30,代码来源:test_surface.py
示例5: test_dipole_and_is_polar
def test_dipole_and_is_polar(self):
self.assertArrayAlmostEqual(self.zno55.dipole, [0, 0, 0])
self.assertFalse(self.zno55.is_polar())
cscl = self.get_structure("CsCl")
cscl.add_oxidation_state_by_element({"Cs": 1, "Cl": -1})
slab = SlabGenerator(cscl, [1, 0, 0], 5, 5,
lll_reduce=False, center_slab=False).get_slab()
self.assertArrayAlmostEqual(slab.dipole, [-4.209, 0, 0])
self.assertTrue(slab.is_polar())
开发者ID:tallakahath,项目名称:pymatgen,代码行数:9,代码来源:test_surface.py
示例6: test_get_orthogonal_c_slab
def test_get_orthogonal_c_slab(self):
TeI = Structure.from_file(get_path("icsd_TeI.cif"),
primitive=False)
trclnc_TeI = SlabGenerator(TeI, (0, 0, 1), 10, 10)
TeI_slabs = trclnc_TeI.get_slabs()
slab = TeI_slabs[0]
norm_slab = slab.get_orthogonal_c_slab()
self.assertAlmostEqual(norm_slab.lattice.angles[0], 90)
self.assertAlmostEqual(norm_slab.lattice.angles[1], 90)
开发者ID:tallakahath,项目名称:pymatgen,代码行数:9,代码来源:test_surface.py
示例7: __init__
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,
x_shift=0, y_shift=0, rot=[0,0,0],
center_slab=True):
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,
center_slab=center_slab)
else:
strt = SlabGenerator(strt, hkl, min_thick,
min_vac + vac_extension,
center_slab=center_slab,
primitive = primitive).get_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
开发者ID:mbkumar,项目名称:MPInterfaces,代码行数:57,代码来源:interface.py
示例8: get_dimensionality
def get_dimensionality(structure, max_hkl=2, el_radius_updates=None,
min_slab_size=5, min_vacuum_size=5,
standardize=True, bonds=None):
"""
This method returns whether a structure is 3D, 2D (layered), or 1D (linear
chains or molecules) according to the algorithm published in Gorai, P.,
Toberer, E. & Stevanovic, V. Computational Identification of Promising
Thermoelectric Materials Among Known Quasi-2D Binary Compounds. J. Mater.
Chem. A 2, 4136 (2016).
Note that a 1D structure detection might indicate problems in the bonding
algorithm, particularly for ionic crystals (e.g., NaCl)
Users can change the behavior of bonds detection by passing either
el_radius_updates to update atomic radii for auto-detection of max bond
distances, or bonds to explicitly specify max bond distances for atom pairs.
Note that if you pass both, el_radius_updates are ignored.
Args:
structure: (Structure) structure to analyze dimensionality for
max_hkl: (int) max index of planes to look for layers
el_radius_updates: (dict) symbol->float to update atomic radii
min_slab_size: (float) internal surface construction parameter
min_vacuum_size: (float) internal surface construction parameter
standardize (bool): whether to standardize the structure before
analysis. Set to False only if you already have the structure in a
convention where layers / chains will be along low <hkl> indexes.
bonds ({(specie1, specie2): max_bond_dist}: bonds are
specified as a dict of tuples: float of specie1, specie2
and the max bonding distance. For example, PO4 groups may be
defined as {("P", "O"): 3}.
Returns: (int) the dimensionality of the structure - 1 (molecules/chains),
2 (layered), or 3 (3D)
"""
if standardize:
structure = SpacegroupAnalyzer(structure). \
get_conventional_standard_structure()
if not bonds:
bonds = get_max_bond_lengths(structure, el_radius_updates)
num_surfaces = 0
for h in range(max_hkl):
for k in range(max_hkl):
for l in range(max_hkl):
if max([h, k, l]) > 0 and num_surfaces < 2:
sg = SlabGenerator(structure, (h, k, l),
min_slab_size=min_slab_size,
min_vacuum_size=min_vacuum_size)
slabs = sg.get_slabs(bonds)
for _ in slabs:
num_surfaces += 1
return 3 - min(num_surfaces, 2)
开发者ID:albalu,项目名称:pymatgen,代码行数:56,代码来源:structure_analyzer.py
示例9: test_normal_search
def test_normal_search(self):
fcc = Structure.from_spacegroup("Fm-3m", Lattice.cubic(3), ["Fe"],
[[0, 0, 0]])
for miller in [(1, 0, 0), (1, 1, 0), (1, 1, 1), (2, 1, 1)]:
gen = SlabGenerator(fcc, miller, 10, 10)
gen_normal = SlabGenerator(fcc, miller, 10, 10,
max_normal_search=max(miller))
slab = gen_normal.get_slab()
self.assertAlmostEqual(slab.lattice.alpha, 90)
self.assertAlmostEqual(slab.lattice.beta, 90)
self.assertGreaterEqual(len(gen_normal.oriented_unit_cell),
len(gen.oriented_unit_cell))
开发者ID:anhhv,项目名称:pymatgen,代码行数:12,代码来源:test_surface.py
示例10: test_triclinic_TeI
def test_triclinic_TeI(self):
# Test case for a triclinic structure of TeI. Only these three
# Miller indices are used because it is easier to identify which
# atoms should be in a surface together. The closeness of the sites
# in other Miller indices can cause some ambiguity when choosing a
# higher tolerance.
numb_slabs = {(0, 0, 1): 5, (0, 1, 0): 3, (1, 0, 0): 7}
TeI = Structure.from_file(get_path("icsd_TeI.cif"),
primitive=False)
for k, v in numb_slabs.items():
trclnc_TeI = SlabGenerator(TeI, k, 10, 10)
TeI_slabs = trclnc_TeI.get_slabs()
self.assertEqual(v, len(TeI_slabs))
开发者ID:tallakahath,项目名称:pymatgen,代码行数:13,代码来源:test_surface.py
示例11: setUp
def setUp(self):
if "PMG_VASP_PSP_DIR" not in os.environ:
os.environ["PMG_VASP_PSP_DIR"] = test_dir
s = PymatgenTest.get_structure("Li2O")
gen = SlabGenerator(s, (1, 0, 0), 10, 10)
self.slab = gen.get_slab()
self.bulk = self.slab.oriented_unit_cell
vis_bulk = MVLSlabSet(self.bulk, bulk=True)
vis = MVLSlabSet(self.slab)
self.d_bulk = vis_bulk.all_input
self.d_slab = vis.all_input
开发者ID:xhqu1981,项目名称:pymatgen,代码行数:14,代码来源:test_sets.py
示例12: setUp
def setUp(self):
if "VASP_PSP_DIR" not in os.environ:
os.environ["VASP_PSP_DIR"] = test_dir
s = PymatgenTest.get_structure("Li2O")
gen = SlabGenerator(s, (1, 0, 0), 10, 10)
vis_bulk = MVLSlabSet(bulk=True)
vis = MVLSlabSet()
vis_bulk_gpu = MVLSlabSet(bulk=True, gpu=True)
self.slab = gen.get_slab()
self.bulk = self.slab.oriented_unit_cell
self.d_bulk = vis_bulk.get_all_vasp_input(self.bulk)
self.d_slab = vis.get_all_vasp_input(self.slab)
self.d_bulk_gpu = vis_bulk_gpu.get_all_vasp_input(self.bulk)
开发者ID:quanshengwu,项目名称:pymatgen,代码行数:15,代码来源:test_sets.py
示例13: setUp
def setUp(self):
s = self.get_structure("Li2O")
gen = SlabGenerator(s, (1, 0, 0), 10, 10)
self.slab = gen.get_slab()
self.bulk = self.slab.oriented_unit_cell
vis_bulk = MVLSlabSet(self.bulk, bulk=True)
vis = MVLSlabSet(self.slab)
vis_dipole = MVLSlabSet(self.slab, auto_dipole=True)
self.d_bulk = vis_bulk.get_vasp_input()
self.d_slab = vis.get_vasp_input()
self.d_dipole = vis_dipole.get_vasp_input()
self.vis = vis
warnings.simplefilter("ignore")
开发者ID:adengz,项目名称:pymatgen,代码行数:15,代码来源:test_sets.py
示例14: setUp
def setUp(self):
if "PMG_VASP_PSP_DIR" not in os.environ:
os.environ["PMG_VASP_PSP_DIR"] = test_dir
s = PymatgenTest.get_structure("Li2O")
gen = SlabGenerator(s, (1, 0, 0), 10, 10)
self.slab = gen.get_slab()
self.bulk = self.slab.oriented_unit_cell
vis_bulk = MVLSlabSet(self.bulk, bulk=True)
vis = MVLSlabSet(self.slab)
vis_dipole = MVLSlabSet(self.slab, auto_dipole=True)
self.d_bulk = vis_bulk.all_input
self.d_slab = vis.all_input
self.d_dipole = vis_dipole.all_input
self.vis = vis
warnings.simplefilter("ignore")
开发者ID:albalu,项目名称:pymatgen,代码行数:17,代码来源:test_sets.py
示例15: test_get_orthogonal_c_slab_site_props
def test_get_orthogonal_c_slab_site_props(self):
TeI = Structure.from_file(get_path("icsd_TeI.cif"),
primitive=False)
trclnc_TeI = SlabGenerator(TeI, (0, 0, 1), 10, 10)
TeI_slabs = trclnc_TeI.get_slabs()
slab = TeI_slabs[0]
# Add site property to slab
sd_list = [[True, True, True] for site in slab.sites]
new_sp = slab.site_properties
new_sp['selective_dynamics'] = sd_list
slab_with_site_props = slab.copy(site_properties=new_sp)
# Get orthogonal slab
norm_slab = slab_with_site_props.get_orthogonal_c_slab()
# Check if site properties is consistent (or kept)
self.assertEqual(slab_with_site_props.site_properties, norm_slab.site_properties)
开发者ID:blondegeek,项目名称:pymatgen,代码行数:17,代码来源:test_surface.py
示例16: test_get_slab
def test_get_slab(self):
s = self.get_structure("LiFePO4")
gen = SlabGenerator(s, [0, 0, 1], 10, 10)
s = gen.get_slab(0.25)
self.assertAlmostEqual(s.lattice.abc[2], 20.820740000000001)
fcc = Structure.from_spacegroup("Fm-3m", Lattice.cubic(3), ["Fe"],
[[0, 0, 0]])
gen = SlabGenerator(fcc, [1, 1, 1], 10, 10)
slab = gen.get_slab()
gen = SlabGenerator(fcc, [1, 1, 1], 10, 10, primitive=False)
slab_non_prim = gen.get_slab()
self.assertEqual(len(slab), 6)
self.assertEqual(len(slab_non_prim), len(slab) * 4)
#Some randomized testing of cell vectors
for i in range(1, 231):
i = random.randint(1, 230)
sg = SpaceGroup.from_int_number(i)
if sg.crystal_system == "hexagonal" or (sg.crystal_system == \
"trigonal" and sg.symbol.endswith("H")):
latt = Lattice.hexagonal(5, 10)
else:
#Cubic lattice is compatible with all other space groups.
latt = Lattice.cubic(5)
s = Structure.from_spacegroup(i, latt, ["H"], [[0, 0, 0]])
miller = (0, 0, 0)
while miller == (0, 0, 0):
miller = (random.randint(0, 6), random.randint(0, 6),
random.randint(0, 6))
gen = SlabGenerator(s, miller, 10, 10)
a, b, c = gen.oriented_unit_cell.lattice.matrix
self.assertAlmostEqual(np.dot(a, gen._normal), 0)
self.assertAlmostEqual(np.dot(b, gen._normal), 0)
开发者ID:tallakahath,项目名称:pymatgen,代码行数:34,代码来源:test_surface.py
示例17: test_get_tasker2_slabs
def test_get_tasker2_slabs(self):
# The uneven distribution of ions on the (111) facets of Halite
# type slabs are typical examples of Tasker 3 structures. We
# will test this algo to generate a Tasker 2 structure instead
slabgen = SlabGenerator(self.MgO, (1, 1, 1), 10, 10,
max_normal_search=1)
# We generate the Tasker 3 structure first
slab = slabgen.get_slabs()[0]
self.assertFalse(slab.is_symmetric())
self.assertTrue(slab.is_polar())
# Now to generate the Tasker 2 structure, we must
# ensure there are enough ions on top to move around
slab.make_supercell([2, 1, 1])
slabs = slab.get_tasker2_slabs()
# Check if our Tasker 2 slab is nonpolar and symmetric
for slab in slabs:
self.assertTrue(slab.is_symmetric())
self.assertFalse(slab.is_polar())
开发者ID:gmatteo,项目名称:pymatgen,代码行数:18,代码来源:test_surface.py
示例18: test_get_slab_regions
def test_get_slab_regions(self):
# If a slab layer in the slab cell is not completely inside
# the cell (noncontiguous), check that get_slab_regions will
# be able to identify where the slab layers are located
s = self.get_structure("LiFePO4")
slabgen = SlabGenerator(s, (0, 0, 1), 15, 15)
slab = slabgen.get_slabs()[0]
slab.translate_sites([i for i, site in enumerate(slab)], [0, 0, -0.25])
bottom_c, top_c = [], []
for site in slab:
if site.frac_coords[2] < 0.5:
bottom_c.append(site.frac_coords[2])
else:
top_c.append(site.frac_coords[2])
ranges = get_slab_regions(slab)
self.assertEqual(tuple(ranges[0]), (0, max(bottom_c)))
self.assertEqual(tuple(ranges[1]), (min(top_c), 1))
开发者ID:gmatteo,项目名称:pymatgen,代码行数:19,代码来源:test_surface.py
示例19: test_nonstoichiometric_symmetrized_slab
def test_nonstoichiometric_symmetrized_slab(self):
# For the (111) halite slab, sometimes a nonstoichiometric
# system is preferred over the stoichiometric Tasker 2.
slabgen = SlabGenerator(self.MgO, (1, 1, 1), 10, 10,
max_normal_search=1)
slabs = slabgen.get_slabs(symmetrize=True)
# We should end up with two terminations, one with
# an Mg rich surface and another O rich surface
self.assertEqual(len(slabs), 2)
for slab in slabs:
self.assertTrue(slab.is_symmetric())
# For a low symmetry primitive_elemental system such as
# R-3m, there should be some nonsymmetric slabs
# without using nonstoichiometric_symmetrized_slab
slabs = generate_all_slabs(self.Dy, 1, 30, 30,
center_slab=True, symmetrize=True)
for s in slabs:
self.assertTrue(s.is_symmetric())
self.assertGreater(len(s), len(self.Dy))
开发者ID:gmatteo,项目名称:pymatgen,代码行数:21,代码来源:test_surface.py
示例20: test_apply_transformation
def test_apply_transformation(self):
s = self.get_structure("LiFePO4")
trans = SlabTransformation([0, 0, 1], 10, 10, shift = 0.25)
gen = SlabGenerator(s, [0, 0, 1], 10, 10)
slab_from_gen = gen.get_slab(0.25)
slab_from_trans = trans.apply_transformation(s)
self.assertArrayAlmostEqual(slab_from_gen.lattice.matrix,
slab_from_trans.lattice.matrix)
self.assertArrayAlmostEqual(slab_from_gen.cart_coords,
slab_from_trans.cart_coords)
fcc = Structure.from_spacegroup("Fm-3m", Lattice.cubic(3), ["Fe"],
[[0, 0, 0]])
trans = SlabTransformation([1, 1, 1], 10, 10)
slab_from_trans = trans.apply_transformation(fcc)
gen = SlabGenerator(fcc, [1, 1, 1], 10, 10)
slab_from_gen = gen.get_slab()
self.assertArrayAlmostEqual(slab_from_gen.lattice.matrix,
slab_from_trans.lattice.matrix)
self.assertArrayAlmostEqual(slab_from_gen.cart_coords,
slab_from_trans.cart_coords)
开发者ID:czhengsci,项目名称:pymatgen,代码行数:21,代码来源:test_advanced_transformations.py
注:本文中的pymatgen.core.surface.SlabGenerator类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论