pyiron / pyiron_atomistics

pyiron_atomistics - an integrated development environment (IDE) for atomistic simulation in computational materials science.
https://pyiron-atomistics.readthedocs.io
BSD 3-Clause "New" or "Revised" License
44 stars 15 forks source link

AtomisticGenericJob, Lammps and Vasp: Implement from_dict() #1356

Closed jan-janssen closed 7 months ago

jan-janssen commented 7 months ago

This pull request includes the changes form https://github.com/pyiron/pyiron_atomistics/pull/1355 so it is recommended to merge https://github.com/pyiron/pyiron_atomistics/pull/1355 first.

By implementing a to_dict() and from_dict() function for the input of the LAMMPS and VASP jobs, it is now possible to transfer these jobs without the need to serialise to HDF5 before.

Transfer job object as dictionary:

from h5io_browser.pointer import get_hierarchical_dict
from pyiron_atomistics import Project
from pyiron_base.storage.hdfio import ProjectHDFio, _extract_module_class_name, _import_class

pr = Project("test")

# setup LAMMPS job object
job = pr.create.job.Lammps("lmp")
job.structure = pr.create.structure.ase.bulk("Al")
job.server.run_mode.non_modal = True

# serialize to dict
job_dict = job.to_dict()

# create a new job from dict - in a new project and using a new job_name
project, job_name = Project("test_reload"), "lmp_reload"
module_path, class_name = _extract_module_class_name(job_dict["TYPE"])
class_object = _import_class(module_path, class_name)
project_hdf = ProjectHDFio(project=project, file_name=job_name)
job_reload = class_object(project_hdf, job_name)
job_reload.from_dict(get_hierarchical_dict(job_dict))
job_reload.run()

This example also requires the changes in https://github.com/pyiron/pyiron_base/pull/1377 and https://github.com/pyiron/pyiron_base/pull/1380 . The same functionality can in principle also be used to copy jobs, still this would require all job types to implement this new functionality.

coveralls commented 7 months ago

Pull Request Test Coverage Report for Build 8315462250

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
pyiron_atomistics/atomistics/structure/periodic_table.py 17 21 80.95%
<!-- Total: 133 137 97.08% -->
Files with Coverage Reduction New Missed Lines %
pyiron_atomistics/atomistics/structure/periodic_table.py 17 87.0%
<!-- Total: 17 -->
Totals Coverage Status
Change from base Build 8295744902: -0.1%
Covered Lines: 14210
Relevant Lines: 15270

💛 - Coveralls