Exemplo n.º 1
0
 def test_normalize(self):
     entry = ComputedEntry("Fe6O9", 6.9, correction=1)
     entry.normalize()
     self.assertEqual(entry.composition.formula, "Fe2 O3")
     self.assertAlmostEqual(entry.uncorrected_energy, 6.9/3)
     self.assertAlmostEqual(entry.correction, 1/3)
     self.assertAlmostEqual(entry.energy * 3, 6.9 + 1)
     entry.normalize("atom")
     self.assertEqual(entry.composition.formula, "Fe0.4 O0.6")
     self.assertAlmostEqual(entry.uncorrected_energy, 6.9/15)
     self.assertAlmostEqual(entry.correction, 1/15)
     self.assertAlmostEqual(entry.energy * 15, 6.9 + 1)
Exemplo n.º 2
0
 def test_normalize_energy_adjustments(self):
     ealist = [ManualEnergyAdjustment(5),
               ConstantEnergyAdjustment(5),
               CompositionEnergyAdjustment(1, 5, uncertainty_per_atom=0, name="Na"),
               TemperatureEnergyAdjustment(0.005, 100, 10, uncertainty_per_degK=0)
               ]
     entry = ComputedEntry("Na5Cl5", 6.9, energy_adjustments=ealist)
     assert entry.correction == 20
     entry.normalize()
     assert entry.correction == 4
     for ea in entry.energy_adjustments:
         assert ea.value == 1
Exemplo n.º 3
0
    def test_normalize_not_in_place(self):
        ealist = [
            ManualEnergyAdjustment(5),
            ConstantEnergyAdjustment(5),
            CompositionEnergyAdjustment(1, 5, uncertainty_per_atom=0, name="Na"),
            TemperatureEnergyAdjustment(0.005, 100, 10, uncertainty_per_deg=0),
        ]
        entry = ComputedEntry("Na5Cl5", 6.9, energy_adjustments=ealist)

        normed_entry = entry.normalize(inplace=False)
        entry.normalize()

        self.assertEqual(normed_entry.as_dict(), entry.as_dict())
Exemplo n.º 4
0
 def test_normalize(self):
     entry = ComputedEntry("Fe6O9", 6.9, correction=1)
     entry_formula = entry.normalize()
     self.assertEqual(entry_formula.composition.formula, "Fe2 O3")
     self.assertAlmostEqual(entry_formula.uncorrected_energy, 6.9 / 3)
     self.assertAlmostEqual(entry_formula.correction, 1 / 3)
     self.assertAlmostEqual(entry_formula.energy * 3, 6.9 + 1)
     self.assertAlmostEqual(entry_formula.energy_adjustments[0].value, 1 / 3)
     entry_atom = entry.normalize("atom")
     self.assertEqual(entry_atom.composition.formula, "Fe0.4 O0.6")
     self.assertAlmostEqual(entry_atom.uncorrected_energy, 6.9 / 15)
     self.assertAlmostEqual(entry_atom.correction, 1 / 15)
     self.assertAlmostEqual(entry_atom.energy * 15, 6.9 + 1)
     self.assertAlmostEqual(entry_atom.energy_adjustments[0].value, 1 / 15)