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 tearDownClass(cls):
     project = Project('structure_testing')
     ham = project.load(1)
     ham.remove()
     project.remove(enable=True)
     s.close_connection()
     os.remove('container.db')
 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
示例#5
0
 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()
示例#6
0
 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()
 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
示例#8
0
 def setUp(self):
     self.count_run_one = 12
     self.count_run_two = 12
     self.file_location = os.path.dirname(os.path.abspath(__file__))
     self.project = Project(os.path.join(self.file_location, 'random_testing_lib'))
     self.ham = self.project.create_job("ExampleJob", "job_test_run")
     self.ham.input['count'] = self.count_run_one
     self.ham.server.run_mode.interactive = True
     self.ham.run()
     self.ham.input['count'] = self.count_run_two
     self.ham.run()
     self.ham.interactive_close()
示例#9
0
 def setUpClass(cls):
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.file_location, "../static/sphinx"))
     pt = PeriodicTable()
     pt.add_element(parent_element="Fe", new_element="Fe_up", spin="0.5")
     Fe_up = pt.element("Fe_up")
     cls.basis = Atoms(
         elements=[Fe_up, Fe_up],
         scaled_positions=[[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]],
         cell=2.6 * np.eye(3),
     )
     cls.sphinx = cls.project.create_job("Sphinx", "job_sphinx")
     cls.sphinx_2_3 = cls.project.create_job("Sphinx", "sphinx_test_2_3")
     cls.sphinx_2_5 = cls.project.create_job("Sphinx", "sphinx_test_2_5")
     cls.sphinx.structure = cls.basis
     cls.sphinx_2_3.structure = Atoms(
         elements=["Fe", "Fe"],
         scaled_positions=[[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]],
         cell=2.6 * np.eye(3),
     )
     cls.sphinx_2_5.structure = Atoms(
         elements=["Fe", "Ni"],
         scaled_positions=[[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]],
         cell=2.83 * np.eye(3),
     )
     cls.current_dir = os.path.abspath(os.getcwd())
     cls.sphinx._create_working_directory()
     cls.sphinx_2_3._create_working_directory()
     cls.sphinx.write_input()
     cls.sphinx.version = "2.6"
     cls.sphinx_2_3.to_hdf()
     cls.sphinx_2_3.decompress()
     cls.sphinx_2_5.decompress()
示例#10
0
class TestExampleJob(unittest.TestCase):
    def setUp(self):
        self.count_run_one = 12
        self.count_run_two = 12
        self.file_location = os.path.dirname(os.path.abspath(__file__))
        self.project = Project(os.path.join(self.file_location, 'random_testing_lib'))
        self.ham = self.project.create_job("ExampleJob", "job_test_run")
        self.ham.input['count'] = self.count_run_one
        self.ham.server.run_mode.interactive = True
        self.ham.run()
        self.ham.input['count'] = self.count_run_two
        self.ham.run()
        self.ham.interactive_close()

    @classmethod
    def tearDownClass(cls):
        file_location = os.path.dirname(os.path.abspath(__file__))
        project = Project(os.path.join(file_location, 'random_testing_lib'))
        ham = project.load(project.get_job_ids()[0])
        ham.remove()
        project.remove(enable=True)

    def test_output(self):
        count = self.ham.get("output/generic/count")
        energy = self.ham.get("output/generic/energy")
        self.assertEqual(self.count_run_one, count[0])
        self.assertEqual(self.count_run_two, count[1])
        self.assertEqual(count[0], len(energy[0]))
        self.assertEqual(count[0], len(energy[1]))
示例#11
0
 def setUpClass(cls):
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(
         os.path.join(cls.file_location, 'testing_murnaghan'))
     cls.basis = cls.project.create_structure(element="Fe",
                                              bravais_basis='fcc',
                                              lattice_constant=3.5)
     cls.project.remove_jobs(recursive=True)
