Commit de98ab67 authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Updated prototype data to be only specified if a match is found.

parent 45facd26
Pipeline #68942 passed with stages
in 16 minutes and 45 seconds
......@@ -479,35 +479,28 @@ class SystemNormalizer(SystemBasedNormalizer):
if (class_test or comp_test) is False:
self.logger.warning('Mismatch in Springer classification or compounds')
def prototypes(self, atomSpecies, wyckoffs, spg_nr):
try:
norm_wyckoff = structure.get_normalized_wyckoff(atomSpecies, wyckoffs)
protoDict = structure.search_aflow_prototype(spg_nr, norm_wyckoff)
def prototypes(self, atom_species: np.array, wyckoffs: np.array, spg_number: int) -> None:
"""Tries to match the material to an entry in the AFLOW prototype data.
If a match is found, a section_prototype is added to section_system.
if protoDict is None:
proto = "%d-_" % spg_nr
labels = dict(prototype_label=proto)
else:
proto = '%d-%s-%s' % (spg_nr, protoDict.get("Prototype", "-"),
protoDict.get("Pearsons Symbol", "-"))
aflow_prototype_id = protoDict.get("aflow_prototype_id", "-")
aflow_prototype_url = protoDict.get("aflow_prototype_url", "-")
labels = dict(
prototype_label=proto,
prototype_aflow_id=aflow_prototype_id,
prototype_aflow_url=aflow_prototype_url)
except Exception as e:
self.logger.error("cannot create AFLOW prototype", exc_info=e)
return
pSect = self._backend.openSection("section_prototype")
self._backend.addValue(
"prototype_assignement_method", "normalized-wyckoff")
self._backend.addValue("prototype_label", labels['prototype_label'])
aid = labels.get("prototype_aflow_id")
if aid:
self._backend.addValue("prototype_aflow_id", aid)
aurl = labels.get("prototype_aflow_url")
if aurl:
self._backend.addValue("prototype_aflow_url", aurl)
self._backend.closeSection("section_prototype", pSect)
Args:
atomic_numbers: Array of atomic numbers.
wyckoff_letters: Array of Wyckoff letters as strings.
spg_number: Space group number.
"""
norm_wyckoff = structure.get_normalized_wyckoff(atom_species, wyckoffs)
protoDict = structure.search_aflow_prototype(spg_number, norm_wyckoff)
if protoDict is not None:
aflow_prototype_id = protoDict["aflow_prototype_id"]
aflow_prototype_url = protoDict["aflow_prototype_url"]
prototype_label = '%d-%s-%s' % (
spg_number,
protoDict.get("Prototype", "-"),
protoDict.get("Pearsons Symbol", "-")
)
pSect = self._backend.openSection("section_prototype")
self._backend.addValue("prototype_label", prototype_label)
self._backend.addValue("prototype_aflow_id", aflow_prototype_id)
self._backend.addValue("prototype_aflow_url", aflow_prototype_url)
self._backend.addValue("prototype_assignement_method", "normalized-wyckoff")
self._backend.closeSection("section_prototype", pSect)
......@@ -361,41 +361,64 @@ def test_vasp_incar_system():
def test_aflow_prototypes():
"""Tests that some basis structures are matched with the correct AFLOW prototypes
"""
# No prototype info for non-bulk structures
backend = run_normalize_for_structure(ase.build.molecule("H2O"))
assert len(backend["section_prototype"]) == 0
# No prototype info for bulk structure without match
rattled = ase.build.bulk("C", crystalstructure="diamond", a=3.57, cubic=True)
rattled.rattle(stdev=2, seed=42)
rattled.wrap()
backend = run_normalize_for_structure(rattled)
assert len(backend["section_prototype"]) == 0
# Diamond
diamond = ase.build.bulk("C", crystalstructure="diamond", a=3.57)
backend = run_normalize_for_structure(diamond)
prototype_aflow_id = backend.get_value("prototype_aflow_id")
prototype_label = backend.get_value("prototype_label")
assert prototype_aflow_id == "A_cF8_227_a"
assert prototype_label == "227-C-cF8"
# BCC
bcc = ase.build.bulk("Fe", crystalstructure="bcc", a=2.856)
backend = run_normalize_for_structure(bcc)
prototype_aflow_id = backend.get_value("prototype_aflow_id")
prototype_label = backend.get_value("prototype_label")
assert prototype_aflow_id == "A_cI2_229_a"
assert prototype_label == "229-W-cI2"
# FCC
fcc = ase.build.bulk("Ge", crystalstructure="fcc", a=5.658)
backend = run_normalize_for_structure(fcc)
prototype_aflow_id = backend.get_value("prototype_aflow_id")
prototype_label = backend.get_value("prototype_label")
assert prototype_aflow_id == "A_cF4_225_a"
assert prototype_label == "225-Cu-cF4"
# Rocksalt
rocksalt = ase.build.bulk("NaCl", crystalstructure="rocksalt", a=5.64)
backend = run_normalize_for_structure(rocksalt)
prototype_aflow_id = backend.get_value("prototype_aflow_id")
prototype_label = backend.get_value("prototype_label")
assert prototype_aflow_id == "AB_cF8_225_a_b"
assert prototype_label == "225-ClNa-cF8"
# Zincblende
zincblende = ase.build.bulk("ZnS", crystalstructure="zincblende", a=5.42, cubic=True)
backend = run_normalize_for_structure(zincblende)
prototype_aflow_id = backend.get_value("prototype_aflow_id")
prototype_label = backend.get_value("prototype_label")
assert prototype_aflow_id == "AB_cF8_216_c_a"
assert prototype_label == "216-SZn-cF8"
# Wurtzite
wurtzite = ase.build.bulk("SiC", crystalstructure="wurtzite", a=3.086, c=10.053)
backend = run_normalize_for_structure(wurtzite)
prototype_aflow_id = backend.get_value("prototype_aflow_id")
prototype_label = backend.get_value("prototype_label")
assert prototype_aflow_id == "AB_hP4_186_b_b"
assert prototype_label == "186-SZn-hP4"
def test_springer_normalizer():
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment