Commit 7e907d39 authored by Martin Kuban's avatar Martin Kuban
Browse files

added fingerprints; WIP Quantity description; WIP documentation

parent 6677d66e
Pipeline #76586 failed with stages
in 18 minutes and 44 seconds
......@@ -1333,7 +1333,14 @@ class section_dos(MSection):
''',
a_legacy=LegacyDefinition(name='number_of_dos_values'))
dos_fingerprint = Quantity(
type=str,
description='''
The DOS fingerprint.
''',
a_legacy=LegacyDefinition(name='dos_fingerprint'))
class section_eigenvalues(MSection):
'''
Section containing (electronic-energy) eigenvalues for one spin channel. If, for
......
......@@ -15,6 +15,8 @@
from .normalizer import Normalizer
import numpy as np
from nomad_dos_fingerprints import DOSFingerprint
import json
class DosNormalizer(Normalizer):
......@@ -62,9 +64,15 @@ class DosNormalizer(Normalizer):
# Final quantities
dos_normed = dos_values / (number_of_atoms * unit_cell_volume)
# Data for DOS fingerprint
dos_energies = dos.dos_energies
print(type(dos_energies))
dos_fingerprint = json.dumps(DOSFingerprint().calculate(np.array(dos_energies), dos_normed).to_dict())
# Add quantities to NOMAD's Metainfo
scc_url = '/section_run/0/section_single_configuration_calculation/%d/section_dos/0' % scc.m_parent_index
self._backend.openContext(scc_url)
dos.dos_values_normalized = dos_normed
dos.dos_fingerprint = dos_fingerprint
self._backend.closeContext(scc_url)
......@@ -17,6 +17,8 @@ import numpy as np
from tests.test_parsing import parse_file
from tests.normalizing.conftest import run_normalize
from nomad_dos_fingerprints import DOSFingerprint, tanimoto_similarity
import json
vasp_parser_dos = (
'parsers/vasp', 'tests/data/parsers/vasp/vasp_dos.xml')
......@@ -36,3 +38,11 @@ def test_dos_normalizer():
expected = 1.7362195274239454e+47
# Compare floats properly with numpy (delta tolerance involved)
assert np.allclose(last_value, expected)
# Check if DOS fingerprint was created
backend_dos_fingerprint = backend.get_value('dos_fingerprint')
dos_fingerprint = DOSFingerprint().from_dict(json.loads(backend_dos_fingerprint))
assert tanimoto_similarity(dos_fingerprint, dos_fingerprint) == 1
\ No newline at end of file
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