class TestStructureContainer(unittest.TestCase): def setUp(self): self.lattice_constant = 3.5 self.project = Project('structure_testing') self.basis = self.project.create_structure( element="Fe", bravais_basis='fcc', lattice_constant=self.lattice_constant) self.structure_container = self.project.create_job( "StructureContainer", "structure_container") self.structure_container.structure = self.basis @classmethod def tearDownClass(cls): project = Project('structure_testing') ham = project.load(1) ham.remove() project.remove(enable=True) s.close_connection() os.remove('container.db') def test_container(self): structure_container = self.project.load(1) self.assertEqual(structure_container.job_id, 1) self.assertEqual(structure_container.job_name, 'structure_container') self.assertEqual(structure_container.project_hdf5.project_path, 'structure_testing/') self.assertTrue(structure_container.status.finished) self.assertEqual(structure_container.structure, self.basis)
class TestStructureContainer(unittest.TestCase): def setUp(self): self.lattice_constant = 3.5 self.file_location = os.path.dirname(os.path.abspath(__file__)) self.project = Project( os.path.join(self.file_location, 'structure_testing')) self.basis = self.project.create_structure( element="Fe", bravais_basis='fcc', lattice_constant=self.lattice_constant) self.structure_container = self.project.create_job( self.project.job_type.StructureContainer, "structure_container") self.structure_container.structure = self.basis @classmethod def tearDownClass(cls): file_location = os.path.dirname(os.path.abspath(__file__)) project = Project(os.path.join(file_location, 'structure_testing')) ham = project.load(project.get_job_ids()[0]) ham.remove() project.remove(enable=True) def test_container(self): structure_container = self.project.load(self.project.get_job_ids()[0]) self.assertEqual(structure_container.job_id, self.project.get_job_ids()[0]) self.assertEqual(structure_container.job_name, 'structure_container') self.assertTrue('atomistics/job/structure_testing/' in structure_container.project_hdf5.project_path) self.assertTrue(structure_container.status.finished) self.assertEqual(structure_container.structure, self.basis)
def test_Chemical_Element_to_and_from_hdf_with_None_Parent(self): pr = Project(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test_periodic_table')) basis = pr.create_structure(element='Ni', bravais_basis='fcc', lattice_constant=3.7) ham = pr.create_job(pr.job_type.Lammps, 'lammps_test_2') test_ham = pr.create_job(pr.job_type.Lammps, 'lammps_test_2') ham.structure = basis ham.to_hdf() test_ham.from_hdf() self.assertEqual(test_ham['input/structure/species'][0], ham['input/structure/species'][0]) ham.remove()
def test_Chemical_Element_to_and_from_hdf(self): ni_up = self.pse.add_element("Ni", "Ni_up", spin="up") pr = Project(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test_periodic_table')) basis = pr.create_structure(element=ni_up, bravais_basis='fcc', lattice_constant=3.7) ham = pr.create_job(pr.job_type.Lammps, 'lammps_test_1') test_ham = pr.create_job(pr.job_type.Lammps, 'lammps_test_1') ham.structure = basis ham.to_hdf() test_ham.from_hdf() self.assertEqual(test_ham['input/structure/species'][0], ham['input/structure/species'][0]) ham.remove()