Exemple #1
0
 def test_atoms_section_equal(self):
     atoms_section = Atoms(atom1())
     new_atoms_section = atoms_section
     self.assertIsInstance(new_atoms_section, Atoms)
     self.assertEqual(new_atoms_section.get_number_of_atoms(),
                      atoms_section.get_number_of_atoms())
     self.assertEqual(new_atoms_section.atoms[0].symbol,
                      atoms_section.atoms[0].symbol)
Exemple #2
0
    def test_atoms_getitem(self):
        atoms = Atoms([atom1(), atom2()])
        for d in range(3):
            self.assertEqual(atom1().position[d], atoms[0].position[d])
            self.assertEqual(atom2().position[d], atoms[1].position[d])

        with self.assertRaises(ValueError):
            atoms[12]
Exemple #3
0
    def test_atoms_setitem(self):
        atoms = Atoms([atom1(), atom2()])
        atom = Atom('Li', (15, 0, 0))
        atoms[1] = atom
        for d in range(3):
            self.assertEqual(atom.position[d], atoms[1].position[d])

        with self.assertRaises(AssertionError):
            atoms[0] = 1

        with self.assertRaises(AssertionError):
            atoms[12] = atom
Exemple #4
0
 def test_atoms_section_plus(self):
     atoms_section1 = Atoms(atom1())
     atoms_section2 = Atoms(atom2())
     new_atoms_section = atoms_section1 + atoms_section2
     self.assertIsInstance(new_atoms_section, Atoms)
     self.assertEqual(
         new_atoms_section.get_number_of_atoms(),
         atoms_section1.get_number_of_atoms() +
         atoms_section2.get_number_of_atoms())
     self.assertEqual(atom1().symbol, new_atoms_section.atoms[0].symbol)
     self.assertEqual(atom2().symbol, new_atoms_section.atoms[1].symbol)
Exemple #5
0
    def test_atoms_initialization(self):

        self.assertIsInstance(Atoms(), Atoms)
        self.assertEqual(Atoms().name, 'Atoms')

        atoms_section = Atoms(atom1())
        self.assertIsInstance(atoms_section, Atoms)
        self.assertEqual(atoms_section.get_number_of_atoms(), 1)
        self.assertEqual(atoms_section.atoms[0].symbol, atom1().symbol)

        with self.assertRaises(AssertionError):
            Atoms(1)

        with self.assertRaises(AssertionError):
            Atoms([1, 2])
Exemple #6
0
 def test_molecular_frame_adaptor(self):
     mf1 = MolecularFrame('Cu crystal').import_from(make_supercell_cu())
     mf2 = MolecularFrame().import_from(mf1.export())
     self.assertEqual(mf1.get_number_of_atoms(), mf2.get_number_of_atoms())
     self.assertTrue(Atoms().name in mf2.get_sections_name())
     self.assertTrue(Box().name in mf2.get_sections_name())
Exemple #7
0
 def test_atoms_section_list(self):
     atoms_section = Atoms([atom1(), atom2()])
     self.assertIsInstance(atoms_section, Atoms)
     self.assertEqual(atoms_section.get_number_of_atoms(), 2)
     self.assertEqual(atoms_section.atoms[0].symbol, atom1().symbol)
     self.assertEqual(atoms_section.atoms[1].symbol, atom2().symbol)
Exemple #8
0
 def test_atoms_add_atom(self):
     atoms_section = Atoms()
     atoms_section.append(atom1())
     self.assertIsInstance(atoms_section, Atoms)
     self.assertEqual(atoms_section.get_number_of_atoms(), 1)
     self.assertEqual(atoms_section.atoms[0].symbol, atom1().symbol)