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)
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]
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
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)
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])
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())
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)
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)