How to use pyiron - 10 common examples

To help you get started, we’ve selected a few pyiron examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyiron / pyiron / pyiron / base / master / parallel.py View on Github external
def run_if_interactive(self):
        if not (
            self.ref_job.server.run_mode.interactive
            or self.ref_job.server.run_mode.interactive_non_modal
        ):
            raise ValueError(
                "The child job has to be run_mode interactive or interactive_non_modal."
            )
        if isinstance(self.ref_job, GenericMaster):
            self.run_static()
        elif self.server.cores == 1:
            self.interactive_ref_job_initialize()
            for parameter in self._job_generator.parameter_list:
                self._job_generator.modify_job(job=self.ref_job, parameter=parameter)
                self.ref_job.run()
            self.ref_job.interactive_close()
        else:
            if self.server.cores > len(self._job_generator.parameter_list):
                number_of_jobs = len(self._job_generator.parameter_list)
            else:
                number_of_jobs = self.server.cores
            max_tasks_per_job = (
                int(len(self._job_generator.parameter_list) // number_of_jobs) + 1
            )
            parameters_sub_lst = [
github pyiron / pyiron / pyiron / base / master / parallel.py View on Github external
def run_if_interactive(self):
        if not (
            self.ref_job.server.run_mode.interactive
            or self.ref_job.server.run_mode.interactive_non_modal
        ):
            raise ValueError(
                "The child job has to be run_mode interactive or interactive_non_modal."
            )
        if isinstance(self.ref_job, GenericMaster):
            self.run_static()
        elif self.server.cores == 1:
            self.interactive_ref_job_initialize()
            for parameter in self._job_generator.parameter_list:
                self._job_generator.modify_job(job=self.ref_job, parameter=parameter)
                self.ref_job.run()
            self.ref_job.interactive_close()
        else:
            if self.server.cores > len(self._job_generator.parameter_list):
                number_of_jobs = len(self._job_generator.parameter_list)
            else:
                number_of_jobs = self.server.cores
            max_tasks_per_job = (
                int(len(self._job_generator.parameter_list) // number_of_jobs) + 1
            )
            parameters_sub_lst = [
github pyiron / pyiron / tests / atomistics / structure / test_atoms.py View on Github external
def test_analyse_ovito_centro_symmetry(self):
        basis = Atoms(
            "FeFe", scaled_positions=[(0, 0, 0), (0.5, 0.5, 0.5)], cell=np.identity(3)
        )
        self.assertTrue(
            all(basis.analyse_ovito_centro_symmetry() == np.array([0.75, 0.75]))
        )
github pyiron / pyiron / tests / vasp / test_vasprun.py View on Github external
def test_get_final_structure(self):
        for vp in self.vp_list:
            basis = vp.get_final_structure()
            self.assertIsInstance(basis, Atoms)
            self.assertTrue(np.max(basis.get_scaled_positions()) < 1.01)
            self.assertFalse(np.max(basis.positions) < 1.01)
github pyiron / pyiron / tests / atomistics / structure / test_atoms.py View on Github external
def test_get_majority_species(self):
        basis = Atoms(
            symbols=4 * ["Fe"], positions=np.random.random((4, 3)), cell=np.eye(3)
        )
        self.assertEqual(basis.get_majority_species()["count"], 4)
        self.assertEqual(basis.get_majority_species()["symbol"], "Fe")
        basis = Atoms(
            symbols=["Fe", "Cu", "Ni", "Al"],
            positions=np.random.random((4, 3)),
            cell=np.eye(3),
        )
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            basis.get_majority_species()
            self.assertEqual(len(w), 1)
github pyiron / pyiron / tests / atomistics / structure / test_atoms.py View on Github external
def test_new_array(self):
        pos, cell = generate_fcc_lattice()
        basis = Atoms(symbols="Al", positions=pos, cell=cell)
        basis.set_repeat([10, 10, 10])
        spins = np.ones(len(basis))
        basis.new_array(name="spins", a=spins)
        self.assertTrue(np.array_equal(basis.arrays["spins"], spins))
github pyiron / pyiron / tests / atomistics / master / test_murnaghan_non_modal.py View on Github external
def tearDownClass(cls):
        file_location = os.path.dirname(os.path.abspath(__file__))
        project = Project(os.path.join(file_location, 'testing_murnaghan_non_modal'))
        project.remove_jobs(recursive=True)
        project.remove(enable=True, enforce=True)
github pyiron / pyiron / tests / testing / test_exampleAtomisticJob.py View on Github external
def tearDownClass(cls):
        cls.job.interactive_close()
        project = Project(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'random_testing_atomistic'))
        job = project.load(project.get_job_ids()[0])
        job.remove()
        project.remove(enable=True)
github pyiron / pyiron / tests / testing / test_exampleJobLib.py View on Github external
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)
github pyiron / pyiron / tests / testing / test_exampleJobLib.py View on Github external
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()