示例#12
0
 def setUpClass(cls):
     cls.count = 12
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.file_location,
                                        'random_testing'))
     cls.ham = cls.project.create_job("ExampleJob", "job_test_run")
     cls.ham.input['count'] = cls.count
     cls.ham.run()
示例#13
0
 def setUpClass(cls):
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(
         os.path.join(cls.file_location, "../static/sphinx"))
     pt = PeriodicTable()
     pt.add_element(parent_element="Fe", new_element="Fe_up", spin="0.5")
     Fe_up = pt.element("Fe_up")
     cls.basis = Atoms(
         elements=[Fe_up, Fe_up],
         scaled_positions=[[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]],
         cell=2.6 * np.eye(3),
     )
     cls.sphinx = cls.project.create_job("Sphinx", "job_sphinx")
     cls.sphinx_band_structure = cls.project.create_job(
         "Sphinx", "sphinx_test_bs")
     cls.sphinx_2_3 = cls.project.create_job("Sphinx", "sphinx_test_2_3")
     cls.sphinx_2_5 = cls.project.create_job("Sphinx", "sphinx_test_2_5")
     cls.sphinx_aborted = cls.project.create_job("Sphinx",
                                                 "sphinx_test_aborted")
     cls.sphinx.structure = cls.basis
     cls.sphinx.fix_spin_constraint = True
     cls.sphinx_band_structure.structure = cls.project.create_structure(
         "Fe", "bcc", 2.81)
     cls.sphinx_band_structure.structure = cls.sphinx_band_structure.structure.create_line_mode_structure(
     )
     cls.sphinx_2_3.structure = Atoms(
         elements=["Fe", "Fe"],
         scaled_positions=[[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]],
         cell=2.6 * np.eye(3),
     )
     cls.sphinx_2_5.structure = Atoms(
         elements=["Fe", "Ni"],
         scaled_positions=[[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]],
         cell=2.83 * np.eye(3),
     )
     cls.sphinx_aborted.structure = Atoms(
         elements=32 * ["Fe"],
         scaled_positions=np.arange(32 * 3).reshape(-1, 3) / (32 * 3),
         cell=3.5 * np.eye(3),
     )
     cls.sphinx_aborted.status.aborted = True
     cls.current_dir = os.path.abspath(os.getcwd())
     cls.sphinx._create_working_directory()
     cls.sphinx_2_3._create_working_directory()
     cls.sphinx.input["VaspPot"] = False
     cls.sphinx.structure.add_tag(selective_dynamics=(True, True, True))
     cls.sphinx.structure.selective_dynamics[1] = (False, False, False)
     cls.sphinx.load_default_groups()
     cls.sphinx.fix_symmetry = False
     cls.sphinx.write_input()
     try:
         cls.sphinx.version = "2.6"
     except ValueError:
         cls.sphinx.version = "2.6.2_default"
     cls.sphinx_2_3.to_hdf()
     cls.sphinx_2_3.decompress()
     cls.sphinx_2_5.decompress()
示例#14
0
 def setUpClass(cls):
     cls.execution_path = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.execution_path, "test_job"))
     cls.job = AtomisticGenericJob(
         project=ProjectHDFio(project=cls.project, file_name="test_job"),
         job_name="test_job",
     )
     cls.job.structure = CrystalStructure(
         element="Al", bravais_basis="fcc", lattice_constants=4
     ).repeat(4)
示例#15
0
 def setUpClass(cls):
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.file_location, "../static/sxextopt"))
     cls.basis = cls.project.create_structure("Fe", "bcc", 2.8)
     job = cls.project.create_job(
         cls.project.job_type.AtomisticExampleJob, "job_single"
     )
     job.server.run_mode.interactive = True
     job.structure = cls.basis
     cls.sxextoptint = cls.project.create_job("SxExtOptInteractive", "job_sxextopt")
     cls.sxextoptint.ref_job = job
