Skip to content

Commit

Permalink
debug retrieval of results from zacrosjob
Browse files Browse the repository at this point in the history
  • Loading branch information
MBueschelberger committed Jul 27, 2023
1 parent eef7817 commit d9a7a0c
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 20 deletions.
37 changes: 37 additions & 0 deletions examples/XYZ/lattice_input.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
lattice periodic_cell

cell_vectors # in row format (Angstroms)
2.774687009376012 0.000000000000000
0.000000000000000 2.774687009376012

repeat_cell 6 6

n_site_types 2
site_type_names brg hol

n_cell_sites 3
site_types brg brg hol

site_coordinates # fractional coordinates (x,y) in row format

0.500000000000000 0.000000000000000
0.000000000000000 0.500000000000000
0.500000000000000 0.500000000000000

neighboring_structure # site-neighsite cell

1-2 self
1-3 self
2-3 self

2-1 north
3-1 north

1-2 east
3-2 east

1-2 southeast

end_neighboring_structure

end_lattice
2 changes: 1 addition & 1 deletion examples/Ziff-Gulari-Barshad-model-variants.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"wall_time": 100
},

"lattice_input": {"xyz_file": "../tests/test_files/lattice_input.dat"},
"lattice_input": {"xyz_file": "XYZ/lattice_input.dat"},

"energetics_input": [
{ "name": "CO_Point_brg",
Expand Down
2 changes: 1 addition & 1 deletion examples/Ziff-Gulari-Barshad-model.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"wall_time": 3600
},

"lattice_input": {"xyz_file": "./Zacros_inputs/lattice_input.dat"},
"lattice_input": {"xyz_file": "./XYZ/lattice_input.dat"},

"energetics_input": [
{ "name": "CO_Point",
Expand Down
13 changes: 4 additions & 9 deletions examples/zacros_model_example.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
"""Example of py/Zacros model"""

import os
import json
from osp.models.zacros.co_pyzacros import COpyZacrosModel
from osp.wrappers.simzacros.simzacros_session import SimzacrosSession
from osp.core.namespaces import emmo, cuba
from osp.core.namespaces import cuba
from osp.core.utils import import_cuds
from osp.core.utils import pretty_print

#path = os.path.join(os.path.dirname(__file__), "Ziff-Gulari-Barshad-model.json")
path = os.path.join(os.path.dirname(__file__), "Ziff-Gulari-Barshad-model-variants.json")

with open(path, mode="r+") as file:
content = json.loads(file.read())

# alternatively with the standard file. Needs connection to minio!
#content = COpyZacrosModel.Config.schema_extra["example"]
content = COpyZacrosModel.Config.schema_extra["example"]
directory = os.path.dirname(__file__)
content["lattice_input"]["xyz_file"] = os.path.join(directory, "XYZ", "lattice_input.dat")
model = COpyZacrosModel(**content)


Expand Down
6 changes: 2 additions & 4 deletions osp/tools/mapping_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,7 @@ def map_results(engine, root_cuds_object: Cuds) -> str:

tarball = map_tarball(engine, last_calculation[0])

elif isinstance(engine, pz.ZacrosResults):
elif isinstance(engine, pz.ZacrosJob):
search_calculation = search.find_cuds_objects_by_oclass(
emmo.MesoscopicCalculation, root_cuds_object,
rel=cuba.relationship)
Expand Down Expand Up @@ -1810,10 +1810,8 @@ def map_tarball(engine, root_cuds_object, path=None) -> str:
:return str: file system path to tarball
"""

path = "plams_workdir/"

tar = tempfile.NamedTemporaryFile().name
shutil.make_archive(tar, "tar", path)
shutil.make_archive(tar, "tar", engine.path)
tar_file = f"{tar}.tar"

print(f"Job output dumped to {tar_file}")
Expand Down
7 changes: 2 additions & 5 deletions osp/wrappers/simzacros/simzacros_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
from osp.tools.io_functions import raise_error
from osp.tools.mapping_functions import map_function, map_results
from osp.core.utils import simple_search as search
from arcp import is_arcp_uri, parse_arcp
from osp.models.utils.general import get_download
import scm.pyzacros as pz
import os
from urllib.parse import parse_qs
from pathlib import Path
# from osp.core.utils import pretty_print


Expand Down Expand Up @@ -41,7 +38,7 @@ def _run(self, root_cuds_object: Cuds):
pz_job = pz.ZacrosJob(settings=pz_settings, lattice=pz_lattice,
mechanism=pz_mechanism, cluster_expansion=pz_cluster_expansion)
results = pz_job.run()
self._tarball = map_results(results, root_cuds_object)
self._tarball = map_results(pz_job, root_cuds_object)

# Attributes to easily access (syntactic) info from results.
self.get_reaction_network = results.get_reaction_network()
Expand Down Expand Up @@ -118,7 +115,7 @@ def _apply_added(self, root_obj, buffer):
lattice = search_lattice.pop()
if "file://" in str(lattice.iri):
split = str(lattice.iri).split("file://")
self.lattice = Path(split[-1]).resolve()
self.lattice = split[-1]
else:
self.lattice = get_download(str(lattice.uid), as_file=True)
else:
Expand Down

0 comments on commit d9a7a0c

Please sign in to comment.