nomad-parser-plugins-electronic 1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. electronicparsers/__init__.py +1162 -0
  2. electronicparsers/abacus/__init__.py +20 -0
  3. electronicparsers/abacus/__main__.py +32 -0
  4. electronicparsers/abacus/metainfo/__init__.py +19 -0
  5. electronicparsers/abacus/metainfo/abacus.py +836 -0
  6. electronicparsers/abacus/nomad_plugin.yaml +44 -0
  7. electronicparsers/abacus/parser.py +1975 -0
  8. electronicparsers/abinit/__init__.py +19 -0
  9. electronicparsers/abinit/__main__.py +31 -0
  10. electronicparsers/abinit/metainfo/__init__.py +20 -0
  11. electronicparsers/abinit/metainfo/abinit.py +871 -0
  12. electronicparsers/abinit/metainfo/abinit_autogenerated.py +6794 -0
  13. electronicparsers/abinit/nomad_plugin.yaml +43 -0
  14. electronicparsers/abinit/parser.py +1922 -0
  15. electronicparsers/ams/__init__.py +19 -0
  16. electronicparsers/ams/__main__.py +31 -0
  17. electronicparsers/ams/metainfo/__init__.py +19 -0
  18. electronicparsers/ams/metainfo/ams.py +769 -0
  19. electronicparsers/ams/nomad_plugin.yaml +19 -0
  20. electronicparsers/ams/parser.py +1849 -0
  21. electronicparsers/ams/rkf.py +620 -0
  22. electronicparsers/atk/__init__.py +19 -0
  23. electronicparsers/atk/__main__.py +31 -0
  24. electronicparsers/atk/metainfo/__init__.py +19 -0
  25. electronicparsers/atk/metainfo/atk.py +71 -0
  26. electronicparsers/atk/nomad_plugin.yaml +34 -0
  27. electronicparsers/atk/parser.py +388 -0
  28. electronicparsers/bigdft/__init__.py +19 -0
  29. electronicparsers/bigdft/__main__.py +31 -0
  30. electronicparsers/bigdft/metainfo/__init__.py +18 -0
  31. electronicparsers/bigdft/nomad_plugin.yaml +19 -0
  32. electronicparsers/bigdft/parser.py +372 -0
  33. electronicparsers/castep/__init__.py +19 -0
  34. electronicparsers/castep/__main__.py +31 -0
  35. electronicparsers/castep/metainfo/__init__.py +19 -0
  36. electronicparsers/castep/metainfo/castep.py +2481 -0
  37. electronicparsers/castep/nomad_plugin.yaml +28 -0
  38. electronicparsers/castep/parser.py +1680 -0
  39. electronicparsers/charmm/__init__.py +19 -0
  40. electronicparsers/charmm/__main__.py +31 -0
  41. electronicparsers/charmm/metainfo/__init__.py +19 -0
  42. electronicparsers/charmm/metainfo/charmm.py +1931 -0
  43. electronicparsers/charmm/nomad_plugin.yaml +18 -0
  44. electronicparsers/charmm/parser.py +61 -0
  45. electronicparsers/cp2k/__init__.py +19 -0
  46. electronicparsers/cp2k/__main__.py +31 -0
  47. electronicparsers/cp2k/metainfo/__init__.py +19 -0
  48. electronicparsers/cp2k/metainfo/cp2k.py +59185 -0
  49. electronicparsers/cp2k/metainfo/cp2k_general.py +1014 -0
  50. electronicparsers/cp2k/nomad_plugin.yaml +49 -0
  51. electronicparsers/cp2k/parser.py +2324 -0
  52. electronicparsers/cpmd/__init__.py +19 -0
  53. electronicparsers/cpmd/__main__.py +31 -0
  54. electronicparsers/cpmd/metainfo/__init__.py +19 -0
  55. electronicparsers/cpmd/metainfo/cpmd.py +10733 -0
  56. electronicparsers/cpmd/metainfo/cpmd_general.py +988 -0
  57. electronicparsers/cpmd/nomad_plugin.yaml +19 -0
  58. electronicparsers/cpmd/parser.py +680 -0
  59. electronicparsers/crystal/__init__.py +19 -0
  60. electronicparsers/crystal/__main__.py +31 -0
  61. electronicparsers/crystal/metainfo/__init__.py +19 -0
  62. electronicparsers/crystal/metainfo/crystal.py +619 -0
  63. electronicparsers/crystal/nomad_plugin.yaml +36 -0
  64. electronicparsers/crystal/parser.py +1745 -0
  65. electronicparsers/dmol3/__init__.py +19 -0
  66. electronicparsers/dmol3/__main__.py +31 -0
  67. electronicparsers/dmol3/metainfo/__init__.py +19 -0
  68. electronicparsers/dmol3/metainfo/dmol3.py +664 -0
  69. electronicparsers/dmol3/nomad_plugin.yaml +19 -0
  70. electronicparsers/dmol3/parser.py +750 -0
  71. electronicparsers/edmft/__init__.py +19 -0
  72. electronicparsers/edmft/__main__.py +31 -0
  73. electronicparsers/edmft/metainfo/__init__.py +19 -0
  74. electronicparsers/edmft/metainfo/edmft.py +96 -0
  75. electronicparsers/edmft/nomad_plugin.yaml +53 -0
  76. electronicparsers/edmft/parser.py +912 -0
  77. electronicparsers/elk/__init__.py +19 -0
  78. electronicparsers/elk/__main__.py +31 -0
  79. electronicparsers/elk/metainfo/__init__.py +19 -0
  80. electronicparsers/elk/metainfo/elk.py +775 -0
  81. electronicparsers/elk/nomad_plugin.yaml +19 -0
  82. electronicparsers/elk/parser.py +493 -0
  83. electronicparsers/exciting/__init__.py +19 -0
  84. electronicparsers/exciting/__main__.py +31 -0
  85. electronicparsers/exciting/metainfo/__init__.py +19 -0
  86. electronicparsers/exciting/metainfo/exciting.py +2942 -0
  87. electronicparsers/exciting/nomad_plugin.yaml +83 -0
  88. electronicparsers/exciting/parser.py +3398 -0
  89. electronicparsers/fhiaims/__init__.py +19 -0
  90. electronicparsers/fhiaims/__main__.py +31 -0
  91. electronicparsers/fhiaims/metainfo/__init__.py +19 -0
  92. electronicparsers/fhiaims/metainfo/fhi_aims.py +1565 -0
  93. electronicparsers/fhiaims/nomad_plugin.yaml +52 -0
  94. electronicparsers/fhiaims/parser.py +2582 -0
  95. electronicparsers/fleur/__init__.py +19 -0
  96. electronicparsers/fleur/__main__.py +31 -0
  97. electronicparsers/fleur/metainfo/__init__.py +19 -0
  98. electronicparsers/fleur/metainfo/fleur.py +623 -0
  99. electronicparsers/fleur/nomad_plugin.yaml +19 -0
  100. electronicparsers/fleur/parser.py +952 -0
  101. electronicparsers/fplo/__init__.py +19 -0
  102. electronicparsers/fplo/__main__.py +31 -0
  103. electronicparsers/fplo/metainfo/__init__.py +19 -0
  104. electronicparsers/fplo/metainfo/fplo.py +188 -0
  105. electronicparsers/fplo/metainfo/fplo_input_autogenerated.py +2744 -0
  106. electronicparsers/fplo/metainfo/fplo_temporaries.py +319 -0
  107. electronicparsers/fplo/nomad_plugin.yaml +19 -0
  108. electronicparsers/fplo/parser.py +42 -0
  109. electronicparsers/gamess/__init__.py +19 -0
  110. electronicparsers/gamess/__main__.py +31 -0
  111. electronicparsers/gamess/metainfo/__init__.py +19 -0
  112. electronicparsers/gamess/metainfo/gamess.py +837 -0
  113. electronicparsers/gamess/nomad_plugin.yaml +19 -0
  114. electronicparsers/gamess/parser.py +941 -0
  115. electronicparsers/gaussian/__init__.py +19 -0
  116. electronicparsers/gaussian/__main__.py +31 -0
  117. electronicparsers/gaussian/metainfo/__init__.py +19 -0
  118. electronicparsers/gaussian/metainfo/gaussian.py +1707 -0
  119. electronicparsers/gaussian/nomad_plugin.yaml +18 -0
  120. electronicparsers/gaussian/parser.py +1556 -0
  121. electronicparsers/gpaw/__init__.py +19 -0
  122. electronicparsers/gpaw/__main__.py +31 -0
  123. electronicparsers/gpaw/metainfo/__init__.py +19 -0
  124. electronicparsers/gpaw/metainfo/gpaw.py +214 -0
  125. electronicparsers/gpaw/nomad_plugin.yaml +19 -0
  126. electronicparsers/gpaw/parser.py +671 -0
  127. electronicparsers/magres/__init__.py +19 -0
  128. electronicparsers/magres/__main__.py +31 -0
  129. electronicparsers/magres/metainfo/__init__.py +19 -0
  130. electronicparsers/magres/metainfo/magres.py +110 -0
  131. electronicparsers/magres/nomad_plugin.yaml +18 -0
  132. electronicparsers/magres/parser.py +505 -0
  133. electronicparsers/molcas/__init__.py +19 -0
  134. electronicparsers/molcas/__main__.py +31 -0
  135. electronicparsers/molcas/metainfo/__init__.py +19 -0
  136. electronicparsers/molcas/metainfo/molcas.py +151 -0
  137. electronicparsers/molcas/nomad_plugin.yaml +19 -0
  138. electronicparsers/molcas/parser.py +59 -0
  139. electronicparsers/mopac/__init__.py +19 -0
  140. electronicparsers/mopac/__main__.py +31 -0
  141. electronicparsers/mopac/metainfo/__init__.py +19 -0
  142. electronicparsers/mopac/metainfo/mopac.py +79 -0
  143. electronicparsers/mopac/nomad_plugin.yaml +19 -0
  144. electronicparsers/mopac/parser.py +304 -0
  145. electronicparsers/nwchem/__init__.py +19 -0
  146. electronicparsers/nwchem/__main__.py +31 -0
  147. electronicparsers/nwchem/metainfo/__init__.py +19 -0
  148. electronicparsers/nwchem/metainfo/nwchem.py +487 -0
  149. electronicparsers/nwchem/nomad_plugin.yaml +19 -0
  150. electronicparsers/nwchem/parser.py +757 -0
  151. electronicparsers/ocean/__init__.py +19 -0
  152. electronicparsers/ocean/__main__.py +31 -0
  153. electronicparsers/ocean/metainfo/__init__.py +19 -0
  154. electronicparsers/ocean/metainfo/ocean.py +410 -0
  155. electronicparsers/ocean/nomad_plugin.yaml +37 -0
  156. electronicparsers/ocean/parser.py +344 -0
  157. electronicparsers/octopus/__init__.py +19 -0
  158. electronicparsers/octopus/__main__.py +31 -0
  159. electronicparsers/octopus/metainfo/__init__.py +19 -0
  160. electronicparsers/octopus/metainfo/octopus.py +71 -0
  161. electronicparsers/octopus/metainfo/octopus_autogenerated.py +11647 -0
  162. electronicparsers/octopus/nomad_plugin.yaml +41 -0
  163. electronicparsers/octopus/parser.py +1214 -0
  164. electronicparsers/onetep/__init__.py +19 -0
  165. electronicparsers/onetep/__main__.py +31 -0
  166. electronicparsers/onetep/metainfo/__init__.py +19 -0
  167. electronicparsers/onetep/metainfo/onetep.py +3443 -0
  168. electronicparsers/onetep/nomad_plugin.yaml +19 -0
  169. electronicparsers/onetep/parser.py +577 -0
  170. electronicparsers/openmx/__init__.py +19 -0
  171. electronicparsers/openmx/__main__.py +31 -0
  172. electronicparsers/openmx/metainfo/__init__.py +19 -0
  173. electronicparsers/openmx/metainfo/openmx.py +24 -0
  174. electronicparsers/openmx/nomad_plugin.yaml +25 -0
  175. electronicparsers/openmx/parser.py +918 -0
  176. electronicparsers/orca/__init__.py +19 -0
  177. electronicparsers/orca/__main__.py +31 -0
  178. electronicparsers/orca/metainfo/__init__.py +19 -0
  179. electronicparsers/orca/metainfo/orca.py +1448 -0
  180. electronicparsers/orca/nomad_plugin.yaml +19 -0
  181. electronicparsers/orca/parser.py +1371 -0
  182. electronicparsers/psi4/__init__.py +19 -0
  183. electronicparsers/psi4/__main__.py +31 -0
  184. electronicparsers/psi4/metainfo/__init__.py +19 -0
  185. electronicparsers/psi4/metainfo/psi4.py +372 -0
  186. electronicparsers/psi4/nomad_plugin.yaml +27 -0
  187. electronicparsers/psi4/parser.py +1362 -0
  188. electronicparsers/qball/__init__.py +19 -0
  189. electronicparsers/qball/__main__.py +31 -0
  190. electronicparsers/qball/metainfo/__init__.py +19 -0
  191. electronicparsers/qball/metainfo/qball.py +27 -0
  192. electronicparsers/qball/nomad_plugin.yaml +25 -0
  193. electronicparsers/qball/parser.py +152 -0
  194. electronicparsers/qbox/__init__.py +19 -0
  195. electronicparsers/qbox/__main__.py +31 -0
  196. electronicparsers/qbox/metainfo/__init__.py +19 -0
  197. electronicparsers/qbox/metainfo/qbox.py +490 -0
  198. electronicparsers/qbox/nomad_plugin.yaml +19 -0
  199. electronicparsers/qbox/parser.py +508 -0
  200. electronicparsers/quantumespresso/__init__.py +19 -0
  201. electronicparsers/quantumespresso/__main__.py +31 -0
  202. electronicparsers/quantumespresso/metainfo/__init__.py +19 -0
  203. electronicparsers/quantumespresso/metainfo/quantum_espresso.py +3296 -0
  204. electronicparsers/quantumespresso/nomad_plugin.yaml +31 -0
  205. electronicparsers/quantumespresso/parser.py +3594 -0
  206. electronicparsers/siesta/__init__.py +19 -0
  207. electronicparsers/siesta/__main__.py +31 -0
  208. electronicparsers/siesta/metainfo/__init__.py +19 -0
  209. electronicparsers/siesta/metainfo/siesta.py +141 -0
  210. electronicparsers/siesta/metainfo/siesta_autogenerated.py +3365 -0
  211. electronicparsers/siesta/nomad_plugin.yaml +19 -0
  212. electronicparsers/siesta/parser.py +607 -0
  213. electronicparsers/soliddmft/__init__.py +19 -0
  214. electronicparsers/soliddmft/__main__.py +31 -0
  215. electronicparsers/soliddmft/metainfo/__init__.py +19 -0
  216. electronicparsers/soliddmft/metainfo/soliddmft.py +274 -0
  217. electronicparsers/soliddmft/nomad_plugin.yaml +26 -0
  218. electronicparsers/soliddmft/parser.py +727 -0
  219. electronicparsers/tbstudio/__init__.py +19 -0
  220. electronicparsers/tbstudio/__main__.py +31 -0
  221. electronicparsers/tbstudio/metainfo/__init__.py +19 -0
  222. electronicparsers/tbstudio/metainfo/tbstudio.py +34 -0
  223. electronicparsers/tbstudio/nomad_plugin.yaml +24 -0
  224. electronicparsers/tbstudio/parser.py +412 -0
  225. electronicparsers/turbomole/__init__.py +19 -0
  226. electronicparsers/turbomole/__main__.py +31 -0
  227. electronicparsers/turbomole/metainfo/__init__.py +19 -0
  228. electronicparsers/turbomole/metainfo/turbomole.py +727 -0
  229. electronicparsers/turbomole/nomad_plugin.yaml +18 -0
  230. electronicparsers/turbomole/parser.py +1585 -0
  231. electronicparsers/utils/__init__.py +20 -0
  232. electronicparsers/utils/magres_workflow.py +61 -0
  233. electronicparsers/utils/utils.py +636 -0
  234. electronicparsers/vasp/__init__.py +19 -0
  235. electronicparsers/vasp/__main__.py +31 -0
  236. electronicparsers/vasp/metainfo/__init__.py +19 -0
  237. electronicparsers/vasp/metainfo/vasp.py +169 -0
  238. electronicparsers/vasp/metainfo/vasp_incars.py +3428 -0
  239. electronicparsers/vasp/metainfo/vasp_incarsOut.py +3428 -0
  240. electronicparsers/vasp/metainfo/vasp_incarsUnknown.py +86 -0
  241. electronicparsers/vasp/nomad_plugin.yaml +28 -0
  242. electronicparsers/vasp/parser.py +2340 -0
  243. electronicparsers/w2dynamics/__init__.py +19 -0
  244. electronicparsers/w2dynamics/__main__.py +31 -0
  245. electronicparsers/w2dynamics/metainfo/__init__.py +19 -0
  246. electronicparsers/w2dynamics/metainfo/w2dynamics.py +1270 -0
  247. electronicparsers/w2dynamics/nomad_plugin.yaml +36 -0
  248. electronicparsers/w2dynamics/parser.py +674 -0
  249. electronicparsers/wannier90/__init__.py +19 -0
  250. electronicparsers/wannier90/__main__.py +31 -0
  251. electronicparsers/wannier90/metainfo/__init__.py +19 -0
  252. electronicparsers/wannier90/metainfo/wannier90.py +56 -0
  253. electronicparsers/wannier90/nomad_plugin.yaml +34 -0
  254. electronicparsers/wannier90/parser.py +671 -0
  255. electronicparsers/wien2k/__init__.py +19 -0
  256. electronicparsers/wien2k/__main__.py +31 -0
  257. electronicparsers/wien2k/metainfo/__init__.py +19 -0
  258. electronicparsers/wien2k/metainfo/wien2k.py +783 -0
  259. electronicparsers/wien2k/nomad_plugin.yaml +18 -0
  260. electronicparsers/wien2k/parser.py +1133 -0
  261. electronicparsers/yambo/__init__.py +19 -0
  262. electronicparsers/yambo/__main__.py +31 -0
  263. electronicparsers/yambo/metainfo/__init__.py +19 -0
  264. electronicparsers/yambo/metainfo/yambo.py +577 -0
  265. electronicparsers/yambo/nomad_plugin.yaml +31 -0
  266. electronicparsers/yambo/parser.py +896 -0
  267. nomad_parser_plugins_electronic-1.0.dist-info/LICENSE +202 -0
  268. nomad_parser_plugins_electronic-1.0.dist-info/METADATA +360 -0
  269. nomad_parser_plugins_electronic-1.0.dist-info/RECORD +272 -0
  270. nomad_parser_plugins_electronic-1.0.dist-info/WHEEL +5 -0
  271. nomad_parser_plugins_electronic-1.0.dist-info/entry_points.txt +43 -0
  272. nomad_parser_plugins_electronic-1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,674 @@
