本文整理汇总了Python中pymatgen.transformations.site_transformations.PartialRemoveSitesTransformation类的典型用法代码示例。如果您正苦于以下问题:Python PartialRemoveSitesTransformation类的具体用法?Python PartialRemoveSitesTransformation怎么用?Python PartialRemoveSitesTransformation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PartialRemoveSitesTransformation类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: apply_transformation
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)
示例2: test_apply_transformation_fast
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")
示例3: test_apply_transformation_enumerate
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)
示例4: test_apply_transformation_enumerate
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)
示例5: test_to_from_dict
def test_to_from_dict(self):
d = PartialRemoveSitesTransformation([tuple(range(4))], [0.5]).as_dict()
t = PartialRemoveSitesTransformation.from_dict(d)
s = t.apply_transformation(self.struct)
self.assertEqual(s.formula, "Li2 O4")