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,3594 @@
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 logging
20
+ import numpy as np
21
+ import re
22
+ from datetime import datetime
23
+ import os
24
+
25
+ from nomad.units import ureg
26
+ from nomad.parsing.file_parser.text_parser import TextParser, Quantity, DataTextParser
27
+ from runschema.run import Run, Program, TimeRun
28
+ from runschema.method import (
29
+ Electronic,
30
+ Method,
31
+ DFT,
32
+ Smearing,
33
+ XCFunctional,
34
+ Functional,
35
+ BasisSet,
36
+ BasisSetContainer,
37
+ AtomParameters,
38
+ KMesh,
39
+ )
40
+ from runschema.system import System, Atoms
41
+ from runschema.calculation import (
42
+ Calculation,
43
+ Energy,
44
+ EnergyEntry,
45
+ Forces,
46
+ ForcesEntry,
47
+ Stress,
48
+ StressEntry,
49
+ Thermodynamics,
50
+ BandEnergies,
51
+ ScfIteration,
52
+ Dos,
53
+ DosValues,
54
+ )
55
+ from simulationworkflowschema import (
56
+ SinglePoint,
57
+ GeometryOptimization,
58
+ MolecularDynamics,
59
+ )
60
+ from .metainfo.quantum_espresso import (
61
+ x_qe_section_scf_diagonalization,
62
+ x_qe_section_bands_diagonalization,
63
+ x_qe_section_compile_options,
64
+ x_qe_section_parallel,
65
+ )
66
+
67
+
68
+ RE_FLOAT = r'[-+]?\d+\.\d*(?:[Ee][-+]\d+)?'
69
+
70
+
71
+ # origin: espresso-5.4.0/Modules/funct.f90
72
+ # update:
73
+ # . New exchange-correlation functionals exist in
74
+ # . espresso-6.5.0/Modules/funct.f90
75
+ # short comments mark the corresponding new metainfo
76
+ _exchange_map = [
77
+ None,
78
+ {
79
+ 'xc_terms': [
80
+ {
81
+ 'XC_functional_name': 'LDA_X',
82
+ }
83
+ ],
84
+ 'xc_section_method': {
85
+ 'x_qe_xc_iexch_name': 'sla',
86
+ 'x_qe_xc_iexch_comment': 'Slater (alpha=2/3)',
87
+ 'x_qe_xc_iexch': 1,
88
+ },
89
+ },
90
+ {
91
+ 'xc_terms': [
92
+ {
93
+ 'XC_functional_name': 'LDA_X',
94
+ 'XC_functional_parameters': {'alpha': 1.0},
95
+ }
96
+ ],
97
+ 'xc_section_method': {
98
+ 'x_qe_xc_iexch_name': 'sl1',
99
+ 'x_qe_xc_iexch_comment': 'Slater (alpha=1.0)',
100
+ 'x_qe_xc_iexch': 2,
101
+ },
102
+ },
103
+ {
104
+ 'xc_terms': [
105
+ {
106
+ 'XC_functional_name': 'x_qe_LDA_X_RELATIVISTIC',
107
+ }
108
+ ],
109
+ 'xc_section_method': {
110
+ 'x_qe_xc_iexch_name': 'rxc',
111
+ 'x_qe_xc_iexch_comment': 'Relativistic Slater',
112
+ 'x_qe_xc_iexch': 3,
113
+ },
114
+ },
115
+ {
116
+ 'xc_terms': [
117
+ {
118
+ 'XC_functional_name': 'OEP_EXX',
119
+ }
120
+ ],
121
+ 'xc_section_method': {
122
+ 'x_qe_xc_iexch_name': 'oep',
123
+ 'x_qe_xc_iexch_comment': 'Optimized Effective Potential',
124
+ 'x_qe_xc_iexch': 4,
125
+ },
126
+ },
127
+ {
128
+ 'xc_terms': [
129
+ {
130
+ 'XC_functional_name': 'HF_X',
131
+ }
132
+ ],
133
+ 'xc_section_method': {
134
+ 'x_qe_xc_iexch_name': 'hf',
135
+ 'x_qe_xc_iexch_comment': 'Hartree-Fock',
136
+ 'x_qe_xc_iexch': 5,
137
+ },
138
+ },
139
+ {
140
+ 'xc_terms': [
141
+ {
142
+ 'XC_functional_name': 'HF_X',
143
+ 'exx_compute_weight': lambda exx: exx,
144
+ 'XC_functional_weight': 0.25,
145
+ },
146
+ {
147
+ 'XC_functional_name': 'LDA_X',
148
+ 'exx_compute_weight': lambda exx: (1.0 - exx),
149
+ 'XC_functional_weight': 0.75,
150
+ },
151
+ ],
152
+ 'xc_section_method': {
153
+ 'x_qe_xc_iexch_name': 'pb0x',
154
+ 'x_qe_xc_iexch_comment': 'PBE0 (Slater*0.75+HF*0.25)',
155
+ 'x_qe_xc_iexch': 6,
156
+ },
157
+ },
158
+ {
159
+ 'xc_terms': [
160
+ {
161
+ 'XC_functional_name': 'HF_X',
162
+ 'exx_compute_weight': lambda exx: exx,
163
+ 'XC_functional_weight': 0.20,
164
+ },
165
+ {
166
+ 'XC_functional_name': 'LDA_X',
167
+ 'exx_compute_weight': lambda exx: (1.0 - exx),
168
+ 'XC_functional_weight': 0.8,
169
+ },
170
+ ],
171
+ 'xc_section_method': {
172
+ 'x_qe_xc_iexch_name': 'b3lp',
173
+ 'x_qe_xc_iexch_comment': 'B3LYP(Slater*0.80+HF*0.20)',
174
+ 'x_qe_xc_iexch': 7,
175
+ },
176
+ },
177
+ # LDA_X_KZK is not part of libXC. Look up it at
178
+ # 'https://gitlab.mpcdf.mpg.de/nomad-lab/nomad-meta-info/wikis/metainfo/XC-functional'
179
+ {
180
+ 'xc_terms': [
181
+ {
182
+ 'XC_functional_name': 'LDA_X_KZK',
183
+ }
184
+ ],
185
+ 'xc_section_method': {
186
+ 'x_qe_xc_iexch_name': 'kzk',
187
+ 'x_qe_xc_iexch_comment': 'Finite-size corrections',
188
+ 'x_qe_xc_iexch': 8,
189
+ },
190
+ },
191
+ {
192
+ 'xc_terms': [
193
+ {
194
+ 'XC_functional_name': 'HF_X',
195
+ 'exx_compute_weight': lambda exx: exx,
196
+ 'XC_functional_weight': 0.218,
197
+ },
198
+ {
199
+ 'XC_functional_name': 'LDA_X',
200
+ 'exx_compute_weight': lambda exx: (1.0 - exx),
201
+ 'XC_functional_weight': 0.782,
202
+ },
203
+ ],
204
+ 'xc_section_method': {
205
+ 'x_qe_xc_iexch_name': 'x3lp',
206
+ 'x_qe_xc_iexch_comment': 'X3LYP(Slater*0.782+HF*0.218)',
207
+ 'x_qe_xc_iexch': 9,
208
+ },
209
+ },
210
+ # update for espresso-6.5.0: KLI
211
+ {
212
+ 'xc_terms': [
213
+ {
214
+ 'XC_functional_name': 'LDA_X_KLI',
215
+ }
216
+ ],
217
+ 'xc_section_method': {
218
+ 'x_qe_xc_iexch_name': 'kli',
219
+ 'x_qe_xc_iexch_comment': 'KLI aproximation for exx',
220
+ 'x_qe_xc_iexch': 10,
221
+ },
222
+ },
223
+ ]
224
+
225
+ # Correlation functionals UNchanged between espresso v5.4 & v6.5
226
+ _correlation_map = [
227
+ None,
228
+ {
229
+ 'xc_terms': [
230
+ {
231
+ 'XC_functional_name': 'LDA_C_PZ',
232
+ }
233
+ ],
234
+ 'xc_section_method': {
235
+ 'x_qe_xc_icorr_name': 'pz',
236
+ 'x_qe_xc_icorr_comment': 'Perdew-Zunger',
237
+ 'x_qe_xc_icorr': 1,
238
+ },
239
+ },
240
+ {
241
+ 'xc_terms': [
242
+ {
243
+ 'XC_functional_name': 'LDA_C_VWN',
244
+ }
245
+ ],
246
+ 'xc_section_method': {
247
+ 'x_qe_xc_icorr_name': 'vwn',
248
+ 'x_qe_xc_icorr_comment': 'Vosko-Wilk-Nusair',
249
+ 'x_qe_xc_icorr': 2,
250
+ },
251
+ },
252
+ {
253
+ 'xc_terms': [
254
+ {
255
+ 'XC_functional_name': 'LDA_C_LYP',
256
+ }
257
+ ],
258
+ 'xc_section_method': {
259
+ 'x_qe_xc_icorr_name': 'lyp',
260
+ 'x_qe_xc_icorr_comment': 'Lee-Yang-Parr',
261
+ 'x_qe_xc_icorr': 3,
262
+ },
263
+ },
264
+ {
265
+ 'xc_terms': [
266
+ {
267
+ 'XC_functional_name': 'LDA_C_PW',
268
+ }
269
+ ],
270
+ 'xc_section_method': {
271
+ 'x_qe_xc_icorr_name': 'pw',
272
+ 'x_qe_xc_icorr_comment': 'Perdew-Wang',
273
+ 'x_qe_xc_icorr': 4,
274
+ },
275
+ },
276
+ {
277
+ 'xc_terms': [
278
+ {
279
+ 'XC_functional_name': 'LDA_C_WIGNER',
280
+ }
281
+ ],
282
+ 'xc_section_method': {
283
+ 'x_qe_xc_icorr_name': 'wig',
284
+ 'x_qe_xc_icorr_comment': 'Wigner',
285
+ 'x_qe_xc_icorr': 5,
286
+ },
287
+ },
288
+ {
289
+ 'xc_terms': [
290
+ {
291
+ 'XC_functional_name': 'LDA_C_HL',
292
+ }
293
+ ],
294
+ 'xc_section_method': {
295
+ 'x_qe_xc_icorr_name': 'hl',
296
+ 'x_qe_xc_icorr_comment': 'Hedin-Lunqvist',
297
+ 'x_qe_xc_icorr': 6,
298
+ },
299
+ },
300
+ {
301
+ 'xc_terms': [
302
+ {
303
+ 'XC_functional_name': 'LDA_C_OB_PZ',
304
+ }
305
+ ],
306
+ 'xc_section_method': {
307
+ 'x_qe_xc_icorr_name': 'obz',
308
+ 'x_qe_xc_icorr_comment': 'Ortiz-Ballone form for PZ',
309
+ 'x_qe_xc_icorr': 7,
310
+ },
311
+ },
312
+ {
313
+ 'xc_terms': [
314
+ {
315
+ 'XC_functional_name': 'LDA_C_OB_PW',
316
+ }
317
+ ],
318
+ 'xc_section_method': {
319
+ 'x_qe_xc_icorr_name': 'obw',
320
+ 'x_qe_xc_icorr_comment': 'Ortiz-Ballone form for PW',
321
+ 'x_qe_xc_icorr': 8,
322
+ },
323
+ },
324
+ {
325
+ 'xc_terms': [
326
+ {
327
+ 'XC_functional_name': 'LDA_C_GL',
328
+ }
329
+ ],
330
+ 'xc_section_method': {
331
+ 'x_qe_xc_icorr_name': 'gl',
332
+ 'x_qe_xc_icorr_comment': 'Gunnarson-Lunqvist',
333
+ 'x_qe_xc_icorr': 9,
334
+ },
335
+ },
336
+ {
337
+ 'xc_terms': [
338
+ {
339
+ 'XC_functional_name': 'LDA_C_KZK',
340
+ }
341
+ ],
342
+ 'xc_section_method': {
343
+ 'x_qe_xc_icorr_name': 'kzk',
344
+ 'x_qe_xc_icorr_comment': 'Finite-size corrections',
345
+ 'x_qe_xc_icorr': 10,
346
+ },
347
+ },
348
+ {
349
+ 'xc_terms': [
350
+ {
351
+ 'XC_functional_name': 'LDA_C_VWN_RPA',
352
+ }
353
+ ],
354
+ 'xc_section_method': {
355
+ 'x_qe_xc_icorr_name': 'vwn-rpa',
356
+ 'x_qe_xc_icorr_comment': 'Vosko-Wilk-Nusair, alt param',
357
+ 'x_qe_xc_icorr': 11,
358
+ },
359
+ },
360
+ {
361
+ 'xc_terms': [
362
+ {
363
+ 'XC_functional_name': 'LDA_C_VWN',
364
+ 'XC_functional_weight': 0.19,
365
+ },
366
+ {
367
+ 'XC_functional_name': 'LDA_C_LYP',
368
+ 'XC_functional_weight': 0.81,
369
+ },
370
+ ],
371
+ 'xc_section_method': {
372
+ 'x_qe_xc_icorr_name': 'b3lp',
373
+ 'x_qe_xc_icorr_comment': 'B3LYP (0.19*vwn+0.81*lyp)',
374
+ 'x_qe_xc_icorr': 12,
375
+ },
376
+ },
377
+ {
378
+ 'xc_terms': [
379
+ {
380
+ 'XC_functional_name': 'LDA_C_VWN_RPA',
381
+ 'XC_functional_weight': 0.19,
382
+ },
383
+ {
384
+ 'XC_functional_name': 'LDA_C_LYP',
385
+ 'XC_functional_weight': 0.81,
386
+ },
387
+ ],
388
+ 'xc_section_method': {
389
+ 'x_qe_xc_icorr_name': 'b3lpv1r',
390
+ 'x_qe_xc_icorr_comment': 'B3LYP-VWN-1-RPA (0.19*vwn_rpa+0.81*lyp)',
391
+ 'x_qe_xc_icorr': 13,
392
+ },
393
+ },
394
+ {
395
+ 'xc_terms': [
396
+ {
397
+ 'XC_functional_name': 'LDA_C_VWN_RPA',
398
+ 'XC_functional_weight': 0.129,
399
+ },
400
+ {
401
+ 'XC_functional_name': 'LDA_C_LYP',
402
+ 'XC_functional_weight': 0.871,
403
+ },
404
+ ],
405
+ 'xc_section_method': {
406
+ 'x_qe_xc_icorr_name': 'x3lp',
407
+ 'x_qe_xc_icorr_comment': 'X3LYP (0.129*vwn_rpa+0.871*lyp)',
408
+ 'x_qe_xc_icorr': 14,
409
+ },
410
+ },
411
+ ]
412
+
413
+ # New 'exchange_gradient_correction' functionals for q-espresso (qe) v6.5
414
+ # igcx=[1..28] unchanged between qe-v5.4 & v6.5
415
+ # New additions: igcx=[29..42]
416
+
417
+ _exchange_gradient_correction_map = [
418
+ None,
419
+ {
420
+ 'xc_terms': [
421
+ {
422
+ 'XC_functional_name': 'GGA_X_B88',
423
+ }
424
+ ],
425
+ 'xc_terms_remove': [
426
+ {
427
+ 'XC_functional_name': 'LDA_X',
428
+ }
429
+ ],
430
+ 'xc_section_method': {
431
+ 'x_qe_xc_igcx_name': 'b88',
432
+ 'x_qe_xc_igcx_comment': 'Becke88 (beta=0.0042)',
433
+ 'x_qe_xc_igcx': 1,
434
+ },
435
+ },
436
+ {
437
+ 'xc_terms': [
438
+ {
439
+ 'XC_functional_name': 'GGA_X_PW91',
440
+ }
441
+ ],
442
+ 'xc_terms_remove': [
443
+ {
444
+ 'XC_functional_name': 'LDA_X',
445
+ }
446
+ ],
447
+ 'xc_section_method': {
448
+ 'x_qe_xc_igcx_name': 'ggx',
449
+ 'x_qe_xc_igcx_comment': 'Perdew-Wang 91',
450
+ 'x_qe_xc_igcx': 2,
451
+ },
452
+ },
453
+ {
454
+ 'xc_terms': [
455
+ {
456
+ 'XC_functional_name': 'GGA_X_PBE',
457
+ }
458
+ ],
459
+ 'xc_terms_remove': [
460
+ {
461
+ 'XC_functional_name': 'LDA_X',
462
+ }
463
+ ],
464
+ 'xc_section_method': {
465
+ 'x_qe_xc_igcx_name': 'pbx',
466
+ 'x_qe_xc_igcx_comment': 'Perdew-Burke-Ernzenhof exch',
467
+ 'x_qe_xc_igcx': 3,
468
+ },
469
+ },
470
+ {
471
+ 'xc_terms': [
472
+ {
473
+ 'XC_functional_name': 'GGA_X_PBE_R',
474
+ }
475
+ ],
476
+ 'xc_terms_remove': [
477
+ {
478
+ 'XC_functional_name': 'LDA_X',
479
+ }
480
+ ],
481
+ 'xc_section_method': {
482
+ 'x_qe_xc_igcx_name': 'rpb',
483
+ 'x_qe_xc_igcx_comment': 'revised PBE by Zhang-Yang',
484
+ 'x_qe_xc_igcx': 4,
485
+ },
486
+ },
487
+ {
488
+ 'xc_terms': [
489
+ {
490
+ 'XC_functional_name': 'GGA_XC_HCTH_120',
491
+ }
492
+ ],
493
+ 'xc_section_method': {
494
+ 'x_qe_xc_igcx_name': 'hcth',
495
+ 'x_qe_xc_igcx_comment': 'Cambridge exch, Handy et al, HCTH/120',
496
+ 'x_qe_xc_igcx': 5,
497
+ },
498
+ },
499
+ {
500
+ 'xc_terms': [
501
+ {
502
+ 'XC_functional_name': 'GGA_X_OPTX',
503
+ }
504
+ ],
505
+ 'xc_section_method': {
506
+ 'x_qe_xc_igcx_name': 'optx',
507
+ 'x_qe_xc_igcx_comment': "Handy's exchange functional",
508
+ 'x_qe_xc_igcx': 6,
509
+ },
510
+ },
511
+ {
512
+ # igcx=7 is not defined in 5.4's funct.f90
513
+ # definition taken from 5.0, which did not have separate imeta
514
+ 'xc_terms': [
515
+ {
516
+ 'XC_functional_name': 'MGGA_X_TPSS',
517
+ }
518
+ ],
519
+ 'xc_terms_remove': [
520
+ {
521
+ 'XC_functional_name': 'LDA_X',
522
+ }
523
+ ],
524
+ 'xc_section_method': {
525
+ 'x_qe_xc_igcx_name': 'tpss',
526
+ 'x_qe_xc_igcx_comment': 'TPSS Meta-GGA (Espresso-version < 5.1)',
527
+ 'x_qe_xc_igcx': 7,
528
+ },
529
+ },
530
+ {
531
+ 'xc_terms': [
532
+ {
533
+ 'XC_functional_name': 'GGA_X_PBE',
534
+ 'XC_functional_weight': 0.75,
535
+ 'exx_compute_weight': lambda exx: (1.0 - exx),
536
+ }
537
+ ],
538
+ 'xc_terms_remove': [
539
+ {
540
+ 'XC_functional_name': 'LDA_X',
541
+ 'XC_functional_weight': 0.75,
542
+ 'exx_compute_weight': lambda exx: (1.0 - exx),
543
+ }
544
+ ],
545
+ 'xc_section_method': {
546
+ 'x_qe_xc_igcx_name': 'pb0x',
547
+ 'x_qe_xc_igcx_comment': 'PBE0 (PBE exchange*0.75)',
548
+ 'x_qe_xc_igcx': 8,
549
+ },
550
+ },
551
+ {
552
+ 'xc_terms': [
553
+ {
554
+ 'XC_functional_name': 'GGA_X_B88',
555
+ 'XC_functional_weight': 0.72,
556
+ 'exx_compute_weight': lambda exx: 0.72 if abs(exx) > 0.01 else 1.0,
557
+ }
558
+ ],
559
+ 'xc_terms_remove': [
560
+ {
561
+ 'XC_functional_name': 'LDA_X',
562
+ 'XC_functional_weight': 0.8,
563
+ 'exx_compute_weight': lambda exx: (1.0 - exx),
564
+ }
565
+ ],
566
+ 'xc_section_method': {
567
+ 'x_qe_xc_igcx_name': 'b3lp',
568
+ 'x_qe_xc_igcx_comment': 'B3LYP (Becke88*0.72)',
569
+ 'x_qe_xc_igcx': 9,
570
+ },
571
+ },
572
+ {
573
+ 'xc_terms': [
574
+ {
575
+ 'XC_functional_name': 'GGA_X_PBE_SOL',
576
+ }
577
+ ],
578
+ 'xc_terms_remove': [
579
+ {
580
+ 'XC_functional_name': 'LDA_X',
581
+ }
582
+ ],
583
+ 'xc_section_method': {
584
+ 'x_qe_xc_igcx_name': 'psx',
585
+ 'x_qe_xc_igcx_comment': 'PBEsol exchange',
586
+ 'x_qe_xc_igcx': 10,
587
+ },
588
+ },
589
+ {
590
+ 'xc_terms': [
591
+ {
592
+ 'XC_functional_name': 'GGA_X_WC',
593
+ }
594
+ ],
595
+ 'xc_terms_remove': [
596
+ {
597
+ 'XC_functional_name': 'LDA_X',
598
+ }
599
+ ],
600
+ 'xc_section_method': {
601
+ 'x_qe_xc_igcx_name': 'wcx',
602
+ 'x_qe_xc_igcx_comment': 'Wu-Cohen',
603
+ 'x_qe_xc_igcx': 11,
604
+ },
605
+ },
606
+ {
607
+ 'xc_terms': [
608
+ {
609
+ 'XC_functional_name': 'HYB_GGA_XC_HSE06',
610
+ 'exx_compute_weight': lambda exx: 1.0 if (abs(exx) > 0.01) else 0.0,
611
+ },
612
+ {
613
+ 'XC_functional_name': 'GGA_X_PBE',
614
+ 'exx_compute_weight': lambda exx: 0.0 if (abs(exx) > 0.01) else 1.0,
615
+ },
616
+ ],
617
+ 'xc_terms_remove': [
618
+ {
619
+ 'XC_functional_name': 'LDA_X',
620
+ },
621
+ {
622
+ 'XC_functional_name': 'GGA_C_PBE',
623
+ 'exx_compute_weight': lambda exx: 1.0 if (abs(exx) > 0.01) else 0.0,
624
+ },
625
+ ],
626
+ 'xc_section_method': {
627
+ 'x_qe_xc_igcx_name': 'hse',
628
+ 'x_qe_xc_igcx_comment': 'HSE screened exchange',
629
+ 'x_qe_xc_igcx': 12,
630
+ },
631
+ },
632
+ {
633
+ 'xc_terms': [
634
+ {
635
+ 'XC_functional_name': 'GGA_X_RPW86',
636
+ }
637
+ ],
638
+ 'xc_terms_remove': [
639
+ {
640
+ 'XC_functional_name': 'LDA_X',
641
+ }
642
+ ],
643
+ 'xc_section_method': {
644
+ 'x_qe_xc_igcx_name': 'rw86',
645
+ 'x_qe_xc_igcx_comment': 'revised PW86',
646
+ 'x_qe_xc_igcx': 13,
647
+ },
648
+ },
649
+ {
650
+ 'xc_terms': [
651
+ {
652
+ 'XC_functional_name': 'GGA_X_PBE',
653
+ }
654
+ ],
655
+ 'xc_terms_remove': [
656
+ {
657
+ 'XC_functional_name': 'LDA_X',
658
+ }
659
+ ],
660
+ 'xc_section_method': {
661
+ 'x_qe_xc_igcx_name': 'pbe',
662
+ 'x_qe_xc_igcx_comment': 'same as PBX, back-comp.',
663
+ 'x_qe_xc_igcx': 14,
664
+ },
665
+ },
666
+ {
667
+ # igcx=15 is not defined in 5.4's funct.f90
668
+ # definition taken from 5.0, which did not have separate imeta
669
+ 'xc_terms': [
670
+ {
671
+ 'XC_functional_name': 'MGGA_X_TB09',
672
+ }
673
+ ],
674
+ 'xc_terms_remove': [
675
+ {
676
+ 'XC_functional_name': 'LDA_X',
677
+ }
678
+ ],
679
+ 'xc_section_method': {
680
+ 'x_qe_xc_igcx_name': 'tb09',
681
+ 'x_qe_xc_igcx_comment': 'TB09 Meta-GGA (Espresso-version < 5.1)',
682
+ 'x_qe_xc_igcx': 15,
683
+ },
684
+ },
685
+ {
686
+ 'xc_terms': [
687
+ {
688
+ 'XC_functional_name': 'GGA_X_C09X',
689
+ }
690
+ ],
691
+ 'xc_terms_remove': [
692
+ {
693
+ 'XC_functional_name': 'LDA_X',
694
+ }
695
+ ],
696
+ 'xc_section_method': {
697
+ 'x_qe_xc_igcx_name': 'c09x',
698
+ 'x_qe_xc_igcx_comment': 'Cooper 09',
699
+ 'x_qe_xc_igcx': 16,
700
+ },
701
+ },
702
+ {
703
+ 'xc_terms': [
704
+ {
705
+ 'XC_functional_name': 'GGA_X_SOGGA',
706
+ }
707
+ ],
708
+ 'xc_terms_remove': [
709
+ {
710
+ 'XC_functional_name': 'LDA_X',
711
+ }
712
+ ],
713
+ 'xc_section_method': {
714
+ 'x_qe_xc_igcx_name': 'sox',
715
+ 'x_qe_xc_igcx_comment': 'sogga',
716
+ 'x_qe_xc_igcx': 17,
717
+ },
718
+ },
719
+ {
720
+ # igcx=18 is not defined in 5.4's funct.f90
721
+ # definition taken from 5.0, which did not have separate imeta
722
+ 'xc_terms': [
723
+ {
724
+ 'XC_functional_name': 'MGGA_X_M06_L',
725
+ }
726
+ ],
727
+ 'xc_section_method': {
728
+ 'x_qe_xc_igcx_name': 'm6lx',
729
+ 'x_qe_xc_igcx_comment': 'M06L Meta-GGA (Espresso-version < 5.1)',
730
+ 'x_qe_xc_igcx': 18,
731
+ },
732
+ },
733
+ {
734
+ 'xc_terms': [
735
+ {
736
+ 'XC_functional_name': 'GGA_X_Q2D',
737
+ }
738
+ ],
739
+ 'xc_terms_remove': [
740
+ {
741
+ 'XC_functional_name': 'LDA_X',
742
+ }
743
+ ],
744
+ 'xc_section_method': {
745
+ 'x_qe_xc_igcx_name': 'q2dx',
746
+ 'x_qe_xc_igcx_comment': 'Q2D exchange grad corr',
747
+ 'x_qe_xc_igcx': 19,
748
+ },
749
+ },
750
+ {
751
+ 'xc_terms': [
752
+ {
753
+ 'XC_functional_name': 'HYB_GGA_XC_GAU_PBE',
754
+ 'exx_compute_weight': lambda exx: 1.0 if (abs(exx) > 0.01) else 0.0,
755
+ },
756
+ {
757
+ 'XC_functional_name': 'GGA_X_PBE',
758
+ 'exx_compute_weight': lambda exx: 0.0 if (abs(exx) > 0.01) else 1.0,
759
+ },
760
+ ],
761
+ 'xc_terms_remove': [
762
+ {
763
+ 'XC_functional_name': 'LDA_X',
764
+ },
765
+ {
766
+ 'XC_functional_name': 'GGA_C_PBE',
767
+ 'exx_compute_weight': lambda exx: 1.0 if (abs(exx) > 0.01) else 0.0,
768
+ },
769
+ ],
770
+ 'xc_section_method': {
771
+ 'x_qe_xc_igcx_name': 'gaup',
772
+ 'x_qe_xc_igcx_comment': 'Gau-PBE hybrid exchange',
773
+ 'x_qe_xc_igcx': 20,
774
+ },
775
+ },
776
+ {
777
+ 'xc_terms': [
778
+ {
779
+ 'XC_functional_name': 'GGA_X_PW86',
780
+ }
781
+ ],
782
+ 'xc_terms_remove': [
783
+ {
784
+ 'XC_functional_name': 'LDA_X',
785
+ }
786
+ ],
787
+ 'xc_section_method': {
788
+ 'x_qe_xc_igcx_name': 'pw86',
789
+ 'x_qe_xc_igcx_comment': 'Perdew-Wang (1986) exchange',
790
+ 'x_qe_xc_igcx': 21,
791
+ },
792
+ },
793
+ {
794
+ 'xc_terms': [
795
+ {
796
+ 'XC_functional_name': 'GGA_X_B86_MGC',
797
+ }
798
+ ],
799
+ 'xc_terms_remove': [
800
+ {
801
+ 'XC_functional_name': 'LDA_X',
802
+ }
803
+ ],
804
+ 'xc_section_method': {
805
+ 'x_qe_xc_igcx_name': 'b86b',
806
+ 'x_qe_xc_igcx_comment': 'Becke (1986) exchange',
807
+ 'x_qe_xc_igcx': 22,
808
+ },
809
+ },
810
+ {
811
+ 'xc_terms': [
812
+ {
813
+ 'XC_functional_name': 'GGA_X_OPTB88_VDW',
814
+ }
815
+ ],
816
+ 'xc_terms_remove': [
817
+ {
818
+ 'XC_functional_name': 'LDA_X',
819
+ }
820
+ ],
821
+ 'xc_section_method': {
822
+ 'x_qe_xc_igcx_name': 'obk8',
823
+ 'x_qe_xc_igcx_comment': 'optB88 exchange',
824
+ 'x_qe_xc_igcx': 23,
825
+ },
826
+ },
827
+ {
828
+ 'xc_terms': [
829
+ {
830
+ 'XC_functional_name': 'GGA_X_OPTB86B_VDW',
831
+ }
832
+ ],
833
+ 'xc_terms_remove': [
834
+ {
835
+ 'XC_functional_name': 'LDA_X',
836
+ }
837
+ ],
838
+ 'xc_section_method': {
839
+ 'x_qe_xc_igcx_name': 'ob86',
840
+ 'x_qe_xc_igcx_comment': 'optB86b exchange',
841
+ 'x_qe_xc_igcx': 24,
842
+ },
843
+ },
844
+ {
845
+ 'xc_terms': [
846
+ {
847
+ 'XC_functional_name': 'GGA_X_EV93',
848
+ }
849
+ ],
850
+ 'xc_terms_remove': [
851
+ {
852
+ 'XC_functional_name': 'LDA_X',
853
+ }
854
+ ],
855
+ 'xc_section_method': {
856
+ 'x_qe_xc_igcx_name': 'evx',
857
+ 'x_qe_xc_igcx_comment': 'Engel-Vosko exchange',
858
+ 'x_qe_xc_igcx': 25,
859
+ },
860
+ },
861
+ {
862
+ 'xc_terms': [
863
+ {
864
+ 'XC_functional_name': 'GGA_X_B86_R',
865
+ }
866
+ ],
867
+ 'xc_terms_remove': [
868
+ {
869
+ 'XC_functional_name': 'LDA_X',
870
+ }
871
+ ],
872
+ 'xc_section_method': {
873
+ 'x_qe_xc_igcx_name': 'b86r',
874
+ 'x_qe_xc_igcx_comment': 'revised Becke (b86b)',
875
+ 'x_qe_xc_igcx': 26,
876
+ },
877
+ },
878
+ {
879
+ 'xc_terms': [
880
+ {
881
+ 'XC_functional_name': 'GGA_X_LV_RPW86',
882
+ }
883
+ ],
884
+ 'xc_terms_remove': [
885
+ {
886
+ 'XC_functional_name': 'LDA_X',
887
+ }
888
+ ],
889
+ 'xc_section_method': {
890
+ 'x_qe_xc_igcx_name': 'cx13',
891
+ 'x_qe_xc_igcx_comment': 'consistent exchange',
892
+ 'x_qe_xc_igcx': 27,
893
+ },
894
+ },
895
+ {
896
+ 'xc_terms': [
897
+ {
898
+ 'XC_functional_name': 'GGA_X_B88',
899
+ 'XC_functional_weight': 0.542,
900
+ 'exx_compute_weight': lambda exx: 0.542 if (abs(exx) > 0.01) else 1.0,
901
+ },
902
+ {
903
+ 'XC_functional_name': 'GGA_X_PW91',
904
+ 'XC_functional_weight': 0.167,
905
+ 'exx_compute_weight': lambda exx: 0.167 if (abs(exx) > 0.01) else 0.0,
906
+ },
907
+ ],
908
+ 'xc_terms_remove': [
909
+ {
910
+ 'XC_functional_name': 'LDA_X',
911
+ 'exx_compute_weight': lambda exx: 0.709 if (abs(exx) > 0.01) else 1.0,
912
+ }
913
+ ],
914
+ 'xc_section_method': {
915
+ 'x_qe_xc_igcx_name': 'x3lp',
916
+ 'x_qe_xc_igcx_comment': 'X3LYP (Becke88*0.542 ' ' + Perdew-Wang91*0.167)',
917
+ 'x_qe_xc_igcx': 28,
918
+ },
919
+ },
920
+ # New additions for qe-v6.5.0: igcx=[29..42]
921
+ # - - - - - -
922
+ # igcx: 29. The ingredient 'vdW-DF-cx' is documented in the nomad-meta-info, where it
923
+ # has the name 'vdw_c_df_cx'
924
+ # 'https://gitlab.mpcdf.mpg.de/nomad-lab/nomad-meta-info/-/wikis/metainfo/XC-functional':
925
+ # 'vdW-DF-cx' implies igcx=27 => 'cx13', hence LDA_X is implicit. Full weight.
926
+ {
927
+ 'xc_terms': [
928
+ {
929
+ 'XC_functional_name': 'vdw_c_df_cx',
930
+ },
931
+ {
932
+ 'XC_functional_name': 'HF_X',
933
+ 'exx_compute_weight': lambda exx: exx,
934
+ 'XC_functional_weight': 0.25,
935
+ },
936
+ ],
937
+ 'xc_terms_remove': [
938
+ {
939
+ 'XC_functional_name': 'LDA_X',
940
+ }
941
+ ],
942
+ 'xc_section_method': {
943
+ 'x_qe_xc_igcx_name': 'cx0',
944
+ 'x_qe_xc_igcx_comment': 'vdW-DF-cx+HF/4 (cx13-0)',
945
+ 'x_qe_xc_igcx': 29,
946
+ },
947
+ },
948
+ # - - - - - -
949
+ # igcx:30. Needs full LDA_X removal, due to 'GGA_X_RPW86' (see igcx:27)
950
+ {
951
+ 'xc_terms': [
952
+ {
953
+ 'XC_functional_name': 'GGA_X_RPW86',
954
+ },
955
+ {
956
+ 'XC_functional_name': 'HF_X',
957
+ 'exx_compute_weight': lambda exx: exx,
958
+ 'XC_functional_weight': 0.25,
959
+ },
960
+ ],
961
+ 'xc_terms_remove': [
962
+ {
963
+ 'XC_functional_name': 'LDA_X',
964
+ }
965
+ ],
966
+ 'xc_section_method': {
967
+ 'x_qe_xc_igcx_name': 'r860',
968
+ 'x_qe_xc_igcx_comment': 'rPW86+HF/4 (rw86-0); (for DF0)',
969
+ 'x_qe_xc_igcx': 30,
970
+ },
971
+ },
972
+ # - - - - - -
973
+ # igcx:31. Similar comments as in 'igcx:29'
974
+ {
975
+ 'xc_terms': [
976
+ {
977
+ 'XC_functional_name': 'vdw_c_df_cx',
978
+ },
979
+ {
980
+ 'XC_functional_name': 'HF_X',
981
+ 'exx_compute_weight': lambda exx: exx,
982
+ 'XC_functional_weight': 0.20,
983
+ },
984
+ ],
985
+ 'xc_terms_remove': [
986
+ {
987
+ 'XC_functional_name': 'LDA_X',
988
+ }
989
+ ],
990
+ 'xc_section_method': {
991
+ 'x_qe_xc_igcx_name': 'cx0p',
992
+ 'x_qe_xc_igcx_comment': 'vdW-DF-cx+HF/5 (cx13-0p)',
993
+ 'x_qe_xc_igcx': 31,
994
+ },
995
+ },
996
+ # - - - - - -
997
+ {
998
+ 'xc_terms': [
999
+ {
1000
+ 'XC_functional_name': 'GGA_X_RESERVED',
1001
+ }
1002
+ ],
1003
+ 'xc_section_method': {
1004
+ 'x_qe_xc_igcx_name': 'ahcx',
1005
+ 'x_qe_xc_igcx_comment': 'vdW-DF-cx based; not yet in use (reserved PH)',
1006
+ 'x_qe_xc_igcx': 32,
1007
+ },
1008
+ },
1009
+ {
1010
+ 'xc_terms': [
1011
+ {
1012
+ 'XC_functional_name': 'GGA_X_RESERVED',
1013
+ }
1014
+ ],
1015
+ 'xc_section_method': {
1016
+ 'x_qe_xc_igcx_name': 'ahf2',
1017
+ 'x_qe_xc_igcx_comment': 'vdW-DF2 based; not yet in use (reserved PH)',
1018
+ 'x_qe_xc_igcx': 33,
1019
+ },
1020
+ },
1021
+ {
1022
+ 'xc_terms': [
1023
+ {
1024
+ 'XC_functional_name': 'GGA_X_RESERVED',
1025
+ }
1026
+ ],
1027
+ 'xc_section_method': {
1028
+ 'x_qe_xc_igcx_name': 'ahpb',
1029
+ 'x_qe_xc_igcx_comment': 'PBE based; not yet in use (reserved PH)',
1030
+ 'x_qe_xc_igcx': 34,
1031
+ },
1032
+ },
1033
+ {
1034
+ 'xc_terms': [
1035
+ {
1036
+ 'XC_functional_name': 'GGA_X_RESERVED',
1037
+ }
1038
+ ],
1039
+ 'xc_section_method': {
1040
+ 'x_qe_xc_igcx_name': 'ahps',
1041
+ 'x_qe_xc_igcx_comment': 'PBE-sol based; not in use (reserved PH)',
1042
+ 'x_qe_xc_igcx': 35,
1043
+ },
1044
+ },
1045
+ {
1046
+ 'xc_terms': [
1047
+ {
1048
+ 'XC_functional_name': 'GGA_X_RESERVED',
1049
+ }
1050
+ ],
1051
+ 'xc_section_method': {
1052
+ 'x_qe_xc_igcx_name': 'cx14',
1053
+ 'x_qe_xc_igcx_comment': 'Exporations (typo?: explorations), (reserved PH)',
1054
+ 'x_qe_xc_igcx': 36,
1055
+ },
1056
+ },
1057
+ {
1058
+ 'xc_terms': [
1059
+ {
1060
+ 'XC_functional_name': 'GGA_X_RESERVED',
1061
+ }
1062
+ ],
1063
+ 'xc_section_method': {
1064
+ 'x_qe_xc_igcx_name': 'cx15',
1065
+ 'x_qe_xc_igcx_comment': 'Exporations (typo? explorations?)(reserved PH)',
1066
+ 'x_qe_xc_igcx': 37,
1067
+ },
1068
+ },
1069
+ #
1070
+ # igcx': 38. Ingredients:
1071
+ # 'b86r' -> 'igcx:26' -> 'GGA_X_B86_R'
1072
+ # 'vdW-DF2' -> 'vdw_c_df2' . See nomad's gitlab:
1073
+ # 'https://gitlab.mpcdf.mpg.de/nomad-lab/nomad-meta-info/-/wikis/metainfo/XC-functional':
1074
+ {
1075
+ 'xc_terms': [
1076
+ {
1077
+ 'XC_functional_name': 'vdw_c_df2',
1078
+ },
1079
+ {
1080
+ 'XC_functional_name': 'GGA_X_B86_R',
1081
+ },
1082
+ {
1083
+ 'XC_functional_name': 'HF_X',
1084
+ 'exx_compute_weight': lambda exx: exx,
1085
+ 'XC_functional_weight': 0.25,
1086
+ },
1087
+ ],
1088
+ 'xc_terms_remove': [
1089
+ {
1090
+ 'XC_functional_name': 'LDA_X',
1091
+ }
1092
+ ],
1093
+ 'xc_section_method': {
1094
+ 'x_qe_xc_igcx_name': 'br0',
1095
+ 'x_qe_xc_igcx_comment': 'vdW-DF2-b86r+HF/4 (b86r-0)',
1096
+ 'x_qe_xc_igcx': 38,
1097
+ },
1098
+ },
1099
+ {
1100
+ 'xc_terms': [
1101
+ {
1102
+ 'XC_functional_name': 'GGA_X_RESERVED',
1103
+ }
1104
+ ],
1105
+ 'xc_section_method': {
1106
+ 'x_qe_xc_igcx_name': 'cx16',
1107
+ 'x_qe_xc_igcx_comment': 'Exporations (typo?, explorations?)(reserved PH)',
1108
+ 'x_qe_xc_igcx': 39,
1109
+ },
1110
+ },
1111
+ # - - - -
1112
+ {
1113
+ 'xc_terms': [
1114
+ {
1115
+ 'XC_functional_name': 'vdw_c_df1',
1116
+ },
1117
+ {
1118
+ 'XC_functional_name': 'GGA_X_C09X',
1119
+ },
1120
+ {
1121
+ 'XC_functional_name': 'HF_X',
1122
+ 'exx_compute_weight': lambda exx: exx,
1123
+ 'XC_functional_weight': 0.25,
1124
+ },
1125
+ ],
1126
+ 'xc_terms_remove': [
1127
+ {
1128
+ 'XC_functional_name': 'LDA_X',
1129
+ }
1130
+ ],
1131
+ 'xc_section_method': {
1132
+ 'x_qe_xc_igcx_name': 'c090',
1133
+ 'x_qe_xc_igcx_comment': 'vdW-DF-c09+HF/4 (c09-0)',
1134
+ 'x_qe_xc_igcx': 40,
1135
+ },
1136
+ },
1137
+ # - - - - - - -
1138
+ # 'igcx:41' Note: 'B86b' is defined in 'igcx:22'
1139
+ {
1140
+ 'xc_terms': [
1141
+ {
1142
+ 'XC_functional_name': 'GGA_X_B86_MGC',
1143
+ }
1144
+ ],
1145
+ 'xc_terms_remove': [
1146
+ {
1147
+ 'XC_functional_name': 'LDA_X',
1148
+ 'XC_functional_weight': 0.75,
1149
+ 'exx_compute_weight': lambda exx: (1.0 - exx),
1150
+ }
1151
+ ],
1152
+ 'xc_section_method': {
1153
+ 'x_qe_xc_igcx_name': 'b86x',
1154
+ 'x_qe_xc_igcx_comment': 'B86b exchange * 0.75',
1155
+ 'x_qe_xc_igcx': 41,
1156
+ },
1157
+ },
1158
+ # - - - - - - -
1159
+ # 'B88' is defined in 'igcx:1'
1160
+ {
1161
+ 'xc_terms': [
1162
+ {
1163
+ 'XC_functional_name': 'GGA_X_B88',
1164
+ }
1165
+ ],
1166
+ 'xc_terms_remove': [
1167
+ {
1168
+ 'XC_functional_name': 'LDA_X',
1169
+ 'XC_functional_weight': 0.50,
1170
+ 'exx_compute_weight': lambda exx: (1.0 - exx),
1171
+ }
1172
+ ],
1173
+ 'xc_section_method': {
1174
+ 'x_qe_xc_igcx_name': 'b88x',
1175
+ 'x_qe_xc_igcx_comment': 'B88 exchange * 0.50',
1176
+ 'x_qe_xc_igcx': 42,
1177
+ },
1178
+ },
1179
+ ]
1180
+
1181
+ # UNchanged between espresso v5.4 & v6.5
1182
+ _correlation_gradient_correction_map = [
1183
+ None,
1184
+ {
1185
+ 'xc_terms': [
1186
+ {
1187
+ 'XC_functional_name': 'GGA_C_P86',
1188
+ }
1189
+ ],
1190
+ 'xc_terms_remove': [
1191
+ {
1192
+ 'XC_functional_name': 'LDA_C_PW',
1193
+ }
1194
+ ],
1195
+ 'xc_section_method': {
1196
+ 'x_qe_xc_igcc_name': 'p86',
1197
+ 'x_qe_xc_igcc_comment': 'Perdew86',
1198
+ 'x_qe_xc_igcc': 1,
1199
+ },
1200
+ },
1201
+ {
1202
+ 'xc_terms': [
1203
+ {
1204
+ 'XC_functional_name': 'GGA_C_PW91',
1205
+ }
1206
+ ],
1207
+ 'xc_terms_remove': [
1208
+ {
1209
+ 'XC_functional_name': 'LDA_C_PW',
1210
+ }
1211
+ ],
1212
+ 'xc_section_method': {
1213
+ 'x_qe_xc_igcc_name': 'ggc',
1214
+ 'x_qe_xc_igcc_comment': 'Perdew-Wang 91 corr.',
1215
+ 'x_qe_xc_igcc': 2,
1216
+ },
1217
+ },
1218
+ {
1219
+ 'xc_terms': [
1220
+ {
1221
+ 'XC_functional_name': 'GGA_C_LYP',
1222
+ }
1223
+ ],
1224
+ 'xc_terms_remove': [
1225
+ {
1226
+ 'XC_functional_name': 'LDA_C_LYP',
1227
+ }
1228
+ ],
1229
+ 'xc_section_method': {
1230
+ 'x_qe_xc_igcc_name': 'blyp',
1231
+ 'x_qe_xc_igcc_comment': 'Lee-Yang-Parr',
1232
+ 'x_qe_xc_igcc': 3,
1233
+ },
1234
+ },
1235
+ {
1236
+ 'xc_terms': [
1237
+ {
1238
+ 'XC_functional_name': 'GGA_C_PBE',
1239
+ }
1240
+ ],
1241
+ 'xc_terms_remove': [
1242
+ {
1243
+ 'XC_functional_name': 'LDA_C_PW',
1244
+ }
1245
+ ],
1246
+ 'xc_section_method': {
1247
+ 'x_qe_xc_igcc_name': 'pbc',
1248
+ 'x_qe_xc_igcc_comment': 'Perdew-Burke-Ernzenhof corr',
1249
+ 'x_qe_xc_igcc': 4,
1250
+ },
1251
+ },
1252
+ {
1253
+ 'xc_terms': [
1254
+ {
1255
+ 'XC_functional_name': 'GGA_XC_HCTH_120',
1256
+ }
1257
+ ],
1258
+ 'xc_section_method': {
1259
+ 'x_qe_xc_igcc_name': 'hcth',
1260
+ 'x_qe_xc_igcc_comment': 'Cambridge exch, Handy et al, HCTH/120',
1261
+ 'x_qe_xc_igcc': 5,
1262
+ },
1263
+ },
1264
+ {
1265
+ # igcc=6 is not defined in 5.4's funct.f90
1266
+ # definition taken from 5.0, which did not have separate imeta
1267
+ 'xc_terms': [
1268
+ {
1269
+ 'XC_functional_name': 'MGGA_C_TPSS',
1270
+ }
1271
+ ],
1272
+ 'xc_terms_remove': [
1273
+ {
1274
+ 'XC_functional_name': 'LDA_C_PW',
1275
+ }
1276
+ ],
1277
+ 'xc_section_method': {
1278
+ 'x_qe_xc_igcc_name': 'tpss',
1279
+ 'x_qe_xc_igcc_comment': 'TPSS Meta-GGA (Espresso-version < 5.1)',
1280
+ 'x_qe_xc_igcc': 6,
1281
+ },
1282
+ },
1283
+ {
1284
+ 'xc_terms': [
1285
+ {
1286
+ 'XC_functional_name': 'GGA_C_LYP',
1287
+ 'XC_functional_weight': 0.81,
1288
+ }
1289
+ ],
1290
+ 'xc_terms_remove': [
1291
+ {
1292
+ 'XC_functional_name': 'LDA_C_LYP',
1293
+ 'XC_functional_weight': 0.81,
1294
+ }
1295
+ ],
1296
+ 'xc_section_method': {
1297
+ 'x_qe_xc_igcc_name': 'b3lp',
1298
+ 'x_qe_xc_igcc_comment': 'B3LYP (Lee-Yang-Parr*0.81)',
1299
+ 'x_qe_xc_igcc': 7,
1300
+ },
1301
+ },
1302
+ {
1303
+ 'xc_terms': [
1304
+ {
1305
+ 'XC_functional_name': 'GGA_C_PBE_SOL',
1306
+ }
1307
+ ],
1308
+ 'xc_terms_remove': [
1309
+ {
1310
+ 'XC_functional_name': 'LDA_C_PW',
1311
+ }
1312
+ ],
1313
+ 'xc_section_method': {
1314
+ 'x_qe_xc_igcc_name': 'psc',
1315
+ 'x_qe_xc_igcc_comment': 'PBEsol corr',
1316
+ 'x_qe_xc_igcc': 8,
1317
+ },
1318
+ },
1319
+ {
1320
+ 'xc_terms': [
1321
+ {
1322
+ 'XC_functional_name': 'GGA_C_PBE',
1323
+ }
1324
+ ],
1325
+ 'xc_terms_remove': [
1326
+ {
1327
+ 'XC_functional_name': 'LDA_C_PW',
1328
+ }
1329
+ ],
1330
+ 'xc_section_method': {
1331
+ 'x_qe_xc_igcc_name': 'pbe',
1332
+ 'x_qe_xc_igcc_comment': 'same as PBX, back-comp.',
1333
+ 'x_qe_xc_igcc': 9,
1334
+ },
1335
+ },
1336
+ {
1337
+ # igcc=10 is not defined in 5.4's funct.f90
1338
+ # definition taken from 5.0, which did not have separate imeta
1339
+ # functionals.f90 tells that correlation is taken from tpss
1340
+ 'xc_terms': [
1341
+ {
1342
+ 'XC_functional_name': 'MGGA_C_TPSS',
1343
+ }
1344
+ ],
1345
+ 'xc_terms_remove': [
1346
+ {
1347
+ 'XC_functional_name': 'LDA_C_PW',
1348
+ }
1349
+ ],
1350
+ 'xc_section_method': {
1351
+ 'x_qe_xc_igcc_name': 'tb09',
1352
+ 'x_qe_xc_igcc_comment': 'TB09 Meta-GGA (Espresso-version < 5.1)',
1353
+ 'x_qe_xc_igcc': 10,
1354
+ },
1355
+ },
1356
+ {
1357
+ # igcc=11 is not defined in 5.4's funct.f90
1358
+ # definition taken from 5.0, which did not have separate imeta
1359
+ 'xc_terms': [
1360
+ {
1361
+ 'XC_functional_name': 'MGGA_C_M06_L',
1362
+ }
1363
+ ],
1364
+ 'xc_section_method': {
1365
+ 'x_qe_xc_igcc_name': 'm6lc',
1366
+ 'x_qe_xc_igcc_comment': 'M06L Meta-GGA (Espresso-version < 5.1)',
1367
+ 'x_qe_xc_igcc': 11,
1368
+ },
1369
+ },
1370
+ {
1371
+ 'xc_terms': [
1372
+ {
1373
+ 'XC_functional_name': 'GGA_C_Q2D',
1374
+ }
1375
+ ],
1376
+ 'xc_terms_remove': [
1377
+ {
1378
+ 'XC_functional_name': 'LDA_C_PW',
1379
+ }
1380
+ ],
1381
+ 'xc_section_method': {
1382
+ 'x_qe_xc_igcc_name': 'q2dc',
1383
+ 'x_qe_xc_igcc_comment': 'Q2D correlation grad corr',
1384
+ 'x_qe_xc_igcc': 12,
1385
+ },
1386
+ },
1387
+ {
1388
+ 'xc_terms': [
1389
+ {
1390
+ 'XC_functional_name': 'GGA_C_LYP',
1391
+ 'XC_functional_weight': 0.871,
1392
+ }
1393
+ ],
1394
+ 'xc_terms_remove': [
1395
+ {
1396
+ 'XC_functional_name': 'LDA_C_LYP',
1397
+ 'XC_functional_weight': 0.871,
1398
+ }
1399
+ ],
1400
+ 'xc_section_method': {
1401
+ 'x_qe_xc_igcc_name': 'x3lp',
1402
+ 'x_qe_xc_igcc_comment': 'X3LYP (Lee-Yang-Parr*0.871)',
1403
+ 'x_qe_xc_igcc': 13,
1404
+ },
1405
+ },
1406
+ {
1407
+ # igcc=14 is not defined in NEITHER of v5.1, v6.1, v6.4's Modules/funct.f90
1408
+ # 'BEEF-vdW, a GGA with vdW-DF2 type nonlocal correlation'
1409
+ 'xc_terms': [
1410
+ {
1411
+ 'XC_functional_name': 'GGA_C_BEEF-vdW',
1412
+ }
1413
+ ],
1414
+ 'xc_terms_remove': [
1415
+ {
1416
+ 'XC_functional_name': 'LDA_C_PW',
1417
+ }
1418
+ ],
1419
+ 'xc_section_method': {
1420
+ 'x_qe_xc_igcc_name': 'BEEF-vdW',
1421
+ 'x_qe_xc_igcc_comment': 'libbeef V0.1.1 library',
1422
+ 'x_qe_xc_igcc': 14,
1423
+ },
1424
+ },
1425
+ ]
1426
+
1427
+ # New additions for espresso-6.5.0: imeta=[4, 5, 6]
1428
+ _meta_gga_map = [
1429
+ None,
1430
+ {
1431
+ 'xc_terms': [
1432
+ {
1433
+ 'XC_functional_name': 'MGGA_X_TPSS',
1434
+ },
1435
+ {
1436
+ 'XC_functional_name': 'MGGA_C_TPSS',
1437
+ },
1438
+ ],
1439
+ 'xc_terms_remove': [
1440
+ {
1441
+ 'XC_functional_name': 'LDA_X',
1442
+ },
1443
+ {
1444
+ 'XC_functional_name': 'LDA_C_PW',
1445
+ },
1446
+ ],
1447
+ 'xc_section_method': {
1448
+ 'x_qe_xc_imeta_name': 'tpss',
1449
+ 'x_qe_xc_imeta_comment': 'TPSS Meta-GGA',
1450
+ 'x_qe_xc_imeta': 1,
1451
+ },
1452
+ },
1453
+ {
1454
+ 'xc_terms': [
1455
+ {
1456
+ 'XC_functional_name': 'MGGA_X_M06_L',
1457
+ },
1458
+ {
1459
+ 'XC_functional_name': 'MGGA_C_M06_L',
1460
+ },
1461
+ ],
1462
+ 'xc_section_method': {
1463
+ 'x_qe_xc_imeta_name': 'm6lx',
1464
+ 'x_qe_xc_imeta_comment': 'M06L Meta-GGA',
1465
+ 'x_qe_xc_imeta': 2,
1466
+ },
1467
+ },
1468
+ {
1469
+ 'xc_terms': [
1470
+ {
1471
+ 'XC_functional_name': 'MGGA_X_TB09',
1472
+ },
1473
+ {
1474
+ # confirmed by looking into functionals.f90
1475
+ 'XC_functional_name': 'MGGA_C_TPSS',
1476
+ },
1477
+ ],
1478
+ 'xc_terms_remove': [
1479
+ {
1480
+ 'XC_functional_name': 'LDA_X',
1481
+ },
1482
+ {
1483
+ 'XC_functional_name': 'LDA_C_PW',
1484
+ },
1485
+ ],
1486
+ 'xc_section_method': {
1487
+ 'x_qe_xc_imeta_name': 'tb09',
1488
+ 'x_qe_xc_imeta_comment': 'TB09 Meta-GGA',
1489
+ 'x_qe_xc_imeta': 3,
1490
+ },
1491
+ },
1492
+ # imeta = [4,5,6] are new espresso-6.5.0/Modules/funct.f90
1493
+ {
1494
+ 'xc_terms': [
1495
+ {
1496
+ 'XC_functional_name': 'MGGA_X_TPSS',
1497
+ },
1498
+ {
1499
+ 'XC_functional_name': 'MGGA_C_TPSS',
1500
+ },
1501
+ ],
1502
+ 'xc_terms_remove': [
1503
+ {
1504
+ 'XC_functional_name': 'LDA_X',
1505
+ },
1506
+ {
1507
+ 'XC_functional_name': 'LDA_C_PW',
1508
+ },
1509
+ ],
1510
+ 'xc_section_method': {
1511
+ 'x_qe_xc_imeta_name': '+meta',
1512
+ 'x_qe_xc_imeta_comment': 'activate MGGA even without MGGA-XC',
1513
+ 'x_qe_xc_imeta': 4,
1514
+ },
1515
+ },
1516
+ # - - - - - - - -
1517
+ {
1518
+ 'xc_terms': [
1519
+ {
1520
+ 'XC_functional_name': 'MGGA_X_SCAN',
1521
+ },
1522
+ {
1523
+ 'XC_functional_name': 'MGGA_C_SCAN',
1524
+ },
1525
+ ],
1526
+ 'xc_terms_remove': [
1527
+ {
1528
+ 'XC_functional_name': 'LDA_X',
1529
+ },
1530
+ {
1531
+ 'XC_functional_name': 'LDA_C_PW',
1532
+ },
1533
+ ],
1534
+ 'xc_section_method': {
1535
+ 'x_qe_xc_imeta_name': 'scan',
1536
+ 'x_qe_xc_imeta_comment': 'SCAN Meta-GGA ',
1537
+ 'x_qe_xc_imeta': 5,
1538
+ },
1539
+ },
1540
+ # - - - - - - - -
1541
+ {
1542
+ 'xc_terms': [
1543
+ {
1544
+ 'XC_functional_name': 'HYB_MGGA_X_SCAN0',
1545
+ },
1546
+ {
1547
+ 'XC_functional_name': 'MGGA_C_SCAN',
1548
+ },
1549
+ ],
1550
+ 'xc_terms_remove': [
1551
+ {
1552
+ 'XC_functional_name': 'LDA_X',
1553
+ },
1554
+ {
1555
+ 'XC_functional_name': 'LDA_C_PW',
1556
+ },
1557
+ ],
1558
+ 'xc_section_method': {
1559
+ 'x_qe_xc_imeta_name': 'sca0',
1560
+ 'x_qe_xc_imeta_comment': 'SCAN0 Meta-GGA',
1561
+ 'x_qe_xc_imeta': 6,
1562
+ },
1563
+ },
1564
+ ]
1565
+
1566
+ _van_der_waals_map = [
1567
+ None,
1568
+ {
1569
+ 'xc_terms': [
1570
+ {
1571
+ 'XC_functional_name': 'VDW_XC_DF1',
1572
+ }
1573
+ ],
1574
+ 'xc_terms_remove': [
1575
+ {
1576
+ 'XC_functional_name': 'LDA_X',
1577
+ },
1578
+ {
1579
+ 'XC_functional_name': 'LDA_C_PW',
1580
+ },
1581
+ ],
1582
+ 'xc_section_method': {
1583
+ 'x_qe_xc_inlc_name': 'vdw1',
1584
+ 'x_qe_xc_inlc_comment': 'vdW-DF1',
1585
+ 'x_qe_xc_inlc': 1,
1586
+ },
1587
+ },
1588
+ {
1589
+ 'xc_terms': [
1590
+ {
1591
+ 'XC_functional_name': 'VDW_XC_DF2',
1592
+ }
1593
+ ],
1594
+ 'xc_terms_remove': [
1595
+ {
1596
+ 'XC_functional_name': 'LDA_X',
1597
+ },
1598
+ {
1599
+ 'XC_functional_name': 'LDA_C_PW',
1600
+ },
1601
+ ],
1602
+ 'xc_section_method': {
1603
+ 'x_qe_xc_inlc_name': 'vdw2',
1604
+ 'x_qe_xc_inlc_comment': 'vdW-DF2',
1605
+ 'x_qe_xc_inlc': 2,
1606
+ },
1607
+ },
1608
+ {
1609
+ 'xc_terms': [
1610
+ {
1611
+ 'XC_functional_name': 'VDW_C_RVV10',
1612
+ }
1613
+ ],
1614
+ 'xc_terms_remove': [
1615
+ {
1616
+ 'XC_functional_name': 'GGA_C_PBE',
1617
+ }
1618
+ ],
1619
+ 'xc_section_method': {
1620
+ 'x_qe_xc_inlc_name': 'vv10',
1621
+ 'x_qe_xc_inlc_comment': 'rVV10',
1622
+ 'x_qe_xc_inlc': 3,
1623
+ },
1624
+ },
1625
+ {
1626
+ 'xc_terms': [
1627
+ {
1628
+ 'XC_functional_name': 'VDW_DFX_x_qe',
1629
+ }
1630
+ ],
1631
+ 'xc_section_method': {
1632
+ 'x_qe_xc_inlc_name': 'vdwx',
1633
+ 'x_qe_xc_inlc_comment': 'vdW-DF-x (reserved Thonhauser,'
1634
+ ' not implemented)',
1635
+ 'x_qe_xc_inlc': 4,
1636
+ },
1637
+ },
1638
+ {
1639
+ 'xc_terms': [
1640
+ {
1641
+ 'XC_functional_name': 'VDW_DFY_x_qe',
1642
+ }
1643
+ ],
1644
+ 'xc_section_method': {
1645
+ 'x_qe_xc_inlc_name': 'vdwy',
1646
+ 'x_qe_xc_inlc_comment': 'vdW-DF-y (reserved Thonhauser,'
1647
+ ' not implemented)',
1648
+ 'x_qe_xc_inlc': 5,
1649
+ },
1650
+ },
1651
+ {
1652
+ 'xc_terms': [
1653
+ {
1654
+ 'XC_functional_name': 'VDW_DFZ_x_qe',
1655
+ }
1656
+ ],
1657
+ 'xc_section_method': {
1658
+ 'x_qe_xc_inlc_name': 'vdwz',
1659
+ 'x_qe_xc_inlc_comment': 'vdW-DF-z (reserved Thonhauser,'
1660
+ ' not implemented)',
1661
+ 'x_qe_xc_inlc': 6,
1662
+ },
1663
+ },
1664
+ ]
1665
+
1666
+ _libxc_shortcut = {
1667
+ '0.810*GGA_C_LYP+0.720*GGA_X_B88+0.200*HF_X+0.190*LDA_C_VWN': {
1668
+ 'xc_terms': [
1669
+ {
1670
+ 'XC_functional_name': 'HYB_GGA_XC_B3LYP',
1671
+ }
1672
+ ]
1673
+ },
1674
+ 'GGA_C_PBE+0.750*GGA_X_PBE+0.250*HF_X': {
1675
+ 'xc_terms': [
1676
+ {
1677
+ 'XC_functional_name': 'HYB_GGA_XC_PBEH',
1678
+ }
1679
+ ]
1680
+ },
1681
+ }
1682
+
1683
+
1684
+ class QuantumEspressoRunParser(TextParser):
1685
+ def __init__(self, quantities):
1686
+ super().__init__(quantities=quantities)
1687
+ self._xc_functional_map = [
1688
+ _exchange_map,
1689
+ _correlation_map,
1690
+ _exchange_gradient_correction_map,
1691
+ _correlation_gradient_correction_map,
1692
+ _van_der_waals_map,
1693
+ _meta_gga_map,
1694
+ ]
1695
+
1696
+ def copy(self):
1697
+ return QuantumEspressoRunParser(self._quantities)
1698
+
1699
+ def get_header(self, key, default=None):
1700
+ return self.get('header', {}).get(key, default)
1701
+
1702
+ def get_xc_functional(self):
1703
+ xc_functional = self.get_header('xc_functional')
1704
+ if xc_functional is None:
1705
+ return {}, []
1706
+
1707
+ _, numbers = xc_functional.split('(')
1708
+ numbers = numbers.split(')')[0]
1709
+ # handle different formatting
1710
+ if len(numbers) == 4:
1711
+ # 4-digit format without spaces
1712
+ numbers_split = re.findall(r'(\d)', numbers)
1713
+ elif len(numbers) == 10:
1714
+ # 5-digit format with/without spaces
1715
+ numbers_split = re.findall(r'[ \d]\d', numbers)
1716
+ else:
1717
+ # 6-digit with spaces
1718
+ numbers_split = numbers.split()
1719
+
1720
+ if not numbers_split:
1721
+ self.logger.warning(
1722
+ 'Unknown XC functional format', data=dict(value=numbers)
1723
+ )
1724
+ numbers_split = [int(n) for n in numbers_split]
1725
+
1726
+ # numbers should have six digits
1727
+ numbers_split.extend([0] * (6 - len(numbers_split)))
1728
+
1729
+ def gen_string(data, separator='+'):
1730
+ string = ''
1731
+ for key in sorted(data.keys()):
1732
+ val = data[key]
1733
+ if len(string) > 0 and val.get('XC_functional_weight', 1.0) > 0:
1734
+ string += separator
1735
+ if val.get('XC_functional_weight', None) is not None:
1736
+ string += '%.3f*' % (val['XC_functional_weight'])
1737
+ string += val['XC_functional_name']
1738
+ return string
1739
+
1740
+ def get_data(source):
1741
+ data = dict()
1742
+ exx_fraction = self.get_header('x_qe_exact_exchange_fraction', 0.0)
1743
+ for term in source:
1744
+ term = term.copy()
1745
+ weight = term.get('exx_compute_weight', 1.0)
1746
+ if not isinstance(weight, float):
1747
+ weight = weight(exx_fraction)
1748
+ term['XC_functional_weight'] = weight
1749
+ data.setdefault(term['XC_functional_name'], term)
1750
+ return data
1751
+
1752
+ def filter_data(data):
1753
+ out = dict()
1754
+ for key, val in data.items():
1755
+ if abs(val['XC_functional_weight']) < 0.01:
1756
+ continue
1757
+ else:
1758
+ if abs(val['XC_functional_weight'] - 1.0) < 0.01:
1759
+ del val['XC_functional_weight']
1760
+ val.pop('exx_compute_weight', None)
1761
+ out[key] = val
1762
+ return out
1763
+
1764
+ # map numbers to values
1765
+ xc_section_method = dict()
1766
+ xc_terms = dict()
1767
+ xc_terms_remove = dict()
1768
+ for i in range(6):
1769
+ xc_component = self._xc_functional_map[i]
1770
+ xc_number = numbers_split[i]
1771
+ if xc_number >= len(xc_component) or xc_component[xc_number] is None:
1772
+ # self.logger.warning(
1773
+ # 'Cannot resolve XC functional',
1774
+ # data=dict(name=xc_names[i], index=xc_number))
1775
+ continue
1776
+ xc_section_method.update(xc_component[xc_number]['xc_section_method'])
1777
+ xc_terms.update(get_data(xc_component[xc_number]['xc_terms']))
1778
+ xc_terms_remove.update(
1779
+ get_data(xc_component[xc_number].get('xc_terms_remove', []))
1780
+ )
1781
+
1782
+ # remove terms
1783
+ for key, val in xc_terms_remove.items():
1784
+ if key in xc_terms:
1785
+ xc_terms[key]['XC_functional_weight'] -= val['XC_functional_weight']
1786
+ else:
1787
+ xc_terms[key] = val
1788
+ xc_terms[key]['XC_functional_weight'] *= -1.0
1789
+
1790
+ # filter data
1791
+ xc_terms = filter_data(xc_terms)
1792
+
1793
+ xc_functional_str = gen_string(xc_terms)
1794
+ if xc_functional_str in _libxc_shortcut:
1795
+ # override for libXC compliance
1796
+ xc_terms = get_data(_libxc_shortcut[xc_functional_str]['xc_terms'])
1797
+ xc_terms = filter_data(xc_terms)
1798
+
1799
+ xc_functional_str = gen_string(xc_terms)
1800
+
1801
+ xc_section_method['XC_functional'] = xc_functional_str
1802
+ result = [xc_terms[key] for key in sorted(xc_terms.keys())]
1803
+
1804
+ return (xc_section_method, result)
1805
+
1806
+ def get_number_of_spin_channels(self):
1807
+ magnetic = self.get_header('starting_magnetization')
1808
+ if magnetic is None:
1809
+ calculation = self.get('self_consistent', {})
1810
+ magnetic = calculation.get('magnetization', calculation.get('spin_pol'))
1811
+ spin = 1 if magnetic is None else 2
1812
+ return spin
1813
+
1814
+
1815
+ class QuantumEspressoOutParser(TextParser):
1816
+ def __init__(self):
1817
+ super().__init__(None)
1818
+
1819
+ def init_quantities(self):
1820
+ def str_to_energy_contributions(val_in):
1821
+ val = [v.split('=') for v in val_in.strip().split('\n')]
1822
+ return {v[0].strip(): float(v[1].split()[0]) * ureg.rydberg for v in val}
1823
+
1824
+ def str_to_forces(val_in):
1825
+ val = val_in.strip().split('\n')
1826
+ val = [v.split('=')[1].split() for v in val if 'force =' in v]
1827
+ return np.array(val, dtype=float) * ureg.rydberg / ureg.bohr
1828
+
1829
+ def str_to_stress(val_in):
1830
+ val = [v.split() for v in val_in.strip().split('\n')]
1831
+ pressure = float(val[0][0]) * ureg.kilobar
1832
+ stress = np.array([v[3:6] for v in val[1:4]], dtype=float) * ureg.kilobar
1833
+ return pressure, stress
1834
+
1835
+ def str_to_labels_positions(val_in):
1836
+ units = re.search(r'ATOMIC_POSITIONS \((.+)\)', val_in)
1837
+ out = dict()
1838
+ if units:
1839
+ out['units'] = units.group(1)
1840
+ val = [v.split()[:4] for v in val_in.strip().split('\n')[1:]]
1841
+ val = np.transpose([v for v in val if v[1][-1].isdecimal()])
1842
+ out['labels'] = val[0]
1843
+ out['positions'] = np.array(val[1:], dtype=float).T
1844
+ return out
1845
+
1846
+ def str_to_atom_data(val_in):
1847
+ val = [
1848
+ v.replace('(', ' ').replace(')', ' ').split()
1849
+ for v in val_in.strip().split('\n')
1850
+ ]
1851
+ return [[float(vi) if not vi[0].isalpha() else vi for vi in v] for v in val]
1852
+
1853
+ def str_to_occupations(val_in):
1854
+ return np.array(val_in.strip().split(), dtype=float)
1855
+
1856
+ def str_to_arrays(val_in):
1857
+ val = [v for v in val_in.strip().split('\n')]
1858
+ pattern = re.compile(r'([\S\s]+?)(\d+\.\d+)\s*Mb\s*\(\s*([\d, ]+)\)')
1859
+ names = []
1860
+ sizes = []
1861
+ dimensions = []
1862
+ for v in val:
1863
+ res = pattern.search(v)
1864
+ if res is None:
1865
+ continue
1866
+ g = res.groups()
1867
+ names.append(g[0].strip())
1868
+ sizes.append(float(g[1]))
1869
+ dimensions.append(g[2].strip())
1870
+ return names, sizes, dimensions
1871
+
1872
+ def str_to_algorithm(val_in):
1873
+ val = val_in.strip().lower()
1874
+ out = None
1875
+ if val == 'davidson':
1876
+ out = 'davidson'
1877
+ elif val == 'cg style':
1878
+ out = 'conjugate_gradient'
1879
+ return out
1880
+
1881
+ def str_to_band_energies(val_in):
1882
+ val = re.findall(r'(\-?[\d\.Ee]+)', val_in)
1883
+ return np.array(val, dtype=float)
1884
+
1885
+ def str_to_profiling(val_in):
1886
+ sections = val_in.strip().split('\n\n')
1887
+ caller, category, function, cpu_time, wall_time, calls = (
1888
+ [],
1889
+ [],
1890
+ [],
1891
+ [],
1892
+ [],
1893
+ [],
1894
+ )
1895
+ section_pattern = re.compile(
1896
+ r'(?:Called by ([\S\s]+?):|([\S\s]+?) routines)'
1897
+ )
1898
+ function_pattern = re.compile(r'(\S+)\s*:')
1899
+ cpu_time_pattern = re.compile(
1900
+ r'(?:(\d+)h)?(?:(\d+)m)?(?:([\d\.]+)s)? (?:CPU|CPU time)'
1901
+ )
1902
+ wall_time_pattern = re.compile(
1903
+ r'(?:(\d+)h)?(?:(\d+)m)?(?:([\d\.]+)s)? (?:WALL|WALL time|wall|wall time)'
1904
+ )
1905
+ calls_pattern = re.compile(r'(\d+)\s*calls')
1906
+ for section in sections:
1907
+ sub_sections = section.split('\n')
1908
+ name = section_pattern.findall(sub_sections[0])
1909
+ if name:
1910
+ caller_name, category_name = name[0][:2]
1911
+ sub_sections = sub_sections[1:]
1912
+ else:
1913
+ caller_name, category_name = '', ''
1914
+
1915
+ for sub_section in sub_sections:
1916
+ function_name = function_pattern.search(sub_section)
1917
+ if function_name is None:
1918
+ continue
1919
+ caller.append(caller_name.strip())
1920
+ category.append(category_name.strip())
1921
+ function.append(function_name.group(1).strip())
1922
+ res = cpu_time_pattern.findall(sub_section)
1923
+ if len(res) == 0:
1924
+ return caller, category, function, cpu_time, wall_time, calls
1925
+ time = sum(
1926
+ [
1927
+ float(res[0][i]) * 60 ** (2 - i) if res[0][i] else 0
1928
+ for i in range(len(res[0]))
1929
+ ]
1930
+ )
1931
+ cpu_time.append(0.0 if res is None else time)
1932
+ res = wall_time_pattern.findall(sub_section)
1933
+ wall_time.append(
1934
+ 0.0
1935
+ if not res
1936
+ else sum(
1937
+ [
1938
+ float(res[0][i]) * 60 ** (2 - i) if res[0][i] else 0
1939
+ for i in range(len(res[0]))
1940
+ ]
1941
+ )
1942
+ )
1943
+ res = calls_pattern.search(sub_section)
1944
+ calls.append(0 if res is None else int(res.group(1)))
1945
+ return caller, category, function, cpu_time, wall_time, calls
1946
+
1947
+ def str_to_dispersion(val_in):
1948
+ val = [v.split() for v in val_in]
1949
+ return {
1950
+ v[0].strip(): {'vdw_radius': float(v[1]), 'C_6': float(v[2])}
1951
+ for v in val
1952
+ }
1953
+
1954
+ def str_to_sticks(val_in):
1955
+ val = [v.split() for v in val_in.strip().split('\n')]
1956
+ return {v[0]: [int(i) for i in v[1:]] for v in val}
1957
+
1958
+ re_float = r'[\d\.Ee\-\+]+'
1959
+
1960
+ header_quantities = [
1961
+ Quantity(
1962
+ 'supercell',
1963
+ rf'(?:operation: I \+ \(|translation:)\s*({re_float})\s*({re_float})\s*({re_float})',
1964
+ dtype=float,
1965
+ repeats=True,
1966
+ ),
1967
+ Quantity(
1968
+ 'pseudopotential_report',
1969
+ r'(pseudopotential report for atomic species:[\s\S]+?)={10}',
1970
+ sub_parser=TextParser(
1971
+ quantities=[
1972
+ Quantity('species', r'atomic species:\s*(\d+)', dtype=int),
1973
+ Quantity(
1974
+ 'version',
1975
+ r'pseudo potential version\s*([\d ]+)',
1976
+ flatten=False,
1977
+ ),
1978
+ Quantity('contents', r'\-\s*([\s\S]+)', flatten=False),
1979
+ ]
1980
+ ),
1981
+ repeats=True,
1982
+ ),
1983
+ Quantity(
1984
+ 'renormalized_wavefunction',
1985
+ r'file (\S+): wavefunction\(s\)([\w ]+)renormalized',
1986
+ repeats=True,
1987
+ ),
1988
+ Quantity(
1989
+ 'dispersion',
1990
+ r'atom\s*VdW radius\s*C_6\s*([\s\S]+?)\n\s*\n',
1991
+ str_operation=str_to_dispersion,
1992
+ convert=False,
1993
+ ),
1994
+ Quantity(
1995
+ 'atom_radii',
1996
+ r'new r_m :\s*[\d\.]+\s*\(alat units\)\s*([\d\.]+) \(a\.u\.\) for type\s*(\d+)',
1997
+ repeats=True,
1998
+ ),
1999
+ Quantity(
2000
+ 'x_qe_xc_functional_user_enforced',
2001
+ r'IMPORTANT: XC functional enforced from input :\s*Exchange\-correlation\s*=\s*(\w+)',
2002
+ str_operation=lambda x: True,
2003
+ ),
2004
+ Quantity(
2005
+ 'x_qe_gamma_algorithms',
2006
+ r'(gamma\-point specific algorithms are used)',
2007
+ str_operation=lambda x: True,
2008
+ ),
2009
+ Quantity(
2010
+ 'x_qe_diagonalization_algorithm',
2011
+ r'of the eigenvalue problem:\s*a (serial) algorithm will be used',
2012
+ ),
2013
+ Quantity(
2014
+ 'g_vector_sticks',
2015
+ r'G-vecs:\s*dense\s*smooth\s*PW\s*([\s\S]+?)\n *\n',
2016
+ str_operation=str_to_sticks,
2017
+ convert=False,
2018
+ ),
2019
+ Quantity('x_qe_ibrav', r'bravais\-lattice index\s*=\s*(\d+)', dtype=int),
2020
+ Quantity(
2021
+ 'alat',
2022
+ rf'lattice parameter \((?:alat|a_0)\)\s*=\s*({re_float})',
2023
+ unit='bohr',
2024
+ dtype=float,
2025
+ ),
2026
+ Quantity(
2027
+ 'x_qe_cell_volume',
2028
+ rf'unit-cell volume\s*=\s*({re_float})',
2029
+ unit='bohr**3',
2030
+ dtype=float,
2031
+ ),
2032
+ Quantity('number_of_atoms', r'number of atoms/cell\s*=\s*(\d+)', dtype=int),
2033
+ Quantity(
2034
+ 'x_qe_number_of_species',
2035
+ r'number of atomic types\s*=\s*(\d+)',
2036
+ dtype=int,
2037
+ ),
2038
+ Quantity(
2039
+ 'number_of_electrons',
2040
+ rf'number of electrons\s*=\s*({re_float})\s*(?:\(up:\s*({re_float})\s*,\s*down:\s*({re_float}))?',
2041
+ dtype=float,
2042
+ ),
2043
+ Quantity(
2044
+ 'x_qe_number_of_states',
2045
+ r'number of Kohn\-Sham states\s*=\s*(\d+)',
2046
+ dtype=int,
2047
+ ),
2048
+ Quantity(
2049
+ 'wavefunction_cutoff',
2050
+ rf'kinetic\-energy cutoff\s*=\s*({re_float})',
2051
+ dtype=float,
2052
+ unit='rydberg',
2053
+ ),
2054
+ Quantity(
2055
+ 'density_cutoff',
2056
+ rf'charge density cutoff\s*=\s*({re_float})',
2057
+ dtype=float,
2058
+ unit='rydberg',
2059
+ ),
2060
+ Quantity(
2061
+ 'fock_cutoff',
2062
+ rf'cutoff for Fock operator\s*=\s*({re_float})',
2063
+ dtype=float,
2064
+ unit='rydberg',
2065
+ ),
2066
+ Quantity(
2067
+ 'scf_threshold_energy_change',
2068
+ rf'convergence threshold\s*=\s*({re_float})',
2069
+ dtype=float,
2070
+ unit='rydberg',
2071
+ ),
2072
+ Quantity(
2073
+ 'x_qe_potential_mixing_beta',
2074
+ rf'mixing beta\s*=\s*({re_float})',
2075
+ dtype=float,
2076
+ ),
2077
+ Quantity(
2078
+ 'mixing_scheme', r'number of iterations used\s*=\s*(\d+)\s*(.*)mixing'
2079
+ ),
2080
+ Quantity(
2081
+ 'xc_functional',
2082
+ r'Exchange\-correlation\s*=\s*(.+)\s*(\([\d ]+\))',
2083
+ convert=False,
2084
+ flatten=False,
2085
+ ),
2086
+ Quantity(
2087
+ 'x_qe_exact_exchange_fraction',
2088
+ rf'EXX\-fraction\s*=\s*({re_float})',
2089
+ dtype=float,
2090
+ ),
2091
+ Quantity('x_qe_md_max_steps', r'\s*nstep\s*=\s*(\d+)', dtype=int),
2092
+ Quantity(
2093
+ 'spin_orbit_mode',
2094
+ r'\s*(.*?)\s*calculation\s*(with(?:out)?)\s*spin-orbit',
2095
+ ),
2096
+ Quantity(
2097
+ 'berry_efield',
2098
+ r'(Using Berry phase electric field[\s\S]+?Number of iterative cycles\s*:\s*\d+)',
2099
+ sub_parser=TextParser(
2100
+ quantities=[
2101
+ Quantity('direction', r'Direction\s*:\s*(\d+)', dtype=int),
2102
+ Quantity(
2103
+ 'intensity',
2104
+ rf'Intensity \((?:Ry\s*)?a.u.\)\s*:\s*({re_float})',
2105
+ dtype=float,
2106
+ ),
2107
+ Quantity(
2108
+ 'strings', r'Strings composed by\s*:\s*(\d+)', dtype=int
2109
+ ),
2110
+ Quantity(
2111
+ 'niter',
2112
+ r'Number of iterative cycles\s*:\s*(\d+)',
2113
+ dtype=int,
2114
+ ),
2115
+ ]
2116
+ ),
2117
+ ),
2118
+ Quantity('assume_isolated', r'Assuming isolated system,\s*(.*?)\s*method'),
2119
+ Quantity(
2120
+ 'x_qe_celldm',
2121
+ rf'celldm\(1\)=\s*({re_float})\s*celldm\(2\)=\s*({re_float})\s*celldm\(3\)=\s*({re_float})\s*'
2122
+ rf'celldm\(4\)=\s*({re_float})\s*celldm\(5\)=\s*({re_float})\s*celldm\(6\)=\s*({re_float})\s*',
2123
+ dtype=float,
2124
+ unit='bohr',
2125
+ ),
2126
+ Quantity(
2127
+ 'units', r'crystal axes: \(cart\. coord\. in units of ([\w ]+)\)\s*'
2128
+ ),
2129
+ Quantity(
2130
+ 'simulation_cell',
2131
+ r'a\(1\) = \(([\-\d\. ]+)\)\s*a\(2\) = \(([\-\d\. ]+)\)\s*a\(3\) = \(([\-\d\. ]+)\)\s*',
2132
+ dtype=float,
2133
+ shape=(3, 3),
2134
+ ),
2135
+ Quantity(
2136
+ 'reciprocal_cell_units',
2137
+ r'reciprocal axes: \(cart\. coord\. in units of ([\w ]+)\)\s*',
2138
+ ),
2139
+ Quantity(
2140
+ 'reciprocal_cell',
2141
+ r'b\(1\) = \(([\-\d\. ]+)\)\s*b\(2\) = \(([\-\d\. ]+)\)\s*b\(3\) = \(([\-\d\. ]+)\)\s*',
2142
+ dtype=float,
2143
+ shape=(3, 3),
2144
+ ),
2145
+ Quantity(
2146
+ 'pseudopotential',
2147
+ r'(PseudoPot\. #[\s\S]+?\n\s*\n)',
2148
+ repeats=True,
2149
+ sub_parser=TextParser(
2150
+ quantities=[
2151
+ Quantity('idx', r'PseudoPot\. # (\d+)'),
2152
+ Quantity('label', r'for (\w+)'),
2153
+ Quantity('filename', r'read from file:?\s*\s*(\S+)'),
2154
+ Quantity('md5sum', r'MD5 check sum:\s*(\S+)'),
2155
+ Quantity('type', r'Pseudo is\s*(.*?),', flatten=False),
2156
+ Quantity('valence', rf'Zval\s*=\s*({re_float})'),
2157
+ Quantity('comment', r'\s*(.+?)\s*Using radial', flatten=False),
2158
+ Quantity(
2159
+ 'integral_ndirections',
2160
+ r'Setup to integrate on\s*(\d+)\s+directions:',
2161
+ ),
2162
+ Quantity(
2163
+ 'integral_lmax_exact', r'integral exact up to l =\s*(\d+)'
2164
+ ),
2165
+ Quantity(
2166
+ 'augmentation_shape',
2167
+ r'Shape of augmentation charge:\s*(.*?)\s*',
2168
+ ),
2169
+ Quantity('ndmx', r'grid of\s*(\d+) points', dtype=int),
2170
+ Quantity('nbeta', r',\s*(\d+) beta functions', dtype=int),
2171
+ Quantity(
2172
+ 'beta', r'l\((\d+)\)\s*=\s*(\d+)', repeats=True, dtype=int
2173
+ ),
2174
+ Quantity(
2175
+ 'ncoefficients',
2176
+ r'Q\(r\) pseudized with\s*(\d+)\s*coefficients',
2177
+ dtype=int,
2178
+ ),
2179
+ Quantity(
2180
+ 'rinner',
2181
+ r'rinner\s*=\s*([\-\d\.\s]+)',
2182
+ str_operation=lambda x: ' '.join(x.split()),
2183
+ convert=False,
2184
+ ),
2185
+ ]
2186
+ ),
2187
+ ),
2188
+ Quantity(
2189
+ 'atom_species_pp',
2190
+ r'atomic species\s*valence\s*mass\s*pseudopotential([\s\S]+?)\n\s*\n',
2191
+ str_operation=str_to_atom_data,
2192
+ convert=False,
2193
+ ),
2194
+ Quantity(
2195
+ 'starting_magnetization',
2196
+ r'Starting magnetic structure\s*atomic species\s*magnetization([\s\S]+?)\n\s*\n',
2197
+ str_operation=str_to_atom_data,
2198
+ convert=False,
2199
+ ),
2200
+ Quantity(
2201
+ 'x_qe_md_cell_mass',
2202
+ rf'cell mass\s*=\s*({re_float})\s*AMU/\(a\.u\.\)\^2',
2203
+ dtype=float,
2204
+ ),
2205
+ Quantity(
2206
+ 'symmetry',
2207
+ r'(\d+\s*Sym\.\s*Ops\.[\s\S]+?)\n\s*\n',
2208
+ sub_parser=TextParser(
2209
+ quantities=[
2210
+ Quantity('nsymm', r'(\d+) Sym\.', dtype=int),
2211
+ Quantity(
2212
+ 'symm_inversion',
2213
+ r'\((\S+)\s*inversion',
2214
+ str_operation=lambda x: 'with' in x,
2215
+ convert=False,
2216
+ ),
2217
+ Quantity(
2218
+ 'nsymm_with_fractional_translation',
2219
+ r'(\d+)\s*have fractional translation',
2220
+ dtype=int,
2221
+ ),
2222
+ Quantity(
2223
+ 'nsymm_ignored',
2224
+ r'(\d+)\s*additional sym\.ops\. were found but ignored',
2225
+ dtype=int,
2226
+ ),
2227
+ ]
2228
+ ),
2229
+ ),
2230
+ Quantity(
2231
+ 'labels_positions',
2232
+ r'(Cartesian axes\s*site n\.\s*atom\s*positions[\s\S]+?)\n\s*\n',
2233
+ repeatas=False,
2234
+ sub_parser=TextParser(
2235
+ quantities=[
2236
+ Quantity('axes', r'(\w+)\s*axes'),
2237
+ Quantity('units', r'site n\.\s*atom\s*positions\s*\(\s*(\S+)'),
2238
+ Quantity('labels', r'(\w+)\s*tau', repeats=True),
2239
+ Quantity(
2240
+ 'positions',
2241
+ rf'=\s*\(\s*({re_float}\s*{re_float}\s*{re_float})\s*\)',
2242
+ repeats=True,
2243
+ dtype=float,
2244
+ ),
2245
+ ]
2246
+ ),
2247
+ ),
2248
+ Quantity(
2249
+ 'k_points',
2250
+ r'(number of k points=[\s\S]+?)\n\s*\n',
2251
+ repeats=False,
2252
+ sub_parser=TextParser(
2253
+ quantities=[
2254
+ Quantity('nk', r'number of k points=\s*(\d+)', dtype=int),
2255
+ Quantity(
2256
+ 'smearing',
2257
+ r'([\w\-]+)\s*(?:broad|smearing|method),?',
2258
+ dtype=str,
2259
+ flatten=False,
2260
+ ),
2261
+ Quantity(
2262
+ 'width',
2263
+ rf'width\s*\(Ry\)=\s*({re_float})',
2264
+ dtype=float,
2265
+ unit='rydberg',
2266
+ ),
2267
+ Quantity('units', r'cart\. coord\. in units (2pi/alat)'),
2268
+ Quantity('ik', r'k\(\s*(\d+)\s*\)', repeats=True),
2269
+ Quantity(
2270
+ 'points',
2271
+ rf'=\s*\(\s*({re_float}\s*{re_float}\s*{re_float})\)',
2272
+ repeats=True,
2273
+ dtype=float,
2274
+ ),
2275
+ Quantity('wk', rf',\s*wk\s*=\s*({re_float})', repeats=True),
2276
+ Quantity(
2277
+ 'warning', r'(Number of k-points >= 100: set verbosity)'
2278
+ ),
2279
+ ]
2280
+ ),
2281
+ ),
2282
+ Quantity(
2283
+ 'dense_grid',
2284
+ rf'(?:G\s+cutoff\s*=\s*({re_float})\s*\(|Dense\s*grid:)\s*(\d+)\s*'
2285
+ r'G\-vectors\)*\s*FFT\s+(?:dimensions|grid):\s*\(\s*([\d ,]+)\)',
2286
+ str_operation=lambda x: x.replace(',', ' ').split(),
2287
+ ),
2288
+ Quantity(
2289
+ 'smooth_grid',
2290
+ rf'(?:G\s+cutoff\s*=\s*({re_float})\s*\(|Smooth\s*grid:)\s*(\d+)\s*'
2291
+ r'G\-vectors\s*(?:smooth grid|FFT dimensions)\s*:\s*\(\s*([\d ,]+)\)',
2292
+ str_operation=lambda x: x.replace(',', ' ').split(),
2293
+ ),
2294
+ Quantity(
2295
+ 'x_qe_core_charge_realspace',
2296
+ r'(Real space treatment of Q\(r\))',
2297
+ str_operation=lambda x: True,
2298
+ ),
2299
+ Quantity(
2300
+ 'input_occupation',
2301
+ r'Occupations\s*read\s*from\s*input\s*'
2302
+ r'(?:Spin-up)?([\d\.Ee\s]+)(?:Spin-down)?([\d\.Ee\s]+)',
2303
+ str_operation=str_to_occupations,
2304
+ convert=False,
2305
+ ),
2306
+ Quantity(
2307
+ 'allocated_arrays',
2308
+ r'allocated arrays\s*est\. size \(Mb\)\s*dimensions([\s\S]+?)Largest',
2309
+ str_operation=str_to_arrays,
2310
+ convert=False,
2311
+ ),
2312
+ Quantity(
2313
+ 'temporary_arrays',
2314
+ r'temporary arrays\s*est\. size \(Mb\)\s*dimensions([\s\S]+?)\n\s*\n',
2315
+ str_operation=str_to_arrays,
2316
+ convert=False,
2317
+ ),
2318
+ Quantity(
2319
+ 'martyna_tuckerman_parameters',
2320
+ rf'alpha, beta MT =\s*({re_float})\s*({re_float})',
2321
+ dtype=float,
2322
+ ),
2323
+ Quantity(
2324
+ 'core_charge_check',
2325
+ rf'Check: negative/imaginary core charge\s*=\s*({re_float})\s*({re_float})',
2326
+ dtype=float,
2327
+ ),
2328
+ Quantity(
2329
+ 'x_qe_input_potential_recalculated_file',
2330
+ r'The potential is recalculated from file\s*:\s*(\S+)',
2331
+ ),
2332
+ Quantity(
2333
+ 'x_qe_starting_density_file',
2334
+ r'The initial density is read from file\s*:\s*(\S+)',
2335
+ ),
2336
+ Quantity(
2337
+ 'x_qe_starting_potential',
2338
+ r'Initial potential from\s*(.+)',
2339
+ flatten=False,
2340
+ ),
2341
+ Quantity(
2342
+ 'x_qe_starting_charge_negative',
2343
+ rf'Check: negative starting charge\s*=\s*({re_float})',
2344
+ dtype=float,
2345
+ ),
2346
+ Quantity(
2347
+ 'starting_charge_negative_spin',
2348
+ rf'negative rho \(up, down\):\s*({re_float})\s*({re_float})',
2349
+ dtype=float,
2350
+ ),
2351
+ Quantity(
2352
+ 'initial_charge',
2353
+ rf'starting charge\s*({re_float})\s*, renormalised to\s*({re_float})',
2354
+ dtype=float,
2355
+ ),
2356
+ Quantity('x_qe_starting_wfc', r'Starting wfc\s*(.+)', flatten=False),
2357
+ Quantity(
2358
+ 'x_qe_time_setup_cpu1_end',
2359
+ rf'total cpu time spent up to now is\s*({re_float})',
2360
+ ),
2361
+ Quantity(
2362
+ 'x_qe_per_process_mem',
2363
+ r'per\-process dynamical memory:\s*([\d\.]+)\s*Mb',
2364
+ dtype=float,
2365
+ unit='mebibyte',
2366
+ ),
2367
+ ]
2368
+
2369
+ diagonalization_quantities = [
2370
+ Quantity(
2371
+ 'diagonalization_algorithm',
2372
+ r'(Davidson|CG style)\s*diagonalization',
2373
+ str_operation=str_to_algorithm,
2374
+ convert=False,
2375
+ ),
2376
+ Quantity('diagonalization_ethr', r'ethr =\s*([\d\.\-E]+)', dtype=float),
2377
+ Quantity(
2378
+ 'diagonalization_iteration_avg',
2379
+ r'avg # of iterations\s*=\s*([\d\.]+)',
2380
+ dtype=float,
2381
+ ),
2382
+ Quantity(
2383
+ 'diagonalization_c_bands_n_unconverged_eigenvalues',
2384
+ r'c_bands:\s*(\d+)\s*eigenvalues not converged',
2385
+ dtype=int,
2386
+ repeats=True,
2387
+ ),
2388
+ ]
2389
+
2390
+ self.energy_quantities = {
2391
+ 'energy_total': rf'total energy\s*=\s*({re_float})',
2392
+ 'x_qe_energy_total_harris_foulkes_estimate': rf'Harris-Foulkes estimate\s*=\s*({re_float})',
2393
+ 'x_qe_energy_total_accuracy_estimate': rf'estimated scf accuracy\s*<\s*({re_float})',
2394
+ 'x_qe_energy_total_paw_all_electron': rf'total all-electron energy\s*=\s*({re_float})',
2395
+ }
2396
+
2397
+ energy_quantities = [
2398
+ Quantity(key, pattern, dtype=float, unit='rydberg')
2399
+ for key, pattern in self.energy_quantities.items()
2400
+ ]
2401
+
2402
+ calculation_quantities = [
2403
+ Quantity('spin_pol', r'SPIN (UP|DOWN)'),
2404
+ Quantity(
2405
+ 'k_points',
2406
+ rf'k\s*=\s*({RE_FLOAT})\s*({RE_FLOAT})\s*({RE_FLOAT})',
2407
+ repeats=True,
2408
+ dtype=float,
2409
+ ),
2410
+ Quantity(
2411
+ 'number_of_planewaves', r'\(\s*(\d+)\s*PWs\)', dftype=int, repeats=True
2412
+ ),
2413
+ Quantity(
2414
+ 'band_energies',
2415
+ r'band(?:s|\s+energies)\s*\(\s*[eE][vV]\s*\)\s*:\s*([\d\.\-\s]+)',
2416
+ str_operation=str_to_band_energies,
2417
+ repeats=True,
2418
+ convert=False,
2419
+ ),
2420
+ Quantity(
2421
+ 'occupation_numbers',
2422
+ r'occupation numbers\s*([\d\.\-\s]+?)\n *\n',
2423
+ repeats=True,
2424
+ dtype=float,
2425
+ ),
2426
+ Quantity(
2427
+ 'homo_lumo',
2428
+ r'highest occupied(?:, lowest unoccupied)* level \(ev\):\s*([\-\d\. ]+)',
2429
+ dtype=float,
2430
+ ),
2431
+ Quantity(
2432
+ 'fermi_energy',
2433
+ rf'(?:the Fermi energy is|the spin up/dw Fermi energies are)\s*([\-\d\. ]+)',
2434
+ dtype=float,
2435
+ ),
2436
+ Quantity(
2437
+ 'energies',
2438
+ r'!\s*(total energy[\s\S]+?)\n\s*\n',
2439
+ sub_parser=TextParser(quantities=energy_quantities),
2440
+ ),
2441
+ Quantity(
2442
+ 'energy_contributions',
2443
+ r'The total energy is the sum of the following terms:\s*([\s\S]+?Ry\n\s*\n)',
2444
+ str_operation=str_to_energy_contributions,
2445
+ convert=False,
2446
+ ),
2447
+ Quantity(
2448
+ 'magnetization_total',
2449
+ rf'total magnetization\s*=\s*({re_float})\s*Bohr mag/cell',
2450
+ dtype=float,
2451
+ unit='bohr_magneton',
2452
+ repeats=True,
2453
+ ),
2454
+ Quantity(
2455
+ 'magnetization_absolute',
2456
+ rf'absolute magnetization\s*=\s*({re_float})\s*Bohr mag/cell',
2457
+ dtype=float,
2458
+ unit='bohr_magneton',
2459
+ repeats=True,
2460
+ ),
2461
+ Quantity(
2462
+ 'convergence_iterations',
2463
+ r'convergence has been achieved in\s*([\d]+) iterations',
2464
+ dtype=int,
2465
+ ),
2466
+ Quantity(
2467
+ 'forces',
2468
+ r'Forces acting on atoms \((?:cartesian axes, )?Ry\/au\):\s*([\s\S]+?)(?:The|\n\s*\n)',
2469
+ str_operation=str_to_forces,
2470
+ convert=False,
2471
+ ),
2472
+ Quantity(
2473
+ 'total_force',
2474
+ rf'Total force\s*=\s*({re_float})\s*Total SCF correction\s*=\s*({re_float})',
2475
+ dtype=float,
2476
+ unit='rydberg/bohr',
2477
+ ),
2478
+ Quantity(
2479
+ 'forces_dispersion',
2480
+ r'Dispersion forces acting on atoms:\s*([\s\S]+?)(?:The|\n\s*\n)',
2481
+ str_operation=str_to_forces,
2482
+ convert=False,
2483
+ ),
2484
+ Quantity(
2485
+ 'total_force_dispersion',
2486
+ rf'Total Dispersion Force =\s*({re_float})',
2487
+ dtype=float,
2488
+ unit='rydberg/bohr',
2489
+ ),
2490
+ Quantity(
2491
+ 'stress',
2492
+ r'total\s*stress\s*\(Ry/bohr\*\*3\)\s*\(kbar\)\s*P=\s*([\s\S]+?)\n\s*\n',
2493
+ str_operation=str_to_stress,
2494
+ convert=False,
2495
+ ),
2496
+ Quantity(
2497
+ 'units', r'crystal axes: \(cart\. coord\. in units of ([\w ]+)\)\s*'
2498
+ ),
2499
+ Quantity(
2500
+ 'simulation_cell',
2501
+ r'a\(1\) = \(([\-\d\. ]+)\)\s*a\(2\) = \(([\-\d\. ]+)\)\s*a\(3\) = \(([\-\d\. ]+)\)\s*',
2502
+ dtype=float,
2503
+ shape=(3, 3),
2504
+ ),
2505
+ Quantity(
2506
+ 'reciprocal_cell_units',
2507
+ r'reciprocal axes: \(cart\. coord\. in units ([\w \/]+)\)',
2508
+ flatten=False,
2509
+ ),
2510
+ Quantity(
2511
+ 'reciprocal_cell',
2512
+ r'b\(1\) = \(([\-\d\. ]+)\)\s*b\(2\) = \(([\-\d\. ]+)\)\s*b\(3\) = \(([\-\d\. ]+)\)\s*',
2513
+ dtype=float,
2514
+ shape=(3, 3),
2515
+ ),
2516
+ Quantity(
2517
+ 'labels_positions',
2518
+ r'(ATOMIC_POSITIONS \(.+\)[\s\S]+?)\n\s*\n',
2519
+ str_operation=str_to_labels_positions,
2520
+ convert=False,
2521
+ ),
2522
+ Quantity(
2523
+ 'starting_magnetization',
2524
+ r'Starting magnetic structure\s*atomic species\s*magnetization([\s\S]+?)\n\s*\n',
2525
+ str_operation=str_to_atom_data,
2526
+ convert=False,
2527
+ ),
2528
+ # Quantity(
2529
+ # 'x_qe_t_md_bfgs_scf_cycles',
2530
+ # r'number of scf cycles\s*=\s*(\d+)', dtype=int),
2531
+ # Quantity(
2532
+ # 'x_qe_t_md_bfgs_trust_new',
2533
+ # r'new trust radius\s*=\s*[\d\.]+ Ry', dtype=float, unit='rydberg'),
2534
+ # Quantity(
2535
+ # 'x_qe_t_md_bfgs_conv_thr_new',
2536
+ # r'new conv_thr\s*=\s*[\d\.]+ bohr', dtype=float, unit='bohr'),
2537
+ # Quantity(
2538
+ # 'x_qe_t_md_bfgs_steps',
2539
+ # r'number of bfgs steps\s*=\s*(\d+)', dtype=int),
2540
+ # Quantity(
2541
+ # 'x_qe_t_md_bfgs_energy_new',
2542
+ # r'energy\s*new\s*=\s*[\d\.\-]+\s*Ry', dtype=float, unit='rydberg'),
2543
+ # Quantity(
2544
+ # 'x_qe_t_md_bfgs_energy_old',
2545
+ # r'energy\s*old\s*=\s*[\d\.\-]+\s*Ry', dtype=float, unit='rydberg'),
2546
+ Quantity(
2547
+ 'exx_refine', r'(EXX: now go back to refine exchange calculation)'
2548
+ ),
2549
+ Quantity(
2550
+ 'memory',
2551
+ r'per\-process dynamical memory:\s*([\d\.]+)\s*Mb',
2552
+ dtype=float,
2553
+ unit='mebibyte',
2554
+ ),
2555
+ Quantity(
2556
+ 'output_datafile', r'Writing output data file ([\w\.]+)', dtype=str
2557
+ ),
2558
+ Quantity(
2559
+ 'negative_rho',
2560
+ r'negative rho \(up, down\):\s*([\d\.E\-\+]+)\s*([\d\.E\-\+]+)',
2561
+ dtype=float,
2562
+ ),
2563
+ Quantity(
2564
+ 'total_time',
2565
+ r'total cpu time spent up to now is\s*([\d\.]+)',
2566
+ unit=ureg.s,
2567
+ repeats=True,
2568
+ ),
2569
+ ]
2570
+
2571
+ scf_quantities = [
2572
+ Quantity(
2573
+ 'iteration',
2574
+ r'(ation\s*#[\s\S]+?(?:\n *iter|End))',
2575
+ repeats=True,
2576
+ sub_parser=TextParser(
2577
+ quantities=[
2578
+ Quantity('number', r'n\s*#\s*(\d+)'),
2579
+ Quantity('ecutwfc', r'ecut=\s*([\d\.]+)', unit='rydberg'),
2580
+ Quantity('beta', r'beta=\s*([\d\.]+)'),
2581
+ Quantity(
2582
+ 'negative_rho',
2583
+ rf'negative rho \(up, down\):\s*([\d\.E\-\+]+)\s*([\d\.E\-\+]+)',
2584
+ dtype=float,
2585
+ ),
2586
+ Quantity(
2587
+ 'magnetic_moments',
2588
+ rf'atom:\s*(\d+)\s*charge:\s*({re_float})\s*magn:\s*({re_float})\s*constr:\s*({re_float})',
2589
+ repeats=True,
2590
+ dtype=float,
2591
+ ),
2592
+ Quantity(
2593
+ 'energies',
2594
+ r'(total energy[\s\S]+?)\n\s*\n',
2595
+ sub_parser=TextParser(quantities=energy_quantities),
2596
+ ),
2597
+ Quantity(
2598
+ 'magnetization_total',
2599
+ rf'total magnetization\s*=\s*({re_float})\s*Bohr mag/cell',
2600
+ dtype=float,
2601
+ unit='bohr_magneton',
2602
+ ),
2603
+ Quantity(
2604
+ 'magnetization_absolute',
2605
+ rf'absolute magnetization\s*=\s*({re_float})\s*Bohr mag/cell',
2606
+ dtype=float,
2607
+ unit='bohr_magneton',
2608
+ ),
2609
+ Quantity(
2610
+ 'total_time',
2611
+ r'total cpu time spent up to now is\s*([\d\.]+)',
2612
+ unit=ureg.s,
2613
+ ),
2614
+ ]
2615
+ + diagonalization_quantities
2616
+ ),
2617
+ )
2618
+ ] + calculation_quantities
2619
+
2620
+ # TODO add electric field calculation
2621
+
2622
+ bandstructure_quantities = diagonalization_quantities + calculation_quantities
2623
+
2624
+ sampling_quantities = [
2625
+ Quantity(
2626
+ 'self_consistent',
2627
+ r'(consistent Calculation[\s\S]+?)(?:Self-|init_run|\Z)',
2628
+ repeats=True,
2629
+ sub_parser=TextParser(quantities=scf_quantities),
2630
+ ),
2631
+ Quantity('dynamics', r'(Entering Dynamics)', repeats=False),
2632
+ ]
2633
+
2634
+ bfgs_quantities = [
2635
+ Quantity(
2636
+ 'final_energy',
2637
+ rf'Final energy\s*=\s*({re_float})\s*Ry',
2638
+ dtype=float,
2639
+ unit='rydberg',
2640
+ ),
2641
+ Quantity(
2642
+ 'convergence',
2643
+ rf'bfgs converged in\s*(\d+)\s*scf cycles and\s*(\d+)\s*bfgs steps',
2644
+ dtype=int,
2645
+ ),
2646
+ ] + sampling_quantities
2647
+
2648
+ md_quantities = [
2649
+ Quantity(
2650
+ 'diffusion_coefficients',
2651
+ r'atom\s*\d+\s*D =\s*({re_float})\s*cm\^2/s',
2652
+ repeats=True,
2653
+ unit='cm**2/s',
2654
+ ),
2655
+ Quantity(
2656
+ 'diffusion_coefficient_mean',
2657
+ r'< D > =\s*({re_float})\s*cm\^2/s',
2658
+ unit='cm**2/s',
2659
+ ),
2660
+ ] + sampling_quantities
2661
+
2662
+ langevin_quantities = sampling_quantities
2663
+
2664
+ vcs_quantities = sampling_quantities
2665
+
2666
+ damped_quantities = sampling_quantities
2667
+
2668
+ run_quantities = [
2669
+ Quantity(
2670
+ 'program_name_version',
2671
+ r'Program\s*(\w+\s*v\.\S+\s*(?:\(svn rev\.\s*\d+\))*)',
2672
+ ),
2673
+ Quantity(
2674
+ 'start_date_time',
2675
+ r'starts (?:on|\.\.\.\s*Today is)\s*(\w+)\s*at\s*([\d: ]+)',
2676
+ flatten=False,
2677
+ ),
2678
+ Quantity(
2679
+ 'compile_parallel_version',
2680
+ r'(Serial multi\-threaded|Serial|Parallel)\s*version\s*(\(MPI\))*',
2681
+ flatten=False,
2682
+ ),
2683
+ Quantity('nthreads', r', running on\s*(\d+)\s*processor cores', dtype=int),
2684
+ Quantity(
2685
+ 'nproc',
2686
+ r'(?:Number of processors in use:|, running on)\s*(\d+)\s*(?:processors)*',
2687
+ dtype=int,
2688
+ ),
2689
+ Quantity('npool', r'npool[\w/]*\s*=\s*(\d+)', dtype=int),
2690
+ Quantity('input_filename', r'Reading input from (.+)', flatten=False),
2691
+ Quantity('ntypx', r'ntypx.*?=\s*(\d+)', dtype=int),
2692
+ Quantity('npk', r'npk.*?=\s*(\d+)', dtype=int),
2693
+ Quantity('lmaxx', r'lmaxx.*?=\s*(\d+)', dtype=int),
2694
+ Quantity('nchix', r'nchix.*?=\s*(\d+)', dtype=int),
2695
+ Quantity('ndmx', r'ndmx.*?=\s*(\d+)', dtype=int),
2696
+ Quantity('nbrx', r'nbrx.*?=\s*(\d+)', dtype=int),
2697
+ Quantity(
2698
+ 'input_positions_cell_dirname',
2699
+ r'Atomic positions and unit cell read from directory:\s*(\S+)',
2700
+ ),
2701
+ Quantity(
2702
+ 'header',
2703
+ r'([Pp]rogram [A-Z]+[\s\S]+?)(?:Self\-|Band)',
2704
+ repeats=False,
2705
+ sub_parser=TextParser(quantities=header_quantities),
2706
+ ),
2707
+ Quantity(
2708
+ 'self_consistent',
2709
+ # r'(consistent Calculation[\s\S]+?(?:BFG|Molecula|Dampe|Over\-dampe|Wentzcovitc|init_run|\Z))',
2710
+ r'(consistent Calculation[\s\S]+?(?:Self-|init_run|\Z))',
2711
+ repeats=False,
2712
+ sub_parser=TextParser(quantities=scf_quantities),
2713
+ ),
2714
+ Quantity(
2715
+ 'bandstructure',
2716
+ r'(Structure Calculation[\s\S]+?)(?:init_run|\Z)',
2717
+ repeats=False,
2718
+ sub_parser=TextParser(quantities=bandstructure_quantities),
2719
+ ),
2720
+ Quantity(
2721
+ 'bfgs_geometry_optimization',
2722
+ r'(S Geometry Optimization[\s\S]+?)(?:init_run|\Z)',
2723
+ repeats=False,
2724
+ sub_parser=TextParser(quantities=bfgs_quantities),
2725
+ ),
2726
+ Quantity(
2727
+ 'molecular_dynamics',
2728
+ r'(r Dynamics Calculation[\s\S]+?)(?:init_run|\Z)',
2729
+ repeats=False,
2730
+ sub_parser=TextParser(quantities=md_quantities),
2731
+ ),
2732
+ Quantity(
2733
+ 'damped_dynamics',
2734
+ r'(d Dynamics Calculation[\s\S]+?)(?:init_run|\Z)',
2735
+ repeats=False,
2736
+ sub_parser=TextParser(quantities=damped_quantities),
2737
+ ),
2738
+ Quantity(
2739
+ 'langevin_dynamics',
2740
+ r'(d Langevin Dynamics Calculation[\s\S]+?)(?:init_run|\Z)',
2741
+ repeats=False,
2742
+ sub_parser=TextParser(quantities=langevin_quantities),
2743
+ ),
2744
+ Quantity(
2745
+ 'vcs_wentzcovitch_damped_minimization',
2746
+ r'(h Damped Cell[\- ]*Dynamics Minimization:[\s\S]+?)(?:init_run|\Z)',
2747
+ repeats=False,
2748
+ sub_parser=TextParser(quantities=vcs_quantities),
2749
+ ),
2750
+ Quantity(
2751
+ 'profiling',
2752
+ r'((?:init_run|PWSCF)\s*:\s*[\s\S]+?)(?:This run|\Z)',
2753
+ repeats=False,
2754
+ str_operation=str_to_profiling,
2755
+ convert=False,
2756
+ ),
2757
+ Quantity(
2758
+ 'end_date_time',
2759
+ r'was terminated on:\s*([\d: ]+)\s*(\w+)',
2760
+ flatten=False,
2761
+ ),
2762
+ Quantity('job_done', r'(JOB DONE)'),
2763
+ ]
2764
+
2765
+ self._quantities = [
2766
+ Quantity(
2767
+ 'run',
2768
+ r'(Program\s*\w+\s*v[\S\s]+?(?:JOB DONE|\Z))',
2769
+ sub_parser=QuantumEspressoRunParser(quantities=run_quantities),
2770
+ repeats=True,
2771
+ )
2772
+ ]
2773
+
2774
+
2775
+ class QuantumEspressoParser:
2776
+ def __init__(self):
2777
+ self.out_parser = QuantumEspressoOutParser()
2778
+ self.dos_parser = DataTextParser()
2779
+ self.smearing_map = {
2780
+ '-99': 'fermi',
2781
+ '-1': 'marzari-vanderbilt',
2782
+ '0': 'gaussian',
2783
+ '1': 'methfessel-paxton',
2784
+ 'Marzari-Vanderbilt': 'marzari-vanderbilt',
2785
+ 'Methfessel-Paxton': 'methfessel-paxton',
2786
+ 'gaussian': 'gaussian',
2787
+ 'Gaussian': 'gaussian',
2788
+ 'Fermi-Dirac': 'fermi',
2789
+ 'tetrahedron': 'tetrahedra',
2790
+ }
2791
+ self._re_label = re.compile(r'([A-Z][a-z]?)')
2792
+
2793
+ def parse_scc(self, run, calculation):
2794
+ sec_run = self.archive.run[-1]
2795
+ initial_time = (
2796
+ sec_run.calculation[-1].time_physical if sec_run.calculation else 0 * ureg.s
2797
+ )
2798
+
2799
+ sec_scc = Calculation()
2800
+ sec_run.calculation.append(sec_scc)
2801
+
2802
+ # energies
2803
+ energies = calculation.get('energies', {})
2804
+ sec_energy = Energy()
2805
+ sec_scc.energy = sec_energy
2806
+ for key, val in energies.items():
2807
+ if val is None:
2808
+ continue
2809
+ if key.startswith('energy_'):
2810
+ sec_energy.m_add_sub_section(
2811
+ getattr(Energy, key.replace('energy_', '').lower()),
2812
+ EnergyEntry(value=val),
2813
+ )
2814
+ else:
2815
+ setattr(sec_scc, key, val.to('joule').magnitude)
2816
+
2817
+ # enery contributions
2818
+ energy_contributions = calculation.get('energy_contributions')
2819
+ if energy_contributions is not None:
2820
+ sec_scc.x_qe_energy_decomposition_name = list(energy_contributions.keys())
2821
+ val = [e.to('joule').magnitude for e in energy_contributions.values()]
2822
+ sec_scc.x_qe_energy_decomposition_value = val
2823
+
2824
+ # forces
2825
+ forces = calculation.get('forces')
2826
+ if forces is not None:
2827
+ sec_scc.forces = Forces(total=ForcesEntry(value_raw=forces))
2828
+ total_force = calculation.get('total_force')
2829
+ if total_force is not None:
2830
+ total_force = total_force.to('newton').magnitude
2831
+ sec_scc.x_qe_force_total = total_force[0]
2832
+ sec_scc.x_qe_force_total_scf_correction = total_force[1]
2833
+ forces = calculation.get('forces_dispersion')
2834
+ if forces is not None:
2835
+ sec_scc.x_qe_atom_dispersion_force = forces.to('newton').magnitude
2836
+ total_force = calculation.get('total_force_dispersion')
2837
+ if total_force is not None:
2838
+ sec_scc.x_qe_dispersion_force_total = total_force.to('newton').magnitude
2839
+
2840
+ # stress
2841
+ sec_thermo = Thermodynamics()
2842
+ sec_scc.thermodynamics.append(sec_thermo)
2843
+ stress = calculation.get('stress')
2844
+ if stress is not None:
2845
+ sec_thermo.pressure = stress[0].to('pascal')
2846
+ sec_scc.stress = Stress(total=StressEntry(value=stress[1]))
2847
+
2848
+ # eigenvalues
2849
+ eigenvalues = calculation.get('band_energies')
2850
+ if eigenvalues is not None:
2851
+ sec_eigenvalues = BandEnergies()
2852
+ sec_scc.eigenvalues.append(sec_eigenvalues)
2853
+ n_spin = run.get_number_of_spin_channels()
2854
+ k_points = calculation.get('k_points')
2855
+ n_eigs = len(eigenvalues[0])
2856
+ k_points = np.reshape(k_points, (n_spin, len(k_points) // n_spin, 3))[0]
2857
+
2858
+ # convert k_points from cartesial to crystal coordinates
2859
+ k_points *= 2 * np.pi / run.get_header('alat').to('m').magnitude
2860
+ reciprocal_cell = (
2861
+ sec_run.system[-1].x_qe_reciprocal_cell.to('1/m').magnitude
2862
+ )
2863
+ k_points = np.dot(np.linalg.inv(reciprocal_cell), k_points.T).T
2864
+
2865
+ try:
2866
+ eigenvalues = (
2867
+ np.reshape(eigenvalues, (n_spin, len(k_points), n_eigs)) * ureg.eV
2868
+ )
2869
+ occupations = calculation.get('occupation_numbers')
2870
+ if occupations is not None:
2871
+ occupations = np.reshape(
2872
+ occupations, (n_spin, len(k_points), n_eigs)
2873
+ )
2874
+
2875
+ sec_eigenvalues.kpoints = k_points
2876
+
2877
+ number_of_planewaves = calculation.get('number_of_planewaves')
2878
+ if number_of_planewaves is not None:
2879
+ number_of_planewaves = np.reshape(
2880
+ number_of_planewaves,
2881
+ (n_spin, len(number_of_planewaves) // n_spin),
2882
+ )
2883
+ sec_eigenvalues.x_qe_eigenvalues_number_of_planewaves = (
2884
+ number_of_planewaves[0]
2885
+ )
2886
+ sec_eigenvalues.energies = eigenvalues
2887
+ if occupations is not None:
2888
+ sec_eigenvalues.occupations = occupations
2889
+
2890
+ except Exception:
2891
+ self.logger.warning('Error reading eigenvalues.')
2892
+
2893
+ # homo lumo
2894
+ homo = calculation.get('homo_lumo')
2895
+ if homo is not None:
2896
+ lumo = None
2897
+ if isinstance(homo, (list, np.ndarray)):
2898
+ homo, lumo = homo
2899
+ sec_energy.highest_occupied = float(homo) * ureg.eV
2900
+ if lumo is not None:
2901
+ sec_energy.lowest_unoccupied = float(lumo) * ureg.eV
2902
+
2903
+ # fermi energy
2904
+ fermi_energy = calculation.get('fermi_energy')
2905
+ if fermi_energy is not None:
2906
+ fermi_energy = (
2907
+ fermi_energy if isinstance(fermi_energy, float) else fermi_energy[-1]
2908
+ )
2909
+ if np.array(fermi_energy).dtype == float:
2910
+ sec_energy.fermi = fermi_energy * ureg.eV
2911
+
2912
+ n_electrons = run.get_header('number_of_electrons')
2913
+ if homo is None and fermi_energy is None and n_electrons is None:
2914
+ self.logger.error('Reference energy is not defined')
2915
+
2916
+ for key in ['magnetization_total', 'magnetization_absolute']:
2917
+ val = calculation.get(key)
2918
+ if val is None:
2919
+ continue
2920
+ # get the last one corresponding to calculation
2921
+ # TODO verify metainfo unit for magnetization
2922
+ setattr(sec_scc, 'x_qe_%s' % key, val[-1].magnitude)
2923
+
2924
+ # time
2925
+ time = calculation.get('total_time')
2926
+ if time is not None:
2927
+ sec_scc.time_physical = time[-1]
2928
+ sec_scc.time_calculation = sec_scc.time_physical - initial_time
2929
+
2930
+ def parse_diagonalization(source, target):
2931
+ diagonalization = {
2932
+ key: val
2933
+ for key, val in source.items()
2934
+ if key.startswith('diagonalization')
2935
+ }
2936
+ if not diagonalization:
2937
+ return
2938
+
2939
+ if (
2940
+ source.get('number') is not None
2941
+ or source.get('ecutwfc') is not None
2942
+ or source.get('beta') is not None
2943
+ ):
2944
+ metainfo_ext = '_scf'
2945
+ diagonalization_section = x_qe_section_scf_diagonalization
2946
+ else:
2947
+ metainfo_ext = '_bands'
2948
+ diagonalization_section = x_qe_section_bands_diagonalization
2949
+ sec_diagonalization = diagonalization_section()
2950
+ sec_def = target.m_def.all_sub_sections_by_section.get(
2951
+ diagonalization_section.m_def
2952
+ )[0]
2953
+ target.m_add_sub_section(sec_def, sec_diagonalization)
2954
+ for key, val in diagonalization.items():
2955
+ if val is None:
2956
+ continue
2957
+ if key == 'diagonalization_c_bands_n_unconverged_eigenvalues':
2958
+ val = sum(val)
2959
+ setattr(sec_diagonalization, 'x_qe%s_%s' % (metainfo_ext, key), val)
2960
+
2961
+ # diagonalization
2962
+ parse_diagonalization(calculation, sec_scc)
2963
+
2964
+ sec_scc.x_qe_exx_refine = calculation.get('exx_refine') is not None
2965
+
2966
+ # miscellaneous
2967
+ miscellaneous_keys = ['convergence_iterations', 'output_datafile']
2968
+ for key in miscellaneous_keys:
2969
+ val = calculation.get(key)
2970
+ if val is None:
2971
+ continue
2972
+ setattr(sec_scc, 'x_qe_%s' % key, val)
2973
+
2974
+ # scf_iteration
2975
+ for iteration in calculation.get('iteration', []):
2976
+ initial_time = (
2977
+ sec_scc.scf_iteration[-1].time_physical
2978
+ if sec_scc.scf_iteration
2979
+ else initial_time
2980
+ )
2981
+ sec_scf_iteration = ScfIteration()
2982
+ sec_scc.scf_iteration.append(sec_scf_iteration)
2983
+
2984
+ energies = iteration.get('energies', {})
2985
+ sec_scf_energy = Energy()
2986
+ sec_scf_iteration.energy = sec_scf_energy
2987
+ for key, val in energies.items():
2988
+ if val is None:
2989
+ continue
2990
+ if key == 'energy_total':
2991
+ sec_scf_energy.total = EnergyEntry(value=val)
2992
+ else:
2993
+ setattr(
2994
+ sec_scf_iteration,
2995
+ '%s_iteration' % key,
2996
+ val.to('joule').magnitude,
2997
+ )
2998
+
2999
+ for key in ['number', 'ecutwfc', 'beta']:
3000
+ val = iteration.get(key)
3001
+ if val is None:
3002
+ continue
3003
+ if key == 'ecutwfc':
3004
+ val = val.to('joule').magnitude
3005
+ setattr(sec_scf_iteration, '%s_%s' % ('x_qe_iteration', key), val)
3006
+
3007
+ magnetic_moments = iteration.get('magnetic_moments')
3008
+ if magnetic_moments is not None:
3009
+ magnetic_moments = np.transpose(magnetic_moments)
3010
+ sec_scf_iteration.x_qe_iter_mpersite_idx = [
3011
+ int(i) for i in magnetic_moments[0]
3012
+ ]
3013
+ sec_scf_iteration.x_qe_iter_mpersite_charge = magnetic_moments[1]
3014
+ sec_scf_iteration.x_qe_iter_mpersite_magn = magnetic_moments[2]
3015
+ sec_scf_iteration.x_qe_iter_mpersite_constr = magnetic_moments[3]
3016
+
3017
+ for key in ['magnetization_total', 'magnetization_absolute']:
3018
+ val = iteration.get(key)
3019
+ if val is None:
3020
+ continue
3021
+ setattr(sec_scf_iteration, 'x_qe_%s_iteration' % key, val.magnitude)
3022
+
3023
+ time = iteration.get('total_time')
3024
+ if time is not None:
3025
+ sec_scf_iteration.time_physical = time
3026
+ sec_scf_iteration.time_calculation = (
3027
+ sec_scf_iteration.time_physical - initial_time
3028
+ )
3029
+
3030
+ parse_diagonalization(iteration, sec_scf_iteration)
3031
+
3032
+ negative_rho = iteration.get('negative_rho')
3033
+ if negative_rho is not None:
3034
+ sec_scf_iteration.x_qe_iteration_charge_negative_up = negative_rho[0]
3035
+ sec_scf_iteration.x_qe_iteration_charge_negative_down = negative_rho[1]
3036
+
3037
+ return sec_scc
3038
+
3039
+ def parse_system(self, run, calculation):
3040
+ def _convert(key, source, units_key='units', units=None):
3041
+ units_mapping = dict(bohr=ureg.bohr, angstrom=ureg.angstrom)
3042
+ value = source.get(key)
3043
+ if value is None:
3044
+ return
3045
+ units = source.get(units_key) if units is None else units
3046
+ units = units.lower()
3047
+ alat = run.get_header('alat', 1.0)
3048
+ value = np.array(value, dtype=float)
3049
+ if units in ['alat', 'a_0']:
3050
+ value *= alat
3051
+ elif units in ['bohr', 'angstrom']:
3052
+ value = value * units_mapping.get(units)
3053
+ elif units == '2 pi/alat':
3054
+ value *= 2 * np.pi / alat
3055
+ elif units == 'crystal':
3056
+ cell = _convert('simulation_cell', calculation)
3057
+ if cell is None:
3058
+ cell = _convert('simulation_cell', run.get('header', {}))
3059
+ if cell is not None:
3060
+ value = np.dot(value, cell)
3061
+ return value
3062
+
3063
+ sec_run = self.archive.run[-1]
3064
+ labels_positions = calculation.get('labels_positions')
3065
+ if labels_positions is None:
3066
+ # get it from header
3067
+ labels_positions = run.get_header('labels_positions')
3068
+ if labels_positions is not None:
3069
+ labels_positions = (
3070
+ labels_positions.get('labels'),
3071
+ _convert('positions', labels_positions),
3072
+ )
3073
+ if labels_positions is None:
3074
+ return
3075
+
3076
+ sec_system = System()
3077
+ sec_run.system.append(sec_system)
3078
+ sec_atoms = Atoms()
3079
+ sec_system.atoms = sec_atoms
3080
+ sec_atoms.labels = [
3081
+ self._re_label.match(label).group(1) for label in labels_positions[0]
3082
+ ]
3083
+ sec_atoms.positions = labels_positions[1]
3084
+
3085
+ simulation_cell = _convert('simulation_cell', calculation)
3086
+ if simulation_cell is None:
3087
+ # get it from headers
3088
+ simulation_cell = _convert('simulation_cell', run.get('header', {}))
3089
+ if simulation_cell is not None:
3090
+ sec_atoms.lattice_vectors = simulation_cell
3091
+
3092
+ sec_atoms.periodic = [True, True, True]
3093
+
3094
+ reciprocal_cell = _convert(
3095
+ 'reciprocal_cell', calculation, 'reciprocal_cell_units'
3096
+ )
3097
+ if reciprocal_cell is None and simulation_cell is not None:
3098
+ # calculate it from simulation cell, i.e. b1 = 2 pi / V (a2 X a3)
3099
+ cell = simulation_cell.to('m').magnitude
3100
+ volume = np.dot(cell[0], np.cross(cell[1], cell[2]))
3101
+ reciprocal_cell = np.array(
3102
+ [np.cross(cell[(i + 1) % 3], cell[(i + 2) % 3]) for i in range(3)],
3103
+ dtype=float,
3104
+ )
3105
+ reciprocal_cell *= 2 * np.pi / volume
3106
+ if reciprocal_cell is not None:
3107
+ sec_system.x_qe_reciprocal_cell = reciprocal_cell
3108
+
3109
+ starting_magnetization = calculation.get(
3110
+ 'starting_magnetization', run.get_header('starting_magnetization')
3111
+ )
3112
+ if starting_magnetization is not None:
3113
+ magnetization = {m[0]: m[1] for m in starting_magnetization}
3114
+ sec_system.x_qe_atom_starting_magnetization = [
3115
+ magnetization.get(atom, 0.0) for atom in labels_positions[0]
3116
+ ]
3117
+
3118
+ k_points = calculation.get(
3119
+ 'k_points', run.get_header('k_points', {}).get('points')
3120
+ )
3121
+ if k_points is not None:
3122
+ k_points = (
3123
+ np.array(k_points, dtype=float) * 2 * np.pi / run.get_header('alat')
3124
+ )
3125
+ sec_system.x_qe_k_info_vec = k_points.to('1/m').magnitude
3126
+
3127
+ # assign other info only to representative system
3128
+ if len(sec_run.system) != 1:
3129
+ return sec_system
3130
+
3131
+ # TODO In old parser, celldm[0] is alat, I do not know why
3132
+ keys = [
3133
+ 'x_qe_md_cell_mass',
3134
+ 'x_qe_celldm',
3135
+ 'x_qe_ibrav',
3136
+ 'alat',
3137
+ 'x_qe_cell_volume',
3138
+ 'x_qe_number_of_species',
3139
+ 'x_qe_number_of_states',
3140
+ ]
3141
+ for key in keys:
3142
+ val = run.get_header(key)
3143
+ if key == 'alat':
3144
+ key = 'x_qe_alat'
3145
+ val = val.to('m').magnitude
3146
+ elif key == 'x_qe_celldm':
3147
+ val = val.to('m').magnitude
3148
+ elif key == 'x_qe_cell_volume':
3149
+ val = val.to('m**3').magnitude
3150
+ if val is not None:
3151
+ setattr(sec_system, key, val)
3152
+
3153
+ symmetry = run.get_header('symmetry', None)
3154
+ if symmetry is not None:
3155
+ for key, val in symmetry.items():
3156
+ setattr(sec_system, 'x_qe_%s' % key, val)
3157
+ else:
3158
+ sec_system.x_qe_nsymm = 0
3159
+
3160
+ for key in ['wk', 'ik', 'nk']:
3161
+ val = run.get_header('k_points', {}).get(key, None)
3162
+ if val is not None:
3163
+ key = key if key == 'nk' else 'k_info_%s' % key
3164
+ setattr(sec_system, 'x_qe_%s' % key, val)
3165
+
3166
+ for grid_type in ['dense', 'smooth']:
3167
+ grid = run.get_header('%s_grid' % grid_type)
3168
+ if grid is None:
3169
+ continue
3170
+ if len(grid) == 5:
3171
+ setattr(sec_system, 'x_qe_%s_g_cutoff' % grid_type, float(grid[0]))
3172
+ grid = grid[1:]
3173
+ setattr(sec_system, 'x_qe_%s_g_vectors' % grid_type, int(grid[0]))
3174
+ setattr(
3175
+ sec_system, 'x_qe_%s_FFT_grid' % grid_type, [int(n) for n in grid[1:]]
3176
+ )
3177
+
3178
+ supercell = run.get_header('supercell')
3179
+ if supercell is not None:
3180
+ sec_system.x_qe_supercell = True
3181
+ sec_system.x_qe_vec_supercell = supercell
3182
+
3183
+ return sec_system
3184
+
3185
+ def parse_configurations(self, run):
3186
+ sec_run = self.archive.run[-1]
3187
+
3188
+ def parse_configuration(calculation):
3189
+ sec_system = self.parse_system(run, calculation)
3190
+ sec_scc = self.parse_scc(run, calculation)
3191
+ if sec_scc is None:
3192
+ return
3193
+ if sec_system is not None:
3194
+ sec_scc.system_ref = sec_system
3195
+ sec_scc.method_ref = sec_run.method[-1]
3196
+
3197
+ for calculation_type in ['self_consistent', 'bandstructure']:
3198
+ calculation = run.get(calculation_type)
3199
+ if calculation is not None:
3200
+ self.sampling_method = 'single_point'
3201
+ parse_configuration(calculation)
3202
+
3203
+ methods = {
3204
+ 'bfgs_geometry_optimization': 'geometry_optimization',
3205
+ 'molecular_dynamics': 'molecular_dynamics',
3206
+ 'langevin_dynamics': 'langevin_dynamics',
3207
+ 'damped_dynamics': 'geometry_optimization',
3208
+ 'vcs_wentzcovitch_damped_minimization': 'geometry_optimization',
3209
+ }
3210
+ for method in methods:
3211
+ sampling = run.get(method)
3212
+ if sampling is not None:
3213
+ self.sampling_method = methods[method]
3214
+ if method.startswith('vcs') and sampling.get('dynamics') is not None:
3215
+ self.sampling_method = 'molecular_dynamics'
3216
+ for calculation in sampling.get('self_consistent', []):
3217
+ parse_configuration(calculation)
3218
+ # TODO include additional method-specific metainfo
3219
+
3220
+ # dos
3221
+ nspin = run.get_number_of_spin_channels()
3222
+ dos_files = [
3223
+ p for p in os.listdir(self.out_parser.maindir) if p.endswith('.dos')
3224
+ ]
3225
+ for dos_file in dos_files:
3226
+ self.dos_parser.mainfile = os.path.join(self.out_parser.maindir, dos_file)
3227
+ if self.dos_parser.data is not None:
3228
+ data = np.transpose(self.dos_parser.data)
3229
+ energies = np.reshape(data[0], (nspin, len(data[0]) // nspin))
3230
+ dos = np.reshape(data[1], (nspin, len(energies[0])))
3231
+ integrated = np.reshape(data[2], (nspin, len(energies[0])))
3232
+ for spin in range(nspin):
3233
+ sec_dos = Dos()
3234
+ sec_run.calculation[-1].dos_electronic.append(sec_dos)
3235
+ sec_dos.spin_channel = spin if nspin == 2 else None
3236
+ sec_dos.energies = energies[0] * ureg.eV
3237
+ sec_dos_total = DosValues()
3238
+ sec_dos.total.append(sec_dos_total)
3239
+ sec_dos_total.value = dos[spin] / ureg.eV
3240
+ sec_dos_total.value_integrated = integrated[spin]
3241
+
3242
+ def parse_method(self, run):
3243
+ sec_method = Method()
3244
+ self.archive.run[-1].method.append(sec_method)
3245
+ sec_kmesh = KMesh()
3246
+ sec_method.k_mesh = sec_kmesh
3247
+ sec_dft = DFT()
3248
+ sec_method.dft = sec_dft
3249
+ sec_electronic = Electronic()
3250
+ sec_method.electronic = sec_electronic
3251
+
3252
+ starting_magnetization = run.get_header('starting_magnetization')
3253
+ spin_orbit_mode = run.get_header('spin_orbit_mode')
3254
+ if starting_magnetization is not None:
3255
+ sec_electronic.n_spin_channels = 2
3256
+ elif spin_orbit_mode is None:
3257
+ sec_electronic.n_spin_channels = 1
3258
+ # TODO: It is unclear what should be the value if noncollinear magnetism is OK
3259
+
3260
+ sec_kmesh.n_points = run.get_header('k_points', {}).get('nk', 1)
3261
+ sec_kmesh.points = run.get_header('k_points', {}).get('points', None)
3262
+
3263
+ g_vector_sticks = run.get_header('g_vector_sticks', {}).get('Sum', None)
3264
+ if g_vector_sticks is not None:
3265
+ names = [
3266
+ 'sum_dense',
3267
+ 'sum_smooth',
3268
+ 'sum_PW',
3269
+ 'sum_G_dense',
3270
+ 'sum_G_smooth',
3271
+ 'sum_G_PW',
3272
+ ]
3273
+ for i in range(len(names)):
3274
+ setattr(sec_method, 'x_qe_sticks_%s' % names[i], g_vector_sticks[i])
3275
+
3276
+ xc_section_method, xc_functionals = run.get_xc_functional()
3277
+ for key, val in xc_section_method.items():
3278
+ if key == 'XC_functional':
3279
+ continue
3280
+ setattr(sec_method, key, val)
3281
+
3282
+ sec_xc_functional = XCFunctional()
3283
+ sec_dft.xc_functional = sec_xc_functional
3284
+ for xc_functional in xc_functionals:
3285
+ sec_functional = Functional()
3286
+ for key, val in xc_functional.items():
3287
+ setattr(sec_functional, key.replace('XC_functional_', ''), val)
3288
+ name = sec_functional.name
3289
+ if name is None:
3290
+ sec_xc_functional.contributions.append(sec_functional)
3291
+ elif '_X_' in name or name.endswith('_X'):
3292
+ sec_xc_functional.exchange.append(sec_functional)
3293
+ elif '_C_' in name or name.endswith('_C'):
3294
+ sec_xc_functional.correlation.append(sec_functional)
3295
+ elif 'HYB' in name:
3296
+ sec_xc_functional.hybrid.append(sec_functional)
3297
+ else:
3298
+ sec_xc_functional.contributions.append(sec_functional)
3299
+
3300
+ xc_functional = run.get_header('xc_functional')
3301
+ if xc_functional is not None:
3302
+ name, num = xc_functional = xc_functional.split('(')
3303
+ sec_method.x_qe_xc_functional_shortname = name.strip()
3304
+ sec_method.x_qe_xc_functional_num = num.strip().rstrip(')')
3305
+
3306
+ # TODO identify if dft+u
3307
+ sec_electronic.method = 'DFT'
3308
+
3309
+ array = run.get_header('allocated_arrays', None)
3310
+ if array is not None:
3311
+ sec_method.x_qe_allocated_array_name = array[0]
3312
+ sec_method.x_qe_allocated_array_size = (
3313
+ (array[1] * ureg.mebibyte).to('bit').magnitude
3314
+ )
3315
+ sec_method.x_qe_allocated_array_dimensions = array[2]
3316
+ array = run.get_header('temporary_arrays', None)
3317
+ if array is not None:
3318
+ sec_method.x_qe_temporary_array_name = array[0]
3319
+ sec_method.x_qe_temporary_array_size = (
3320
+ (array[1] * ureg.mebibyte).to('bit').magnitude
3321
+ )
3322
+ sec_method.x_qe_temporary_array_dimensions = array[2]
3323
+
3324
+ spin_orbit_mode = run.get_header('spin_orbit_mode')
3325
+ if spin_orbit_mode is not None:
3326
+ sec_method.x_qe_spin_noncollinear = (
3327
+ spin_orbit_mode[0].strip().lower() == 'noncollinear'
3328
+ )
3329
+ sec_method.x_qe_spin_orbit = spin_orbit_mode[1] == 'with'
3330
+
3331
+ # other method variables
3332
+ names = [
3333
+ 'scf_threshold_energy_change',
3334
+ 'x_qe_core_charge_realspace',
3335
+ 'x_qe_exact_exchange_fraction',
3336
+ 'x_qe_diagonalization_algorithm',
3337
+ 'x_qe_potential_mixing_beta',
3338
+ 'x_qe_md_max_steps',
3339
+ 'x_qe_input_potential_recalculated_file',
3340
+ 'x_qe_starting_density_file',
3341
+ 'x_qe_starting_potential',
3342
+ 'x_qe_starting_charge_negative',
3343
+ 'x_qe_starting_wfc',
3344
+ 'x_qe_time_setup_cpu1_end',
3345
+ 'x_qe_per_process_mem',
3346
+ 'x_qe_gamma_algorithms',
3347
+ 'x_qe_xc_functional_user_enforced',
3348
+ ]
3349
+ for key in names:
3350
+ val = run.get_header(key)
3351
+ if val is None:
3352
+ continue
3353
+ if key == 'x_qe_per_process_mem':
3354
+ val = val.to('bit').magnitude
3355
+ setattr(sec_method, key, val)
3356
+
3357
+ mixing_scheme = run.get_header('mixing_scheme')
3358
+ if mixing_scheme is not None:
3359
+ sec_method.x_qe_potential_mixing_iterations = mixing_scheme[0]
3360
+ sec_method.x_qe_potential_mixing_scheme = mixing_scheme[1]
3361
+
3362
+ sec_smearing = Smearing()
3363
+ sec_electronic.smearing = sec_smearing
3364
+ smearing = run.get_header('k_points', {}).get('smearing', None)
3365
+ if smearing in self.smearing_map:
3366
+ sec_smearing.kind = self.smearing_map[smearing]
3367
+
3368
+ smearing_width = run.get_header('k_points', {}).get('width', None)
3369
+ if smearing_width is not None:
3370
+ # TODO smearing width should have metainfo units
3371
+ sec_smearing.width = smearing_width.to('joule').magnitude
3372
+
3373
+ martyna_tuckerman_parameters = run.get_header('martyna_tuckerman_parameters')
3374
+ if martyna_tuckerman_parameters is not None:
3375
+ sec_method.x_qe_isolated_system_method_martyna_tuckerman_alpha = (
3376
+ martyna_tuckerman_parameters[0]
3377
+ )
3378
+ sec_method.x_qe_isolated_system_method_martyna_tuckerman_beta = (
3379
+ martyna_tuckerman_parameters[1]
3380
+ )
3381
+
3382
+ core_charge_check = run.get_header('core_charge_check')
3383
+ if core_charge_check is not None:
3384
+ sec_method.x_qe_core_charge_negative = core_charge_check[0]
3385
+ sec_method.x_qe_core_charge_imaginary = core_charge_check[1]
3386
+
3387
+ starting_charge_negative_spin = run.get_header('starting_charge_negative_spin')
3388
+ if starting_charge_negative_spin is not None:
3389
+ sec_method.x_qe_starting_charge_negative_up = starting_charge_negative_spin[
3390
+ 0
3391
+ ]
3392
+ sec_method.x_qe_starting_charge_negative_down = (
3393
+ starting_charge_negative_spin[1]
3394
+ )
3395
+
3396
+ initial_charge = run.get_header('initial_charge')
3397
+ if initial_charge is not None:
3398
+ sec_method.x_qe_starting_charge = initial_charge[0]
3399
+ sec_method.x_qe_starting_charge_renormalized = initial_charge[1]
3400
+
3401
+ # basis set
3402
+ for scope in ['wavefunction', 'density']:
3403
+ cutoff = run.get_header('%s_cutoff' % scope)
3404
+ if cutoff is not None:
3405
+ sec_method.electrons_representation.append(
3406
+ BasisSetContainer(
3407
+ type='plane waves',
3408
+ scope=[scope],
3409
+ basis_set=[
3410
+ BasisSet(
3411
+ type='plane waves',
3412
+ scope=['valence'],
3413
+ cutoff=cutoff,
3414
+ )
3415
+ ],
3416
+ )
3417
+ )
3418
+
3419
+ pseudopotential = run.get_header('pseudopotential', [])
3420
+
3421
+ pseudopotential_report = dict()
3422
+ for report in run.get_header('pseudopotential_report', []):
3423
+ species = report.get('species')
3424
+ if species is None:
3425
+ continue
3426
+ pseudopotential_report[species] = {
3427
+ 'version': report.get('version', '').strip(),
3428
+ 'contents': report.get('contents'),
3429
+ }
3430
+
3431
+ renormalized_wavefunction = {
3432
+ r[0]: ' '.join(r[1:])
3433
+ for r in run.get_header('renormalized_wavefunction', [])
3434
+ }
3435
+
3436
+ atom_radii = {r[1]: r[0] * ureg.bohr for r in run.get_header('atom_radii', [])}
3437
+
3438
+ atom_species = {r[3]: r for r in run.get_header('atom_species_pp', [])}
3439
+ atom_species_names = [
3440
+ 'label',
3441
+ 'n_valence_electrons',
3442
+ 'x_qe_kind_mass',
3443
+ 'x_qe_pp_label',
3444
+ 'x_qe_pp_weight',
3445
+ ]
3446
+
3447
+ for pp in pseudopotential:
3448
+ sec_method_atom_kind = AtomParameters()
3449
+ sec_method.atom_parameters.append(sec_method_atom_kind)
3450
+ for key, val in pp.items():
3451
+ if val is None:
3452
+ continue
3453
+ if key == 'beta':
3454
+ val = np.transpose(val)
3455
+ sec_method_atom_kind.x_qe_pp_l_idx = val[0]
3456
+ sec_method_atom_kind.x_qe_pp_l = val[1]
3457
+ elif key == 'rinner':
3458
+ setattr(sec_method_atom_kind, 'x_qe_%s' % key, val)
3459
+ else:
3460
+ setattr(sec_method_atom_kind, 'x_qe_pp_%s' % key, val)
3461
+
3462
+ pp_report = pseudopotential_report.get(pp.get('idx'), None)
3463
+ if pp_report is not None:
3464
+ sec_method_atom_kind.x_qe_pp_report_version = pp_report['version']
3465
+ sec_method_atom_kind.x_qe_pp_report_contents = pp_report['contents']
3466
+
3467
+ filename = os.path.basename(pp.get('filename', ''))
3468
+ sec_method_atom_kind.method_atom_kind_pseudopotential_name = filename
3469
+ renormalized = renormalized_wavefunction.get(filename, None)
3470
+ if renormalized is not None:
3471
+ sec_method_atom_kind.x_qe_pp_renormalized_wfc = renormalized
3472
+
3473
+ radius = atom_radii.get(pp.get('idx'), None)
3474
+ if radius is not None:
3475
+ sec_method_atom_kind.x_qe_species_integration_radius = radius.to(
3476
+ 'm'
3477
+ ).magnitude
3478
+
3479
+ dispersion = run.get_header('dispersion', {}).get(pp.get('label'), {})
3480
+ for key, val in dispersion.items():
3481
+ setattr(
3482
+ sec_method_atom_kind, 'x_qe_dispersion_correction_%s' % key, val
3483
+ )
3484
+
3485
+ atom_sp = atom_species.get(
3486
+ pp.get('label'), [None] * len(atom_species_names)
3487
+ )
3488
+ for i in range(len(atom_sp)):
3489
+ if atom_sp[i] is not None:
3490
+ setattr(sec_method_atom_kind, atom_species_names[i], atom_sp[i])
3491
+
3492
+ number_of_electrons = run.get_header('number_of_electrons')
3493
+ if number_of_electrons is not None:
3494
+ number_of_electrons = (
3495
+ [number_of_electrons]
3496
+ if isinstance(number_of_electrons, float)
3497
+ else number_of_electrons
3498
+ )
3499
+ sec_method.electronic.n_electrons = number_of_electrons
3500
+
3501
+ def init_parser(self):
3502
+ self.out_parser.mainfile = self.filepath
3503
+ self.out_parser.logger = self.logger
3504
+ self.dos_parser.mainfile = self.filepath
3505
+ self.dos_parser.logger = self.logger
3506
+
3507
+ def parse(self, filepath, archive, logger):
3508
+ self.filepath = filepath
3509
+ self.archive = archive
3510
+ self.logger = logger if logger is not None else logging
3511
+
3512
+ self.init_parser()
3513
+
3514
+ # TODO include x_qe_warning
3515
+ for run in self.out_parser.get('run', []):
3516
+ self.sampling_method = None
3517
+ sec_run = Run()
3518
+ self.archive.run.append(sec_run)
3519
+ sec_run.program = Program(name='Quantum Espresso')
3520
+ name_version = run.get('program_name_version')
3521
+ if name_version is not None:
3522
+ sec_run.x_qe_program_name = name_version[0]
3523
+ sec_run.program.version = ' '.join(name_version[1:]).lstrip('v.')
3524
+
3525
+ date_time = run.get('start_date_time')
3526
+ if date_time is not None:
3527
+ date_time = datetime.strptime(
3528
+ date_time.replace(' ', ''), '%d%b%Y%H:%M:%S'
3529
+ )
3530
+ sec_run.time_run = TimeRun(
3531
+ date_start=(date_time - datetime(1970, 1, 1)).total_seconds()
3532
+ )
3533
+
3534
+ sec_compile_options = x_qe_section_compile_options()
3535
+ sec_run.x_qe_section_compile_options.append(sec_compile_options)
3536
+ for key in [
3537
+ 'compile_parallel_version',
3538
+ 'ntypx',
3539
+ 'npk',
3540
+ 'lmaxx',
3541
+ 'nchix',
3542
+ 'ndmx',
3543
+ 'nbrx',
3544
+ ]:
3545
+ val = run.get(key)
3546
+ if val is not None:
3547
+ setattr(sec_compile_options, 'x_qe_%s' % key, val)
3548
+
3549
+ sec_parallel = None
3550
+ for key in ['nthreads', 'nproc', 'npool']:
3551
+ val = run.get(key)
3552
+ if val is not None:
3553
+ if sec_parallel is None:
3554
+ sec_parallel = x_qe_section_parallel()
3555
+ sec_run.x_qe_section_parallel.append(sec_parallel)
3556
+ setattr(sec_parallel, 'x_qe_%s' % key, val)
3557
+
3558
+ for key in ['input_filename', 'input_positions_cell_dirname']:
3559
+ val = run.get(key)
3560
+ if val is not None:
3561
+ setattr(sec_run, 'x_qe_%s' % key, val)
3562
+
3563
+ self.parse_method(run)
3564
+
3565
+ self.parse_configurations(run)
3566
+
3567
+ self.archive.workflow2 = SinglePoint()
3568
+ if self.sampling_method is not None:
3569
+ if self.sampling_method == 'geometry_optimization':
3570
+ self.archive.workflow2 = GeometryOptimization()
3571
+ elif self.sampling_method.endswith('dynamics'):
3572
+ self.archive.workflow2 = MolecularDynamics()
3573
+
3574
+ profiling = run.get('profiling')
3575
+ if profiling is not None:
3576
+ sec_run.x_qe_profile_caller = profiling[0]
3577
+ sec_run.x_qe_profile_category = profiling[1]
3578
+ sec_run.x_qe_profile_function = profiling[2]
3579
+ sec_run.x_qe_profile_cputime = profiling[3]
3580
+ sec_run.x_qe_profile_walltime = profiling[4]
3581
+ sec_run.x_qe_profile_ncalls = profiling[5]
3582
+
3583
+ date_time = run.get('end_date_time')
3584
+ if date_time is not None:
3585
+ date_time = datetime.strptime(
3586
+ date_time.replace(': ', ':0').replace(' ', ''), '%H:%M:%S%d%b%Y'
3587
+ )
3588
+ sec_run.time_run.date_end = (
3589
+ date_time - datetime(1970, 1, 1)
3590
+ ).total_seconds()
3591
+
3592
+ job_done = run.get('job_done')
3593
+ if job_done:
3594
+ sec_run.clean_end = True