Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

49 add support for h5md files #71

Merged
merged 52 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
3527305
created h5md parser shell
Jun 20, 2023
5143419
basic parser structure / code
Jun 21, 2023
c9356d8
parse system and method complete, parse calculation in progress
Jul 3, 2023
ff42201
fixed connection to nomad and debugging parse_method
Jul 5, 2023
ae740d9
finished with all basic parsing functions
Jul 26, 2023
259d69f
added bond_list to atoms and atomsgroup
Jul 26, 2023
fd48534
added bond_list to system[0].atoms in gromacs parser
Jul 26, 2023
1b279bf
adjusted gromacs tests for interaction groupings
Jul 26, 2023
c58d1fc
reorganized interactions in lammps parse_method into groups, created …
Jul 27, 2023
2055c40
started tests for h5md
Jul 28, 2023
8504180
done with initial tests except workflow results
Aug 9, 2023
0c17b8b
added basic metainfo for h5md atoms_group parameters unknown
Aug 9, 2023
f2534a5
added custom params to atoms_group
Aug 9, 2023
feef71d
fixing setting of attributes in parse_calc
Aug 9, 2023
dcf303f
implemented custom calculations and atomsgroup params
Aug 9, 2023
094a82d
start link to H5MD-NOMAD docs
Aug 15, 2023
192afa2
saving changes
Sep 18, 2023
7d5aa79
starting to implement workflow results
Sep 19, 2023
3017a37
working on parse_workflow
Sep 20, 2023
34c5bb6
added basic parsing of ensemble properties
Sep 20, 2023
54b2aa3
comment
Sep 21, 2023
0097f57
finished basic workflow results parsing
Oct 23, 2023
2c06b4a
added list to thermostat params
Oct 30, 2023
cce0902
added back MDParser class
Oct 30, 2023
f6f74b8
fixed rebasing issues in lammps parser (sec_system definition was acc…
Oct 30, 2023
ebcb04a
basic separation of hdf5 and h5md parsers
Nov 1, 2023
48ce5c6
corrected new metadata names in Interactions
Nov 6, 2023
2d2cc7d
removed some commented out older code
Nov 7, 2023
54d2469
recovered previous lammps parser from #72 after rebasing error
Nov 22, 2023
d7724e9
recovered previous gromacs parser from #72 after rebasing error
Nov 22, 2023
395e812
implemented super-parser for parse_calculation, not yet tested
Dec 6, 2023
d433122
working on integrating MDParser to H5MD
Dec 11, 2023
525a6ab
implemented MDParser up to parse_calculation() in H5MD parser
Dec 11, 2023
ffbda4a
finished with mdworkflow method + MDParser with H5MD
Dec 11, 2023
1e8e478
integrated super parser for H5MD
Dec 12, 2023
15ac3fd
only access outer hdf5 groups once
Dec 12, 2023
9cfb1af
partial fixes from Alvin's review
Dec 13, 2023
b6a9aeb
added metainfo for x_h5md_parameters for force calculations, and impl…
Dec 14, 2023
da9a36a
more review fixes
Dec 14, 2023
c616845
shifted get_workflow_results() to class method
Dec 15, 2023
1040c59
another round of review fixes
Dec 15, 2023
e69637c
reorg observable_info by time
Dec 18, 2023
0d9007c
direct definitions of h5md groups
Dec 18, 2023
f6bcf84
made several of the former class properties simply defined as private…
Dec 19, 2023
793138e
changed xxx_info() to parse functions (not properties)
Dec 19, 2023
704c5b0
completely redid parsing of system_info, system, observable_info, obs…
Dec 19, 2023
869266f
implemented initial functionality of the parse function within the hd…
Jan 12, 2024
1fa25cf
full implementation of parse() with old code commented
Jan 15, 2024
4f11fa2
removed comments and clean
Jan 15, 2024
c3e86df
test in raw file units
Jan 15, 2024
28f3b73
most 2nd review changes
Jan 16, 2024
71b5133
more changes from review #2
Jan 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions atomisticparsers/h5md/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This is a NOMAD parser for the [H5MD](http://www.??.org/) schema for hdf5 files. It will read
an hdf5 file and transform the content into NOMAD's unified Metainfo based Archive format according to the H5MD schema.



19 changes: 19 additions & 0 deletions atomisticparsers/h5md/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD.
# See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from .parser import H5MDParser
31 changes: 31 additions & 0 deletions atomisticparsers/h5md/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD.
# See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import sys
import json
import logging

from nomad.utils import configure_logging
from nomad.datamodel import EntryArchive
from atomisticparsers.h5md import H5MDParser

if __name__ == "__main__":
configure_logging(console_log_level=logging.DEBUG)
archive = EntryArchive()
H5MDParser().parse(sys.argv[1], archive, logging)
json.dump(archive.m_to_dict(), sys.stdout, indent=2)
24 changes: 24 additions & 0 deletions atomisticparsers/h5md/metainfo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD.
# See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from nomad.metainfo import Environment

from . import h5md

m_env = Environment()
m_env.m_add_sub_section(Environment.packages, h5md.m_package)
190 changes: 190 additions & 0 deletions atomisticparsers/h5md/metainfo/h5md.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD.
# See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import numpy as np # pylint: disable=unused-import
import typing # pylint: disable=unused-import
from nomad.metainfo import ( # pylint: disable=unused-import
MSection, MCategory, Category, Package, Quantity, Section, SubSection, SectionProxy,
Reference
)
from nomad.datamodel.metainfo import simulation


m_package = Package()


class ParamEntry(MSection):
'''
Generic section defining a parameter name and value
'''

m_def = Section(validate=False)

kind = Quantity(
type=str,
shape=[],
description='''
Name of the parameter.
''')

value = Quantity(
type=str,
shape=[],
description='''
Value of the parameter as a string.
''')

unit = Quantity(
type=str,
shape=[],
description='''
Unit of the parameter as a string.
''')

# TODO add description quantity


class CalcEntry(MSection):
'''
Section describing a general type of calculation.
'''

m_def = Section(validate=False)

kind = Quantity(
type=str,
shape=[],
description='''
Kind of the quantity.
''')

value = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
Value of this contribution.
''')

unit = Quantity(
type=str,
shape=[],
description='''
Unit of the parameter as a string.
''')

# TODO add description quantity

class ForceCalculations(simulation.method.ForceCalculations):

m_def = Section(validate=False, extends_base_section=True,)

x_h5md_parameters = SubSection(
sub_section=ParamEntry.m_def,
description='''
Contains non-normalized force calculation parameters.
''',
repeats=True)

class NeighborSearching(simulation.method.NeighborSearching):

m_def = Section(validate=False, extends_base_section=True,)

x_h5md_parameters = SubSection(
sub_section=ParamEntry.m_def,
description='''
Contains non-normalized neighbor searching parameters.
''',
repeats=True)

class AtomsGroup(simulation.system.AtomsGroup):
'''
Describes a group of atoms which may constitute a sub system as in the case of a
molecule.
'''

m_def = Section(validate=False, extends_base_section=True,)

x_h5md_parameters = SubSection( # TODO should this be called parameters or attributes or what?
sub_section=ParamEntry.m_def,
description='''
Contains additional information about the atom group .
''',
repeats=True)


class Calculation(simulation.calculation.Calculation):

m_def = Section(validate=False, extends_base_section=True,)

x_h5md_custom_calculations = SubSection(
sub_section=ParamEntry.m_def,
description='''
Contains other generic custom calculations that are not already defined.
''',
repeats=True)


class Energy(simulation.calculation.Energy):

m_def = Section(validate=False, extends_base_section=True,)

x_h5md_energy_contributions = SubSection(
sub_section=simulation.calculation.EnergyEntry.m_def,
description='''
Contains other custom energy contributions that are not already defined.
''',
repeats=True)


class Author(MSection):
'''
Contains the specifications of the program.
'''

m_def = Section(validate=False)

name = Quantity(
type=str,
shape=[],
description='''
Specifies the name of the author who generated the h5md file.
''',)

email = Quantity(
type=str,
shape=[],
description='''
Author's email.
''',)


class Run(simulation.run.Run):

m_def = Section(validate=False, extends_base_section=True,)

# TODO Not sure how we are dealing with versioning with H5MD-NOMAD
x_h5md_version = Quantity(
type=np.dtype(np.int32),
shape=[2],
description='''
Specifies the version of the h5md schema being followed.
''',)

x_h5md_author = SubSection(sub_section=Author.m_def)

x_h5md_creator = SubSection(sub_section=simulation.run.Program.m_def)
19 changes: 19 additions & 0 deletions atomisticparsers/h5md/nomad_plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
code_category: Atomistic code
# code_homepage: http://www.??.org/
# TODO is this the correct category
code_name: H5MD
metadata:
codeCategory: Atomistic code
codeLabel: H5MD
codeLabelStyle: All in capitals
codeName: h5md
# codeUrl: http://www.??.org/
parserDirName: dependencies/parsers/atomistic/atomisticparsers/h5md/
parserGitUrl: https://github.com/nomad-coe/atomistic-parsers.git
parserSpecific: ''
preamble: ''
status: production
tableOfFiles: ''
name: parsers/h5md
parser_class_name: atomisticparsers.h5md.parser.H5MDParser
python_package: atomisticparsers.h5md