本文整理匯總了Python中pymatgen.transformations.advanced_transformations.EnumerateStructureTransformation.apply_transformation方法的典型用法代碼示例。如果您正苦於以下問題:Python EnumerateStructureTransformation.apply_transformation方法的具體用法?Python EnumerateStructureTransformation.apply_transformation怎麽用?Python EnumerateStructureTransformation.apply_transformation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pymatgen.transformations.advanced_transformations.EnumerateStructureTransformation
的用法示例。
在下文中一共展示了EnumerateStructureTransformation.apply_transformation方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_apply_transformation
# 需要導入模塊: from pymatgen.transformations.advanced_transformations import EnumerateStructureTransformation [as 別名]
# 或者: from pymatgen.transformations.advanced_transformations.EnumerateStructureTransformation import apply_transformation [as 別名]
def test_apply_transformation(self):
enum_trans = EnumerateStructureTransformation(refine_structure=True)
p = Poscar.from_file(os.path.join(test_dir, 'POSCAR.LiFePO4'),
check_for_POTCAR=False)
struct = p.structure
expected_ans = [1, 3, 1]
for i, frac in enumerate([0.25, 0.5, 0.75]):
trans = SubstitutionTransformation({'Fe': {'Fe': frac}})
s = trans.apply_transformation(struct)
oxitrans = OxidationStateDecorationTransformation({'Li': 1,
'Fe': 2,
'P': 5,
'O': -2})
s = oxitrans.apply_transformation(s)
alls = enum_trans.apply_transformation(s, 100)
self.assertEquals(len(alls), expected_ans[i])
self.assertIsInstance(trans.apply_transformation(s), Structure)
for s in alls:
self.assertIn("energy", s)
#make sure it works for non-oxidation state decorated structure
trans = SubstitutionTransformation({'Fe': {'Fe': 0.5}})
s = trans.apply_transformation(struct)
alls = enum_trans.apply_transformation(s, 100)
self.assertEquals(len(alls), 3)
self.assertIsInstance(trans.apply_transformation(s), Structure)
for s in alls:
self.assertNotIn("energy", s)
示例2: test_max_disordered_sites
# 需要導入模塊: from pymatgen.transformations.advanced_transformations import EnumerateStructureTransformation [as 別名]
# 或者: from pymatgen.transformations.advanced_transformations.EnumerateStructureTransformation import apply_transformation [as 別名]
def test_max_disordered_sites(self):
l = Lattice.cubic(4)
s_orig = Structure(l, [{"Li": 0.2, "Na": 0.2, "K": 0.6}, {"O": 1}],
[[0, 0, 0], [0.5, 0.5, 0.5]])
est = EnumerateStructureTransformation(max_cell_size=None,
max_disordered_sites=5)
s = est.apply_transformation(s_orig)
self.assertEqual(len(s), 8)
示例3: test_max_disordered_sites
# 需要導入模塊: from pymatgen.transformations.advanced_transformations import EnumerateStructureTransformation [as 別名]
# 或者: from pymatgen.transformations.advanced_transformations.EnumerateStructureTransformation import apply_transformation [as 別名]
def test_max_disordered_sites(self):
l = Lattice.cubic(4)
s_orig = Structure(l, [{"Li": 0.2, "Na": 0.2, "K": 0.6}, {"O": 1}],
[[0, 0, 0], [0.5, 0.5, 0.5]])
est = EnumerateStructureTransformation(max_cell_size=None,
max_disordered_sites=5)
dd = est.apply_transformation(s_orig, return_ranked_list=100)
self.assertEqual(len(dd), 9)
for d in dd:
self.assertEqual(len(d["structure"]), 10)
示例4: enumerate_ordering
# 需要導入模塊: from pymatgen.transformations.advanced_transformations import EnumerateStructureTransformation [as 別名]
# 或者: from pymatgen.transformations.advanced_transformations.EnumerateStructureTransformation import apply_transformation [as 別名]
def enumerate_ordering(self, structure):
# Generate the disordered structure first.
s = Structure.from_sites(structure.sites)
for indices, fraction in zip(self._indices, self._fractions):
for ind in indices:
new_sp = {sp: occu * fraction for sp, occu in structure[ind].species_and_occu.items()}
s[ind] = new_sp
# Perform enumeration
from pymatgen.transformations.advanced_transformations import EnumerateStructureTransformation
trans = EnumerateStructureTransformation()
return trans.apply_transformation(s, 10000)
示例5: enumerate_ordering
# 需要導入模塊: from pymatgen.transformations.advanced_transformations import EnumerateStructureTransformation [as 別名]
# 或者: from pymatgen.transformations.advanced_transformations.EnumerateStructureTransformation import apply_transformation [as 別名]
def enumerate_ordering(self, structure):
# Generate the disordered structure first.
editor = StructureEditor(structure)
for indices, fraction in zip(self._indices, self._fractions):
for ind in indices:
new_sp = {sp: occu * fraction
for sp, occu
in structure[ind].species_and_occu.items()}
editor.replace_site(ind, new_sp)
mod_s = editor.modified_structure
# Perform enumeration
from pymatgen.transformations.advanced_transformations import \
EnumerateStructureTransformation
trans = EnumerateStructureTransformation()
return trans.apply_transformation(mod_s, 10000)