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

Random parser improvements #239

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Conversation

ondracka
Copy link
Collaborator

Few random parser fixes, related to one Nomad datamining ongoing minithesis, authored by @SimonKratochvil and I did some initial review locally. The OpenMX and QE patches should hopefully be fine. Please double check the FHIaims patches, there I'm far from being an expert. Especially the FHIaims src_threshold_energy patch seems to introduce some normalizing issues with basis set !?!

Traceback (most recent call last):
File "/Users/simonkratochvil/Documents/nomad_parsers/nomad-pyenv/bin/nomad", line 8, in
sys.exit(run_cli())
File "/Users/simonkratochvil/Documents/nomad_parsers/nomad/nomad/cli/cli.py", line 76, in run_cli
return cli(obj=POPO()) # pylint: disable=E1120,E1123
File "/Users/simonkratochvil/Documents/nomad_parsers/nomad-pyenv/lib/python3.9/site-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
File "/Users/simonkratochvil/Documents/nomad_parsers/nomad-pyenv/lib/python3.9/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/Users/simonkratochvil/Documents/nomad_parsers/nomad-pyenv/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/simonkratochvil/Documents/nomad_parsers/nomad-pyenv/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/simonkratochvil/Documents/nomad_parsers/nomad-pyenv/lib/python3.9/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/Users/simonkratochvil/Documents/nomad_parsers/nomad/nomad/cli/parse.py", line 87, in _parse
normalize_all(entry_archive)
File "/Users/simonkratochvil/Documents/nomad_parsers/nomad/nomad/client/processing.py", line 111, in normalize_all
normalize(normalizer, entry_archive, logger=logger)
File "/Users/simonkratochvil/Documents/nomad_parsers/nomad/nomad/client/processing.py", line 96, in normalize
normalizer_instance.normalize(logger=logger)
File "/Users/simonkratochvil/Documents/nomad_parsers/nomad/nomad/normalizing/init.py", line 79, in normalize
self.normalizer.normalize(self.archive, logger)
File "/Users/simonkratochvil/Documents/nomad_parsers/nomad/nomad/normalizing/results.py", line 127, in normalize
self.normalize_run(logger=self.logger)
File "/Users/simonkratochvil/Documents/nomad_parsers/nomad/nomad/normalizing/results.py", line 243, in normalize_run
results.method = MethodNormalizer(
File "/Users/simonkratochvil/Documents/nomad_parsers/nomad/nomad/normalizing/method.py", line 296, in method
simulation = DFTMethod(
File "/Users/simonkratochvil/Documents/nomad_parsers/nomad/nomad/normalizing/method.py", line 555, in simulation
self._method.method_id = self.method_id_dft(
File "/Users/simonkratochvil/Documents/nomad_parsers/nomad/nomad/normalizing/method.py", line 751, in method_id_dft
return method_dict.hash()
File "/Users/simonkratochvil/Documents/nomad_parsers/nomad/nomad/utils/init.py", line 538, in hash
hash_str = json.dumps(self, sort_keys=True)
File "/opt/homebrew/Cellar/[email protected]/3.9.19/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/init.py", line 234, in dumps
return cls(
File "/opt/homebrew/Cellar/[email protected]/3.9.19/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/opt/homebrew/Cellar/[email protected]/3.9.19/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/opt/homebrew/Cellar/[email protected]/3.9.19/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type x_fhi_aims_section_controlIn_basis_set is not JSON serializable

The FHIaims test failures should be preexisting.

@ndaelman-hu
Copy link
Contributor

@ondracka I'll plan your this review in for tomorrow

Copy link
Contributor

@ndaelman-hu ndaelman-hu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just minor modifications, thx for the contribution!

Comment on lines 87 to 89
re_float = r'[-+]?\d+\.\d*(?:[Ee][-+]\d+)?'
re_float = r'[-+]?\d+\.*\d*(?:[Ee][-+]\d+)?'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to support cases like 124e-2?
If you consider the decimal optional, maybe use ? instead of *.

Comment on lines 2210 to 2214
'integer': None,
'cubic': None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should add integer and cubic to the main schema? Any suggested names?
Note that in the new schema, you'll be able to extend the definition yourself.

'cold': 'marzari-vanderbilt',
}

sec_smearing.kind = occupation_types_dict.get(val[0])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a try block to capture IndexError

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And include val[1] too, pls

}

sec_smearing.kind = occupation_types_dict.get(val[0])
# width is defined as unitless in the metainfo (should be Joules)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, let me add this as a TODO.

@@ -2224,6 +2242,10 @@ def _prep_elemental_tier(basis_settings: MSection) -> dict[str, Any]:
if hybrid_coeff is not None:
# is it necessary to check if xc is a hybrid type aside from hybrid_coeff
sec_method.x_fhi_aims_controlIn_hybrid_xc_coeff = hybrid_coeff
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other TODO for me:

The old schema has the alpha parameter (exact_exchange_mixing_factor) in the results, but now I see that it's missing this in run. data has it again, so the future parser should use that naming.

electronicparsers/openmx/parser.py Show resolved Hide resolved
kpoints_multiplicities.append(2)
sec_k_mesh.points = np.array(kpoints).astype(complex)
sec_k_mesh.multiplicities = kpoints_multiplicities
eigenvalues.kpoints_multiplicities = kpoints_multiplicities
else:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a comment saying # fall back to gamma-point

Copy link
Collaborator Author

@ondracka ondracka Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe
# if no explicit k-points are written we have gamma-point only

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have your request about the k-line density scheduled next.

tests/test_openmxparser.py Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the name of test_C2N2 be test_C2H2 instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants