Beispiel #1
0
    def setUpClass(cls):
        cls.execution_path = os.path.dirname(os.path.abspath(__file__))
        cls.project = Project(os.path.join(cls.execution_path, "lammps"))

        structure = Atoms(
            symbols="Fe2",
            positions=np.outer(np.arange(2), np.ones(3)),
            cell=2 * np.eye(3),
        )

        cls.job = Lammps(
            project=ProjectHDFio(project=cls.project, file_name="lammps"),
            job_name="lammps",
        )
        cls.job.server.run_mode.interactive = True
        cls.job.structure = structure

        cls.minimize_job = Lammps(
            project=ProjectHDFio(project=cls.project, file_name="lammps"),
            job_name="minimize_lammps",
        )
        cls.minimize_control_job = Lammps(
            project=ProjectHDFio(project=cls.project, file_name="lammps"),
            job_name="minimize_control_lammps",
        )
Beispiel #2
0
 def setUp(self) -> None:
     super().setUp()
     self.job = Lammps(
         project=ProjectHDFio(project=self.project, file_name="lammps"),
         job_name="lammps",
     )
     self.ref = Lammps(
         project=ProjectHDFio(project=self.project, file_name="ref"),
         job_name="ref",
     )
     # Creating jobs this way puts them at the right spot, but decouples them from our self.project instance.
     # I still don't understand what's happening as deeply as I'd like (at all!) but I've been fighting with it too
     # long, so for now I will just force the issue by redefining the project attribute(s). -Liam Huber
     self.project = self.job.project
     self.ref_project = self.ref.project
    def create_job(self, job_type, job_name, delete_existing_job=False):
        """
        Create one of the following jobs:
        - 'StructureContainer’:
        - ‘StructurePipeline’:
        - ‘AtomisticExampleJob’: example job just generating random number
        - ‘ExampleJob’: example job just generating random number
        - ‘Lammps’:
        - ‘KMC’:
        - ‘Sphinx’:
        - ‘Vasp’:
        - ‘GenericMaster’:
        - ‘SerialMaster’: series of jobs run in serial
        - ‘AtomisticSerialMaster’:
        - ‘ParallelMaster’: series of jobs run in parallel
        - ‘KmcMaster’:
        - ‘ThermoLambdaMaster’:
        - ‘RandomSeedMaster’:
        - ‘MeamFit’:
        - ‘Murnaghan’:
        - ‘MinimizeMurnaghan’:
        - ‘ElasticMatrix’:
        - ‘ConvergenceVolume’:
        - ‘ConvergenceEncutParallel’:
        - ‘ConvergenceKpointParallel’:
        - ’PhonopyMaster’:
        - ‘DefectFormationEnergy’:
        - ‘LammpsASE’:
        - ‘PipelineMaster’:
        - ’TransformationPath’:
        - ‘ThermoIntEamQh’:
        - ‘ThermoIntDftEam’:
        - ‘ScriptJob’: Python script or jupyter notebook job container
        - ‘ListMaster': list of jobs

        Args:
            job_type (str): job type can be ['StructureContainer’, ‘StructurePipeline’, ‘AtomisticExampleJob’,
                                             ‘ExampleJob’, ‘Lammps’, ‘KMC’, ‘Sphinx’, ‘Vasp’, ‘GenericMaster’,
                                             ‘SerialMaster’, ‘AtomisticSerialMaster’, ‘ParallelMaster’, ‘KmcMaster’,
                                             ‘ThermoLambdaMaster’, ‘RandomSeedMaster’, ‘MeamFit’, ‘Murnaghan’,
                                             ‘MinimizeMurnaghan’, ‘ElasticMatrix’, ‘ConvergenceVolume’,
                                             ‘ConvergenceEncutParallel’, ‘ConvergenceKpointParallel’, ’PhonopyMaster’,
                                             ‘DefectFormationEnergy’, ‘LammpsASE’, ‘PipelineMaster’,
                                             ’TransformationPath’, ‘ThermoIntEamQh’, ‘ThermoIntDftEam’, ‘ScriptJob’,
                                             ‘ListMaster']
            job_name (str): name of the job

        Returns:
            GenericJob: job object depending on the job_type selected
        """
        job = JobType(
            job_type,
            project=ProjectHDFio(project=self.copy(), file_name=job_name),
            job_name=job_name,
            job_class_dict=self.job_type.job_class_dict,
            delete_existing_job=delete_existing_job,
        )
        if self.user is not None:
            job.user = self.user
        return job
