Skip to content

Instantly share code, notes, and snippets.

@jmmshn
Created November 13, 2018 23:02
Show Gist options
  • Save jmmshn/b545cca24905252646008233f4cf5eef to your computer and use it in GitHub Desktop.
Save jmmshn/b545cca24905252646008233f4cf5eef to your computer and use it in GitHub Desktop.
[check_struct_fws] Check if a given structure is in the fireworks db
from maggma.stores import MongoStore
from pymatgen.analysis.structure_matcher import StructureMatcher, ElementComparator
from pymatgen import Structure
sm = StructureMatcher(comparator=ElementComparator(),
primitive_cell=False)
def check_fws( struct_in ):
js_fw_store = MongoStore("", "",
host="",
username="",
password="",
lu_field="last_updated")
js_fw_store.connect()
res = js_fw_store.query({ "spec._tasks.1.structure": { "$exists": True },
'name':'{}-structure optimization'.format(struct_in.composition.reduced_formula)
})
for itr in res:
struct_db = Structure.from_dict(itr['spec']['_tasks'][1]['structure'])
if sm.fit(struct_db, struct_in):
matches += 1
return True
else:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment