Skip to content

Commit

Permalink
Fix/parsing lattice file (#18)
Browse files Browse the repository at this point in the history
*  make references to original file instead of parsing them

* update code with respect to parsing of structures

* update unit tests

* debug energy landscape refinement

* debug adp

* update syntactic settings

* update wrapper tools for binding site calculation

* update defaults in syntactic settings

* make neighbour cut off optional in PES exploration

* update wrong variable

* update bad indent

* debug initializing mesoscale model

* mute neighbour cut off mapping for now

* update default value for neighbor cut off

* update wrong variable for process parallelization

* update retrieval of mechanisms

* update mode of temporary files

* add function to replace site types

* debug: print molar fractions and gas species

* uncomment unneeded code lines

* comment further lines for debug

* debug:comment unneeded lines for cluster expansion

* debug: comment unneeded lines

* debug:update list indexing

* move pz job out of get_rate-function

* debug: print lattice ids

* debug: print lattice ids

* debug:add seek mechanism while writing to temp file

* debug: update wrong variable

* debug: add example which imports the graph at mesoscopic level

* mute molar fraction for O2 in ADP

* remove printing, change CO2 to CO

* add needed comma to result output var

* add needed comma in tuple

* move from list to tuple

* debug: print resulting data from scan job

* debug:print settings

* update wrapping function for snapshots, uncomment pressure division

* remove float conversion in generic setting for zacros

* also remove float conversion from other generic settings

* move float conversion to other function and add asterisk

* remove print statements, successfully run adp

* update examples

* correct indentation

* add plot and update example

* update engine paths

* update function for mapping results

* update path variables

* update path keyword

* update path variable
  • Loading branch information
MBueschelberger committed Sep 28, 2023
1 parent 0c5c437 commit 9660d1f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 20 deletions.
6 changes: 3 additions & 3 deletions examples/CO+Pt111_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
"n_gas_species": 1,
"gas_specs_names": ["CO"],
"gas_molar_fracs": [0.1],
"snapshots": ["on time", 3.5],
"snapshots": ["on logtime", 1e-8, 3.5],
"species_numbers": ["on time", 3.5],
"process_statistics": ["on time", 3.5],
"max_time": 0.00001,
},
"adp": {
"min": 0.2,
"max": 0.8,
"min": 0.001,
"max": 0.999,
"num": 5
}
}
Expand Down
Binary file added examples/apd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions examples/plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import numpy as np
import adaptiveDesignProcedure as adp
import matplotlib.pyplot as plt

path = "plams_workdir/adp.results/"

x_CO_model = np.linspace(0.001,0.999,201)
TOF_CO2_model, = adp.predict( x_CO_model.reshape(-1,1), path ).T

ax = plt.axes()
ax.set_xlabel('Molar Fraction CO', fontsize=14)
ax.set_ylabel("TOF (mol/s/site)", fontsize=14)
ax.plot(x_CO_model, TOF_CO2_model, color='red', linestyle='-', lw=2, zorder=0)
plt.tight_layout()
plt.savefig("apd.png")

7 changes: 4 additions & 3 deletions osp/tools/mapping_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1577,7 +1577,7 @@ def map_energies(root_cuds_object: Cuds) -> list:
return electronic_energy_values


def map_results(engine, root_cuds_object: Cuds) -> str:
def map_results(engine, root_cuds_object: Cuds, path:str=None) -> str:
"""
Add main results to the Cuds (Wrapper) object.
Expand Down Expand Up @@ -1760,7 +1760,7 @@ def map_results(engine, root_cuds_object: Cuds) -> str:
search_calculation = search.find_cuds_objects_by_oclass(
emmo.MesoscopicCalculation, root_cuds_object,
rel=cuba.relationship)
tarball = map_tarball(engine, search_calculation[0])
tarball = map_tarball(engine, search_calculation[0], path=path)

else:
raise_error(file=os.path.basename(__file__), function=map_results.__name__,
Expand Down Expand Up @@ -1901,9 +1901,10 @@ def map_tarball(engine, root_cuds_object, path=None) -> str:
:return str: file system path to tarball
"""
path = path or engine.path

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

print(f"Job output dumped to {tar_file}")
Expand Down
28 changes: 14 additions & 14 deletions osp/wrappers/simzacros/simzacros_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,26 @@ def get_rate( conditions ):
uuid = get_upload(adpML.forestFileForCFD)
pkl = emmo.PKLFile(uid=UUID(uuid))
self.adp_cuds.add(pkl, rel=emmo.hasOutput)
self._tarball = map_results(pz_job, root_cuds_object, path=self.workdir)

else:
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(pz_job, root_cuds_object)

# Attributes to easily access (syntactic) info from results.
self.get_reaction_network = results.get_reaction_network()
self.provided_quantities_names = results.provided_quantities_names()
self.provided_quantities = results.provided_quantities()
self.number_of_lattice_sites = results.number_of_lattice_sites()
self.gas_species_names = results.gas_species_names()
self.surface_species_names = results.surface_species_names()
self.site_type_names = results.site_type_names()
self.number_of_snapshots = results.number_of_snapshots()
self.number_of_process_statistics = results.number_of_process_statistics()
self.elementary_steps_names = results.elementary_steps_names()

# Attributes to easily access (syntactic) info from results.
self.get_reaction_network = results.get_reaction_network()
self.provided_quantities_names = results.provided_quantities_names()
self.provided_quantities = results.provided_quantities()
self.number_of_lattice_sites = results.number_of_lattice_sites()
self.gas_species_names = results.gas_species_names()
self.surface_species_names = results.surface_species_names()
self.site_type_names = results.site_type_names()
self.number_of_snapshots = results.number_of_snapshots()
self.number_of_process_statistics = results.number_of_process_statistics()
self.elementary_steps_names = results.elementary_steps_names()

self._tarball = map_results(pz_job, root_cuds_object)
# OVERRIDE
def _load_from_backend(self, uids, expired=None):
"""Load the cuds object from the simulation engine."""
Expand Down

0 comments on commit 9660d1f

Please sign in to comment.