本文整理汇总了Python中pymatgen.analysis.reaction_calculator.Reaction.normalized_repr_and_factor方法的典型用法代码示例。如果您正苦于以下问题:Python Reaction.normalized_repr_and_factor方法的具体用法?Python Reaction.normalized_repr_and_factor怎么用?Python Reaction.normalized_repr_and_factor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.analysis.reaction_calculator.Reaction
的用法示例。
在下文中一共展示了Reaction.normalized_repr_and_factor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_init
# 需要导入模块: from pymatgen.analysis.reaction_calculator import Reaction [as 别名]
# 或者: from pymatgen.analysis.reaction_calculator.Reaction import normalized_repr_and_factor [as 别名]
def test_init(self):
reactants = [Composition("Fe"),
Composition("O2")]
products = [Composition("Fe2O3")]
rxn = Reaction(reactants, products)
self.assertEqual(str(rxn), "2 Fe + 1.5 O2 -> Fe2O3")
self.assertEqual(rxn.normalized_repr, "4 Fe + 3 O2 -> 2 Fe2O3")
d = rxn.as_dict()
rxn = Reaction.from_dict(d)
repr, factor = rxn.normalized_repr_and_factor()
self.assertEqual(repr, "4 Fe + 3 O2 -> 2 Fe2O3")
self.assertAlmostEqual(factor, 2)
reactants = [Composition("FePO4"), Composition('Mn')]
products = [Composition("FePO4"), Composition('Xe')]
rxn = Reaction(reactants, products)
self.assertEqual(str(rxn), "FePO4 -> FePO4")
products = [Composition("Ti2 O4"), Composition("O1")]
reactants = [Composition("Ti1 O2")]
rxn = Reaction(reactants, products)
self.assertEqual(str(rxn), "2 TiO2 -> 2 TiO2")
reactants = [Composition("FePO4"), Composition("Li")]
products = [Composition("LiFePO4")]
rxn = Reaction(reactants, products)
self.assertEqual(str(rxn), "FePO4 + Li -> LiFePO4")
reactants = [Composition("MgO")]
products = [Composition("MgO")]
rxn = Reaction(reactants, products)
self.assertEqual(str(rxn), "MgO -> MgO")
reactants = [Composition("Mg")]
products = [Composition("Mg")]
rxn = Reaction(reactants, products)
self.assertEqual(str(rxn), "Mg -> Mg")
reactants = [Composition("FePO4"), Composition("LiPO3")]
products = [Composition("LiFeP2O7")]
rxn = Reaction(reactants, products)
self.assertEqual(str(rxn),
"FePO4 + LiPO3 -> LiFeP2O7")
reactants = [Composition("Na"), Composition("K2O")]
products = [Composition("Na2O"), Composition("K")]
rxn = Reaction(reactants, products)
self.assertEqual(str(rxn),
"2 Na + K2O -> Na2O + 2 K")
# Test for an old bug which has a problem when excess product is
# defined.
products = [Composition("FePO4"), Composition("O")]
reactants = [Composition("FePO4")]
rxn = Reaction(reactants, products)
self.assertEqual(str(rxn), "FePO4 -> FePO4")
products = list(map(Composition, ['LiCrO2', 'La8Ti8O12', 'O2']))
reactants = [Composition('LiLa3Ti3CrO12')]
rxn = Reaction(reactants, products)
self.assertEqual(str(rxn),
"LiLa3Ti3CrO12 -> LiCrO2 + 1.5 La2Ti2O3 + 2.75 O2")