Esempio n. 1
0
 def setUp(self):
     comp = Composition("LiFeO2")
     entry = PDEntry(comp, 53)
     self.transformed_entry = TransformedPDEntry(
         {
             DummySpecies("Xa"): 1,
             DummySpecies("Xb"): 1
         }, entry)
Esempio n. 2
0
class TransformedPDEntryTest(unittest.TestCase):
    def setUp(self):
        comp = Composition("LiFeO2")
        entry = PDEntry(comp, 53)

        terminal_compositions = ["Li2O", "FeO", "LiO8"]
        terminal_compositions = [Composition(c) for c in terminal_compositions]

        sp_mapping = OrderedDict()
        for i, comp in enumerate(terminal_compositions):
            sp_mapping[comp] = DummySpecies("X" + chr(102 + i))

        self.transformed_entry = TransformedPDEntry(entry, sp_mapping)

    def test_get_energy(self):
        self.assertEqual(self.transformed_entry.energy, 53, "Wrong energy!")
        self.assertAlmostEqual(self.transformed_entry.original_entry.energy,
                               53.0, 11)

    def test_get_energy_per_atom(self):
        self.assertAlmostEqual(self.transformed_entry.energy_per_atom,
                               53.0 / (23 / 15), 11)

    def test_get_name(self):
        self.assertEqual(self.transformed_entry.name, "LiFeO2", "Wrong name!")

    def test_get_composition(self):
        comp = self.transformed_entry.composition
        expected_comp = Composition({
            DummySpecies("Xf"): 14 / 30,
            DummySpecies("Xg"): 1.0,
            DummySpecies("Xh"): 2 / 30
        })
        self.assertEqual(comp, expected_comp, "Wrong composition!")

    def test_is_element(self):
        self.assertFalse(self.transformed_entry.is_element)

    def test_to_from_dict(self):
        d = self.transformed_entry.as_dict()
        entry = TransformedPDEntry.from_dict(d)
        self.assertEqual(entry.name, "LiFeO2", "Wrong name!")
        self.assertAlmostEqual(entry.energy_per_atom, 53.0 / (23 / 15), 11)

    def test_str(self):
        self.assertIsNotNone(str(self.transformed_entry))

    def test_normalize(self):
        norm_entry = self.transformed_entry.normalize(mode="atom")
        expected_comp = Composition({
            DummySpecies("Xf"): 7 / 23,
            DummySpecies("Xg"): 15 / 23,
            DummySpecies("Xh"): 1 / 23
        })
        self.assertEqual(norm_entry.composition, expected_comp,
                         "Wrong composition!")
Esempio n. 3
0
    def setUp(self):
        comp = Composition("LiFeO2")
        entry = PDEntry(comp, 53)

        terminal_compositions = ["Li2O", "FeO", "LiO8"]
        terminal_compositions = [Composition(c) for c in terminal_compositions]

        sp_mapping = OrderedDict()
        for i, comp in enumerate(terminal_compositions):
            sp_mapping[comp] = DummySpecies("X" + chr(102 + i))

        self.transformed_entry = TransformedPDEntry(entry, sp_mapping)
Esempio n. 4
0
class TransformedPDEntryTest(unittest.TestCase):
    def setUp(self):
        comp = Composition("LiFeO2")
        entry = PDEntry(comp, 53)
        self.transformed_entry = TransformedPDEntry(
            {
                DummySpecies("Xa"): 1,
                DummySpecies("Xb"): 1
            }, entry)

    def test_get_energy(self):
        self.assertEqual(self.transformed_entry.energy, 53, "Wrong energy!")
        self.assertEqual(self.transformed_entry.original_entry.energy, 53.0)

    def test_get_energy_per_atom(self):
        self.assertEqual(self.transformed_entry.energy_per_atom, 53.0 / 2)

    def test_get_name(self):
        self.assertEqual(self.transformed_entry.name, "LiFeO2", "Wrong name!")

    def test_get_composition(self):
        comp = self.transformed_entry.composition
        expected_comp = Composition({
            DummySpecies("Xa"): 1,
            DummySpecies("Xb"): 1
        })
        self.assertEqual(comp, expected_comp, "Wrong composition!")

    def test_is_element(self):
        self.assertFalse(self.transformed_entry.is_element)

    def test_to_from_dict(self):
        d = self.transformed_entry.as_dict()
        entry = TransformedPDEntry.from_dict(d)
        self.assertEqual(entry.name, "LiFeO2", "Wrong name!")
        self.assertEqual(entry.energy_per_atom, 53.0 / 2)

    def test_str(self):
        self.assertIsNotNone(str(self.transformed_entry))
Esempio n. 5
0
 def test_to_from_dict(self):
     d = self.transformed_entry.as_dict()
     entry = TransformedPDEntry.from_dict(d)
     self.assertEqual(entry.name, "LiFeO2", "Wrong name!")
     self.assertEqual(entry.energy_per_atom, 53.0 / 2)