Ejemplo n.º 1
0
 def test_molecular_frame_formatter(self):
     mf1 = MolecularFrame('Cu crystal').import_from(make_supercell_cu())
     filename = "cu_pytest.xyz"
     mf1.write(filename)
     mf2 = MolecularFrame().read(filename)
     self.assertEqual(mf1.get_number_of_atoms(), mf2.get_number_of_atoms())
     os.system("rm -f %s" % filename)
Ejemplo n.º 2
0
 def test_molecular_frame_plus(self):
     mf1 = MolecularFrame('Cu crystal').import_from(make_supercell_cu())
     mf2 = MolecularFrame('Li crystal').import_from(make_supercell_li())
     mf = mf1 + mf2  # plus operator
     self.assertIsInstance(mf, MolecularFrame)
     self.assertTrue(mf1.name in mf.name and mf2.name in mf.name)
     self.assertEqual(mf.get_number_of_atoms(),
                      mf1.get_number_of_atoms() + mf2.get_number_of_atoms())
Ejemplo n.º 3
0
 def test_molecular_frame_equal(self):
     mf = MolecularFrame('Cu crystal').import_from(make_supercell_cu())
     new_mf = mf  # equal operator
     self.assertEqual(new_mf.get_number_of_atoms(),
                      mf.get_number_of_atoms())
     self.assertEqual(new_mf.name, mf.name)
     self.assertEqual(new_mf.atoms_section.atoms[1].x,
                      mf.atoms_section.atoms[1].x)  # atom x position
     self.assertEqual(
         new_mf.atoms_section.atoms[1].symbol,
         mf.atoms_section.atoms[1].symbol)  # second atom symbol
Ejemplo n.º 4
0
 def test_molecular_frame_import_ase(self):
     mf = MolecularFrame('Cu crystal')
     mf.import_from(package_instance=make_supercell_cu(),
                    package_name="ASE")
     self.assertEqual(mf.get_number_of_atoms(),
                      make_supercell_cu().get_number_of_atoms())
     self.assertEqual(mf.name, 'Cu crystal')
     self.assertAlmostEqual(
         mf.atoms_section.atoms[1].x,
         make_supercell_cu().get_positions()[1][0])  # 2nd atom
     self.assertEqual(mf.get_atoms_section().atoms[1].symbol,
                      'Cu')  # second atom symbol
Ejemplo n.º 5
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())