示例#16
0
 def setUpClass(cls):
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.file_location, "../static/minim"))
     cls.basis = cls.project.create_structure("Fe", "bcc", 2.8)
     job = cls.project.create_job(
         cls.project.job_type.AtomisticExampleJob, "job_single"
     )
     job.server.run_mode.interactive = True
     job.structure = cls.basis
     cls.minim = cls.project.create_job("ScipyMinimizer", "job_scipy")
     cls.minim.ref_job = job
示例#17
0
 def setUpClass(cls):
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.file_location, "../static/sphinx"))
     cls.sphinx = cls.project.create_job("Sphinx", "job_sphinx")
     cls.sphinx.structure = Atoms(elements=['Fe']*2, scaled_positions=[3*[0.0], 3*[0.5]], cell=2.6*np.eye(3))
     cls.sphinx.structure.set_initial_magnetic_moments(np.ones(2))
     cls.current_dir = os.path.abspath(os.getcwd())
     cls.sphinx._create_working_directory()
     cls.sphinx.write_input()
     cls.sphinx.version = "2.6"
     cls.sphinx.server.run_mode.interactive = True
 def setUpClass(cls):
     cls.lattice_constant = 3.5
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(
         os.path.join(cls.file_location, 'structure_testing'))
     cls.basis = cls.project.create_structure(
         element="Fe",
         bravais_basis='fcc',
         lattice_constant=cls.lattice_constant)
     cls.structure_container = cls.project.create_job(
         cls.project.job_type.StructureContainer, "structure_container")
     cls.structure_container.structure = cls.basis
示例#19
0
 def tearDownClass(cls):
     project = Project(
         os.path.join(os.path.dirname(os.path.abspath(__file__)),
                      'random_testing'))
     ham = project.load(project.get_job_ids()[0])
     ham.remove()
     project.remove(enable=True)
class TestExampleJob(unittest.TestCase):
    def setUp(self):
        self.count = 12
        self.file_location = os.path.dirname(os.path.abspath(__file__))
        self.project = Project(os.path.join(self.file_location, 'random_testing_non_modal'))
        self.project.remove_jobs(recursive=True)
        self.project.set_logging_level('INFO')

    @classmethod
    def tearDownClass(cls):
        # print('tear down')
        file_location = os.path.dirname(os.path.abspath(__file__))
        project = Project(os.path.join(file_location, 'random_testing_non_modal'))
        project.remove_jobs()
        project.remove(enable=True)

    def test_non_modal_run(self):
        ham_non_modal = self.project.create_job(self.project.job_type.ExampleJob, "job_non_modal")
        ham_non_modal.input['count'] = self.count
        ham_non_modal.server.run_mode.non_modal = True
        ham_non_modal.run()
        self.assertFalse(ham_non_modal.status.finished)
        self.project.wait_for_job(ham_non_modal, interval_in_s=5, max_iterations=50)
        self.assertTrue(ham_non_modal.status.finished)

        lines = self.project['job_non_modal/input.inp']
        input_lst = ["alat 3.2 #lattice constant (would be in a more realistic example in the structure file)\n",
                     "alpha 0.1 #noise amplitude\n",
                     "a_0 3 #equilibrium lattice constant\n",
                     "a_1 0\n",
                     "a_2 1. #2nd order in energy (corresponds to bulk modulus)\n",
                     "a_3 0. #3rd order\n",
                     "a_4 0. #4th order\n",
                     "count " + str(self.count) + " #number of calls (dummy)\n",
                     "write_restart True\n",
                     "read_restart False\n"]
        self.assertEqual(input_lst, lines)

        lines = self.project['job_non_modal/restart.out']
        restart_lst = ["count " + str(self.count) + " \n"]
        self.assertEqual(restart_lst, lines)
        energy_lst = ham_non_modal.get("output/generic/energy_tot")
        self.assertEqual(len(energy_lst), self.count)

        lines = self.project['job_non_modal/output.log']
        output_lst = ["exampleExecutable logFile \n",
                      "alat 3.2 \n",
                      "count " + str(self.count) + " \n"]
        self.assertEqual(output_lst, lines[0:3])
        energy_output_lst = np.array([float(line.split('  ')[1]) for line in lines[3:]])
        for e_1, e_2 in zip(energy_lst, energy_output_lst):
            self.assertTrue(1 > e_1 > 0)
            self.assertEqual(e_1, e_2)

        ham_non_modal.remove()
