httk quickstart: analysis

httk-analysis provides a number of helpful tools to analyse computational results.

Draw a phase diagram

from httk.analyse.matsci import PhaseDiagram
from httk.atomistic import UnitcellStructureView
from httk.atomistic.storage.records import UnitcellStructureRecord
from httk.core import DataRecord
from httk.store import SqliteStore
from httk.store.optimade import OptimadeStore

# This example fetches structures from the MaterialsProject database via OPTIMADE
store = OptimadeStore("https://optimade.materialsproject.org/")
# Using your own database is of course also fine, e.g.:
#   store = SqliteStore("database.sqlite")

search = store.searcher()
structure = search.variable(store.entry_type("structures"))
search.add(structure.elements.has_only("Ca", "O", "Ti"))

structures, energies = [], []
for row in search.results(structure=structure, record=record):
    structures.append(row.structure)
    energies.append(row.record.value)

labels = [UnitcellStructureView(structure).chemical_formula_reduced for structure in structures]
pd = PhaseDiagram.from_structures(structures, energies, ids=labels)
stable = {labels[index] for index in pd.hull_indices}
print("stable", sorted(stable))
print("energy above hull", dict(zip(labels, pd.energy_above_hull)))

More

The top-site data guide gives the ecosystem overview. The full database details cover child tables and references, content-based deduplication, cursors, store federation, and serving a store over the OPTIMADE protocol.