In [1]:
# Import modules.
import os
import ase.db
from ase.visualize import view
from catmap.api.cathub import CatalysisHub
In [2]:
# Instantiate cathub interface object.
cathub = CatalysisHub()
# GraphQL search string to the publications table.
publication = "WO3 surface doping for OER to be published"
Formation energies as used by CatMAP are simply reaction energies with respect to a fixed reference. Therefore, you only need to query for reactions from the relevant gas phase references, in order to download the relevant set of formation energies.
In [3]:
# Choose your references.
references = ['H2gas', 'H2Ogas']
# Fetch energies and create an EnergyLandscape object.
energy_landscape = cathub.publication_energy_landscape(publication, references, site_specific=True, limit=10)
We have now retrieved a list of dictionaries, reactions
. The reaction energies can be attached to a catmap.api.energy_landscape
object as formation energies.
In [4]:
# Take a peak.
energy_landscape.formation_energies
Out[4]:
Finally, as usual, we export a CatMAP input file.
In [9]:
fname = 'my_energies.txt'
energy_landscape.make_input_file(fname)
In [11]:
# Take a peak at the file.
with open(fname) as fp:
for line in fp.readlines()[:5]:
print(line)
Notice the reference
column contains catalysis-hub ids corresponding to the atomic structure.
Next, we will retrieve atomic structures from the publication.
In [12]:
# Return a list of atoms objects.
images = cathub.get_publication_atoms(publication, limit=10)
# This may take time due to a GraphQL query per atom object.
Finally, we can save them to an ase database, keeping the catalysis-hub ids, to connect them with the energy data file.
In [13]:
# Save them to an ASE-db file.
os.remove('my_asedb.db')
c = ase.db.connect('my_asedb.db')
for atoms in images:
c.write(atoms, key_value_pairs=atoms.info['key_value_pairs'])
In [ ]:
# Alternative approach.
pubid = cathub.get_publication_uids
unique_ids = cathub.get_publication_uids