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,1975 @@
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
+
20
+ import re
21
+ import os
22
+ import logging
23
+ import numpy as np
24
+ from collections import namedtuple
25
+ from datetime import datetime
26
+
27
+ from .metainfo import abacus
28
+ from nomad.units import ureg
29
+ from nomad.parsing.file_parser import TextParser, Quantity, DataTextParser
30
+ from runschema.run import Run, Program, TimeRun
31
+ from runschema.method import (
32
+ AtomParameters,
33
+ Method,
34
+ BasisSet,
35
+ BasisSetContainer,
36
+ Electronic,
37
+ Smearing,
38
+ Scf,
39
+ DFT,
40
+ XCFunctional,
41
+ Functional,
42
+ KMesh,
43
+ )
44
+ from runschema.system import System, Atoms, Symmetry
45
+ from runschema.calculation import (
46
+ Calculation,
47
+ Energy,
48
+ Dos,
49
+ DosValues,
50
+ BandStructure,
51
+ BandEnergies,
52
+ EnergyEntry,
53
+ ScfIteration,
54
+ Forces,
55
+ ForcesEntry,
56
+ Stress,
57
+ StressEntry,
58
+ )
59
+ from simulationworkflowschema import (
60
+ GeometryOptimization,
61
+ MolecularDynamics,
62
+ MolecularDynamicsMethod,
63
+ GeometryOptimizationMethod,
64
+ SinglePoint,
65
+ SinglePointMethod,
66
+ )
67
+ from .metainfo.abacus import (
68
+ Method as xsection_method,
69
+ x_abacus_section_parallel,
70
+ x_abacus_section_specie_basis_set,
71
+ )
72
+
73
+
74
+ # TODO determine if we can update regex to the following
75
+ re_float = r'[-+]?\d+\.*\d*(?:[Ee][-+]\d+)?'
76
+
77
+
78
+ class ABACUSInputParser(TextParser):
79
+ def __init__(self):
80
+ super().__init__(None)
81
+
82
+ def init_quantities(self):
83
+ self._quantities = [
84
+ Quantity(
85
+ 'stru_filename',
86
+ r'\n *stru_file\s*(\S+)',
87
+ repeats=False,
88
+ ),
89
+ Quantity(
90
+ 'kpt_filename',
91
+ r'\n *kpoint_file\s*(\S+)',
92
+ repeats=False,
93
+ ),
94
+ Quantity(
95
+ 'basis_type',
96
+ r'\n *basis_type\s*(\w+)',
97
+ repeats=False,
98
+ ),
99
+ Quantity(
100
+ 'x_abacus_init_velocities',
101
+ r'\n *init_vel\s*(\d+)',
102
+ repeats=False,
103
+ dtype=bool,
104
+ ),
105
+ Quantity(
106
+ 'xc',
107
+ r'\n *dft_functional\s*(\w+)',
108
+ repeats=False,
109
+ ),
110
+ Quantity('kpar', r'\n *kpar\s*(\d+)', repeats=False),
111
+ Quantity('bndpar', r'\n *bndpar\s*(\d+)', repeats=False),
112
+ Quantity('diago_proc', r'\n *diago_proc\s*(\d+)', repeats=False),
113
+ Quantity('scf_max_iteration', r'\n *scf_nmax\s*(\d+)', repeats=False),
114
+ Quantity('nelec', r'\n *nelec\s*(\d+)', repeats=False),
115
+ Quantity('md_type', r'\n *md_type\s*(\d+)', repeats=False),
116
+ Quantity('md_nstep', r'\n *md_nstep\s*(\d+)', repeats=False),
117
+ Quantity(
118
+ 'occupations',
119
+ r'\n *occupations\s*(\w+)',
120
+ repeats=False,
121
+ ),
122
+ Quantity(
123
+ 'smearing_method',
124
+ r'\n *smearing_method\s*(\w+)',
125
+ repeats=False,
126
+ ),
127
+ Quantity(
128
+ 'smearing_width',
129
+ rf'\n *smearing_sigma\s*({re_float})',
130
+ repeats=False,
131
+ unit='rydberg',
132
+ ),
133
+ Quantity('dft_plus_u', r'\n *dft_plus_u\s*(\d)', repeats=False, dtype=bool),
134
+ Quantity(
135
+ xsection_method.x_abacus_mixing_method,
136
+ rf'\n *mixing_type\s*(\S+)',
137
+ repeats=False,
138
+ ),
139
+ Quantity(
140
+ xsection_method.x_abacus_mixing_beta,
141
+ rf'\n *mixing_beta\s*({re_float})',
142
+ repeats=False,
143
+ ),
144
+ Quantity(
145
+ xsection_method.x_abacus_diagonalization_algorithm,
146
+ rf'\n *ks_solver\s*(\w+)',
147
+ repeats=False,
148
+ ),
149
+ Quantity(
150
+ xsection_method.x_abacus_dispersion_correction_method,
151
+ r'\n *vdw_method\s*(\S+)',
152
+ repeats=False,
153
+ ),
154
+ Quantity(
155
+ xsection_method.x_abacus_gamma_algorithms,
156
+ rf'\n *gamma_only\s*(\d)',
157
+ repeats=False,
158
+ dtype=bool,
159
+ ),
160
+ Quantity(
161
+ xsection_method.x_abacus_scf_threshold_density,
162
+ rf'\n *scf_thr\s*({re_float})',
163
+ repeats=False,
164
+ dtype=float,
165
+ ),
166
+ Quantity(
167
+ xsection_method.x_abacus_initial_magnetization_total,
168
+ rf'\n *tot_magnetization\s*({re_float})',
169
+ repeats=False,
170
+ dtype=float,
171
+ ),
172
+ Quantity(
173
+ xsection_method.x_abacus_hse_omega,
174
+ rf'\n *exx_hse_omega\s*({re_float})',
175
+ repeats=False,
176
+ unit='1/bohr',
177
+ ),
178
+ Quantity(
179
+ xsection_method.x_abacus_hybrid_xc_coeff,
180
+ rf'\n *exx_hybrid_alpha\s*({re_float})',
181
+ repeats=False,
182
+ ),
183
+ Quantity(
184
+ xsection_method.x_abacus_exx_ccp_rmesh_times,
185
+ rf'\n *exx_ccp_rmesh_times\s*({re_float})',
186
+ repeats=False,
187
+ ),
188
+ Quantity(
189
+ xsection_method.x_abacus_exx_dm_threshold,
190
+ rf'\n *exx_dm_threshold\s*({re_float})',
191
+ repeats=False,
192
+ ),
193
+ Quantity(
194
+ xsection_method.x_abacus_exx_cauchy_threshold,
195
+ rf'\n *exx_cauchy_threshold\s*({re_float})',
196
+ repeats=False,
197
+ ),
198
+ Quantity(
199
+ xsection_method.x_abacus_exx_schwarz_threshold,
200
+ rf'\n *exx_schwarz_threshold\s*({re_float})',
201
+ repeats=False,
202
+ ),
203
+ Quantity(
204
+ xsection_method.x_abacus_exx_c_threshold,
205
+ rf'\n *exx_c_threshold\s*({re_float})',
206
+ repeats=False,
207
+ ),
208
+ Quantity(
209
+ xsection_method.x_abacus_exx_v_threshold,
210
+ rf'\n *exx_v_threshold\s*({re_float})',
211
+ repeats=False,
212
+ ),
213
+ Quantity(
214
+ xsection_method.x_abacus_exx_pca_threshold,
215
+ rf'\n *exx_pca_threshold\s*({re_float})',
216
+ repeats=False,
217
+ ),
218
+ ]
219
+
220
+
221
+ class ABACUSOutParser(TextParser):
222
+ def __init__(self):
223
+ super().__init__(None)
224
+
225
+ def init_quantities(self):
226
+ def str_to_sites(val_in):
227
+ data = dict()
228
+ val = [v.strip().split() for v in val_in.split('\n')][0]
229
+ if len(val) == 5:
230
+ labels, x, y, z, mag = val
231
+ elif len(val) == 8:
232
+ labels, x, y, z, mag, vx, vy, vz = val
233
+ data['velocities'] = np.array([vx, vy, vz], dtype=float)
234
+ data['labels'] = labels
235
+ data['positions'] = np.array([x, y, z], dtype=float)
236
+ data['magnetic_moments'] = float(mag)
237
+ return data
238
+
239
+ def str_to_coordclass(val_in):
240
+ if val_in == 'DIRECT':
241
+ name = 'direct'
242
+ elif val_in == 'CARTESIAN':
243
+ name = 'cartesian'
244
+ return name
245
+
246
+ def str_to_matrix(val_in):
247
+ val = [v.strip().split() for v in val_in.split('\n')]
248
+ return np.reshape(val, (3, 3)).astype(float)
249
+
250
+ def str_to_dict(val_in):
251
+ data = dict()
252
+ val = val_in.split()
253
+ data[val[0]] = int(val[1])
254
+ return data
255
+
256
+ def str_to_kpoints(val_in):
257
+ lines = (
258
+ re.search(
259
+ rf'KPOINTS\s*DIRECT_X\s*DIRECT_Y\s*DIRECT_Z\s*WEIGHT([\s\S]+?)DONE',
260
+ val_in,
261
+ )
262
+ .group(1)
263
+ .strip()
264
+ .split('\n')
265
+ )
266
+ data = []
267
+ for line in lines:
268
+ data.append(line.strip().split()[1:5])
269
+ # TODO pylinit error, unbalanced-tuple-unpacking
270
+ data = np.array(data, dtype=float)
271
+ kpoints = data[:, :3]
272
+ weights = data[:, 3]
273
+ return kpoints, weights
274
+
275
+ def str_to_sticks(val_in):
276
+ Data = namedtuple('PW', ['proc', 'columns', 'pw'])
277
+ val = re.findall(
278
+ rf'\s+({re_float})\s+({re_float})\s+({re_float})\n', val_in
279
+ )
280
+ data = []
281
+ for v in val:
282
+ data.append(Data(proc=int(v[0]), columns=int(v[1]), pw=int(v[2])))
283
+ return data
284
+
285
+ def str_to_orbital(val_in):
286
+ Data = namedtuple(
287
+ 'Orbital',
288
+ ['index', 'l', 'n', 'nr', 'dr', 'rcut', 'check_unit', 'new_unit'],
289
+ )
290
+ val = re.findall(
291
+ rf'\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+({re_float})\s+({re_float})\s+({re_float})\s+({re_float})\n',
292
+ val_in,
293
+ )
294
+ data = []
295
+ for v in val:
296
+ data.append(
297
+ Data(
298
+ index=int(v[0]),
299
+ l=int(v[1]),
300
+ n=int(v[2]),
301
+ nr=int(v[3]),
302
+ dr=float(v[4]),
303
+ rcut=float(v[5]),
304
+ check_unit=float(v[6]),
305
+ new_unit=float(v[7]),
306
+ )
307
+ )
308
+ return data
309
+
310
+ def str_to_energy_occupation(val_in):
311
+ def extract_data(val_in, nks):
312
+ State = namedtuple(
313
+ 'State', ['kpoint', 'energies', 'occupations', 'npws']
314
+ )
315
+ data = []
316
+ for i in range(nks):
317
+ kx, ky, kz, npws = re.search(
318
+ rf'{i+1}/{nks} kpoint \(Cartesian\)\s*=\s*({re_float})\s*({re_float})\s*({re_float})\s*\((\d+)\s*pws\)',
319
+ val_in,
320
+ ).groups()
321
+ # TODO pylinit error, unbalanced-tuple-unpacking
322
+ res = np.array(
323
+ list(
324
+ map(
325
+ lambda x: x.strip().split(),
326
+ re.search(
327
+ rf'{i+1}/{nks} kpoint \(Cartesian\)\s*=.*\n([\s\S]+?)\n\n',
328
+ val_in,
329
+ )
330
+ .group(1)
331
+ .split('\n'),
332
+ )
333
+ ),
334
+ dtype=float,
335
+ )
336
+ energies = res[:, 1]
337
+ occupations = res[:, 2]
338
+ state = State(
339
+ kpoint=np.array([kx, ky, kz], dtype=float),
340
+ energies=energies.astype(float),
341
+ occupations=occupations.astype(float),
342
+ npws=int(npws),
343
+ )
344
+ data.append(state)
345
+ return data
346
+
347
+ nspin = int(
348
+ re.search(
349
+ r'STATE ENERGY\(eV\) AND OCCUPATIONS\s*NSPIN\s*==\s*(\d+)', val_in
350
+ ).group(1)
351
+ )
352
+ nks = int(re.search(r'\d+/(\d+) kpoint \(Cartesian\)', val_in).group(1))
353
+ data = dict()
354
+ if nspin in [1, 4]:
355
+ data['up'] = extract_data(val_in, nks)
356
+ elif nspin == 2:
357
+ val_up = re.search(r'SPIN UP :([\s\S]+?)\n\nSPIN', val_in).group()
358
+ data['up'] = extract_data(val_up, nks)
359
+ val_dw = re.search(
360
+ r'SPIN DOWN :([\s\S]+?)(?:\n\n\s*EFERMI|\n\n\n)', val_in
361
+ ).group()
362
+ data['down'] = extract_data(val_dw, nks)
363
+ return data
364
+
365
+ def str_to_bandstructure(val_in):
366
+ def extract_data(val_in, nks):
367
+ State = namedtuple('State', ['kpoint', 'energies'])
368
+ data = []
369
+ for i in range(nks):
370
+ kx, ky, kz = re.search(
371
+ rf'k\-points{i+1}\(\d+\):\s*({re_float})\s*({re_float})\s*({re_float})',
372
+ val_in,
373
+ ).groups()
374
+ res = np.array(
375
+ list(
376
+ map(
377
+ lambda x: x.strip().split(),
378
+ re.search(
379
+ rf'k\-points{i+1}\(\d+\):.*\n([\s\S]+?)\n\n', val_in
380
+ )
381
+ .group(1)
382
+ .split('\n'),
383
+ )
384
+ )
385
+ )
386
+ energies = res[:, 2]
387
+ # TODO check this error
388
+ state = State(
389
+ kpoint=np.array([kx, ky, kz], dtype=float),
390
+ energies=energies.astype(float),
391
+ )
392
+ data.append(state)
393
+ return data
394
+
395
+ nks = int(re.search(r'k\-points\d+\((\d+)\)', val_in).group(1))
396
+ data = dict()
397
+ if re.search('spin up', val_in) and re.search('spin down', val_in):
398
+ val = re.search(r'spin up :\n([\s\S]+?)\n\n\n', val_in).group()
399
+ val_new = extract_data(val, nks)
400
+ data['up'] = val_new[: int(nks / 2)]
401
+ data['down'] = val_new[int(nks / 2) :]
402
+ else:
403
+ data['up'] = extract_data(val_in, nks)
404
+ return data
405
+
406
+ def str_to_force(val_in):
407
+ data = []
408
+ val = [v.strip().split() for v in val_in.split('\n')]
409
+ for v in val:
410
+ data.append(np.array(v[1:], dtype=float))
411
+ return np.array(data) * ureg.eV / ureg.angstrom
412
+
413
+ def str_to_polarization(val_in):
414
+ P = namedtuple('P', ['value', 'mod', 'vector'])
415
+ data = np.array(val_in.split(), dtype=float)
416
+ unit = ureg.C / ureg.meter**2
417
+ return P(value=data[0] * unit, mod=data[1], vector=data[2:] * unit)
418
+
419
+ atom_quantities = [
420
+ Quantity('label', r'atom label\s*=\s*(\w+)'),
421
+ Quantity('orbital', r'L=\d+, number of zeta\s*=\s*(\d+)', repeats=True),
422
+ Quantity(
423
+ 'natoms',
424
+ r'number of atom for this type\s*=\s*(\d+)',
425
+ ),
426
+ Quantity(
427
+ 'start_magnetization',
428
+ r'start magnetization\s*=\s*(\w+)',
429
+ repeats=True,
430
+ str_operation=lambda x: x == 'TRUE',
431
+ ),
432
+ Quantity(
433
+ 'noncollinear_magnetization',
434
+ rf'noncollinear magnetization_x\s*=\s*({re_float})\n\s*noncollinear magnetization_y\s*=\s*({re_float})\n\s*noncollinear magnetization_z\s*=\s*({re_float})\n\s*',
435
+ dtype=float,
436
+ ),
437
+ ]
438
+
439
+ structure_quantities = [
440
+ Quantity(
441
+ 'sites',
442
+ rf'tau[cd]_([a-zA-Z]+)\d+\s+({re_float})\s+({re_float})\s+({re_float})\s+({re_float})\s+({re_float})\s+({re_float})\s+({re_float})',
443
+ repeats=True,
444
+ str_operation=str_to_sites,
445
+ ),
446
+ Quantity(
447
+ 'sites',
448
+ rf'tau[cd]_([a-zA-Z]+)\d+\s+({re_float})\s+({re_float})\s+({re_float})\s+({re_float})',
449
+ repeats=True,
450
+ str_operation=str_to_sites,
451
+ ),
452
+ Quantity(
453
+ 'units',
454
+ rf'UNIT = ({re_float}) Bohr',
455
+ dtype=float,
456
+ repeats=False,
457
+ unit='bohr',
458
+ ),
459
+ Quantity(
460
+ 'coord_class',
461
+ r'(DIRECT) COORDINATES|(CARTESIAN) COORDINATES',
462
+ repeat=False,
463
+ str_operation=str_to_coordclass,
464
+ ),
465
+ ]
466
+
467
+ symmetry_quantities = [
468
+ Quantity(
469
+ 'lattice_vectors',
470
+ rf'LATTICE VECTORS: \(CARTESIAN COORDINATE: IN UNIT OF A0\)\n\s*({re_float})\s*({re_float})\s*({re_float})\n\s*({re_float})\s*({re_float})\s*({re_float})\n\s*({re_float})\s*({re_float})\s*({re_float})\n',
471
+ str_operation=str_to_matrix,
472
+ convert=False,
473
+ repeats=False,
474
+ ),
475
+ Quantity('right_hand_lattice', r'right hand lattice\s*=\s*(\d+)'),
476
+ Quantity(
477
+ 'norm_a',
478
+ rf'NORM_A\s*=\s*({re_float})',
479
+ ),
480
+ Quantity(
481
+ 'norm_b',
482
+ rf'NORM_B\s*=\s*({re_float})',
483
+ ),
484
+ Quantity(
485
+ 'norm_c',
486
+ rf'NORM_C\s*=\s*({re_float})',
487
+ ),
488
+ Quantity('alpha', rf'ALPHA\s*\(DEGREE\)\s*=\s*({re_float})'),
489
+ Quantity('beta', rf'BETA\s*\(DEGREE\)\s*=\s*({re_float})'),
490
+ Quantity('gamma', rf'GAMMA\s*\(DEGREE\)\s*=\s*({re_float})'),
491
+ Quantity('bravais_name', r'BRAVAIS LATTICE NAME\s*=\s*([.\w\(\)\- ]+)'),
492
+ Quantity('ibrav', r'IBRAV\s*=\s*([\w ]+)', dtype=int),
493
+ Quantity('number_of_rotation_matrices', r'ROTATION MATRICES\s*=\s*(\d+)'),
494
+ Quantity(
495
+ 'number_of_point_group_operations',
496
+ r'PURE POINT GROUP OPERATIONS\s*=\s*(\d+)',
497
+ ),
498
+ Quantity(
499
+ 'number_of_space_group_operations',
500
+ r'SPACE GROUP OPERATIONS\s*=\s*(\d+)',
501
+ ),
502
+ Quantity('point_group', r'POINT GROUP\s*=\s*([\w\_]+)', convert=False),
503
+ ]
504
+
505
+ orbital_quantities = [
506
+ Quantity(
507
+ 'delta_k',
508
+ rf'delta k\s*\(1/Bohr\)\s*=\s*({re_float})',
509
+ unit='1/bohr',
510
+ dtype=float,
511
+ ),
512
+ Quantity(
513
+ 'delta_r',
514
+ rf'delta r\s*\(Bohr\)\s*=\s*({re_float})',
515
+ unit='bohr',
516
+ dtype=float,
517
+ ),
518
+ Quantity(
519
+ 'dr_uniform',
520
+ rf'dr_uniform\s*\(Bohr\)\s*=\s*({re_float})',
521
+ unit='bohr',
522
+ dtype=float,
523
+ ),
524
+ Quantity(
525
+ 'rmax', rf'rmax\s*\(Bohr\)\s*=\s*({re_float})', unit='bohr', dtype=float
526
+ ),
527
+ Quantity('kmesh', rf'kmesh\s*=\s*(\d+)', dtype=int),
528
+ Quantity(
529
+ 'orbital_information',
530
+ r'ORBITAL\s*L\s*N\s*nr\s*dr\s*RCUT\s*CHECK_UNIT\s*NEW_UNIT\n([\s\S]+)SET NONLOCAL PSEUDOPOTENTIAL PROJECTORS',
531
+ convert=False,
532
+ str_operation=str_to_orbital,
533
+ repeats=True,
534
+ ),
535
+ ]
536
+
537
+ header_quantities = [
538
+ Quantity('number_of_species', r'ntype\s*=\s*(\d+)', dtype=int),
539
+ Quantity(
540
+ 'alat',
541
+ rf'lattice constant \(Bohr\)\s*=\s*({re_float})',
542
+ unit='bohr',
543
+ dtype=float,
544
+ ),
545
+ Quantity('atom_labels', r'atom label\s*=\s*(\w+)', repeats=True),
546
+ Quantity(
547
+ 'number_of_atoms_for_labels',
548
+ r'number of atom for this type\s*=\s*(\d+)',
549
+ repeats=True,
550
+ ),
551
+ Quantity(
552
+ 'atom_data',
553
+ r'READING ATOM TYPE\s*\d+([\s\S]+?)\n\n',
554
+ repeats=True,
555
+ sub_parser=TextParser(quantities=atom_quantities),
556
+ convert=False,
557
+ ),
558
+ Quantity('number_of_atoms', r'TOTAL ATOM NUMBER\s*=\s*(\d+)', dtype=int),
559
+ Quantity(
560
+ 'positions',
561
+ rf'(CARTESIAN COORDINATES \( UNIT = {re_float} Bohr \)\.+\n\s*atom\s*x\s*y\s*z\s*mag(\s*vx\s*vy\s*vz\s*|\s*)\n[\s\S]+?)\n\n|(DIRECT COORDINATES\n\s*atom\s*x\s*y\s*z\s*mag(\s*vx\s*vy\s*vz\s*|\s*)\n[\s\S]+?)\n\n',
562
+ sub_parser=TextParser(quantities=structure_quantities),
563
+ convert=False,
564
+ repeats=False,
565
+ ),
566
+ Quantity('orbital_files', r'orbital file:\s*(\S+)', repeats=True),
567
+ Quantity(
568
+ 'cell_volume',
569
+ rf'Volume \(Bohr\^3\)\s*=\s*({re_float})',
570
+ unit='bohr**3',
571
+ dtype=float,
572
+ ),
573
+ Quantity(
574
+ 'units', r'Lattice vectors: \(Cartesian coordinate: in unit of (\w+)\)'
575
+ ),
576
+ Quantity(
577
+ 'lattice_vectors',
578
+ rf'Lattice vectors: \(Cartesian coordinate: in unit of a_0\)\n\s*({re_float})\s*({re_float})\s*({re_float})\n\s*({re_float})\s*({re_float})\s*({re_float})\n\s*({re_float})\s*({re_float})\s*({re_float})\n',
579
+ str_operation=str_to_matrix,
580
+ convert=False,
581
+ repeats=False,
582
+ ),
583
+ Quantity(
584
+ 'reciprocal_units',
585
+ r'Reciprocal vectors: \(Cartesian coordinate: in unit of ([\w\/ ]+)\)',
586
+ flatten=False,
587
+ ),
588
+ Quantity(
589
+ 'reciprocal_vectors',
590
+ rf'Reciprocal vectors: \(Cartesian coordinate: in unit of 2 pi/a_0\)\n\s*({re_float})\s*({re_float})\s*({re_float})\n\s*({re_float})\s*({re_float})\s*({re_float})\n\s*({re_float})\s*({re_float})\s*({re_float})\n',
591
+ str_operation=str_to_matrix,
592
+ convert=False,
593
+ repeats=False,
594
+ ),
595
+ Quantity(
596
+ 'pseudopotential',
597
+ r'(Read in pseudopotential file is [\s\S]+?\n\n)',
598
+ repeats=True,
599
+ sub_parser=TextParser(
600
+ quantities=[
601
+ Quantity('filename', r'file is\s*(\S+)'),
602
+ Quantity(
603
+ 'type', r'pseudopotential type\s*=\s*(\w+)', flatten=False
604
+ ),
605
+ Quantity(
606
+ 'xc',
607
+ r'exchange-correlation functional\s*=\s*(\w+)',
608
+ flatten=False,
609
+ ),
610
+ Quantity('valence', rf'valence electrons\s*=\s*({re_float})'),
611
+ Quantity('lmax', rf'lmax\s*=\s*({re_float})'),
612
+ Quantity(
613
+ 'nzeta', rf'number of zeta\s*=\s*({re_float})', dtype=int
614
+ ),
615
+ Quantity(
616
+ 'nprojectors',
617
+ rf'number of projectors\s*=\s*({re_float})',
618
+ dtype=int,
619
+ ),
620
+ ]
621
+ ),
622
+ ),
623
+ Quantity(
624
+ 'fermi_energy_in',
625
+ rf'read in fermi energy\s*=\s*({re_float})',
626
+ dtype=float,
627
+ repeats=True,
628
+ ),
629
+ Quantity(
630
+ xsection_method.x_abacus_pao_radial_cutoff,
631
+ rf'PAO radial cut off \(Bohr\)\s*=\s*({re_float})',
632
+ unit='bohr',
633
+ dtype=float,
634
+ repeats=False,
635
+ ),
636
+ Quantity(
637
+ 'number_of_electrons_out',
638
+ rf'total electron number of element \w+\s*=\s*(\d+)',
639
+ repeats=True,
640
+ ),
641
+ Quantity('occupied_bands', rf'occupied bands\s*=\s*({re_float})'),
642
+ Quantity('nlocal', rf'NLOCAL\s*=\s*({re_float})', repeats=False),
643
+ Quantity('nbands', rf'NBANDS\s*=\s*({re_float})', repeats=False),
644
+ Quantity(
645
+ 'symmetry',
646
+ r'(LATTICE VECTORS: \(CARTESIAN COORDINATE: IN UNIT OF A0\)\s*[\s\S]+?)\n\n',
647
+ repeats=False,
648
+ sub_parser=TextParser(quantities=symmetry_quantities),
649
+ ),
650
+ Quantity(
651
+ 'number_of_spin_channels',
652
+ r'nspin\s*=\s*(\d+)',
653
+ dtype=int,
654
+ repeats=False,
655
+ ),
656
+ Quantity(
657
+ 'ksampling_method',
658
+ r'Input type of k points\s*=\s*([\w\-\(\) ]+)',
659
+ str_operation=lambda x: x,
660
+ ),
661
+ Quantity('nkstot', r'nkstot\s*=\s*(\d+)', dtype=int),
662
+ Quantity('nkstot_ibz', r'nkstot_ibz\s*=\s*(\d+)', dtype=int),
663
+ Quantity(
664
+ 'k_points',
665
+ r'minimum distributed K point number\s*=\s*\d+([\s\S]+?DONE : INIT K-POINTS Time)',
666
+ str_operation=str_to_kpoints,
667
+ ),
668
+ Quantity(
669
+ 'density_cutoff',
670
+ rf'energy cutoff for charge/potential \(unit:Ry\)\s*=\s*({re_float})',
671
+ unit='rydberg',
672
+ dtype=float,
673
+ ),
674
+ Quantity(
675
+ 'density_fft_grid',
676
+ r'\[fft grid for charge/potential\]\s*=\s*(\d+)[,\s]*(\d+)[,\s]*(\d+)[,\s]*',
677
+ ),
678
+ Quantity(
679
+ 'fft_grid_division',
680
+ r'\[fft grid division\]\s*=\s*(\d+)[,\s]*(\d+)[,\s]*(\d+)[,\s]*',
681
+ ),
682
+ Quantity('nbxx', r'nbxx\s*=\s*(\d+)'),
683
+ Quantity('nrxx', r'nrxx\s*=\s*(\d+)'),
684
+ Quantity(
685
+ 'number_of_pw_for_density',
686
+ r'SETUP PLANE WAVES FOR CHARGE/POTENTIAL\n\s*number of plane waves\s*=\s*(\d+)',
687
+ ),
688
+ Quantity(
689
+ 'number_of_sticks_for_density',
690
+ r'SETUP PLANE WAVES FOR CHARGE/POTENTIAL\n.*\n\s*number of sticks\s*=\s*(\d+)\n',
691
+ ),
692
+ Quantity(
693
+ 'parallel_pw_for_density',
694
+ r'PARALLEL PW FOR CHARGE/POTENTIAL\n\s*PROC\s*COLUMNS\(POT\)\s*PW\n([\s\S]+?)\-+',
695
+ str_operation=str_to_sticks,
696
+ convert=False,
697
+ ),
698
+ Quantity('number_of_g', r'number of \|g\|\s*=\s*(\d+)'),
699
+ Quantity('max_g', rf'max \|g\|\s*=\s*({re_float})'),
700
+ Quantity('min_g', rf'min \|g\|\s*=\s*({re_float})'),
701
+ Quantity(
702
+ 'wavefunction_cutoff',
703
+ rf'energy cutoff for wavefunc \(unit:Ry\)\s*=\s*({re_float})',
704
+ unit='rydberg',
705
+ dtype=float,
706
+ ),
707
+ Quantity(
708
+ 'wavefunction_fft_grid',
709
+ r'\[fft grid for wave functions\]\s*=\s*(\d+)[,\s]*(\d+)[,\s]*(\d+)[,\s]*',
710
+ ),
711
+ Quantity(
712
+ 'number_of_pw_for_wavefunction',
713
+ r'SETUP PLANE WAVES FOR WAVE FUNCTIONS\n[\s\S]+\s*number of plane waves\s*=\s*(\d+)',
714
+ ),
715
+ Quantity(
716
+ 'number_of_sticks_for_wavefunction',
717
+ r'SETUP PLANE WAVES FOR WAVE FUNCTIONS\n[\s\S]+\s*number of sticks\s*=\s*(\d+)\n',
718
+ ),
719
+ Quantity(
720
+ 'parallel_pw_for_wavefunction',
721
+ r'PARALLEL PW FOR WAVE FUNCTIONS\n\s*PROC\s*COLUMNS\(W\)\s*PW\n([\s\S]+?)\-+',
722
+ str_operation=str_to_sticks,
723
+ convert=False,
724
+ ),
725
+ Quantity('number_of_total_pw', r'number of total plane waves\s*=\s*(\d+)'),
726
+ Quantity(
727
+ 'total_number_of_nlocal_projectors',
728
+ r'TOTAL NUMBER OF NONLOCAL PROJECTORS\s*=\s*(\d+)',
729
+ ),
730
+ Quantity('init_chg', rf'init_chg\s*=\s*(\w+)'),
731
+ Quantity(
732
+ 'max_mesh_in_pp', rf'max mesh points in Pseudopotential\s*=\s*(\d+)'
733
+ ),
734
+ Quantity(
735
+ 'dq', rf'dq\(describe PAO in reciprocal space\)\s*=\s*({re_float})'
736
+ ),
737
+ Quantity('max_q', rf'max q\s*=\s*({re_float})'),
738
+ Quantity(
739
+ 'number_of_pseudo_ao',
740
+ r'number of pseudo atomic orbitals for (\w+) is (\d+)',
741
+ repeats=True,
742
+ str_operation=str_to_dict,
743
+ convert=False,
744
+ ),
745
+ Quantity(
746
+ 'orbital_settings',
747
+ r'SETUP ONE DIMENSIONAL ORBITALS/POTENTIAL\s*([\s\S]+?)SETUP THE TWO-CENTER INTEGRATION TABLES',
748
+ sub_parser=TextParser(quantities=orbital_quantities),
749
+ convert=False,
750
+ ),
751
+ Quantity(
752
+ 'allocation_method',
753
+ r'divide the H&S matrix using ([\w ]+ algorithms\.\n[\s\S]+?)\n\n',
754
+ sub_parser=TextParser(
755
+ quantities=[
756
+ Quantity(
757
+ 'method',
758
+ r'([\w ]+) algorithms',
759
+ dtype=str,
760
+ str_operation=lambda x: x,
761
+ ),
762
+ Quantity('nb2d', r'nb2d\s*=\s*(\d+)', dtype=int),
763
+ Quantity(
764
+ 'trace_loc_row',
765
+ r'trace_loc_row dimension\s*=\s*(\d+)',
766
+ dtype=int,
767
+ ),
768
+ Quantity(
769
+ 'trace_loc_col',
770
+ r'trace_loc_row dimension\s*=\s*(\d+)',
771
+ dtype=int,
772
+ ),
773
+ Quantity('nloc', r'nloc\s*=\s*(\d+)', dtype=int),
774
+ ]
775
+ ),
776
+ ),
777
+ ]
778
+
779
+ search_quantities = [
780
+ Quantity(
781
+ 'search_adjacent_atoms',
782
+ r'SETUP SEARCHING RADIUS FOR PROGRAM TO SEARCH ADJACENT ATOMS\s*([\s\S]+?)\n\n',
783
+ sub_parser=TextParser(
784
+ quantities=[
785
+ Quantity(
786
+ 'longest_orb_rcut',
787
+ rf'longest orb rcut \(Bohr\)\s*=\s*({re_float})',
788
+ unit='bohr',
789
+ dtype=float,
790
+ ),
791
+ Quantity(
792
+ 'longest_nonlocal_projector_rcut',
793
+ rf'longest nonlocal projector rcut \(Bohr\)\s*=\s*({re_float})',
794
+ unit='bohr',
795
+ dtype=float,
796
+ ),
797
+ Quantity(
798
+ 'searching_radius',
799
+ rf'searching radius is \(Bohr\)\)\s*=\s*({re_float})',
800
+ unit='bohr',
801
+ dtype=float,
802
+ ),
803
+ Quantity(
804
+ 'searching_radius_unit',
805
+ rf'searching radius unit is \(Bohr\)\)\s*=\s*({re_float})',
806
+ unit='bohr',
807
+ dtype=float,
808
+ ),
809
+ ]
810
+ ),
811
+ ),
812
+ Quantity(
813
+ 'grid_integration',
814
+ r'SETUP EXTENDED REAL SPACE GRID FOR GRID INTEGRATION\s*([\s\S]+?)\n\n',
815
+ sub_parser=TextParser(
816
+ quantities=[
817
+ Quantity(
818
+ 'read_space_grid',
819
+ r'\[real space grid\]\s*=\s*(\d+)[,\s]*(\d+)[,\s]*(\d+)[,\s]*',
820
+ ),
821
+ Quantity(
822
+ 'big_cell_numbers_in_grid',
823
+ r'\[big cell numbers in grid\]\s*=\s*(\d+)[,\s]*(\d+)[,\s]*(\d+)[,\s]*',
824
+ ),
825
+ Quantity(
826
+ 'meshcell_numbers_in_big_cell',
827
+ r'\[meshcell numbers in big cell\]\s*=\s*(\d+)[,\s]*(\d+)[,\s]*(\d+)[,\s]*',
828
+ ),
829
+ Quantity(
830
+ 'extended_fft_grid',
831
+ r'\[extended fft grid\]\s*=\s*(\d+)[,\s]*(\d+)[,\s]*(\d+)[,\s]*',
832
+ ),
833
+ Quantity(
834
+ 'extended_fft_grid_dim',
835
+ r'\[dimension of extened grid\]\s*=\s*(\d+)[,\s]*(\d+)[,\s]*(\d+)[,\s]*',
836
+ ),
837
+ Quantity(
838
+ 'atom_number',
839
+ r'Atom number in sub-FFT-grid\s*=\s*(\d+)',
840
+ dtype=int,
841
+ ),
842
+ Quantity(
843
+ 'local_orbitals_number',
844
+ r'Local orbitals number in sub-FFT-grid\s*=\s*(\d+)',
845
+ dtype=int,
846
+ ),
847
+ Quantity('nnr', r'ParaV\.nnr\s*=\s*(\d+)', dtype=int),
848
+ Quantity('nnrg', r'nnrg\s*=\s*(\d+)', dtype=int),
849
+ Quantity('nnrg_last', r'nnrg_last\s*=\s*(\d+)', dtype=int),
850
+ Quantity('nnrg_now', r'nnrg_now\s*=\s*(\d+)', dtype=int),
851
+ Quantity('lgd_last', r'nnrg_now\s*=\s*(\d+)', dtype=int),
852
+ Quantity('lgd_now', r'nnrg_now\s*=\s*(\d+)', dtype=int),
853
+ ]
854
+ ),
855
+ ),
856
+ ]
857
+
858
+ calculation_quantities = [
859
+ Quantity(
860
+ 'energy_occupation',
861
+ r'(STATE ENERGY\(eV\) AND OCCUPATIONS\s*NSPIN\s*==\s*\d+[\s\S]+?(?:\n\n\s*EFERMI|\n\n\n))',
862
+ repeats=False,
863
+ str_operation=str_to_energy_occupation,
864
+ convert=False,
865
+ ),
866
+ Quantity(
867
+ 'reference_fermi',
868
+ rf'EFERMI\s*=\s*({re_float})\s*eV',
869
+ unit='eV',
870
+ dtype=float,
871
+ ),
872
+ Quantity(
873
+ 'total',
874
+ rf'\s*final etot is\s*({re_float})\s*eV',
875
+ unit='eV',
876
+ dtype=float,
877
+ ),
878
+ Quantity(
879
+ 'forces',
880
+ r'TOTAL\-FORCE\s*\(eV/Angstrom\)\n\n.*\s*atom\s*x\s*y\s*z\n([\s\S]+?)\n\n',
881
+ str_operation=str_to_force,
882
+ convert=False,
883
+ ),
884
+ Quantity(
885
+ 'stress',
886
+ rf'(?:TOTAL\-|MD\s*)STRESS\s*\(KBAR\)\n\n.*\n\n\s*({re_float})\s*({re_float})\s*({re_float})\n\s*({re_float})\s*({re_float})\s*({re_float})\n\s*({re_float})\s*({re_float})\s*({re_float})\n',
887
+ str_operation=str_to_matrix,
888
+ unit='kilobar',
889
+ convert=False,
890
+ ),
891
+ Quantity(
892
+ 'pressure',
893
+ rf'TOTAL\-PRESSURE:\s*({re_float})\s*KBAR',
894
+ unit='kilobar',
895
+ dtype=float,
896
+ ),
897
+ Quantity(
898
+ 'positions',
899
+ rf'(CARTESIAN COORDINATES \( UNIT = {re_float} Bohr \)\.+\n\s*atom\s*x\s*y\s*z\s*mag\s*vx\s*vy\s*vz\s*\n[\s\S]+?)\n\n|(DIRECT COORDINATES\n\s*atom\s*x\s*y\s*z\s*mag\s*vx\s*vy\s*vz\s*\n[\s\S]+?)\n\n',
900
+ sub_parser=TextParser(quantities=structure_quantities),
901
+ convert=False,
902
+ ),
903
+ Quantity(
904
+ 'cell_volume',
905
+ rf'Volume \(Bohr\^3\)\s*=\s*({re_float})',
906
+ unit='bohr**3',
907
+ dtype=float,
908
+ ),
909
+ Quantity(
910
+ 'units', r'Lattice vectors: \(Cartesian coordinate: in unit of (\w+)\)'
911
+ ),
912
+ Quantity(
913
+ 'lattice_vectors',
914
+ rf'Lattice vectors: \(Cartesian coordinate: in unit of a_0\)\n\s*({re_float})\s*({re_float})\s*({re_float})\n\s*({re_float})\s*({re_float})\s*({re_float})\n\s*({re_float})\s*({re_float})\s*({re_float})\n',
915
+ str_operation=str_to_matrix,
916
+ convert=False,
917
+ repeats=False,
918
+ ),
919
+ Quantity(
920
+ 'reciprocal_units',
921
+ r'Reciprocal vectors: \(Cartesian coordinate: in unit of ([\w\/ ]+)\)',
922
+ flatten=False,
923
+ ),
924
+ Quantity(
925
+ 'reciprocal_vectors',
926
+ rf'Reciprocal vectors: \(Cartesian coordinate: in unit of 2 pi/a_0\)\n\s*({re_float})\s*({re_float})\s*({re_float})\n\s*({re_float})\s*({re_float})\s*({re_float})\n\s*({re_float})\s*({re_float})\s*({re_float})\n',
927
+ str_operation=str_to_matrix,
928
+ convert=False,
929
+ repeats=False,
930
+ ),
931
+ Quantity(
932
+ 'k_points',
933
+ r'minimum distributed K point number\s*=\s*\d+([\s\S]+?DONE : INIT K-POINTS Time)',
934
+ str_operation=str_to_kpoints,
935
+ ),
936
+ ] + search_quantities
937
+
938
+ scf_quantities = [
939
+ Quantity(
940
+ 'iteration',
941
+ rf'(ELEC\s*=\s*[+\d]+\s*\-+[\s\S]+?\s*E_Fermi\s*{re_float}\s*{re_float})\n',
942
+ repeats=True,
943
+ sub_parser=TextParser(
944
+ quantities=[
945
+ Quantity('elec_step', r'ELEC\s*=\s*[+]?(\d+)', dtype=int),
946
+ Quantity(
947
+ 'density_error',
948
+ rf'Density error is\s*({re_float})',
949
+ dtype=float,
950
+ ),
951
+ Quantity(
952
+ 'energy_total_scf_iteration',
953
+ rf'E_KohnSham\s*{re_float}\s*({re_float})',
954
+ dtype=float,
955
+ unit='eV',
956
+ ),
957
+ Quantity(
958
+ 'x_abacus_energy_total_harris_foulkes_estimate',
959
+ rf'E_Harris\s*{re_float}\s*({re_float})',
960
+ dtype=float,
961
+ unit='eV',
962
+ ),
963
+ Quantity(
964
+ 'e_fermi',
965
+ rf'E_Fermi\s*{re_float}\s*({re_float})',
966
+ dtype=float,
967
+ unit='eV',
968
+ ),
969
+ Quantity(
970
+ 'e_band',
971
+ rf'E_band\s*{re_float}\s*({re_float})',
972
+ dtype=float,
973
+ unit='eV',
974
+ ),
975
+ Quantity(
976
+ 'e_one_elec',
977
+ rf'E_one_elec\s*{re_float}\s*({re_float})',
978
+ dtype=float,
979
+ unit='eV',
980
+ ),
981
+ Quantity(
982
+ 'correction_hartree',
983
+ rf'E_Hartree\s*{re_float}\s*({re_float})',
984
+ dtype=float,
985
+ unit='eV',
986
+ ),
987
+ Quantity(
988
+ 'XC_functional',
989
+ rf'E_xc\s*{re_float}\s*({re_float})',
990
+ dtype=float,
991
+ unit='eV',
992
+ ),
993
+ Quantity(
994
+ 'e_ewald',
995
+ rf'E_ewald\s*{re_float}\s*({re_float})',
996
+ dtype=float,
997
+ unit='eV',
998
+ ),
999
+ Quantity(
1000
+ 'e_demet',
1001
+ rf'E_demet\s*{re_float}\s*({re_float})',
1002
+ dtype=float,
1003
+ unit='eV',
1004
+ ),
1005
+ Quantity(
1006
+ 'e_descf',
1007
+ rf'E_descf\s*{re_float}\s*({re_float})',
1008
+ dtype=float,
1009
+ unit='eV',
1010
+ ),
1011
+ Quantity(
1012
+ 'e_efield',
1013
+ rf'E_efield\s*{re_float}\s*({re_float})',
1014
+ dtype=float,
1015
+ unit='eV',
1016
+ ),
1017
+ Quantity(
1018
+ 'hartree_fock_X_scaled',
1019
+ rf'E_exx\s*{re_float}\s*({re_float})',
1020
+ dtype=float,
1021
+ unit='eV',
1022
+ ),
1023
+ Quantity(
1024
+ 'e_vdw',
1025
+ rf'E_vdwD\d+\s*{re_float}\s*({re_float})',
1026
+ dtype=float,
1027
+ unit='eV',
1028
+ ),
1029
+ Quantity(
1030
+ 'magnetization_total',
1031
+ rf'total magnetism \(Bohr mag/cell\)\s*({re_float})\s*({re_float})\s*({re_float})',
1032
+ dtype=float,
1033
+ unit='bohr_magneton',
1034
+ ),
1035
+ Quantity(
1036
+ 'magnetization_absolute',
1037
+ rf'absolute magnetism \(Bohr mag/cell\)\s*=\s*({re_float})',
1038
+ dtype=float,
1039
+ unit='bohr_magneton',
1040
+ ),
1041
+ ]
1042
+ ),
1043
+ )
1044
+ ] + calculation_quantities
1045
+
1046
+ nscf_quantities = [
1047
+ Quantity(
1048
+ 'band_structure',
1049
+ r'(band eigenvalue in this processor \(eV\)\s*:\n[\s\S]+?\n\n\n)',
1050
+ str_operation=str_to_bandstructure,
1051
+ convert=False,
1052
+ ),
1053
+ Quantity(
1054
+ 'min_state_energy',
1055
+ rf'min state energy (eV)\s*=\s*({re_float})',
1056
+ unit='eV',
1057
+ dtype=float,
1058
+ repeats=True,
1059
+ ),
1060
+ Quantity(
1061
+ 'max_state_energy',
1062
+ rf'max state energy (eV)\s*=\s*({re_float})',
1063
+ unit='eV',
1064
+ dtype=float,
1065
+ repeats=True,
1066
+ ),
1067
+ Quantity(
1068
+ 'delta_energy',
1069
+ rf'delta energy interval (eV)\s*=\s*({re_float})',
1070
+ unit='eV',
1071
+ dtype=float,
1072
+ repeats=True,
1073
+ ),
1074
+ Quantity(
1075
+ 'nbands', rf'number of bands\s*=\s*(\d+)', dtype=int, repeats=True
1076
+ ),
1077
+ Quantity(
1078
+ 'sum_bands', rf'sum up the states\s*=\s*(\d+)', dtype=int, repeats=True
1079
+ ),
1080
+ Quantity(
1081
+ 'fermi_energy_dos',
1082
+ rf'Fermi energy (?:\(spin = \d+\)\s*|\s*)is\s*({re_float})\s*Rydberg',
1083
+ dtype=float,
1084
+ repeats=False,
1085
+ ),
1086
+ Quantity('ionic_phase', rf'The Ionic Phase:\s*({re_float})', dtype=float),
1087
+ Quantity(
1088
+ 'electronic_phase', rf'Electronic Phase:\s*({re_float})', dtype=float
1089
+ ),
1090
+ Quantity(
1091
+ 'polarization',
1092
+ r'(The calculated polarization direction is in \w+ direction[\s\S]+?C/m\^2)',
1093
+ sub_parser=TextParser(
1094
+ quantities=[
1095
+ Quantity(
1096
+ 'direction',
1097
+ r'The calculated polarization direction is in (\w+) direction',
1098
+ ),
1099
+ Quantity(
1100
+ 'P',
1101
+ rf'P\s*=\s*({re_float})\s*\(mod\s*({re_float})\)\s*\(\s*({re_float}),\s*({re_float}),\s*({re_float})\)\s*C/m\^2',
1102
+ str_operation=str_to_polarization,
1103
+ convert=False,
1104
+ ),
1105
+ ]
1106
+ ),
1107
+ ),
1108
+ ] + search_quantities
1109
+
1110
+ relax_quantities = [
1111
+ Quantity(
1112
+ 'ion_step',
1113
+ r'(?:STEP OF ION RELAXATION\s*:\s*|RELAX IONS\s*:\s*\d+\s*\(in total:\s*)(\d+)',
1114
+ dtype=int,
1115
+ ),
1116
+ Quantity(
1117
+ 'self_consistent',
1118
+ r'((?:STEP OF ION RELAXATION|RELAX IONS)\s*:\s*\d+[\s\S]+?(?:Setup the|\!FINAL_ETOT_IS))',
1119
+ repeats=False,
1120
+ sub_parser=TextParser(quantities=scf_quantities),
1121
+ ),
1122
+ ]
1123
+
1124
+ fullscf_quantities = [
1125
+ Quantity(
1126
+ 'self_consistent',
1127
+ r'([^NON]SELF-CONSISTENT[\s\S]+?\!FINAL_ETOT_IS)',
1128
+ repeats=False,
1129
+ sub_parser=TextParser(quantities=scf_quantities),
1130
+ )
1131
+ ]
1132
+
1133
+ nonscf_quantities = [
1134
+ Quantity(
1135
+ 'nonself_consistent',
1136
+ r'(NONSELF\-CONSISTENT[\s\S]+?\|CLASS_NAME)',
1137
+ repeats=False,
1138
+ sub_parser=TextParser(quantities=nscf_quantities),
1139
+ )
1140
+ ]
1141
+
1142
+ md_quantities = [
1143
+ Quantity('md_step', r'STEP OF MOLECULAR DYNAMICS\s*:\s*(\d+)', dtype=int),
1144
+ Quantity(
1145
+ 'self_consistent',
1146
+ r'(STEP OF MOLECULAR DYNAMICS\s*:\s*\d+[\s\S]+?Energy\s*Potential\s*Kinetic)',
1147
+ repeats=False,
1148
+ sub_parser=TextParser(quantities=scf_quantities),
1149
+ ),
1150
+ Quantity(
1151
+ 'energy',
1152
+ rf'Energy\s*Potential\s*Kinetic\s*Temperature\s*(?:Pressure \(KBAR\)\s*\n|\n)\s*({re_float})',
1153
+ dtype=float,
1154
+ unit='hartree',
1155
+ ),
1156
+ Quantity(
1157
+ 'potential',
1158
+ rf'Energy\s*Potential\s*Kinetic\s*Temperature\s*(?:Pressure \(KBAR\)\s*\n|\n)\s*{re_float}\s*({re_float})',
1159
+ dtype=float,
1160
+ unit='hartree',
1161
+ ),
1162
+ Quantity(
1163
+ 'electronic_kinetic_energy',
1164
+ rf'Energy\s*Potential\s*Kinetic\s*Temperature\s*(?:Pressure \(KBAR\)\s*\n|\n)\s*{re_float}\s*{re_float}\s*({re_float})',
1165
+ dtype=float,
1166
+ unit='hartree',
1167
+ ),
1168
+ Quantity(
1169
+ 'temperature',
1170
+ rf'Energy\s*Potential\s*Kinetic\s*Temperature\s*(?:Pressure \(KBAR\)\s*\n|\n)\s*{re_float}\s*{re_float}\s*{re_float}\s*({re_float})',
1171
+ dtype=float,
1172
+ unit='kelvin',
1173
+ ),
1174
+ Quantity(
1175
+ 'pressure',
1176
+ rf'Energy\s*Potential\s*Kinetic\s*Temperature\s*Pressure \(KBAR\)\s*\n\s*{re_float}\s*{re_float}\s*{re_float}\s*{re_float}\s*({re_float})',
1177
+ dtype=float,
1178
+ unit='kilobar',
1179
+ ),
1180
+ ]
1181
+
1182
+ self._quantities = [
1183
+ Quantity(
1184
+ 'program_version',
1185
+ r'Version:\s*(.*)\n',
1186
+ str_operation=lambda x: ''.join(x),
1187
+ ),
1188
+ Quantity('nproc', r'Processor Number is\s*(\d+)\n', dtype=int),
1189
+ Quantity(
1190
+ 'start_date_time',
1191
+ r'Start Time is\s*(.*)\n',
1192
+ str_operation=lambda x: ''.join(x),
1193
+ ),
1194
+ Quantity(
1195
+ 'input_filename',
1196
+ r'global_in_card\s*=\s*(.*)\n',
1197
+ ),
1198
+ Quantity(
1199
+ 'pseudopotential_dirname',
1200
+ r'pseudo_dir\s*=\s*([.\w\-\\ ]*?)',
1201
+ ),
1202
+ Quantity(
1203
+ 'basis_set_dirname',
1204
+ r'orbital_dir\s*=\s*([.\w\-\\ ]*?)',
1205
+ ),
1206
+ Quantity('drank', r'DRANK\s*=\s*(\d+)\n', dtype=int),
1207
+ Quantity('dsize', r'DSIZE\s*=\s*(\d+)\n', dtype=int),
1208
+ Quantity('dcolor', r'DCOLOR\s*=\s*(\d+)\n', dtype=int),
1209
+ Quantity('grank', r'GRANK\s*=\s*(\d+)\n', dtype=int),
1210
+ Quantity('gsize', r'GSIZE\s*=\s*(\d+)\n', dtype=int),
1211
+ Quantity(
1212
+ 'header',
1213
+ r'READING GENERAL INFORMATION([\s\S]+?)(?:[NON]*SELF-|STEP OF|RELAX CELL)',
1214
+ sub_parser=TextParser(quantities=header_quantities),
1215
+ ),
1216
+ Quantity(
1217
+ 'full_scf',
1218
+ r'([^NON]SELF-CONSISTENT[\s\S]+?)Total\s*Time',
1219
+ sub_parser=TextParser(quantities=fullscf_quantities),
1220
+ repeats=True,
1221
+ ),
1222
+ Quantity(
1223
+ 'non_scf',
1224
+ r'(NONSELF-CONSISTENT[\s\S]+?)Total\s*Time',
1225
+ sub_parser=TextParser(quantities=nonscf_quantities),
1226
+ repeats=True,
1227
+ ),
1228
+ Quantity(
1229
+ 'geometry_optimization',
1230
+ r'((STEP OF ION RELAXATION|RELAX IONS)\s*:\s*\d+[\s\S]+?(Setup the|\!FINAL_ETOT_IS))',
1231
+ sub_parser=TextParser(quantities=relax_quantities),
1232
+ repeats=True,
1233
+ ),
1234
+ Quantity(
1235
+ 'ion_converged',
1236
+ r'Ion relaxation \(is converged!\)',
1237
+ str_operation=lambda x: True,
1238
+ ),
1239
+ Quantity(
1240
+ 'force_threshold',
1241
+ rf'Ion relaxation is not converged yet \(threshold is\s*({re_float})\)',
1242
+ unit='eV/angstrom',
1243
+ repeats=False,
1244
+ ),
1245
+ Quantity(
1246
+ 'lattice_converged',
1247
+ r'Lattice relaxation \(is converged!\)',
1248
+ str_operation=lambda x: True,
1249
+ ),
1250
+ Quantity(
1251
+ 'stress_threshold',
1252
+ rf'Lattice relaxation is not converged yet \(threshold is\s*({re_float})\)',
1253
+ unit='kilobar',
1254
+ repeats=False,
1255
+ ),
1256
+ Quantity(
1257
+ 'molecular_dynamics',
1258
+ r'(STEP OF MOLECULAR DYNAMICS\s*:\s*\d+[\s\S]+?(?:\n{4,5}))',
1259
+ sub_parser=TextParser(quantities=md_quantities),
1260
+ repeats=True,
1261
+ ),
1262
+ Quantity(
1263
+ 'final_energy',
1264
+ rf'\!FINAL_ETOT_IS\s*({re_float})',
1265
+ dtype=float,
1266
+ unit='eV',
1267
+ ),
1268
+ Quantity(
1269
+ 'finish_date_time',
1270
+ r'Finish\s*Time\s*:\s*(.*)\n',
1271
+ str_operation=lambda x: ''.join(x),
1272
+ ),
1273
+ Quantity(
1274
+ 'total_time',
1275
+ rf'Total\s*Time\s*:\s*(\d+)\s*h\s*(\d+)\s*mins\s*(\d+)\s*secs',
1276
+ str_operation=lambda x: int(x.strip().split()[0]) * 3600
1277
+ + int(x.strip().split()[1]) * 60
1278
+ + int(x.strip().split()[2]),
1279
+ unit='seconds',
1280
+ ),
1281
+ ]
1282
+
1283
+
1284
+ class ABACUSParser:
1285
+ def __init__(self):
1286
+ # super().__init__(name='parsers/abacus', code_name='ABACUS',
1287
+ # code_homepage='http://abacus.ustc.edu.cn/',
1288
+ # mainfile_contents_re=(r'\s*\n\s*WELCOME TO ABACUS'))
1289
+ self.out_parser = ABACUSOutParser()
1290
+ self.input_parser = ABACUSInputParser()
1291
+ self.tdos_parser = DataTextParser()
1292
+ self.sampling_method = None
1293
+
1294
+ self._xc_map = {
1295
+ 'PWLDA': [{'name': 'LDA_C_PW'}, {'name': 'LDA_X'}],
1296
+ 'PZ': [{'name': 'LDA_C_PZ'}, {'name': 'LDA_X'}],
1297
+ 'LDA': [{'name': 'LDA_C_PZ'}, {'name': 'LDA_X'}],
1298
+ 'BLYP': [{'name': 'GGA_C_LYP'}, {'name': 'GGA_X_B88'}],
1299
+ 'BP': [{'name': 'GGA_C_P86'}, {'name': 'GGA_X_B88'}],
1300
+ 'PBE': [{'name': 'GGA_C_PBE'}, {'name': 'GGA_X_PBE'}],
1301
+ 'RPBE': [{'name': 'GGA_C_PBE'}, {'name': 'GGA_X_RPBE'}],
1302
+ 'WC': [{'name': 'GGA_C_PBE'}, {'name': 'GGA_X_WC'}],
1303
+ 'PW91': [{'name': 'GGA_C_PW91'}, {'name': 'GGA_X_PW91'}],
1304
+ 'HCTH': [{'name': 'GGA_C_HCTH_A'}, {'name': 'GGA_X_HCTH_A'}],
1305
+ 'OLYP': [{'name': 'GGA_C_LYP'}, {'name': 'GGA_X_OPTX'}],
1306
+ 'REVPBE': [{'name': 'GGA_C_PBE'}, {'name': 'GGA_X_PBE_R'}],
1307
+ 'SCAN': [{'name': 'MGGA_C_SCAN'}, {'name': 'MGGA_X_SCAN'}],
1308
+ 'HF': [{'name': 'HF_X'}],
1309
+ 'HSE': [{'name': 'HYB_GGA_XC_HSE06'}],
1310
+ 'PBE0': [
1311
+ {'name': 'GGA_C_PBE'},
1312
+ {
1313
+ 'name': 'GGA_X_PBE',
1314
+ 'weight': lambda x: 0.75 if x is None else 1.0 - x,
1315
+ },
1316
+ {'name': 'HF_X', 'weight': lambda x: 0.25 if x is None else x},
1317
+ ],
1318
+ }
1319
+
1320
+ def parse_configurations(self):
1321
+ sec_run = self.archive.run[-1]
1322
+ header = self.out_parser.get('header', {})
1323
+ nspin_ori = header.get('number_of_spin_channels')
1324
+ nspin = 1 if nspin_ori == 4 else nspin_ori
1325
+ nbands = header.get('nbands')
1326
+
1327
+ def parse_bandstructure(section):
1328
+ sec_scc = Calculation()
1329
+ sec_run.calculation.append(sec_scc)
1330
+ sec_nscf = section.get('nonself_consistent')
1331
+
1332
+ # atom data
1333
+ parse_system()
1334
+
1335
+ # search adjacent atoms
1336
+ searching_sec = sec_nscf.get('search_adjacent_atoms')
1337
+ if searching_sec is not None:
1338
+ for key in [
1339
+ 'longest_orb_rcut',
1340
+ 'longest_nonlocal_projector_rcut',
1341
+ 'searching_radius',
1342
+ 'searching_radius_unit',
1343
+ ]:
1344
+ val = searching_sec.get(key)
1345
+ if val:
1346
+ setattr(sec_scc, f'x_abacus_{key}', val)
1347
+
1348
+ # grid_integration
1349
+ grid_sec = sec_nscf.get('grid_integration')
1350
+ if grid_sec is not None:
1351
+ for key in [
1352
+ 'read_space_grid',
1353
+ 'big_cell_numbers_in_grid',
1354
+ 'meshcell_numbers_in_big_cell',
1355
+ 'extended_fft_grid',
1356
+ 'extended_fft_grid_dim',
1357
+ ]:
1358
+ val = grid_sec.get(key)
1359
+ if val is not None:
1360
+ setattr(sec_scc, f'x_abacus_{key}', val)
1361
+
1362
+ sec_k_band = BandStructure()
1363
+ sec_scc.band_structure_electronic.append(sec_k_band)
1364
+ sec_k_band.reciprocal_cell = sec_run.system[-1].x_abacus_reciprocal_vectors
1365
+
1366
+ # get efermi
1367
+ efermi = header.get('fermi_energy_in')
1368
+ if efermi is None:
1369
+ efermi = [sec_nscf.get('fermi_energy_dos')]
1370
+ if efermi is not None:
1371
+ # fermi energy is not spin-dependent
1372
+ sec_k_band.energy_fermi = efermi[0] * ureg.rydberg
1373
+
1374
+ band_k_points = []
1375
+ band_energies = []
1376
+ for slabel, data in sec_nscf.get('band_structure').items():
1377
+ for state in data:
1378
+ if slabel == 'up':
1379
+ band_k_points.append(state.kpoint.tolist())
1380
+ band_energies.append(state.energies.tolist())
1381
+ sec_k_band_segment = BandEnergies()
1382
+ sec_k_band.segment.append(sec_k_band_segment)
1383
+ sec_k_band_segment.kpoints = np.dot(
1384
+ np.linalg.inv(header.get('reciprocal_vectors')),
1385
+ np.array(band_k_points).T,
1386
+ ).T
1387
+ sec_k_band_segment.energies = (
1388
+ np.reshape(band_energies, (nspin, -1, nbands)) * ureg.eV
1389
+ )
1390
+
1391
+ def parse_dos():
1392
+ sec_scc = sec_run.calculation[-1]
1393
+
1394
+ # parse TDOS file
1395
+ tdos_file = 'TDOS'
1396
+ if tdos_file not in os.listdir(self.out_parser.maindir):
1397
+ return
1398
+ self.tdos_parser.mainfile = os.path.join(self.out_parser.maindir, tdos_file)
1399
+ data = self.tdos_parser.data
1400
+ if data is None:
1401
+ return
1402
+ data = data.T
1403
+ n_spin_channels = len(data[1:])
1404
+ for spin in range(n_spin_channels):
1405
+ sec_dos = Dos()
1406
+ sec_scc.dos_electronic.append(sec_dos)
1407
+ sec_dos.spin_channel = spin if n_spin_channels == 2 else None
1408
+ sec_dos.n_energies = len(data[0])
1409
+ sec_dos.energies = data[0] * ureg.eV
1410
+ sec_dos_total = DosValues()
1411
+ sec_dos.total.append(sec_dos_total)
1412
+ sec_dos_total.value = data[spin + 1] / ureg.eV
1413
+ # TODO: parse PDOS file
1414
+
1415
+ def parse_scf(iteration):
1416
+ sec_scc = sec_run.calculation[-1]
1417
+ sec_scf = ScfIteration()
1418
+ sec_scc.scf_iteration.append(sec_scf)
1419
+
1420
+ density_errors = iteration.get('density_error')
1421
+ sec_scf.x_abacus_density_change_scf_iteration = density_errors
1422
+
1423
+ # energies
1424
+ sec_scf.x_abacus_energy_total_harris_foulkes_estimate = (
1425
+ iteration.x_abacus_energy_total_harris_foulkes_estimate
1426
+ )
1427
+ sec_scf.energy = Energy(
1428
+ total=EnergyEntry(value=iteration.energy_total_scf_iteration)
1429
+ )
1430
+ if iteration.e_fermi is not None:
1431
+ sec_scf.energy.fermi = iteration.e_fermi
1432
+
1433
+ # magnetization
1434
+ for key in ['magnetization_total', 'magnetization_absolute']:
1435
+ val = iteration.get(key)
1436
+ if val is None:
1437
+ continue
1438
+ setattr(sec_scf, f'x_abacus_{key}', val)
1439
+
1440
+ def parse_system():
1441
+ sec_system = System()
1442
+ sec_run.system.append(sec_system)
1443
+ structure = header.get('positions')
1444
+
1445
+ # structure
1446
+ alat = header.get('alat')
1447
+ sec_system.x_abacus_alat = alat # bohr
1448
+ sec_atoms = Atoms()
1449
+ sec_system.atoms = sec_atoms
1450
+ lattice_vectors = header.get('lattice_vectors') * alat
1451
+ sec_atoms.lattice_vectors = lattice_vectors
1452
+
1453
+ labels, positions, mags, velocities = [], [], [], []
1454
+ sec_run.x_abacus_init_velocities = self.input_parser.get(
1455
+ 'x_abacus_init_velocities', 0
1456
+ )
1457
+ for site in structure.get('sites', []):
1458
+ labels.append(site['labels'])
1459
+ positions.append(site['positions'])
1460
+ mags.append(site['magnetic_moments'])
1461
+ if sec_run.x_abacus_init_velocities:
1462
+ velocities.append(site['velocities'])
1463
+
1464
+ coord_class = structure.get('coord_class')
1465
+ if coord_class == 'cartesian':
1466
+ units = structure.get('units')
1467
+ sec_atoms.positions = np.array(positions) * units
1468
+ elif coord_class == 'direct':
1469
+ sec_atoms.positions = np.array(positions) @ lattice_vectors
1470
+ sec_atoms.labels = labels
1471
+ if velocities:
1472
+ sec_atoms.velocities = velocities * ureg.angstrom / ureg.fs
1473
+ sec_system.x_abacus_atom_magnetic_moments = mags
1474
+ sec_system.x_abacus_cell_volume = header.get('cell_volume')
1475
+ sec_system.x_abacus_reciprocal_vectors = (
1476
+ header.get('reciprocal_vectors') * 2 * np.pi / alat
1477
+ )
1478
+
1479
+ # symmetry
1480
+ symmetry = header.get('symmetry')
1481
+ if symmetry:
1482
+ sec_system_sym = Symmetry()
1483
+ sec_system.symmetry.append(sec_system_sym)
1484
+ sec_system_sym.crystal_system = symmetry.get('bravais_name')[1].lower()
1485
+ brav_dict = {
1486
+ 'triclinic': 'a',
1487
+ 'monoclinic': 'b',
1488
+ 'orthorhombic': 'o',
1489
+ 'tetragonal': 't',
1490
+ 'hexagonal': 'h',
1491
+ 'cubic': 'c',
1492
+ 'rhombohedral': 'R',
1493
+ }
1494
+ ibrav = symmetry.get('ibrav')
1495
+ if ibrav:
1496
+ sec_system.x_abacus_ibrav = ibrav
1497
+ if ibrav in [4, 14]:
1498
+ sec_system_sym.bravais_lattice = brav_dict[
1499
+ sec_system_sym.crystal_system
1500
+ ]
1501
+ else:
1502
+ sec_system_sym.bravais_lattice = (
1503
+ brav_dict[sec_system_sym.crystal_system]
1504
+ + symmetry.get('bravais_name')[2][0]
1505
+ )
1506
+ sec_system_sym.x_abacus_point_group_schoenflies_name = symmetry.get(
1507
+ 'point_group'
1508
+ )
1509
+ celldm = [
1510
+ symmetry.get(f'norm_{key}') * alat.to('angstrom').magnitude
1511
+ for key in ['a', 'b', 'c']
1512
+ ]
1513
+ celldm.extend([symmetry.get(key) for key in ['alpha', 'beta', 'gamma']])
1514
+ sec_system.x_abacus_celldm = celldm
1515
+ for name in [
1516
+ 'rotation_matrices',
1517
+ 'point_group_operations',
1518
+ 'space_group_operations',
1519
+ ]:
1520
+ val = symmetry.get(f'number_of_{name}')
1521
+ setattr(sec_system_sym, f'x_abacus_number_of_{name}', val)
1522
+
1523
+ # numbers
1524
+ sec_atoms.n_atoms = header.get('number_of_atoms')
1525
+ sec_system.x_abacus_number_of_species = header.number_of_species
1526
+ sec_system.x_abacus_number_of_electrons_out = header.number_of_electrons_out
1527
+ sec_system.number_of_electrons_out = self.input_parser.get('nelec')
1528
+
1529
+ def parse_section(section):
1530
+ sec_scc = Calculation()
1531
+ sec_run.calculation.append(sec_scc)
1532
+
1533
+ # atom data
1534
+ parse_system()
1535
+
1536
+ sub_section = section.get('self_consistent')
1537
+ if sub_section is None:
1538
+ return
1539
+
1540
+ # search adjacent atoms
1541
+ searching_sec = sub_section.get('search_adjacent_atoms')
1542
+ if searching_sec is not None:
1543
+ for key in [
1544
+ 'longest_orb_rcut',
1545
+ 'longest_nonlocal_projector_rcut',
1546
+ 'searching_radius',
1547
+ 'searching_radius_unit',
1548
+ ]:
1549
+ val = searching_sec.get(key)
1550
+ if val:
1551
+ setattr(sec_scc, f'x_abacus_{key}', val)
1552
+
1553
+ # grid_integration
1554
+ grid_sec = sub_section.get('grid_integration')
1555
+ if grid_sec is not None:
1556
+ for key in [
1557
+ 'read_space_grid',
1558
+ 'big_cell_numbers_in_grid',
1559
+ 'meshcell_numbers_in_big_cell',
1560
+ 'extended_fft_grid',
1561
+ 'extended_fft_grid_dim',
1562
+ ]:
1563
+ val = grid_sec.get(key)
1564
+ if val is not None:
1565
+ setattr(sec_scc, f'x_abacus_{key}', val)
1566
+
1567
+ # energies
1568
+ sec_energy = Energy()
1569
+ sec_scc.energy = sec_energy
1570
+ vdw_m_dict = {'d2': 'DFT-D2', 'd3_0': 'DFT-D3(0)', 'd3_bj': 'DFT-D3(BJ)'}
1571
+ # TODO AN: I do not quite understand this loop over scf_iterations
1572
+ # and the loop over iteration
1573
+ scf_iteration = sub_section.get('iteration')
1574
+ if scf_iteration is not None:
1575
+ sec_scc.n_scf_iterations = len(scf_iteration)
1576
+ for iteration in scf_iteration:
1577
+ parse_scf(iteration)
1578
+ e_vdw = iteration.get('e_vdw', None)
1579
+ if e_vdw is not None:
1580
+ sec_energy.van_der_walls = EnergyEntry(value=e_vdw)
1581
+ vdw_method = self.input_parser.get(
1582
+ 'x_abacus_dispersion_correction_method'
1583
+ )
1584
+ # TODO AN these methods are not in the enumerated list
1585
+ if vdw_method in ['d2', 'd3_0', 'd3_bj']:
1586
+ kind = 'G06'
1587
+ sec_run.method[
1588
+ -1
1589
+ ].x_abacus_dispersion_correction_method = vdw_m_dict[vdw_method]
1590
+ else:
1591
+ kind = ''
1592
+ sec_run.method[-1].electronic.van_der_waals_method = kind
1593
+ sec_energy.xc = EnergyEntry(value=iteration.get('XC_functional'))
1594
+ sec_energy.electrostatic = EnergyEntry(
1595
+ correction=iteration.get('correction_hartree')
1596
+ )
1597
+ sec_energy.hartree_fock_x_scaled = EnergyEntry(
1598
+ value=iteration.get('hartree_fock_X_scaled')
1599
+ )
1600
+
1601
+ sec_energy.total = EnergyEntry(value=sub_section.get('total'))
1602
+ sec_energy.fermi = sub_section.get('reference_fermi')
1603
+
1604
+ # eigenvalues
1605
+ eigenvalues = sub_section.get('energy_occupation')
1606
+ if eigenvalues is not None:
1607
+ kpoints, npws, eigs, eig, occs, occ = [], [], [], [], [], []
1608
+ sec_eigenvalues = BandEnergies()
1609
+ sec_scc.eigenvalues.append(sec_eigenvalues)
1610
+ for s_label, data in eigenvalues.items():
1611
+ for state in data:
1612
+ if s_label == 'up':
1613
+ kpoints.append(state.kpoint)
1614
+ npws.append(state.npws)
1615
+ eig.append(state.energies)
1616
+ occ.append(state.occupations)
1617
+ eigs.append(eig)
1618
+ occs.append(occ)
1619
+ sec_eigenvalues.energies = np.array(eigs) * ureg.eV
1620
+ sec_eigenvalues.occupations = np.array(occs)
1621
+ sec_eigenvalues.x_abacus_eigenvalues_number_of_planewaves = np.array(
1622
+ npws
1623
+ )
1624
+ # kpoints in direct coordinates
1625
+ sec_eigenvalues.kpoints = np.dot(
1626
+ np.linalg.inv(header.get('reciprocal_vectors')), np.array(kpoints).T
1627
+ ).T
1628
+
1629
+ # force
1630
+ forces = sub_section.get('forces')
1631
+ if forces is not None:
1632
+ sec_scc.forces = Forces(total=ForcesEntry(value=forces))
1633
+
1634
+ # stress and pressure
1635
+ stress = sub_section.get('stress')
1636
+ pressure = sub_section.get('pressure')
1637
+ if stress is not None:
1638
+ sec_scc.stress = Stress(total=StressEntry(value=stress))
1639
+ if pressure is not None:
1640
+ sec_scc.pressure = pressure
1641
+
1642
+ # md settings
1643
+ electronic_kinetic_energy = section.get('electronic_kinetic_energy')
1644
+ if electronic_kinetic_energy is not None:
1645
+ sec_energy.electronic = EnergyEntry(kinetic=electronic_kinetic_energy)
1646
+ temperature = section.get('temperature')
1647
+ if temperature is not None:
1648
+ sec_scc.temperature = temperature
1649
+ pressure = section.get('pressure')
1650
+ if pressure is not None:
1651
+ sec_scc.pressure = pressure
1652
+ total_energy = section.get('energy')
1653
+ if total_energy is not None:
1654
+ sec_energy.total = EnergyEntry(value=total_energy)
1655
+
1656
+ # scf
1657
+ for section in self.out_parser.get('full_scf', []):
1658
+ parse_section(section)
1659
+
1660
+ # relax/cell-relax/md
1661
+ for method in ['geometry_optimization', 'molecular_dynamics']:
1662
+ sections = self.out_parser.get(method)
1663
+ if sections is not None:
1664
+ self.sampling_method = method
1665
+ for section in sections:
1666
+ parse_section(section)
1667
+ md_nstep_in = self.input_parser.get('md_nstep')
1668
+ if md_nstep_in is not None:
1669
+ sec_run.x_abacus_md_nstep_in = md_nstep_in
1670
+ md_nstep_out = sections[-1].get('md_step')
1671
+ if md_nstep_out is not None:
1672
+ sec_run.x_abacus_md_nstep_out = md_nstep_out + 1
1673
+
1674
+ # nscf
1675
+ for section in self.out_parser.get('non_scf', []):
1676
+ parse_bandstructure(section)
1677
+
1678
+ if self.sampling_method is None:
1679
+ self.sampling_method = 'single_point'
1680
+
1681
+ parse_dos()
1682
+
1683
+ # total time
1684
+ sec_run.x_abacus_program_execution_time = self.out_parser.get('total_time')
1685
+
1686
+ def parse_method(self):
1687
+ sec_run = self.archive.run[-1]
1688
+ sec_method = Method()
1689
+ sec_run.method.append(sec_method)
1690
+ sec_electronic = Electronic()
1691
+ sec_method.electronic = sec_electronic
1692
+ header = self.out_parser.get('header', {})
1693
+
1694
+ # input parameters from INPUT file
1695
+ input_file = 'INPUT'
1696
+ if input_file in os.listdir(self.out_parser.maindir):
1697
+ self.input_parser.mainfile = os.path.join(
1698
+ self.out_parser.maindir, input_file
1699
+ )
1700
+ sec_method.scf = Scf(n_max_iteration=self.input_parser.get('scf_max_iteration'))
1701
+ input_names = [
1702
+ 'scf_threshold_density',
1703
+ 'mixing_method',
1704
+ 'mixing_beta',
1705
+ 'gamma_algorithms',
1706
+ 'diagonalization_algorithm',
1707
+ 'initial_magnetization_total',
1708
+ 'dispersion_correction_method',
1709
+ 'exx_ccp_rmesh_times',
1710
+ 'exx_dm_threshold',
1711
+ 'exx_cauchy_threshold',
1712
+ 'exx_schwarz_threshold',
1713
+ 'exx_c_threshold',
1714
+ 'exx_v_threshold',
1715
+ 'exx_pca_threshold',
1716
+ ]
1717
+ for key in input_names:
1718
+ val = self.input_parser.get(f'x_abacus_{key}')
1719
+ if val is None:
1720
+ continue
1721
+ sec_method.m_set(sec_method.m_def.all_quantities[f'x_abacus_{key}'], val)
1722
+
1723
+ # kmesh
1724
+ sec_kmesh = KMesh()
1725
+ sec_method.k_mesh = sec_kmesh
1726
+ nkstot = header.get('nkstot')
1727
+ nkstot_ibz = header.get('nkstot_ibz')
1728
+ sec_kmesh.n_points = nkstot_ibz if nkstot_ibz is not None else nkstot
1729
+ sec_kmesh.generation_method = header.get('ksampling_method')
1730
+ sec_kmesh.points, sec_kmesh.weights = header.get('k_points')
1731
+
1732
+ # smearing
1733
+ occupations = self.input_parser.get('occupations', 'smearing')
1734
+ smearing_kind = None
1735
+ if occupations == 'tetrahedra':
1736
+ smearing_kind = occupations
1737
+ elif occupations == 'fixed':
1738
+ smearing_kind = 'empty'
1739
+ else:
1740
+ smearing_method = self.input_parser.get('smearing_method', 'fixed')
1741
+ if smearing_method == 'mp':
1742
+ smearing_kind = 'methfessel-paxton'
1743
+ elif smearing_method in ['gauss', 'gaussian']:
1744
+ smearing_kind = 'gaussian'
1745
+ else:
1746
+ smearing_kind = 'empty'
1747
+ smearing_width = self.input_parser.get('smearing_width')
1748
+ if smearing_width is not None:
1749
+ smearing_width = smearing_width.to('joule').magnitude
1750
+ sec_electronic.smearing = Smearing(kind=smearing_kind, width=smearing_width)
1751
+
1752
+ sec_method.x_abacus_basis_type = self.input_parser.get('basis_type', 'pw')
1753
+
1754
+ # basis set settings
1755
+ ems = []
1756
+ for name in ['wavefunction', 'density']:
1757
+ orbital_settings = header.get('orbital_settings')
1758
+ bs = BasisSet(
1759
+ type='plane waves',
1760
+ scope=['valence'],
1761
+ cutoff=header.get(
1762
+ f'{name}_cutoff'
1763
+ ), # http://abacus.deepmodeling.com/en/latest/advanced/input_files/input-main.html#ecutwfc
1764
+ )
1765
+ if orbital_settings:
1766
+ bs.type = 'numeric AOs'
1767
+ for key in ['delta_k', 'delta_r', 'dr_uniform', 'rmax', 'kmesh']:
1768
+ val = orbital_settings.get(key)
1769
+ setattr(bs, f'x_abacus_basis_sets_{key}', val)
1770
+ for i, orb in enumerate(
1771
+ orbital_settings.get('orbital_information', [])
1772
+ ):
1773
+ sec_specie_basis_set = x_abacus_section_specie_basis_set()
1774
+ bs.x_abacus_section_specie_basis_set.append(sec_specie_basis_set)
1775
+ sec_specie_basis_set.x_abacus_specie_basis_set_filename = (
1776
+ os.path.basename(header.get('orbital_files')[i])
1777
+ )
1778
+ ln_list = []
1779
+ for data in orb:
1780
+ ln_list.append([data.l, data.n])
1781
+ sec_specie_basis_set.x_abacus_specie_basis_set_ln = ln_list
1782
+ sec_specie_basis_set.x_abacus_specie_basis_set_rcutoff = data.rcut
1783
+ sec_specie_basis_set.x_abacus_specie_basis_set_rmesh = data.nr
1784
+ sec_specie_basis_set.x_abacus_specie_basis_set_number_of_orbitals = len(
1785
+ ln_list
1786
+ )
1787
+ ems.append(BasisSetContainer(scope=[name], basis_set=[bs]))
1788
+ sec_method.electrons_representation = ems
1789
+
1790
+ if self.input_parser.get('dft_plus_u'):
1791
+ sec_electronic.method = 'DFT+U'
1792
+ else:
1793
+ sec_electronic.method = 'DFT'
1794
+
1795
+ # spin mode
1796
+ nspin_ori = header.get('number_of_spin_channels')
1797
+ nspin = 1 if nspin_ori == 4 else nspin_ori
1798
+ sec_electronic.n_spin_channels = nspin
1799
+ sec_method.x_abacus_spin_orbit = nspin_ori == 4
1800
+ sec_method.x_abacus_noncollinear = bool(
1801
+ header.get('atom_data')[-1]
1802
+ .get('noncollinear_magnetization', np.array([]))
1803
+ .any()
1804
+ )
1805
+ # TODO NOMAD metainfo does not include full
1806
+ sec_electronic.relativity_method = (
1807
+ None if nspin_ori == 4 else 'scalar_relativistic'
1808
+ )
1809
+
1810
+ # atom_kind and pseudopotential settings
1811
+ pp_xc = ''
1812
+ for i, pp in enumerate(header.get('pseudopotential', [])):
1813
+ sec_atom_parameters = AtomParameters()
1814
+ sec_method.atom_parameters.append(sec_atom_parameters)
1815
+ sec_atom_parameters.label = header.get('atom_data')[i].get('label')
1816
+ sec_atom_parameters.n_valence_electrons = pp.get('valence')
1817
+ sec_atom_parameters.pseudopotential_name = os.path.basename(
1818
+ pp.get('filename', '')
1819
+ )
1820
+ sec_method.x_abacus_pao_radial_cutoff = header.get(
1821
+ 'x_abacus_pao_radial_cutoff'
1822
+ )
1823
+ for key, val in pp.items():
1824
+ if key in ['filename', 'valence'] or val is None:
1825
+ continue
1826
+ if key == 'xc':
1827
+ pp_xc = pp.get('xc', None)
1828
+ setattr(sec_atom_parameters, f'x_abacus_pp_{key}', val)
1829
+
1830
+ # xc functional from output
1831
+ xc_in = self.input_parser.get('xc', None)
1832
+ xc = xc_in.upper() if xc_in is not None else pp_xc
1833
+ if xc is not None:
1834
+ sec_dft = DFT()
1835
+ sec_method.dft = sec_dft
1836
+ sec_xc_func = XCFunctional()
1837
+ sec_dft.xc_functional = sec_xc_func
1838
+ sec_method.x_abacus_xc_functional = xc
1839
+
1840
+ # hybrid func
1841
+ hse_omega, hybrid_coeff = None, None
1842
+ if xc in ['HYB_GGA_XC_HSE06', 'HSE']:
1843
+ hse_omega = self.input_parser.get(
1844
+ 'x_abacus_hse_omega', (0.11 / ureg.bohr).to('1/m')
1845
+ )
1846
+ if hse_omega is not None:
1847
+ sec_method.x_abacus_hse_omega = hse_omega.magnitude
1848
+ if xc in ['HYB_GGA_XC_HSE06', 'HSE', 'PBE0']:
1849
+ hybrid_coeff = self.input_parser.get('x_abacus_hybrid_xc_coeff', 0.25)
1850
+ if hybrid_coeff is not None:
1851
+ sec_method.x_abacus_hybrid_xc_coeff = hybrid_coeff
1852
+
1853
+ if 'LDA_' in xc or 'GGA_' in xc or 'HF_' in xc or 'HYB_' in xc:
1854
+ xc_meta_list = []
1855
+ for xc_i in xc.split('+'):
1856
+ xc_meta_list.append({'name': xc_i})
1857
+ else:
1858
+ xc_meta_list = self._xc_map.get(xc, [])
1859
+ for xc_meta in xc_meta_list:
1860
+ xc_func = Functional(name=xc_meta.get('name'))
1861
+ if '_X_' in xc_func.name or xc_func.name.endswith('_X'):
1862
+ sec_xc_func.exchange.append(xc_func)
1863
+ elif '_C_' in xc_func.name or xc_func.name.endswith('_C'):
1864
+ sec_xc_func.correlation.append(xc_func)
1865
+ elif 'HYB' in xc_func.name:
1866
+ sec_xc_func.hybrid.append(xc_func)
1867
+ else:
1868
+ sec_xc_func.contributions.append(xc_func)
1869
+ weight = xc_meta.get('weight', None)
1870
+ if weight is not None and hybrid_coeff is not None:
1871
+ xc_func.weight = weight(float(hybrid_coeff))
1872
+ xc_parameters = dict()
1873
+ if hse_omega is not None:
1874
+ hybrid_coeff = 0.25 if hybrid_coeff is None else hybrid_coeff
1875
+ xc_parameters.setdefault(
1876
+ '$\\omega$ in m^-1', hse_omega.to('1/m').magnitude
1877
+ )
1878
+ if hybrid_coeff is not None:
1879
+ xc_parameters.setdefault(
1880
+ 'hybrid coefficient $\\alpha$', hybrid_coeff
1881
+ )
1882
+ if xc_parameters:
1883
+ xc_func.parameters = xc_parameters
1884
+
1885
+ def init_parser(self):
1886
+ self.out_parser.mainfile = self.filepath
1887
+ self.out_parser.logger = self.logger
1888
+ self.input_parser.logger = self.logger
1889
+ self.tdos_parser.logger = self.logger
1890
+
1891
+ def parse(self, filepath, archive, logger):
1892
+ self.filepath = os.path.abspath(filepath)
1893
+ self.archive = archive
1894
+ self.logger = logger if logger is not None else logging
1895
+
1896
+ self.init_parser()
1897
+
1898
+ sec_run = Run()
1899
+ archive.run.append(sec_run)
1900
+ sec_run.program = Program(
1901
+ name='ABACUS', version=self.out_parser.get('program_version')
1902
+ )
1903
+ header = self.out_parser.get('header', {})
1904
+
1905
+ # parallel
1906
+ sec_parallel = x_abacus_section_parallel()
1907
+ sec_run.x_abacus_section_parallel.append(sec_parallel)
1908
+ sec_parallel.x_abacus_nproc = self.out_parser.get('nproc')
1909
+ for key in ['kpar', 'bndpar', 'diago_proc']:
1910
+ val = self.input_parser.get(key)
1911
+ if val is not None:
1912
+ setattr(sec_parallel, f'x_abacus_{key}', val)
1913
+ for key in ['method', 'nb2d', 'trace_loc_row', 'trace_loc_col', 'nloc']:
1914
+ allocation_method = header.get('allocation_method')
1915
+ if allocation_method is not None:
1916
+ val = allocation_method.get(key)
1917
+ if val is not None:
1918
+ setattr(sec_parallel, f'x_abacus_allocation_{key}', val)
1919
+
1920
+ # input files
1921
+ self.parse_method()
1922
+ self.parse_configurations()
1923
+ sec_run.x_abacus_stru_filename = self.input_parser.get('stru_filename', 'STRU')
1924
+ sec_run.x_abacus_kpt_filename = self.input_parser.get('kpt_filename', 'KPT')
1925
+ sec_run.x_abacus_input_filename = self.out_parser.get('input_filename')
1926
+ for key in ['basis_set_dirname', 'pseudopotential_dirname']:
1927
+ val = self.out_parser.get(key)
1928
+ if val is not None:
1929
+ setattr(sec_run, f'x_abacus_{key}', val)
1930
+
1931
+ # sampling method
1932
+ if self.sampling_method is not None:
1933
+ workflow = None
1934
+ if self.sampling_method == 'molecular_dynamics':
1935
+ workflow = MolecularDynamics(method=MolecularDynamicsMethod())
1936
+ md_type = self.input_parser.get('md_type')
1937
+ if md_type == 0:
1938
+ workflow.method.thermodynamic_ensemble = 'NVE'
1939
+ elif md_type in [1, 2, 3]:
1940
+ workflow.method.thermodynamic_ensemble = 'NVT'
1941
+ elif self.sampling_method == 'geometry_optimization':
1942
+ workflow = GeometryOptimization(method=GeometryOptimizationMethod())
1943
+ force_threshold = self.out_parser.get('force_threshold')
1944
+ stress_threshold = self.out_parser.get('stress_threshold')
1945
+ if force_threshold:
1946
+ workflow.method.convergence_tolerance_force_maximum = (
1947
+ force_threshold.to('newton').magnitude
1948
+ )
1949
+ if stress_threshold:
1950
+ workflow.method.convergence_tolerance_stress_maximum = (
1951
+ stress_threshold.to('pascal').magnitude
1952
+ )
1953
+ elif self.sampling_method == 'single_point':
1954
+ workflow = SinglePoint(method=SinglePointMethod())
1955
+ workflow.method.method = archive.run[-1].method[-1].electronic.method
1956
+ archive.workflow2 = workflow
1957
+
1958
+ # start date
1959
+ date_time = self.out_parser.get('start_date_time')
1960
+ sec_time = TimeRun()
1961
+ sec_run.time_run = sec_time
1962
+ if date_time is not None:
1963
+ date_time = datetime.strptime(
1964
+ date_time.replace(' ', ''), '%a%b%d%H:%M:%S%Y'
1965
+ )
1966
+ sec_time.date_start = (date_time - datetime(1970, 1, 1)).total_seconds()
1967
+
1968
+ # end date
1969
+ date_time = self.out_parser.get('finish_date_time')
1970
+ if date_time is not None:
1971
+ date_time = datetime.strptime(
1972
+ date_time.replace(' ', ''), '%a%b%d%H:%M:%S%Y'
1973
+ )
1974
+ sec_time.date_end = (date_time - datetime(1970, 1, 1)).total_seconds()
1975
+ sec_run.clean_end = True