From dbf6b62379d3e05eacc6c4a755e1ee55c5694804 Mon Sep 17 00:00:00 2001 From: Martin Kuban <kuban@physik.hu-berlin.de> Date: Mon, 15 Jun 2020 12:57:54 +0200 Subject: [PATCH] added meta-info section for DOS fingerprint --- nomad/datamodel/metainfo/public.py | 57 ++++++++++++++++++++++++++---- nomad/normalizing/dos.py | 10 ++++-- 2 files changed, 58 insertions(+), 9 deletions(-) diff --git a/nomad/datamodel/metainfo/public.py b/nomad/datamodel/metainfo/public.py index 48b8aa013e..1a59bea80d 100644 --- a/nomad/datamodel/metainfo/public.py +++ b/nomad/datamodel/metainfo/public.py @@ -1201,6 +1201,56 @@ class section_calculation_to_folder_refs(MSection): a_legacy=LegacyDefinition(name='calculation_to_folder_kind')) +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 + (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=int, + shape=['first_index_of_DOS_grid', 'last_index_of_DOS_grid'], + description=''' + Indices used to compare DOS fingerprints of different energy ranges. + ''', + a_legacy=LegacyDefinition(name='indices')) + + stepsize = Quantity( + type=np.dtype(np.float64), + shape=[], + description=''' + 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. + ''', + a_legacy=LegacyDefinition(name='filling_factor')) + + grid_id = Quantity( + type=str, + description=''' + Identifier of the DOS grid that was used for the creation of the fingerprint. + Similarity can only be calculated if the same grid was used for both fingerprints. + ''', + a_legacy=LegacyDefinition(name='grid_id')) + + class section_dos(MSection): ''' Section collecting information of a (electronic-energy or vibrational-energy) density @@ -1333,12 +1383,7 @@ 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')) + dos_fingerprint = SubSection(section_dos_fingerprint, repeats=False) class section_eigenvalues(MSection): diff --git a/nomad/normalizing/dos.py b/nomad/normalizing/dos.py index 58570fc2ad..ab2cf27f8d 100644 --- a/nomad/normalizing/dos.py +++ b/nomad/normalizing/dos.py @@ -67,12 +67,16 @@ class DosNormalizer(Normalizer): # 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()) + dos_fingerprint = DOSFingerprint().calculate(np.array(dos_energies), dos_normed) # 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 + 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) -- GitLab