1
+ #
2
+ # Copyright The NOMAD Authors.
3
+ #
4
+ # This file is part of NOMAD.
5
+ # See https://nomad-lab.eu for further info.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+ import numpy as np
20
+ import os
21
+ import logging
22
+ import h5py
23
+ import re
24
+
25
+ from nomad.units import ureg
26
+ from nomad.parsing.file_parser import TextParser, Quantity
27
+ from simulationworkflowschema import SinglePoint
28
+ from runschema.run import Run, Program
29
+ from runschema.calculation import Calculation, ScfIteration, Energy, GreensFunctions
30
+ from runschema.method import (
31
+ Method,
32
+ HoppingMatrix,
33
+ HubbardKanamoriModel,
34
+ LatticeModelHamiltonian,
35
+ FrequencyMesh,
36
+ TimeMesh,
37
+ DMFT,
38
+ )
39
+ from runschema.system import System, Atoms
40
+ from .metainfo.w2dynamics import (
41
+ x_w2dynamics_axes,
42
+ x_w2dynamics_quantities,
43
+ x_w2dynamics_config_parameters,
44
+ x_w2dynamics_config_atoms_parameters,
45
+ )
46
+ from ..wannier90.parser import WOutParser, HrParser
47
+
48
+ from ..utils import get_files, BeyondDFTWorkflowsParser
49
+
50
+
51
+ re_n = r'[\n\r]'
52
+
53
+
54
+ class LogParser(TextParser):
55
+ def __init__(self):
56
+ super().__init__(None)
57
+
58
+ def init_quantities(self):
59
+ self._quantities = [
60
+ Quantity(
61
+ 'program_version', r'Version\s*([0-9.]+)', dtype=str, flatten=False
62
+ )
63
+ ]
64
+
65
+
66
+ class W2DynamicsParser(BeyondDFTWorkflowsParser):
67
+ def __init__(self):
68
+ self._re_namesafe = re.compile(r'[^\w]')
69
+ self.log_parser = LogParser()
70
+ self._calculation_type = 'dmft'
71
+ self.wout_parser = WOutParser()
72
+ self.hr_parser = HrParser()
73
+ self.data = None
74
+ self._child_archives = {}
75
+
76
+ self._hubbard_kanamori_map = {'u': 'u', 'j': 'jh', 'v': 'up'}
77
+
78
+ self._dmft_qmc_map = {'ntau': 'n_tau', 'niw': 'n_matsubara_freq'}
79
+
80
+ self._dataset_run_mapping = {
81
+ '.axes': x_w2dynamics_axes,
82
+ '.quantities': x_w2dynamics_quantities,
83
+ }
84
+
85
+ self._inequivalent_atom_map = {
86
+ 'self_energy_iw': 'siw',
87
+ 'greens_function_iw': 'giw',
88
+ 'greens_function_tau': 'gtau',
89
+ }
90
+
91
+ def parse_program_version(self):
92
+ """Parses the program version from the .log file if present.
93
+
94
+ Returns:
95
+ str: program version label
96
+ """
97
+ log_files = get_files('*.log', self.filepath, self.mainfile)
98
+ if log_files:
99
+ if len(log_files) > 1:
100
+ self.logger.warning(
101
+ 'Multiple logging files found, the last one will be parsed.',
102
+ data={'files': log_files},
103
+ )
104
+
105
+ self.log_parser.mainfile = log_files[-1]
106
+ return self.log_parser.get('program_version', None)
107
+
108
+ def parse_axes(self, source, target):
109
+ """Parses the key `.axes` from the hdf5 mainfile
110
+
111
+ Args:
112
+ source (HDF5group): group `.axes` from the hdf5 mainfile
113
+ target (MSection): EntryArchive.Run[-1].x_w2dynamics_axes code-specific section
114
+ """
115
+ for key in source.keys():
116
+ if key in ['iw', 'tau']:
117
+ continue
118
+ # resolve value from 'value'
119
+ value = source[key]
120
+ if isinstance(value, h5py.Group) and 'value' in value.keys():
121
+ value = value['value']
122
+ if not isinstance(value, h5py.Dataset):
123
+ continue
124
+ name = self._re_namesafe.sub('_', key)
125
+ quantity_def = target.m_def.all_quantities.get(f'x_w2dynamics_{name}')
126
+ if quantity_def and value.shape:
127
+ target.m_set(quantity_def, value[:])
128
+
129
+ def parse_system(self, wannier90_name: str):
130
+ """Parses System from the Wannier90 output file (*.wout) if present in the upload.
131
+ Otherwise, a warning appears.
132
+
133
+ Args:
134
+ wannier90_name (str): name of the initial Wannier90 *_hk.dat initial model used
135
+ """
136
+ sec_run = self.archive.run[-1]
137
+
138
+ wannier90_mainfiles = get_files(
139
+ '*.wout', self.filepath, self.mainfile, deep=False
140
+ )
141
+ if wannier90_mainfiles: # parse crystal from Wannier90
142
+ # We scan for the proper Wannier90 file that matches the HDF5 group '.config' content
143
+ if len(wannier90_mainfiles) > 1:
144
+ self.logger.warning(
145
+ 'Multiple Wannier90 *.wout files found, we will scan these files '
146
+ 'and match them with .config/general.hkfile. If this is not '
147
+ 'found, we will consider the last Wannier90 *.wout file.',
148
+ data={'files': wannier90_mainfiles},
149
+ )
150
+ if wannier90_name:
151
+ matched_wannier90_mainfile = [
152
+ filename
153
+ for filename in wannier90_mainfiles
154
+ if wannier90_name in filename
155
+ ]
156
+ if matched_wannier90_mainfile:
157
+ wannier90_mainfiles = matched_wannier90_mainfile
158
+ wannier90_mainfile = wannier90_mainfiles[-1]
159
+
160
+ self.wout_parser.mainfile = wannier90_mainfile
161
+ sec_system = System()
162
+ sec_run.system.append(sec_system)
163
+
164
+ structure = self.wout_parser.get('structure')
165
+ if structure is None:
166
+ self.logger.error('Error parsing the structure from .wout')
167
+ return
168
+
169
+ sec_atoms = Atoms()
170
+ sec_system.atoms = sec_atoms
171
+ if self.wout_parser.get('lattice_vectors', []):
172
+ lattice_vectors = np.vstack(
173
+ self.wout_parser.get('lattice_vectors', [])[-3:]
174
+ )
175
+ sec_atoms.lattice_vectors = lattice_vectors * ureg.angstrom
176
+ if self.wout_parser.get('reciprocal_lattice_vectors') is not None:
177
+ sec_atoms.lattice_vectors_reciprocal = (
178
+ np.vstack(self.wout_parser.get('reciprocal_lattice_vectors')[-3:])
179
+ / ureg.angstrom
180
+ )
181
+
182
+ pbc = (
183
+ [True, True, True]
184
+ if lattice_vectors is not None
185
+ else [False, False, False]
186
+ )
187
+ sec_atoms.periodic = pbc
188
+ sec_atoms.labels = structure.get('labels')
189
+ if structure.get('positions') is not None:
190
+ sec_atoms.positions = structure.get('positions') * ureg.angstrom
191
+ else: # TODO parse specific lattice model: discuss it Jonas Schwab
192
+ self.logger.warning(
193
+ 'Wannier90 output files not found in the same folder, cannot resolve the system metainfo.'
194
+ )
195
+
196
+ def parse_input_model(self, data: h5py.Group, wannier90_name: str):
197
+ """Parses input model into Run.Method.LatticeModelHamiltonian in two differentiated
198
+ subsections:
199
+ 1- Hopping matrices from the Wannier90 *hr.dat file
200
+ 2- HubbardKanamoriHamiltonian from the hdf5 mainfile
201
+
202
+ Args:
203
+ data (h5py.Group): group `.config` from the hdf5 mainfile
204
+ wannier90_name (str): name of the initial Wannier90 *_hk.dat initial model used
205
+ """
206
+ sec_run = self.archive.run[0]
207
+ sec_hamiltonian = LatticeModelHamiltonian()
208
+ sec_run.method.append(Method(lattice_model_hamiltonian=[sec_hamiltonian]))
209
+
210
+ # HoppingMatrix
211
+ wannier90_hr_files = get_files(
212
+ '*hr.dat', self.filepath, self.mainfile, deep=False
213
+ )
214
+ if wannier90_hr_files: # parse tight-binding model from Wannier90
215
+ # We scan for the proper Wannier90 file that matches the HDF5 group '.config' content
216
+ if len(wannier90_hr_files) > 1:
217
+ self.logger.warning(
218
+ 'Multiple Wannier90 *_hr.dat files found, we will scan these files '
219
+ 'and match them with .config/general.hkfile. If this is not '
220
+ 'found, we will consider the last Wannier90 *_hr.dat file.',
221
+ data={'files': wannier90_hr_files},
222
+ )
223
+ if wannier90_name:
224
+ matched_wannier90_hr_file = [
225
+ filename
226
+ for filename in wannier90_hr_files
227
+ if wannier90_name in filename
228
+ ]
229
+ if matched_wannier90_hr_file:
230
+ wannier90_hr_files = matched_wannier90_hr_file
231
+ wannier90_hr_file = wannier90_hr_files[-1]
232
+
233
+ self.hr_parser.mainfile = wannier90_hr_file
234
+ sec_hopping_matrix = HoppingMatrix()
235
+ sec_hamiltonian.hopping_matrix = sec_hopping_matrix
236
+ sec_hopping_matrix.n_orbitals = self.wout_parser.get('Nwannier')
237
+ deg_factors = self.hr_parser.get('degeneracy_factors', [])
238
+ if deg_factors is not None:
239
+ sec_hopping_matrix.n_wigner_seitz_points = deg_factors[1]
240
+ sec_hopping_matrix.degeneracy_factors = deg_factors[2:]
241
+ full_hoppings = self.hr_parser.get('hoppings', [])
242
+ try:
243
+ sec_hopping_matrix.value = np.reshape(
244
+ full_hoppings,
245
+ (
246
+ sec_hopping_matrix.n_wigner_seitz_points,
247
+ sec_hopping_matrix.n_orbitals
248
+ * sec_hopping_matrix.n_orbitals,
249
+ 7,
250
+ ),
251
+ )
252
+ except Exception:
253
+ self.logger.warning(
254
+ 'Could not parse the hopping matrix values. Please, revise your output files.'
255
+ )
256
+ else: # TODO parse specific lattice model
257
+ self.logger.warning(
258
+ 'Wannier90 _hr.dat files not found in the same folder, cannot resolve the initial model metainfo.'
259
+ )
260
+
261
+ # HubbardKanamoriModel
262
+ # TODO add parse of slater integrals
263
+ # TODO add parse of the u_matrix.dat file
264
+ for n in range(data.attrs.get('general.nat', 1)):
265
+ sec_hubbard_kanamori_model = HubbardKanamoriModel()
266
+ sec_hamiltonian.hubbard_kanamori_model.append(sec_hubbard_kanamori_model)
267
+
268
+ angular_momentum = 'd'
269
+ sec_hubbard_kanamori_model.orbital = angular_momentum
270
+ sec_hubbard_kanamori_model.double_counting_correction = data.attrs.get(
271
+ 'general.dc', None
272
+ )
273
+ # w2dynamics keeps spin-rotational invariance
274
+ for key in self._hubbard_kanamori_map.keys():
275
+ parameters = (
276
+ data.attrs.get(
277
+ f'atoms.{n+1}.{key}{angular_momentum}{angular_momentum}', None
278
+ )
279
+ * ureg.eV
280
+ )
281
+ setattr(
282
+ sec_hubbard_kanamori_model,
283
+ self._hubbard_kanamori_map.get(key),
284
+ parameters,
285
+ )
286
+
287
+ if data.attrs.get(f'atoms.{n+1}.hamiltonian') == 'Density':
288
+ sec_hubbard_kanamori_model.j = 0.0
289
+ elif data.attrs.get(f'atoms.{n+1}.hamiltonian') == 'Kanamori':
290
+ sec_hubbard_kanamori_model.j = sec_hubbard_kanamori_model.jh
291
+
292
+ def parse_method(self, data: h5py.Group):
293
+ """Parses DMFT and code-specific metadata from `.config` in the hdf5 mainfile
294
+
295
+ Args:
296
+ data (h5py.Group): group `.config` from the hdf5 mainfile
297
+ """
298
+ sec_run = self.archive.run[0]
299
+
300
+ sec_method = Method()
301
+ sec_run.method.append(sec_method)
302
+ # ref to the Non- and InteractionHamiltonian
303
+ sec_method.starting_method_ref = sec_run.method[0]
304
+
305
+ def parse_config(keys):
306
+ key = keys.split('.')[-1]
307
+ if isinstance(data.attrs.get(keys), str):
308
+ value = data.attrs.get(keys)
309
+ else:
310
+ value = data.attrs.get(keys).tolist()
311
+ return key, value
312
+
313
+ # Parse Method.x_w2dynamics_config general and qmc quantities
314
+ sec_config = x_w2dynamics_config_parameters()
315
+ sec_method.x_w2dynamics_config = sec_config
316
+ config_general = {}
317
+ config_qmc = {}
318
+ for keys in data.attrs.keys():
319
+ if keys.startswith('general'):
320
+ key, value = parse_config(keys)
321
+ config_general[key] = value
322
+ elif keys.startswith('qmc'):
323
+ key, value = parse_config(keys)
324
+ config_qmc[key] = value
325
+ sec_config.x_w2dynamics_config_general = config_general
326
+ sec_config.x_w2dynamics_config_qmc = config_qmc
327
+ # Parse Method.x_w2dynamics_config atoms quantities
328
+ for i in range(data.attrs.get(f'general.nat', 0)):
329
+ sec_config_subsection = x_w2dynamics_config_atoms_parameters()
330
+ sec_config.x_w2dynamics_config_atoms.append(sec_config_subsection)
331
+ for key in data.attrs.keys():
332
+ if key.startswith(f'atoms.{i+1}'):
333
+ keys_mod = (key.replace('-', '_')).split('.')
334
+ parameters = data.attrs.get(key)
335
+ setattr(
336
+ sec_config_subsection,
337
+ f'x_w2dynamics_{keys_mod[-1]}',
338
+ parameters,
339
+ )
340
+
341
+ # DMFT section
342
+ sec_dmft = DMFT()
343
+ sec_method.dmft = sec_dmft
344
+ sec_dmft.n_impurities = data.attrs.get(f'general.nat', 0)
345
+ if data.attrs.get(f'general.beta'):
346
+ sec_dmft.inverse_temperature = data.attrs.get(f'general.beta') / ureg.eV
347
+ if data.attrs.get(f'general.magnetism'):
348
+ sec_dmft.magnetic_state = data.attrs.get(f'general.magnetism') + 'magnetic'
349
+ corr_orbs_per_atoms = []
350
+ occ_per_atoms = []
351
+ for i in range(sec_dmft.n_impurities):
352
+ nd = sec_method.x_w2dynamics_config.x_w2dynamics_config_atoms[
353
+ i
354
+ ].x_w2dynamics_nd
355
+ np = sec_method.x_w2dynamics_config.x_w2dynamics_config_atoms[
356
+ i
357
+ ].x_w2dynamics_np
358
+ corr_orbs_per_atoms.append(nd + np)
359
+ if data.attrs.get(f'general.totdens'):
360
+ occ_per_atoms.append(data.attrs.get(f'general.totdens'))
361
+ sec_dmft.n_correlated_orbitals = corr_orbs_per_atoms
362
+ sec_dmft.n_electrons = occ_per_atoms
363
+ sec_dmft.impurity_solver = 'CT-HYB'
364
+ # FrequencyMesh
365
+ iw = self.data.get('.axes').get('iw')
366
+ if iw is not None:
367
+ iw = iw[:].reshape((len(iw), 1))
368
+ sec_freq_mesh = FrequencyMesh(
369
+ dimensionality=1, n_points=len(iw), points=iw * 1j * ureg.eV
370
+ )
371
+ sec_method.m_add_sub_section(Method.frequency_mesh, sec_freq_mesh)
372
+ # TimeMesh
373
+ tau = self.data.get('.axes').get('tau')
374
+ if tau is not None:
375
+ tau = tau[:].reshape((len(tau), 1))
376
+ sec_tau_mesh = TimeMesh(
377
+ dimensionality=1, n_points=len(tau), points=tau * 1j
378
+ )
379
+ sec_method.m_add_sub_section(Method.time_mesh, sec_tau_mesh)
380
+
381
+ def parse_scc(self):
382
+ """Parses the output calculation from dmft-xxx or stat-xxx. Every iteration step quantity
383
+ is saved as a path to the hdf5 file to spare the size of the archive.
384
+
385
+ The last step is used to store the converged quantities.
386
+ """
387
+ sec_run = self.archive.run[0]
388
+ sec_scc = Calculation()
389
+ sec_run.calculation.append(sec_scc)
390
+ if sec_run.m_xpath('system'):
391
+ sec_scc.system_ref = sec_run.system[-1]
392
+ sec_scc.method_ref = sec_run.method[-1] # ref DMFT
393
+
394
+ # order calculations
395
+ calc_keys = [
396
+ key
397
+ for key in self.data.keys()
398
+ if key.startswith('dmft-') or key.startswith('stat-')
399
+ ]
400
+ calc_keys.sort()
401
+ ineq_keys = [
402
+ key for key in self.data.get(calc_keys[0]).keys() if key.startswith('ineq-')
403
+ ]
404
+ ineq_keys.sort()
405
+
406
+ # calculating how many inequivalent atoms are per unit cell
407
+ n_ineq = 0
408
+ for keys in self.data[calc_keys[0]]:
409
+ if keys.startswith('ineq'):
410
+ n_ineq += 1
411
+ n_atoms = sec_run.method[-1].dmft.n_impurities
412
+
413
+ filename = os.path.join(
414
+ os.path.dirname(self.filepath.split('/raw/')[-1]), self.mainfile
415
+ )
416
+ farg = 'r+b' # Always reading the hdf5 mainfile
417
+ for key in calc_keys:
418
+ if key not in self.data.keys():
419
+ continue
420
+ sec_scf_iteration = ScfIteration()
421
+ sec_scc.scf_iteration.append(sec_scf_iteration)
422
+ if self.archive.m_context:
423
+ with self.archive.m_context.raw_file(filename, farg) as f:
424
+ for subkey in self.data.get(key).keys():
425
+ parameter = self.data.get(key).get(subkey)
426
+ if subkey == 'mu':
427
+ value = parameter.get('value')
428
+ sec_energy = Energy()
429
+ sec_scf_iteration.energy = sec_energy
430
+ sec_energy.fermi = np.float64(value) * ureg.eV
431
+ elif subkey not in ineq_keys:
432
+ value = parameter.get('value')[:]
433
+ value = f'{os.path.basename(self.mainfile)}#/{key}/{subkey}/value'
434
+ name = self._re_namesafe.sub('_', subkey)
435
+ setattr(sec_scf_iteration, f'x_w2dynamics_{name}', value)
436
+ else:
437
+ sec_ineq = x_w2dynamics_quantities()
438
+ sec_scf_iteration.x_w2dynamics_ineq.append(sec_ineq)
439
+ for name in parameter.keys():
440
+ # resolve value from 'value'
441
+ value = parameter.get(name)
442
+ if (
443
+ isinstance(value, h5py.Group)
444
+ and 'value' in value.keys()
445
+ ):
446
+ value = value.get('value')
447
+ if not isinstance(value, h5py.Dataset):
448
+ continue
449
+ value = f'{os.path.basename(self.mainfile)}#/{key}/{subkey}/{name}/value'
450
+ name = self._re_namesafe.sub('_', name)
451
+ setattr(sec_ineq, f'x_w2dynamics_{name}', value)
452
+
453
+ # Storing converged quantities from dmft-last or stat-last
454
+ if key.endswith('last'):
455
+ sec_gf = GreensFunctions()
456
+ sec_scc.greens_functions.append(sec_gf)
457
+ if sec_run.method[-1].m_xpath('frequency_mesh'):
458
+ sec_gf.matsubara_freq = np.transpose(
459
+ sec_run.method[-1]
460
+ .frequency_mesh[0]
461
+ .points.to('eV')
462
+ .magnitude.imag
463
+ )[0]
464
+ if sec_run.method[-1].m_xpath('time_mesh'):
465
+ sec_gf.tau = np.transpose(
466
+ sec_run.method[-1].time_mesh[0].points.imag
467
+ )[0]
468
+ if self.data.get(key).get('mu') is not None:
469
+ sec_gf.chemical_potential = (
470
+ np.float64(self.data.get(key).get('mu').get('value')) * ureg.eV
471
+ )
472
+ norb = self.data.get('.config').attrs.get('atoms.1.nd')
473
+ for subkey in self._inequivalent_atom_map.keys():
474
+ parameters = []
475
+ if n_ineq == n_atoms:
476
+ for i in range(n_ineq):
477
+ value = (
478
+ self.data.get(key)
479
+ .get(f'ineq-00{i + 1}')
480
+ .get(self._inequivalent_atom_map.get(subkey, []))
481
+ .get('value')[:]
482
+ )
483
+ parameters.append(value)
484
+ elif n_atoms % n_ineq == 0 and n_ineq > 1:
485
+ for i in range(n_atoms):
486
+ value = (
487
+ self.data.get(key)
488
+ .get(f'ineq-00{(i % n_ineq) + 1}')
489
+ .get(self._inequivalent_atom_map.get(subkey, []))
490
+ .get('value')[:]
491
+ )
492
+ parameters.append(value)
493
+ elif n_ineq == 1:
494
+ for i in range(n_atoms):
495
+ value = (
496
+ self.data.get(key)
497
+ .get('ineq-001')
498
+ .get(self._inequivalent_atom_map.get(subkey, []))
499
+ .get('value')[:]
500
+ )
501
+ parameters.append(value)
502
+ else:
503
+ self.logger.warning(
504
+ 'Number of inequivalent atoms and number of atoms per unit cell '
505
+ 'is neither equal nor multiples. Please, revise the output.'
506
+ )
507
+ break
508
+
509
+ parameters = np.array(parameters)
510
+ # reordering calculation matrices to standarize w2dynamics and solid_dmft
511
+ # (and potentially, other DMFT codes)
512
+ parameters_reorder = np.array(
513
+ [
514
+ [
515
+ [parameters[i, no, ns, :] for no in range(norb)]
516
+ for ns in range(2)
517
+ ]
518
+ for i in range(n_atoms)
519
+ ]
520
+ )
521
+ setattr(sec_gf, subkey, parameters_reorder)
522
+ # summing over atoms per unit cell to keep same array dimensions
523
+ parameters = []
524
+ if n_ineq == n_atoms:
525
+ for i in range(n_ineq):
526
+ value = (
527
+ self.data.get(key)
528
+ .get(f'ineq-00{i + 1}')
529
+ .get('occ')
530
+ .get('value')[:]
531
+ )
532
+ parameters.append(
533
+ [
534
+ [value[no, ns, no, ns] for no in range(norb)]
535
+ for ns in range(2)
536
+ ]
537
+ )
538
+ elif n_atoms % n_ineq == 0 and n_ineq > 1:
539
+ for i in range(n_atoms):
540
+ value = (
541
+ self.data.get(key)
542
+ .get(f'ineq-00{(i % n_ineq) + 1}')
543
+ .get('occ')
544
+ .get('value')[:]
545
+ )
546
+ parameters.append(
547
+ [
548
+ [value[no, ns, no, ns] for no in range(norb)]
549
+ for ns in range(2)
550
+ ]
551
+ )
552
+ elif n_ineq == 1:
553
+ for i in range(n_atoms):
554
+ value = (
555
+ self.data.get(key)
556
+ .get(f'ineq-001')
557
+ .get('occ')
558
+ .get('value')[:]
559
+ )
560
+ parameters.append(
561
+ [
562
+ [value[no, ns, no, ns] for no in range(norb)]
563
+ for ns in range(2)
564
+ ]
565
+ )
566
+ sec_gf.orbital_occupations = np.array(parameters)
567
+
568
+ def init_parser(self):
569
+ self.data = None
570
+
571
+ def get_mainfile_keys(self, **kwargs):
572
+ filepath = kwargs.get('filename')
573
+ mainfile = os.path.basename(filepath)
574
+ wannier90_files = get_files('*.wout', filepath, mainfile, deep=False)
575
+ if len(wannier90_files) == 1:
576
+ return ['DMFT_workflow']
577
+ return True
578
+
579
+ def parse(self, filepath, archive, logger):
580
+ self.filepath = filepath
581
+ self.archive = archive
582
+ self.maindir = os.path.dirname(self.filepath)
583
+ self.mainfile = os.path.basename(self.filepath)
584
+ self.logger = logging.getLogger(__name__) if logger is None else logger
585
+
586
+ try:
587
+ data = h5py.File(self.filepath)
588
+ self.data = data
589
+ except Exception:
590
+ self.logger.error('Error opening hdf5 file.')
591
+ data = None
592
+ return
593
+
594
+ sec_run = Run()
595
+ archive.run.append(sec_run)
596
+
597
+ # Program section
598
+ sec_run.program = Program(
599
+ name='w2dynamics', version=self.parse_program_version()
600
+ )
601
+
602
+ # run.x_w2dynamics_axes section
603
+ sec_axes = x_w2dynamics_axes()
604
+ sec_run.x_w2dynamics_axes = sec_axes
605
+ self.parse_axes(self.data.get('.axes'), sec_axes)
606
+
607
+ # System section
608
+ if self.data.get('.config'):
609
+ wannier90_name = self.data.get('.config').attrs.get('general.hkfile')
610
+ if wannier90_name:
611
+ wannier90_name = wannier90_name.split('_')[0]
612
+ else:
613
+ self.logger.warning(
614
+ 'HDF5 attribute .config/general.hkfile not found. We will '
615
+ 'scan the folder to find the Wannier90 input model.'
616
+ )
617
+ self.parse_system(wannier90_name)
618
+ # Method.DMFT section with inputs (HoppingMatrix + InteractionModel)
619
+ self.parse_input_model(self.data.get('.config'), wannier90_name)
620
+ self.parse_method(self.data.get('.config'))
621
+
622
+ # Calculation section
623
+ self.parse_scc()
624
+
625
+ # Workflow section
626
+ workflow = SinglePoint()
627
+ self.archive.workflow2 = workflow
628
+
629
+ # Checking if other mainfiles are present, if the closest is a Wannier90, tries to
630
+ # link it with the corresponding w2dynamics data
631
+ wannier90_files = get_files('*.wout', self.filepath, self.mainfile, deep=False)
632
+ if len(wannier90_files) == 1:
633
+ wannier90_path = wannier90_files[-1].split('raw/')[-1]
634
+ filepath_stripped = self.filepath.split('raw/')[-1]
635
+ try:
636
+ # For automatic workflows
637
+ from nomad.search import search
638
+ from nomad.app.v1.models import MetadataRequired
639
+
640
+ upload_id = self.archive.metadata.upload_id
641
+ search_ids = search(
642
+ owner='visible',
643
+ user_id=self.archive.metadata.main_author.user_id,
644
+ query={'upload_id': upload_id},
645
+ required=MetadataRequired(include=['entry_id', 'mainfile']),
646
+ ).data
647
+ metadata = [[sid['entry_id'], sid['mainfile']] for sid in search_ids]
648
+ if len(metadata) > 1:
649
+ for entry_id, mainfile in metadata:
650
+ if (
651
+ mainfile == filepath_stripped
652
+ ): # we skipped the current parsed mainfile
653
+ continue
654
+ entry_archive = archive.m_context.load_archive(
655
+ entry_id, upload_id, None
656
+ )
657
+ if (
658
+ wannier90_path == mainfile
659
+ ): # TODO add condition on system section or is this enough? System is resolved anyways from wannier90_path
660
+ wannier90_archive = entry_archive
661
+ dmft_workflow_archive = self._child_archives.get(
662
+ 'DMFT_workflow'
663
+ )
664
+ self.parse_dmft_workflow(
665
+ wannier90_archive, dmft_workflow_archive
666
+ )
667
+ break
668
+ except Exception:
669
+ self.logger.warning(
670
+ 'Could not resolve the automatic workflow for w2dynamics. '
671
+ 'You can try reorganizing the data in the folders: '
672
+ 'DFT data in the top-most folder. Wannier90 data in the top-most folder '
673
+ 'or one folder below DFT. w2dynamics data one folder below DFT and Wannier90.'
674
+ )
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright The NOMAD Authors.
3
+ #
4
+ # This file is part of NOMAD.
5
+ # See https://nomad-lab.eu for further info.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+ from .parser import Wannier90Parser