Beispiel #4
0
 def setUpClass(cls):
     state.update({
         'resource_paths':
         os.path.join(os.path.dirname(os.path.abspath(__file__)),
                      "../static")
     })
     cls.execution_path = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.execution_path, "test_vasp"))
     cls.job = cls.project.create_job("Vasp", "trial")
     cls.job_spin = cls.project.create_job("Vasp", "spin")
     cls.job_spin.structure = CrystalStructure("Fe",
                                               BravaisBasis="bcc",
                                               a=2.83)
     cls.job_spin.structure = cls.job_spin.structure.repeat(2)
     cls.job_spin.structure[2] = "Se"
     cls.job_spin.structure[3] = "O"
     cls.job_metadyn = cls.project.create_job("VaspMetadyn",
                                              "trial_metadyn")
     cls.job_complete = Vasp(
         project=ProjectHDFio(project=cls.project,
                              file_name="vasp_complete"),
         job_name="vasp_complete",
     )
     poscar_file = posixpath.join(
         cls.execution_path,
         "../static/vasp_test_files/full_job_sample/POSCAR")
     cls.job_complete.structure = read_atoms(poscar_file,
                                             species_from_potcar=True)
     poscar_file = posixpath.join(
         cls.execution_path,
         "../static/vasp_test_files/poscar_samples/POSCAR_metadyn")
     cls.job_metadyn.structure = read_atoms(poscar_file)
Beispiel #5
0
 def setUpClass(cls):
     cls.execution_path = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.execution_path, "lammps"))
     cls.job = Lammps(
         project=ProjectHDFio(project=cls.project, file_name="lammps"),
         job_name="lammps",
     )
     cls.job_water = Lammps(
         project=ProjectHDFio(project=cls.project,
                              file_name="lammps_water"),
         job_name="lammps_water",
     )
     cls.job_water_dump = Lammps(
         project=ProjectHDFio(project=cls.project,
                              file_name="lammps_water_dump"),
         job_name="lammps_water_dump",
     )
     cls.job_dump = Lammps(
         project=ProjectHDFio(project=cls.project,
                              file_name="lammps_dump_static"),
         job_name="lammps_dump_static",
     )
     cls.job_vcsgc_input = Lammps(
         project=ProjectHDFio(project=cls.project,
                              file_name="lammps_vcsgc_input"),
         job_name="lammps_vcsgc_input",
     )
     cls.minimize_job = Lammps(
         project=ProjectHDFio(project=cls.project, file_name="lammps"),
         job_name="minimize_lammps",
     )
     cls.minimize_control_job = Lammps(
         project=ProjectHDFio(project=cls.project, file_name="lammps"),
         job_name="minimize_control_lammps",
     )
     cls.job_read_restart = Lammps(
         project=ProjectHDFio(project=cls.project, file_name="lammps"),
         job_name="read_restart",
     )
     cls.job_average = Lammps(
         project=ProjectHDFio(project=cls.project, file_name="lammps"),
         job_name="average",
     )
     cls.job_fail = Lammps(
         project=ProjectHDFio(project=cls.project, file_name="lammps"),
         job_name="fail",
     )
Beispiel #6
0
 def setUpClass(cls):
     cls.execution_path = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.execution_path, "gpaw"))
     atoms = Atoms("Fe1", positions=np.zeros((1, 3)), cell=np.eye(3))
     job = Gpaw(
         project=ProjectHDFio(project=cls.project, file_name="gpaw"),
         job_name="gpaw",
     )
     job.structure = atoms
     job.encut = 300
     job.set_kpoints([5, 5, 5])
     job.to_hdf()
     cls.job = Gpaw(
         project=ProjectHDFio(project=cls.project, file_name="gpaw"),
         job_name="gpaw",
     )
     cls.job.from_hdf()
Beispiel #7
0
 def test_serialization(self):
     self.job.to_hdf()
     loaded = Gpaw(
         project=ProjectHDFio(project=self.project, file_name="gpaw"),
         job_name="gpaw",
     )
     loaded.from_hdf()
     self.assertEqual(self.job.encut, loaded.encut)
Beispiel #8
0
 def setUpClass(cls):
     cls.execution_path = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.execution_path, "test_quickff"))
     cls.job = cls.project.create_job("QuickFF", "trial")
     cls.job_complete = QuickFF(
         project=ProjectHDFio(project=cls.project, file_name="quickff_complete"),
         job_name="quickff_complete",
     )
Beispiel #9
0
 def setUp(self) -> None:
     self.job = ToyAtomisticJob(
         project=ProjectHDFio(project=self.project, file_name="test_job"),
         job_name="test_job",
     )
     self.job.structure = CrystalStructure(element="Al",
                                           bravais_basis="fcc",
                                           lattice_constants=4).repeat(4)
     self.job.run()
Beispiel #10
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)
Beispiel #11
0
        def setUp(self):
            if self.project.load('trial') is not None:
                self.project.remove_job('trial')
            self.job = self.project.create_job("QuickFF", 'trial')

            if self.project.load('quickff_complete') is not None:
                self.project.remove_job("quickff_complete")
            self.job_complete = QuickFF(
                project=ProjectHDFio(project=self.project, file_name="quickff_complete"),
                job_name="quickff_complete",
            )
Beispiel #12
0
    def setUp(self):
        if self.project.load('trial') is not None:
            self.project.remove_job("trial")
        self.job = self.project.create_job("Yaff", "trial")

        if self.project.load('yaff_complete') is not None:
            self.project.remove_job("yaff_complete")
        self.job_complete = Yaff(
            project=ProjectHDFio(project=self.project,
                                 file_name="yaff_complete"),
            job_name="yaff_complete",
        )
Beispiel #13
0
 def setUpClass(cls):
     state.update({
         "resource_paths":
         os.path.join(os.path.dirname(os.path.abspath(__file__)),
                      "../static/calphy_test_files")
     })
     cls.execution_path = os.path.dirname(os.path.abspath(__file__))
     # cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.execution_path, "test_calphy"))
     cls.job = Calphy(
         project=ProjectHDFio(project=cls.project, file_name="test_calphy"),
         job_name="test_calphy",
     )
     filepath = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                             "../static/")
     cls.output_project = Project(os.path.join(filepath, "test_files"))
Beispiel #14
0
def load_file(fp, filetype=None, project=None):
    """
    Load the file and return an appropriate object containing the data.

    Args:
        fp (str / file): path to the file or file object to be displayed.
        filetype (str/None): File extension, if given this overwrites the assumption based on the filename.
        project (pyiron-Project/None): Project calling this function, provided to all objects referring to such.

        Supported file types are:
        '.h5', '.hdf'
        '.json'
        '.txt'
        '.csv'
        '.ipynb'
        Image extensions supported by PIL

    Returns:
        :class:`FileHDFio`: pointing to the file of filetype = '.h5'
        dict: containing data from file of filetype = '.json'
        list: of all lines from file for filetype = '.txt'
        :class:`pandas.DataFrame`: containing data from file of filetype = '.csv'

    """

    def _load_txt(file):
        if isinstance(file, str):
            with open(file, encoding="utf8") as f:
                return f.readlines()
        else:
            return file.readlines()

    def _load_ipynb(file):
        return OwnNotebookNode(nbformat.read(file, as_version=4))

    def _load_json(file):
        if isinstance(file, str):
            with open(file) as f:
                return json.load(f)
        else:
            return json.load(file)

    def _load_csv(file):
        return pandas.read_csv(file)

    def _load_img(file):
        return Image.open(file)

    def _load_default(file):
        try:
            return _load_txt(file)
        except Exception as e:
            raise IOError("File could not be loaded.") from e

    def _resolve_filetype(file, _filetype):
        if _filetype is None and isinstance(file, str):
            _, _filetype = os.path.splitext(file)
        elif _filetype is None and hasattr(file, "name"):
            _, _filetype = os.path.splitext(file.name)
        elif _filetype is None:
            return None
        elif _filetype[0] != ".":
            _filetype = "." + _filetype
        return _filetype.lower()

    filetype = _resolve_filetype(fp, filetype)

    if filetype in [".h5", ".hdf"] and isinstance(fp, str):
        if project is None:
            return FileHDFio(file_name=fp)
        else:
            return ProjectHDFio(file_name=fp, project=project)
    elif filetype in [".json"]:
        return _load_json(fp)
    elif filetype in [".txt"]:
        return _load_txt(fp)
    elif filetype in [".csv"]:
        return _load_csv(fp)
    elif _has_imported["nbformat"] and filetype in [".ipynb"]:
        return _load_ipynb(fp)
    elif _has_imported["PIL"] and filetype in Image.registered_extensions():
        return _load_img(fp)
    else:
        return _load_default(fp)
Beispiel #15
0
def load_file(filename, filetype=None, project=None):
    """
        Load the file and return an appropriate object containing the data.

        Args:
            filename (str): path to the file to be displayed.
            filetype (str/None): File extension, if given this overwrites the assumption based on the filename.
            project (pyiron-Project/None): Project calling this function, provided to all objects referring to such.

            Supported file types are:
            '.h5', '.hdf'
            '.json'
            '.txt'
            '.csv'
            '.ipynb'
            Image extensions supported by PIL

        Returns:
            :class:`FileHDFio`: pointing to the file of filetype = '.h5'
            dict: containing data from file of filetype = '.json'
            list: of all lines from file for filetype = '.txt'
            :class:`pandas.DataFrame`: containing data from file of filetype = '.csv'

    """
    def _load_txt(file):
        with open(file, encoding='utf8') as f:
            return f.readlines()

    def _load_ipynb(file):
        return OwnNotebookNode(nbformat.read(file, as_version=4))

    def _load_json(file):
        with open(file) as f:
            return json.load(f)

    def _load_csv(file):
        return pandas.read_csv(file)

    def _load_img(file):
        return Image.open(file)

    def _load_default(file):
        try:
            return _load_txt(file)
        except Exception as e:
            raise IOError("File could not be loaded.") from e

    if filetype is None:
        _, filetype = os.path.splitext(filename)
    elif filetype[0] != '.':
        filetype = '.' + filetype
    filetype = filetype.lower()

    if filetype in ['.h5', '.hdf']:
        if project is None:
            return FileHDFio(file_name=filename)
        else:
            return ProjectHDFio(file_name=filename, project=project)
    elif filetype in ['.json']:
        return _load_json(filename)
    elif filetype in ['.txt']:
        return _load_txt(filename)
    elif filetype in ['.csv']:
        return _load_csv(filename)
    elif _has_imported['nbformat'] and filetype in ['.ipynb']:
        return _load_ipynb(filename)
    elif _has_imported['PIL'] and filetype in Image.registered_extensions():
        return _load_img(filename)
    else:
        return _load_default(filename)