本文整理汇总了Python中pymatgen.transformations.site_transformations.PartialRemoveSitesTransformation.apply_transformation方法的典型用法代码示例。如果您正苦于以下问题:Python PartialRemoveSitesTransformation.apply_transformation方法的具体用法?Python PartialRemoveSitesTransformation.apply_transformation怎么用?Python PartialRemoveSitesTransformation.apply_transformation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.transformations.site_transformations.PartialRemoveSitesTransformation
的用法示例。
在下文中一共展示了PartialRemoveSitesTransformation.apply_transformation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_apply_transformation_fast
# 需要导入模块: from pymatgen.transformations.site_transformations import PartialRemoveSitesTransformation [as 别名]
# 或者: from pymatgen.transformations.site_transformations.PartialRemoveSitesTransformation import apply_transformation [as 别名]
def test_apply_transformation_fast(self):
t = PartialRemoveSitesTransformation([tuple(range(4)), tuple(range(4, 8))], [0.5, 0.5], PartialRemoveSitesTransformation.ALGO_FAST)
s = t.apply_transformation(self.struct)
self.assertEqual(s.formula, "Li2 O2")
t = PartialRemoveSitesTransformation([tuple(range(8))], [0.5], PartialRemoveSitesTransformation.ALGO_FAST)
s = t.apply_transformation(self.struct)
self.assertEqual(s.formula, "Li2 O2")
示例2: test_apply_transformation_enumerate
# 需要导入模块: from pymatgen.transformations.site_transformations import PartialRemoveSitesTransformation [as 别名]
# 或者: from pymatgen.transformations.site_transformations.PartialRemoveSitesTransformation import apply_transformation [as 别名]
def test_apply_transformation_enumerate(self):
t = PartialRemoveSitesTransformation(
[tuple(range(4)), tuple(range(4, 8))],
[0.5, 0.5],
PartialRemoveSitesTransformation.ALGO_ENUMERATE
)
s = t.apply_transformation(self.struct)
self.assertEqual(s.formula, "Li2 O2")
s = t.apply_transformation(self.struct, 12)
self.assertEqual(len(s), 12)
示例3: test_apply_transformation_enumerate
# 需要导入模块: from pymatgen.transformations.site_transformations import PartialRemoveSitesTransformation [as 别名]
# 或者: from pymatgen.transformations.site_transformations.PartialRemoveSitesTransformation import apply_transformation [as 别名]
def test_apply_transformation_enumerate(self):
if not enumlib_present:
raise SkipTest("enumlib not present. "
"Skipping ALGO.ENUMERATE "
"PartialRemoveSitesTransformationTest...")
t = PartialRemoveSitesTransformation(
[tuple(range(4)), tuple(range(4, 8))],
[0.5, 0.5],
PartialRemoveSitesTransformation.ALGO_ENUMERATE
)
s = t.apply_transformation(self.struct)
self.assertEqual(s.formula, "Li2 O2")
s = t.apply_transformation(self.struct, 12)
self.assertEqual(len(s), 12)
示例4: apply_transformation
# 需要导入模块: from pymatgen.transformations.site_transformations import PartialRemoveSitesTransformation [as 别名]
# 或者: from pymatgen.transformations.site_transformations.PartialRemoveSitesTransformation import apply_transformation [as 别名]
def apply_transformation(self, structure, return_ranked_list=False):
"""
Apply the transformation.
Args:
structure:
input structure
return_ranked_list:
Boolean stating whether or not multiple structures are
returned. If return_ranked_list is an int, that number of
structures is returned.
Returns:
Depending on returned_ranked list, either a transformed structure
or
a list of dictionaries, where each dictionary is of the form
{"structure" = .... , "other_arguments"}
the key "transformation" is reserved for the transformation that
was actually applied to the structure.
This transformation is parsed by the alchemy classes for generating
a more specific transformation history. Any other information will
be stored in the transformation_parameters dictionary in the
transmuted structure class.
"""
sp = smart_element_or_specie(self._specie)
specie_indices = [i for i in xrange(len(structure)) if structure[i].species_and_occu == Composition({sp: 1})]
trans = PartialRemoveSitesTransformation([specie_indices], [self._frac], algo=self._algo)
return trans.apply_transformation(structure, return_ranked_list)