Commit 4678766c authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Added dos fingerprints to dependencies. Minor liniting.

parent 5f91b4c6
Pipeline #76628 failed with stages
in 22 minutes and 28 seconds
......@@ -191,3 +191,6 @@
[submodule "dependencies/parsers/tinker"]
path = dependencies/parsers/tinker
url = https://gitlab.mpcdf.mpg.de/nomad-lab/parser-tinker.git
[submodule "dependencies/nomad-dos-fingerprints"]
path = dependencies/nomad-dos-fingerprints
url = https://gitlab.mpcdf.mpg.de/nomad-lab/nomad-dos-fingerprints.git
Subproject commit bb633623789ee9850873ba0b16a32c66c8265558
......@@ -1204,20 +1204,20 @@ class section_calculation_to_folder_refs(MSection):
class section_dos_fingerprint(MSection):
'''
Section for the fingerprint of the electronic density-of-states (DOS).
DOS fingerprints are a modification of the D-Fingerprints reported in Chem. Mater. 2015, 27, 3, 735–743
DOS fingerprints are a modification of the D-Fingerprints reported in Chem. Mater. 2015, 27, 3, 735–743
(doi:10.1021/cm503507h). The fingerprint consists of a binary representation of the DOS,
that is used to evaluate the similarity of materials based on their electronic structure.
'''
m_def = Section(validate=False, a_legacy=LegacyDefinition(name='section_dos_fingerprint'))
bins = Quantity(
type=str,
description='''
Byte representation of the DOS fingerprint.
''',
a_legacy=LegacyDefinition(name='bins'))
indices = Quantity(
type=np.dtype(np.int16),
shape=['first_index_of_DOS_grid', 'last_index_of_DOS_grid'],
......@@ -1225,7 +1225,7 @@ class section_dos_fingerprint(MSection):
Indices used to compare DOS fingerprints of different energy ranges.
''',
a_legacy=LegacyDefinition(name='indices'))
stepsize = Quantity(
type=np.dtype(np.float64),
shape=[],
......@@ -1233,15 +1233,15 @@ class section_dos_fingerprint(MSection):
Stepsize of interpolation in the first step of the generation of DOS fingerprints.
''',
a_legacy=LegacyDefinition(name='stepsize'))
filling_factor = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
Proportion of 1 bins in the DOS fingerprint.
Proportion of 1 bins in the DOS fingerprint.
''',
a_legacy=LegacyDefinition(name='filling_factor'))
grid_id = Quantity(
type=str,
description='''
......@@ -1250,6 +1250,7 @@ class section_dos_fingerprint(MSection):
''',
a_legacy=LegacyDefinition(name='grid_id'))
class section_dos(MSection):
'''
Section collecting information of a (electronic-energy or vibrational-energy) density
......@@ -1383,11 +1384,11 @@ class section_dos(MSection):
a_legacy=LegacyDefinition(name='number_of_dos_values'))
section_dos_fingerprint = SubSection(
sub_section = SectionProxy('section_dos_fingerprint'),
sub_section=SectionProxy('section_dos_fingerprint'),
repeats=False,
a_legacy=LegacyDefinition(name='section_dos_fingerprint'))
class section_eigenvalues(MSection):
'''
Section containing (electronic-energy) eigenvalues for one spin channel. If, for
......
......@@ -18,6 +18,7 @@ import numpy as np
from nomad_dos_fingerprints import DOSFingerprint
class DosNormalizer(Normalizer):
def normalize(self, logger=None) -> None:
......@@ -64,19 +65,24 @@ class DosNormalizer(Normalizer):
# Final quantities
dos_normed = dos_values / (number_of_atoms * unit_cell_volume)
# Data for DOS fingerprint
dos_energies = dos.dos_energies
dos_fingerprint = DOSFingerprint().calculate(np.array(dos_energies), dos_normed)
dos_fingerprint = None
try:
dos_energies = dos.dos_energies
dos_fingerprint = DOSFingerprint().calculate(np.array(dos_energies), dos_normed)
except Exception as e:
logger.error('could not generate dos fingerprint', exc_info=e)
# 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
sec_dos_fingerprint = dos.m_create(section_dos_fingerprint)
sec_dos_fingerprint.bins = dos_fingerprint.bins
sec_dos_fingerprint.indices = dos_fingerprint.indices
sec_dos_fingerprint.stepsize = dos_fingerprint.stepsize
sec_dos_fingerprint.grid_id = dos_fingerprint.grid_id
sec_dos_fingerprint.filling_factor = dos_fingerprint.filling_factor
if dos_fingerprint is not None:
sec_dos_fingerprint = dos.m_create(section_dos_fingerprint)
sec_dos_fingerprint.bins = dos_fingerprint.bins
sec_dos_fingerprint.indices = dos_fingerprint.indices
sec_dos_fingerprint.stepsize = dos_fingerprint.stepsize
sec_dos_fingerprint.grid_id = dos_fingerprint.grid_id
sec_dos_fingerprint.filling_factor = dos_fingerprint.filling_factor
self._backend.closeContext(scc_url)
......@@ -35,6 +35,7 @@ parmed==3.0.0
mdtraj
mdanalysis
nomadcore
nomadDOSfingerprints
# [infrastructure]
optimade
......
......@@ -19,7 +19,6 @@ from tests.normalizing.conftest import run_normalize
from nomad_dos_fingerprints import DOSFingerprint, tanimoto_similarity
import matplotlib.pyplot as plt
vasp_parser_dos = (
'parsers/vasp', 'tests/data/parsers/vasp/vasp_dos.xml')
......@@ -43,12 +42,10 @@ def test_dos_normalizer():
# Check if DOS fingerprint was created
backend_dos_fingerprint = backend['section_dos_fingerprint'][0]
dos_fingerprint = DOSFingerprint().from_dict(dict(
bins = backend_dos_fingerprint.bins,
indices = backend_dos_fingerprint.indices,
grid_id = backend_dos_fingerprint.grid_id,
stepsize = backend_dos_fingerprint.stepsize,
filling_factor = backend_dos_fingerprint.filling_factor))
bins=backend_dos_fingerprint.bins,
indices=backend_dos_fingerprint.indices,
grid_id=backend_dos_fingerprint.grid_id,
stepsize=backend_dos_fingerprint.stepsize,
filling_factor=backend_dos_fingerprint.filling_factor))
assert tanimoto_similarity(dos_fingerprint, dos_fingerprint) == 1
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