示例#21
0
class TestVasp(unittest.TestCase):
    """
    Tests the pyiron.objects.hamilton.dft.vasp.Vasp class
    """
    def setUp(self):
        self.file_location = os.path.dirname(os.path.abspath(__file__))
        self.project = Project(os.path.join(self.file_location, 'test_vasp'))
        self.job = self.project.create_job("Vasp", "trial")

    @classmethod
    def tearDownClass(cls):
        pass

    def test_init(self):
        self.assertEqual(self.job.__name__, "Vasp")
        self.assertEqual(self.job._sorted_indices, None)
        self.assertIsInstance(self.job.input, Input)
        self.assertIsInstance(self.job._output_parser, Output)

    def test_calc_static(self):
        self.job.calc_static(electronic_steps=90,
                             retain_charge_density=True,
                             retain_electrostatic_potential=True)
        self.assertEqual(self.job.input.incar["IBRION"], -1)
        self.assertEqual(self.job.input.incar["NELM"], 90)
        self.assertEqual(self.job.input.incar["LVTOT"], True)
        self.assertEqual(self.job.input.incar["LCHARG"], True)

    def test_set_structure(self):
        self.assertEqual(self.job.structure, None)
        atoms = CrystalStructure("Pt", BravaisBasis="fcc", a=3.98)
        self.job.structure = atoms
        self.assertEqual(self.job.structure, atoms)
        self.job.structure = None
        self.assertEqual(self.job.structure, None)
        self.job.structure = atoms
        self.assertEqual(self.job.structure, atoms)

    def test_list_potenitals(self):
        self.assertRaises(ValueError, self.job.list_potentials)

    def tearDown(self):
        pass
示例#22
0
 def tearDownClass(cls):
     cls.execution_path = os.path.dirname(os.path.abspath(__file__))
     project = Project(os.path.join(cls.execution_path, "table"))
     project.remove_jobs(recursive=True)
     project.remove(enable=True)
示例#23
0
 def setUpClass(cls):
     cls.execution_path = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.execution_path, "table"))
 def tearDownClass(cls):
     file_location = os.path.dirname(os.path.abspath(__file__))
     project = Project(os.path.join(file_location, "testing_serial_non_modal"))
     project.remove(enable=True, enforce=True)
 def setUpClass(cls):
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(
         os.path.join(cls.file_location, "testing_serial_non_modal")
     )
     cls.project.remove_jobs_silently(recursive=True)
示例#26
0
 def tearDownClass(cls):
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     project = Project(os.path.join(cls.file_location, "vasp_import_testing"))
     project.remove_jobs_silently(recursive=True)
     project.remove(enable=True)
示例#27
0
 def setUpClass(cls):
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.file_location, "vasp_import_testing"))
 def tearDownClass(cls):
     project = Project('testing_murnaghan_non_modal')
     project.remove_jobs(recursive=True)
     project.remove(enable=True, enforce=True)
 def setUpClass(cls):
     cls.project = Project('testing_murnaghan_non_modal')
     cls.basis = cls.project.create_structure(element="Fe", bravais_basis='bcc', lattice_constant=2.8)
     cls.project.remove_jobs(recursive=True)
示例#30
0
 def tearDownClass(cls):
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     project = Project(os.path.join(cls.file_location, 'testing_murnaghan'))
     project.remove(enable=True, enforce=True)