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,1585 @@
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 os
20
+ import numpy as np
21
+ import logging
22
+ import re
23
+ from datetime import datetime
24
+ from ase.data import atomic_numbers
25
+
26
+ from nomad.units import ureg
27
+ from nomad.parsing.file_parser import TextParser, Quantity, FileParser
28
+ from runschema.run import Run, Program, TimeRun
29
+ from runschema.method import (
30
+ AtomParameters,
31
+ Functional,
32
+ Method,
33
+ Electronic,
34
+ BasisSet,
35
+ BasisSetAtomCentered,
36
+ Smearing,
37
+ XCFunctional,
38
+ DFT,
39
+ BasisSetContainer,
40
+ )
41
+ from runschema.system import System, Atoms
42
+ from runschema.calculation import (
43
+ Calculation,
44
+ Energy,
45
+ EnergyEntry,
46
+ Forces,
47
+ ForcesEntry,
48
+ Thermodynamics,
49
+ BandEnergies,
50
+ ScfIteration,
51
+ )
52
+ from simulationworkflowschema import GeometryOptimization, GeometryOptimizationMethod
53
+
54
+ from .metainfo import turbomole # pylint: disable=unused-import
55
+
56
+
57
+ MOL = 6.02214076e23
58
+
59
+
60
+ class AuxiliaryOutParser(FileParser):
61
+ def __init__(self, re_line, start):
62
+ super().__init__()
63
+ self._re_line = re.compile(re_line)
64
+ self._start = start
65
+
66
+ @property
67
+ def matrix(self):
68
+ if self._file_handler is None:
69
+ self._file_handler = []
70
+ with open(self.mainfile) as f:
71
+ while True:
72
+ line = f.readline()
73
+ if not line:
74
+ break
75
+ line = self._re_line.match(line)
76
+ if not line:
77
+ continue
78
+ value = line.group(1).split()
79
+ if int(value[0]) > len(self._file_handler):
80
+ self._file_handler.append([])
81
+ self._file_handler[-1].extend(value[self._start :])
82
+ return self._file_handler
83
+
84
+ def parse(self, key=None):
85
+ pass
86
+
87
+
88
+ class EigenvaluesParser(TextParser):
89
+ def __init__(self):
90
+ super().__init__()
91
+
92
+ def init_quantities(self):
93
+ self._quantities = [
94
+ Quantity('irrep', r'irrep\s*([\w ]+\n)'),
95
+ Quantity(
96
+ 'eigenvalues',
97
+ r'eigenvalues H\s*([\d\.\-\+EeDd ]+)\n',
98
+ dtype=float,
99
+ repeats=True,
100
+ str_operation=lambda x: x.replace('D', 'E').replace('E', 'e').split(),
101
+ ),
102
+ Quantity(
103
+ 'occupation', r'occupation\s*([\d\.\- ]*\n)', dtype=float, repeats=True
104
+ ),
105
+ ]
106
+
107
+
108
+ class ControlParser(TextParser):
109
+ def __init__(self):
110
+ super().__init__()
111
+
112
+ def init_quantities(self):
113
+ def str_to_drvopt(val_in):
114
+ val = [v.split() for v in val_in.strip().split('\n')]
115
+ return {v[0].strip(): v[1] for v in val}
116
+
117
+ # TODO add more quantities
118
+ self._quantities = [
119
+ Quantity('operating_system', r'operating system\s*(\S+)'),
120
+ Quantity('scf_iter_limit', r'scfiterlimit\s*(\S+)'),
121
+ Quantity('scf_conv', r'scfconv\s*(\S+)'),
122
+ Quantity('time_for_integral_calc', r'thime\s*(\S+)'),
123
+ Quantity('pople_kind', r'pople\s*(\S+)'),
124
+ Quantity(
125
+ 'damping_parameter',
126
+ r'scfdamp\s*start=\s*(\S+)\s*step=\s*(\S+)\s*min=\s*(\S+)',
127
+ ),
128
+ Quantity('scfint', r'unit=\s*(\S+)\s*size=\s*(\S+)\s*file=\s*(\S+)\s*'),
129
+ Quantity('interconversion_status', r'interconversion\s*(\S+)'),
130
+ Quantity(
131
+ 'drvopt', r'drvopt\s*([\s\S]+?)\n *\$', str_operation=str_to_drvopt
132
+ ),
133
+ ]
134
+
135
+
136
+ class OutParser(TextParser):
137
+ def __init__(self):
138
+ super().__init__()
139
+
140
+ def init_quantities(self):
141
+ re_float = r'[\d\.\-\+eEDd]+'
142
+
143
+ def str_to_atomic_info(val_in):
144
+ vals = [v.split() for v in val_in.strip().split('\n')]
145
+ # first two are 'atomic', 'coordinates'
146
+ if vals[0][0] == '1':
147
+ vals = np.transpose(vals)
148
+ info = dict(
149
+ coordinates=np.array(vals[-3:].T, dtype=float) * ureg.bohr,
150
+ atom=vals[1],
151
+ )
152
+ else:
153
+ keys = vals[0][2:]
154
+ vals = np.transpose(vals[1:])
155
+ info = dict(coordinates=np.array(vals[:3].T, dtype=float) * ureg.bohr)
156
+ for n, key in enumerate(keys):
157
+ info[key] = vals[n + 3]
158
+ info['atom'] = [v.title() for v in info.get('atom', [])]
159
+ return info
160
+
161
+ def str_to_time(val_in):
162
+ time = 0.0
163
+ multipliers = {'d': 24 * 3600, 'h': 3600, 'm': 60, 's': 1}
164
+ for unit, multiplier in multipliers.items():
165
+ match = re.search(rf'([\d\.]+) {unit}', val_in)
166
+ if match:
167
+ time += float(match.group(1)) * multiplier
168
+ if not time:
169
+ try:
170
+ time = float(val_in)
171
+ except Exception:
172
+ pass
173
+ return time
174
+
175
+ def str_to_hessian(val_in):
176
+ re_row = re.compile(r'(\d*)\s*\w*\s*d(?:x|y|z) +([\d\.\- ]+\d)')
177
+ re_value = re.compile(r'\-*\d+\.\d+')
178
+ n_axis = 3
179
+
180
+ hessian = []
181
+ row_n = -1
182
+ for val in val_in.strip().split('\n'):
183
+ row = re.search(re_row, val)
184
+ if not row:
185
+ continue
186
+ if row.group(1):
187
+ row_n = (int(row.group(1)) - 1) * n_axis
188
+ else:
189
+ row_n += 1
190
+
191
+ if len(hessian) < row_n + 1:
192
+ hessian.append([])
193
+ hessian[row_n].extend(re_value.findall(row.group(2)))
194
+
195
+ for n in range(len(hessian)):
196
+ hessian[n].extend([0] * (len(hessian) - len(hessian[n])))
197
+
198
+ hessian = np.array(hessian, dtype=float)
199
+ # symmetrize
200
+ hessian = hessian + hessian.T - np.diag(hessian.diagonal())
201
+ n_atoms = len(hessian) // n_axis
202
+ hessian = np.reshape(hessian, (n_atoms, n_axis, n_atoms, n_axis))
203
+ return (
204
+ np.transpose(hessian, axes=(0, 2, 1, 3)) * ureg.hartree / ureg.bohr**2
205
+ )
206
+
207
+ # TODO integrate with hessian
208
+ def str_to_normal_modes_vibrational_frequencies(val_in):
209
+ re_row = re.compile(r'(\d*)\s*\w*\s+(?:x|y|z) +([\d\.\- ]+\d)')
210
+ re_value = re.compile(r'\-*\d+\.\d+')
211
+ n_axis = 3
212
+
213
+ row_n = -1
214
+ normal_modes = []
215
+ for val in val_in.strip().split('\n'):
216
+ row = re.search(re_row, val)
217
+ if not row:
218
+ continue
219
+ if row.group(1):
220
+ row_n = (int(row.group(1)) - 1) * n_axis
221
+ else:
222
+ row_n += 1
223
+
224
+ if len(normal_modes) < row_n + 1:
225
+ normal_modes.append([])
226
+ normal_modes[row_n].extend(re_value.findall(row.group(2)))
227
+
228
+ n_atoms = len(normal_modes) // n_axis
229
+ normal_modes = np.array(normal_modes, dtype=float)
230
+ n_modes = np.size(normal_modes) // (n_atoms * n_axis)
231
+ normal_modes = np.transpose(
232
+ np.reshape(normal_modes, (n_atoms, n_axis, n_modes)), axes=(2, 0, 1)
233
+ )
234
+
235
+ def get_values(pattern, dtype=str):
236
+ values_str = re.findall(pattern, val_in)
237
+ values = []
238
+ for value in values_str:
239
+ if dtype is float:
240
+ values.extend(re_value.findall(value))
241
+ else:
242
+ values.extend(value.split())
243
+ return np.array(values, dtype=dtype)
244
+
245
+ frequencies = get_values(r'frequency\s+([\d\.\- ]+\d)', float)
246
+
247
+ infrared = [v == 'YES' for v in get_values(r'IR\s+([YES\- ]+)')]
248
+
249
+ raman = [v == 'YES' for v in get_values(r'RAMAN\s+([YES\- ]+)')]
250
+
251
+ intensity = get_values(r'intensity \(km/mol\)\s+([\d\.\- ]+\d)', float)
252
+
253
+ return dict(
254
+ normal_modes=normal_modes,
255
+ mode_energies=frequencies,
256
+ infrared_activity=infrared,
257
+ raman_activity=raman,
258
+ intensities=intensity,
259
+ )
260
+
261
+ def str_to_energy_gradient(val_in):
262
+ re_row = re.compile(r'dE/d((?:x|y|z)) +([\d\.\-\+ Dd]+\d)')
263
+ re_value = re.compile(r'\-*\d+\.\d+D*d*\-*\+*\d*')
264
+
265
+ gradients = []
266
+ for val in val_in.strip().split('\n'):
267
+ row = re.search(re_row, val)
268
+ if not row:
269
+ continue
270
+ row_n = ['x', 'y', 'z'].index(row.group(1))
271
+ if len(gradients) < row_n + 1:
272
+ gradients.append([])
273
+ gradients[row_n].extend(
274
+ [
275
+ v.replace('D', 'E').replace('d', 'e')
276
+ for v in re_value.findall(row.group(2))
277
+ ]
278
+ )
279
+
280
+ gradients = np.array(gradients, dtype=float)
281
+ return np.transpose(gradients) * (ureg.hartree / ureg.bohr)
282
+
283
+ def str_to_iteration(val_in):
284
+ val = val_in.split('\n')
285
+ keys = [v.strip() for v in val[0].split(' ') if v]
286
+ # replace key with metainfo name
287
+ units = {'energy_total': ureg.hartree}
288
+ for n in range(len(keys)):
289
+ if keys[n] == 'CCSD energy':
290
+ keys[n] = 'energy_total'
291
+ elif keys[n] == 'wall':
292
+ keys[n] = 'time'
293
+ val = [v.split() for v in val[1:]]
294
+ val = np.transpose(
295
+ np.array([v for v in val if len(v) == len(keys)], dtype=float)
296
+ )
297
+ return [
298
+ {key: val[n][i] * units.get(key, 1.0) for n, key in enumerate(keys)}
299
+ for i in range(len(val[0]))
300
+ ]
301
+
302
+ def str_to_embedding_coordinates(val_in):
303
+ val = [v.split() for v in val_in.strip().split('\n')]
304
+ val = np.transpose([v for v in val if len(v) >= 4])
305
+ label = [v.title() for v in val[0]]
306
+ charge = val[4] if len(val) > 4 else [0] * len(label)
307
+ return dict(
308
+ label=label,
309
+ coordinates=np.array(val[1:4].T, dtype=float) * ureg.bohr,
310
+ charge=np.array(charge, dtype=float) * ureg.elementary_charge,
311
+ )
312
+
313
+ def str_to_scf_energies(val_in):
314
+ val = [float(v) for v in val_in.strip().replace('D', 'E').split()]
315
+ return dict(
316
+ energy_total=val[1] * ureg.hartree,
317
+ x_turbomole_energy_1electron_scf_iteration=val[2] * ureg.hartree,
318
+ x_turbomole_energy_2electron_scf_iteration=val[3] * ureg.hartree,
319
+ )
320
+
321
+ def str_to_norm(val_in):
322
+ name, val = val_in.split('=')
323
+ val = val.split()
324
+ name = 'norm_fia' if 'Fia' in name else 'norm_fock'
325
+ return {name: float(val[0].replace('D', 'E')), '%s_orbital' % name: val[1]}
326
+
327
+ def str_to_fon(val_in):
328
+ val = [v.split('=') for v in val_in.split('\n')]
329
+ return {v[0].strip(): float(v[1]) for v in val if len(v) == 2}
330
+
331
+ def str_to_energies(val_in):
332
+ re_energy = re.compile(rf'([\w\(\) ]+)\s*(?:=|:)\s*({re_float})')
333
+ energies = dict()
334
+ for val in val_in.strip().split('\n'):
335
+ val = re_energy.search(val)
336
+ if val:
337
+ key = val.group(1).strip()
338
+ energies[key] = (
339
+ float(val.group(2)) * ureg.hartree
340
+ if 'energy' in key
341
+ else float(val.group(2))
342
+ )
343
+ return energies
344
+
345
+ def str_to_gw_parameters(val_in):
346
+ val = [v.rsplit(' ', 1) for v in val_in.strip().split('\n')]
347
+ parameters = dict()
348
+ for v in val:
349
+ if v[1] in ['T', 'F']:
350
+ v[1] = v[1] == 'T'
351
+ parameters[v[0].strip()] = v[1]
352
+ return parameters
353
+
354
+ def str_to_qp_states(val_in):
355
+ val = [v.split() for v in val_in.strip().split('\n')]
356
+ val = np.transpose(
357
+ np.array([v[1:] for v in val if len(v) == 9], dtype=float)
358
+ )
359
+ keys = [
360
+ 'eigenvalue_ks_GroundState',
361
+ 'eigenvalue_quasiParticle_energy',
362
+ 'eigenvalue_ExchangeCorrelation_perturbativeGW',
363
+ 'eigenvalue_ExactExchange_perturbativeGW',
364
+ 'eigenvalue_correlation_perturbativeGW',
365
+ 'eigenvalue_ks_ExchangeCorrelation',
366
+ 'Z_factor',
367
+ 'ExchangeCorrelation_perturbativeGW_derivation',
368
+ ]
369
+ states = dict()
370
+ for n, key in enumerate(keys):
371
+ states[key] = val[n]
372
+ return states
373
+
374
+ def str_to_options(val_in):
375
+ val = [v.split(':', 1) for v in val_in.strip().split('\n')]
376
+ return {v[0].strip(): v[1].strip() for v in val if len(v) == 2}
377
+
378
+ def str_to_convergence(val_in):
379
+ re_value = re.compile(r'([\w ]+)\s*(yes|no)\s*')
380
+ convergence = dict()
381
+ for val in val_in.split('\n'):
382
+ val = re_value.search(val)
383
+ if val:
384
+ convergence[val.group(1).strip()] = val.group(2) == 'yes'
385
+ return convergence
386
+
387
+ def str_to_thermodynamics(val_in):
388
+ keys, vals = val_in.strip().split('\n')
389
+ # we could have taken units from prinout but some quantities do not have units
390
+ keys = [k.strip().lower() for k in keys.split()]
391
+ vals = [float(v) for v in vals.split()]
392
+ units = {
393
+ 't': ureg.K,
394
+ 'p': ureg.MPa,
395
+ 'chem.pot.': ureg.kJ / MOL,
396
+ 'energy': ureg.kJ / MOL,
397
+ 'entropy': ureg.kJ / MOL,
398
+ 'cv': ureg.kJ / ureg.K / MOL,
399
+ 'cp': ureg.kJ / ureg.K / MOL,
400
+ 'enthalpy': ureg.kJ / MOL,
401
+ }
402
+ vals = {key: vals[n] * units.get(key, 1.0) for n, key in enumerate(keys)}
403
+ # we calculate entropy energy correction
404
+ if 'entropy' in vals and 't' in vals:
405
+ vals['entropy'] *= vals['t'].magnitude
406
+ return vals
407
+
408
+ iteration_quantities = [
409
+ Quantity(
410
+ 'damping_scf_iteration',
411
+ rf'current damping\s*:*=*\s*({re_float})',
412
+ str_operation=lambda x: 1.0 / (1.0 + float(x)),
413
+ convert=False,
414
+ ),
415
+ Quantity(
416
+ 'energies',
417
+ r'ATION\s*ENERGY.+\s*(\d*\s*.+)',
418
+ str_operation=str_to_scf_energies,
419
+ convert=False,
420
+ ),
421
+ Quantity(
422
+ 'energy_XC', rf'Exc\s*=\s*({re_float})', dtype=float, unit=ureg.hartree
423
+ ),
424
+ Quantity(
425
+ 'norm_diis_scf_iteration',
426
+ rf'Norm of current diis error\s*:\s*({re_float})',
427
+ dtype=float,
428
+ ),
429
+ Quantity(
430
+ 'norm_fia',
431
+ rf'max\. resid\. (norm for Fia\-block=\s*{re_float})\s*for orbital\s*(\w+)',
432
+ str_operation=str_to_norm,
433
+ convert=False,
434
+ ),
435
+ Quantity(
436
+ 'norm_fock',
437
+ rf'max\. resid\. (fock norm\s*=\s*{re_float})\s*for orbital\s*(\w+)',
438
+ str_operation=str_to_norm,
439
+ convert=False,
440
+ ),
441
+ Quantity(
442
+ 'delta_eigenvalues',
443
+ rf'Delta Eig\.\s*=\s*({re_float})',
444
+ dtype=float,
445
+ unit=ureg.eV,
446
+ ),
447
+ Quantity(
448
+ 'fon',
449
+ r'FON Calculation\s*\-+\s*([\s\S]+?\-{50})',
450
+ str_operation=str_to_fon,
451
+ convert=False,
452
+ ),
453
+ ]
454
+
455
+ scf_quantities = [
456
+ Quantity(
457
+ 'iteration',
458
+ rf'(current damping\s*:\s*{re_float}\s*ITERATION[\s\S]+?)\n\s*\n',
459
+ repeats=True,
460
+ sub_parser=TextParser(quantities=iteration_quantities),
461
+ ),
462
+ # alternative format
463
+ Quantity(
464
+ 'iteration',
465
+ r'(ATION\s*ENERGY[\s\S]+?)(?:\n *\n *ITER|End of SCF iterations)',
466
+ repeats=True,
467
+ sub_parser=TextParser(quantities=iteration_quantities),
468
+ ),
469
+ Quantity(
470
+ 'number_of_scf_iterations',
471
+ r'convergence criteria satisfied after\s*(\d+)\s*iterations',
472
+ dtype=int,
473
+ ),
474
+ ]
475
+
476
+ module_quantities = [
477
+ Quantity(
478
+ 'atomic_info',
479
+ r'Atomic coordinate, charge and isotope? information\s*\|\s*\+\-+\+\s*'
480
+ r'([\s\S]+?center of nuclear charge.+)',
481
+ sub_parser=TextParser(
482
+ quantities=[
483
+ Quantity(
484
+ 'info',
485
+ r'(atomic\s+coordinates\s+atom(?:\s+shells)?\s+charge(?:\s+pseudo)?\s+isotop\s*)'
486
+ r'([\s\S]+?)\n\s*\n',
487
+ str_operation=str_to_atomic_info,
488
+ ),
489
+ Quantity(
490
+ 'center_of_nuclear_mass',
491
+ rf'center of nuclear mass\s*:\s*({re_float})\s*({re_float})\s*({re_float})',
492
+ dtype=float,
493
+ ),
494
+ Quantity(
495
+ 'center_of_nuclear_charge',
496
+ rf'center of nuclear charge\s*:\s*({re_float})\s*({re_float})\s*({re_float})',
497
+ dtype=float,
498
+ ),
499
+ ]
500
+ ),
501
+ ),
502
+ Quantity(
503
+ 'basis_set_info',
504
+ r'(\w* (?:basis set|BASIS SET) information\s*[\s\S]+?)\n\s*\n *\n',
505
+ repeats=True,
506
+ sub_parser=TextParser(
507
+ quantities=[
508
+ Quantity(
509
+ 'auxiliary',
510
+ r'(\w*) (?:basis|BASIS)',
511
+ str_operation=lambda x: 'auxiliary' in x.lower(),
512
+ convert=False,
513
+ ),
514
+ Quantity(
515
+ 'spherical',
516
+ r'(with spherical basis functions)',
517
+ str_operation=lambda x: True,
518
+ convert=False,
519
+ ),
520
+ Quantity(
521
+ 'atom',
522
+ r'(\w*)\s*(\d+)\s*(\d+)\s*(\d+)\s*([\w\-]+)\s*\[([\w\|]+)\]',
523
+ repeats=True,
524
+ ),
525
+ Quantity(
526
+ 'total',
527
+ r'total number of (.+?):\s*(\d+)',
528
+ repeats=True,
529
+ str_operation=lambda x: x.rsplit(' ', 1),
530
+ ),
531
+ ]
532
+ ),
533
+ ),
534
+ Quantity(
535
+ 'mo_occupation',
536
+ r'mo occupation\s*:\s*irrep\s*mo\'s\s*occupied\s*([\s\S]+?)\n\s*\n',
537
+ str_operation=lambda x: [v.split() for v in x.strip().split('\n')],
538
+ ),
539
+ Quantity(
540
+ 'wavefunction_model',
541
+ r'([w ]+)closed shell calculation for the wavefunction models:\s*(\S+)',
542
+ ),
543
+ Quantity(
544
+ 'dft_functional',
545
+ r'density functional\s*\-+(\s*[\s\S]+?)\n\s*\n *\n',
546
+ sub_parser=TextParser(
547
+ quantities=[
548
+ Quantity(
549
+ 'functional',
550
+ r'(?:functional\s*:\s*(.+)|\n *(\S+)\s*(?:meta-GGA |hybrid )*functional\n)',
551
+ ),
552
+ Quantity('exchange', r'exchange:\s*(.+)', flatten=False),
553
+ Quantity('correlation', r'correlation:\s*(.+)', flatten=False),
554
+ ]
555
+ ),
556
+ ),
557
+ Quantity(
558
+ 'embedding_point_charges',
559
+ r'EMBEDDING IN PERIODIC POINT CHARGES\s*\|\s*.+\s*.+\s*'
560
+ r'([\s\S]+?)\n\s*\n *\n',
561
+ sub_parser=TextParser(
562
+ quantities=[
563
+ Quantity(
564
+ 'pceem_max_multipole',
565
+ r'Maximum multipole moment used\s*:\s*(\d+)',
566
+ dtype=int,
567
+ ),
568
+ Quantity(
569
+ 'pceem_multipole_precision',
570
+ rf'Multipole precision parameter\s*:\s*({re_float})',
571
+ dtype=float,
572
+ ),
573
+ Quantity(
574
+ 'pceem_min_separation_cells',
575
+ rf'Minimum separation between cells\s*:\s*({re_float})',
576
+ dtype=float,
577
+ ),
578
+ Quantity(
579
+ 'lattice_vectors',
580
+ r'Cell vectors \(au\):\s*(.+)\s*(.+)\s*(.+)',
581
+ dtype=float,
582
+ unit=ureg.bohr,
583
+ shape=[3, 3],
584
+ ),
585
+ Quantity(
586
+ 'redefined',
587
+ r'Redefined unit cell content \(au\):\s*.+\s*([\s\S]+?)\n\s*\n',
588
+ str_operation=str_to_embedding_coordinates,
589
+ convert=False,
590
+ ),
591
+ Quantity(
592
+ 'pc_cluster',
593
+ r'PC cluster transformed to the center of cell 0 \(au\):\s*.+\s*([\s\S]+?)\n\s*\n',
594
+ str_operation=str_to_embedding_coordinates,
595
+ convert=False,
596
+ ),
597
+ Quantity(
598
+ 'qm_cluster',
599
+ r'QM cluster transformed to the center of cell 0 \(au\):\s*.+\s*([\s\S]+?)\n\s*\n',
600
+ str_operation=str_to_embedding_coordinates,
601
+ convert=False,
602
+ ),
603
+ ]
604
+ ),
605
+ ),
606
+ Quantity(
607
+ 'dft_d3',
608
+ r'(DFTD3 V[\d\.]+ Rev \d+[\s\S]+?)\n\s*\n *\n',
609
+ sub_parser=TextParser(
610
+ quantities=[
611
+ Quantity('version', r'DFTD3 V([\d\.]+ Rev \d+)', flatten=False),
612
+ Quantity(
613
+ 'energy_van_der_Waals',
614
+ rf'Edisp /kcal,au:\s*\S+\s*({re_float})',
615
+ dtype=float,
616
+ unit=ureg.hartree,
617
+ ),
618
+ ]
619
+ ),
620
+ ),
621
+ Quantity(
622
+ 'uhf',
623
+ r'UHF mod.+? switched (on) !',
624
+ str_operation=lambda x: x == 'on',
625
+ convert=False,
626
+ ),
627
+ Quantity(
628
+ 'smearing',
629
+ r'(\w+ smearing switched on[\s\S]+?)\n\s*\n',
630
+ sub_parser=TextParser(
631
+ quantities=[
632
+ Quantity(
633
+ 'kind', r'(\w+) smearing', str_operation=lambda x: x.lower()
634
+ ),
635
+ Quantity(
636
+ 'width',
637
+ rf'Final electron temperature:\s*({re_float})',
638
+ dtype=float,
639
+ ),
640
+ ]
641
+ ),
642
+ ),
643
+ Quantity(
644
+ 'energy_reference_wavefunction',
645
+ rf'Energy of reference wave function is\s*({re_float})',
646
+ dtype=float,
647
+ ),
648
+ Quantity(
649
+ 'energies',
650
+ r'(total energy\s*=[\s\S]+?)\n\s*\n',
651
+ str_operation=str_to_energies,
652
+ convert=False,
653
+ ),
654
+ Quantity(
655
+ 'self_consistency',
656
+ r'OPTIMIZATION OF THE GROUND STATE CLUSTER AMPLITUDES\s*\*\s*\*\s*\*\s*\*+'
657
+ r'([\s\S]+?)\*{50}',
658
+ sub_parser=TextParser(
659
+ quantities=[
660
+ Quantity(
661
+ 'iteration',
662
+ r'(Iter\.\s+CCSD energy[\s\S]+?)(?:CC equations|\n *\n)',
663
+ str_operation=str_to_iteration,
664
+ ),
665
+ Quantity(
666
+ 'convergence',
667
+ r'(?:converged in (\d+) iterations|within (\d+) cycles)',
668
+ dtype=int,
669
+ ),
670
+ ]
671
+ ),
672
+ ),
673
+ Quantity(
674
+ 'energies_MP2',
675
+ r'(RHF\s*energy[\s\S]+?SOS\-MP2 energy.+)',
676
+ str_operation=str_to_energies,
677
+ ),
678
+ Quantity(
679
+ 'energies_CCSD',
680
+ r'(RHF\s*energy[\s\S]+?Final CCSD energy.*)',
681
+ str_operation=str_to_energies,
682
+ ),
683
+ Quantity(
684
+ 'energies_CCSD(T0)',
685
+ r'(RHF\s*energy[\s\S]+?Final CCSD\(T0\) energy.+)',
686
+ str_operation=str_to_energies,
687
+ ),
688
+ Quantity(
689
+ 'energy_gradient',
690
+ r'cartesian gradient of the energy \(hartree/bohr\)\s*\-+\s*([\s\S]+?)'
691
+ r'calculation of the energy gradient finished',
692
+ str_operation=str_to_energy_gradient,
693
+ convert=False,
694
+ ),
695
+ Quantity(
696
+ 'eigenvalue_file',
697
+ r'orbitals \$\S+\s*will be written to file (\w+)',
698
+ repeats=True,
699
+ ),
700
+ Quantity(
701
+ 'wall_time',
702
+ rf'total\s*wall\-time\s*:(.+)',
703
+ str_operation=str_to_time,
704
+ convert=False,
705
+ ),
706
+ ]
707
+
708
+ aoforce_quantities = module_quantities + [
709
+ Quantity(
710
+ 'hessian',
711
+ r'CARTESIAN FORCE CONSTANT MATRIX \(hartree/bohr\*\*2\)\s*'
712
+ r'.+\s*\-+([\s\S]+?)\n\s*\n *\n',
713
+ str_operation=str_to_hessian,
714
+ convert=False,
715
+ ),
716
+ Quantity(
717
+ 'hessian_file',
718
+ r'\*\*\*\s*projected\s+hessian\s+written\s+onto\s+\$hessian\s+\(projected\),\s+file=\<(.+)\>',
719
+ ),
720
+ Quantity(
721
+ 'normal_modes_vibrational_frequencies',
722
+ r'(NORMAL MODES and VIBRATIONAL FREQUENCIES \(cm\*\*\(-1\)\)\s*\-+[\s\S]+?)(?:\*{50}|\Z)',
723
+ str_operation=str_to_normal_modes_vibrational_frequencies,
724
+ convert=False,
725
+ ),
726
+ Quantity(
727
+ 'normal_modes_file',
728
+ r'\*\*\*\s*normal\s+modes\s+written\s+onto\s+\$vibrational\s+normal\s+modes,\s+file=\<(.+?)\>',
729
+ ),
730
+ Quantity(
731
+ 'vibrational_spectrum_file',
732
+ r'\*\*\*\s+vibrational\s+spectroscopic\s+data\s+written\s+onto\$vibrational\s+spectrum\s+file=\<(.+?)\>',
733
+ ),
734
+ Quantity(
735
+ 'energy_zero_point',
736
+ rf'\*\s*zero point VIBRATIONAL energy\s*:\s*({re_float})',
737
+ dtype=float,
738
+ unit=ureg.hartree,
739
+ ),
740
+ Quantity(
741
+ 'energy_total',
742
+ rf'\*\s*SCF\-energy\s*:\s*({re_float})',
743
+ drype=float,
744
+ unit=ureg.hartree,
745
+ ),
746
+ Quantity(
747
+ 'energy_current',
748
+ rf'\*\s*SCF \+ E\(vib0\)\s*:\s*({re_float})',
749
+ dtype=float,
750
+ unit=ureg.hartree,
751
+ ),
752
+ ]
753
+
754
+ ccsdf12_quantities = module_quantities + [
755
+ Quantity(
756
+ 'energies',
757
+ r'time in triples corr.+\s*\*+([\s\S]+?)\*{50}',
758
+ str_operation=str_to_energies,
759
+ convert=False,
760
+ )
761
+ ]
762
+
763
+ dscf_quantities = module_quantities + [
764
+ Quantity(
765
+ 'self_consistency',
766
+ r'(scf convergence criterion : increment of total energy[\s\S]+?iterations)',
767
+ sub_parser=TextParser(quantities=scf_quantities),
768
+ )
769
+ ]
770
+
771
+ escf_quantities = module_quantities + [
772
+ Quantity(
773
+ 'gw',
774
+ r'(GW version\s*\d+[\s\S]+?)\n\s*\n *\n',
775
+ sub_parser=TextParser(
776
+ quantities=[
777
+ Quantity(
778
+ 'parameters',
779
+ r'par[ae]meters:\s*\-+([\s\S]+?)\-{20}',
780
+ str_operation=str_to_gw_parameters,
781
+ ),
782
+ Quantity(
783
+ 'qp_states',
784
+ r'orb\s*eps\s*QP\-eps\s*Sigma\s*Sigma_x\s*Sigma_c\s*Vxc\s*Z\s*dS/de'
785
+ r'([\s\S]+?)\n\s*\n',
786
+ repeats=True,
787
+ str_operation=str_to_qp_states,
788
+ convert=False,
789
+ ),
790
+ ]
791
+ ),
792
+ )
793
+ ]
794
+
795
+ freeh_quantities = module_quantities + [
796
+ Quantity(
797
+ 'thermodynamics',
798
+ r'(T\s*[Pp]\s*.+\n)[\s\S]+?(\d[\d\.\- ]+)',
799
+ repeats=True,
800
+ str_operation=str_to_thermodynamics,
801
+ convert=False,
802
+ ),
803
+ Quantity(
804
+ 'energy_zero_point',
805
+ rf'zero point vibrational energy\s*\-+\s*zpe=\s*({re_float})\s*kJ/mol',
806
+ dtype=float,
807
+ unit=ureg.kJ / MOL,
808
+ ),
809
+ ]
810
+
811
+ grad_quantities = module_quantities
812
+
813
+ pnoccsd_quantities = module_quantities + [
814
+ Quantity('methods', r' Method \d+:\s*(\S+)', repeats=True),
815
+ Quantity(
816
+ 'energies',
817
+ r'(RHF\s*energy[\s\S]+?Final CCSD\(T\) energy.+)',
818
+ str_operation=str_to_energies,
819
+ ),
820
+ ]
821
+
822
+ # TODO verify this
823
+ # the only example I found shows ricc2 quantities are same with ccsdf12
824
+ ricc2_quantities = ccsdf12_quantities + [
825
+ Quantity(
826
+ 'energy_total',
827
+ rf'Total\s+Energy\s*:\s*({re_float})',
828
+ dtype=float,
829
+ unit=ureg.eV,
830
+ )
831
+ ]
832
+
833
+ ridft_quantities = module_quantities + [
834
+ Quantity(
835
+ 'self_consistency',
836
+ r'Starting SCF iterations([\s\S]+?)\-{40}',
837
+ sub_parser=TextParser(quantities=scf_quantities),
838
+ )
839
+ ]
840
+
841
+ rirpa_quantities = module_quantities + [
842
+ # TODO verify this I cannot find an example file
843
+ Quantity(
844
+ 'energies_RPA',
845
+ r'(HXX\+RIRPA\s+total\s+energy\s*=[\s\S]+?HXX\s+total\s+energy\s*=.+)',
846
+ str_operation=str_to_energies,
847
+ )
848
+ ]
849
+
850
+ statpt_quantities = module_quantities + [
851
+ Quantity(
852
+ 'atomic_info',
853
+ r'ATOM\s*CARTESIAN COORDINATES\s*([\s\S]+?)\*{50}',
854
+ sub_parser=TextParser(
855
+ quantities=[
856
+ Quantity('info', r'([\s\S]+)', str_operation=str_to_atomic_info)
857
+ ]
858
+ ),
859
+ ),
860
+ Quantity(
861
+ 'options',
862
+ r'Stationary point options\s*\*+\s*\*+\s*([\s\S]+?)\*{40}',
863
+ str_operation=str_to_options,
864
+ ),
865
+ Quantity(
866
+ 'convergence',
867
+ r'CONVERGENCE INFORMATION\s*Converged\?\s*Value\s*Criterion\s*([\s\S]+?)\*{50}',
868
+ str_operation=str_to_convergence,
869
+ ),
870
+ ]
871
+
872
+ run_quantities = [
873
+ Quantity(
874
+ 'x_turbomole_nodename', r'\w+\s*\((.+)\)\s*:\s*TURBO', flatten=False
875
+ ),
876
+ Quantity(
877
+ 'program_version',
878
+ r'MOLE (?:V|rev\.)( *[\d\.]+\s*\([\d ]+\))',
879
+ flatten=False,
880
+ ),
881
+ Quantity(
882
+ 'time',
883
+ r'(\d\d\d\d-\d\d-\d\d\s*\d\d:\d\d:\d\d\.\d\d\d)',
884
+ flatten=False,
885
+ repeats=True,
886
+ ),
887
+ Quantity(
888
+ 'module_aoforce',
889
+ r'(a o f o r c e \- program[\s\S]+?(?:force : all done\s*\*\*\*\*|\Z))',
890
+ sub_parser=TextParser(quantities=aoforce_quantities),
891
+ ),
892
+ Quantity(
893
+ 'module_ccsdf12',
894
+ r'(C C S D F 1 2\s*P R O G R A M[\s\S]+?(?:ccsdf12 : all done\s*\*\*\*\*|\Z))',
895
+ sub_parser=TextParser(quantities=ccsdf12_quantities),
896
+ ),
897
+ Quantity(
898
+ 'module_dscf',
899
+ r'(d s c f \- program[\s\S]+?(?:dscf : all done\s*\*\*\*\*|\Z))',
900
+ sub_parser=TextParser(quantities=dscf_quantities),
901
+ ),
902
+ Quantity(
903
+ 'module_escf',
904
+ r'(e s c f[\s\S]+?(?:escf : all done\s*\*\*\*\*|\Z))',
905
+ sub_parser=TextParser(quantities=escf_quantities),
906
+ ),
907
+ Quantity(
908
+ 'module_freeh',
909
+ r'(f r e e e n t h a l p y - program[\s\S]+?(?:freeh : all done\s*\*\*\*\*|\Z))',
910
+ sub_parser=TextParser(quantities=freeh_quantities),
911
+ ),
912
+ Quantity(
913
+ 'module_grad',
914
+ r'(g r a d \- program[\s\S]+?(?:grad : all done\s*\*\*\*\*|\Z))',
915
+ sub_parser=TextParser(quantities=grad_quantities),
916
+ ),
917
+ Quantity(
918
+ 'module_pnoccsd',
919
+ r'(P N O C C S D - P R O G R A M[\s\S]+(?:pnoccsd : all done\s*\*\*\*\*|\Z))',
920
+ sub_parser=TextParser(quantities=pnoccsd_quantities),
921
+ ),
922
+ Quantity(
923
+ 'module_ricc2',
924
+ r'(R I C C 2 \- PROGRAM[\s\S]+?(?:ricc2 : all done\s*\*\*\*\*|\Z))',
925
+ sub_parser=TextParser(quantities=ricc2_quantities),
926
+ ),
927
+ Quantity(
928
+ 'module_ridft',
929
+ r'(r i d f t\s*DFT program[\s\S]+?(?:ridft : all done\s*\*\*\*\*|\Z))',
930
+ sub_parser=TextParser(quantities=ridft_quantities),
931
+ ),
932
+ # TODO implement RIRPA, pnoccsd, freeh
933
+ Quantity(
934
+ 'module_rirpa',
935
+ r'(PROGRAM\s+RIRPA[\s\s]+?(?:rirpa : all done\s*\*\*\*\*|\Z))',
936
+ sub_parser=TextParser(quantities=rirpa_quantities),
937
+ ),
938
+ Quantity(
939
+ 'module_statpt',
940
+ r'(this is S T A T P T[\s\S]+?(?:statpt : all done\s*\*\*\*\*|\Z))',
941
+ sub_parser=TextParser(quantities=statpt_quantities),
942
+ ),
943
+ ]
944
+
945
+ # necessary to wrap it around a module so we keep the order
946
+ self._quantities = [
947
+ Quantity(
948
+ 'module_run',
949
+ r'(TURBOMOLE (?:V|rev)[\s\S]+?(?:all done\s*\*\*\*\*\s*[\d\.\-: ]+|\Z))',
950
+ repeats=True,
951
+ sub_parser=TextParser(quantities=run_quantities),
952
+ )
953
+ ]
954
+
955
+
956
+ class TurbomoleParser:
957
+ def __init__(self):
958
+ self.out_parser = OutParser()
959
+ self.matrix_parser = AuxiliaryOutParser(r' *(\d+\s+\d+\s+[\d\.\- ]+)\n', 2)
960
+ self.vibrational_parser = AuxiliaryOutParser(
961
+ r' *(\d+\s+\w*\s+[\d\.\-]+\s+[\d\.\-]+\s+[YES\-]+\s+[YES\-]+)', 0
962
+ )
963
+ self.eigenvalues_parser = EigenvaluesParser()
964
+ self.control_parser = ControlParser()
965
+
966
+ self.xc_functional_map = {
967
+ 'S-VWN': ['LDA_X', 'LDA_C_VWN_3'],
968
+ 'PWLDA': ['LDA_X', 'LDA_C_PW'],
969
+ 'B-VWN': ['GGA_X_B88', 'LDA_C_VWN'],
970
+ 'B-LYP': ['GGA_X_B88', 'GGA_C_LYP'],
971
+ 'B-P': ['GGA_X_B88', 'GGA_C_P86'],
972
+ 'B-P86': ['GGA_X_B88', 'GGA_C_P86'],
973
+ 'PBE': ['GGA_X_PBE', 'GGA_C_PBE'],
974
+ 'TPSS': ['MGGA_X_TPSS', 'MGGA_C_TPSS'],
975
+ 'M06': ['MGGA_X_M06', 'MGGA_C_M06'],
976
+ 'BH-LYP': ['HYB_GGA_XC_BHANDHLYP'],
977
+ 'B3-LYP': ['HYB_GGA_XC_B3LYP'],
978
+ 'PBE0': ['HYB_GGA_XC_PBEH'],
979
+ 'TPSSh': ['HYB_MGGA_XC_TPSSH'],
980
+ 'M06-2X': ['MGGA_X_M06_2X', 'MGGA_C_M06_2X'],
981
+ 'B2-PLYP': ['HYB_GGA_XC_B2PLYP'],
982
+ }
983
+
984
+ self.models_map = {
985
+ 'MP2': 'MP2',
986
+ 'CCS': 'CCS',
987
+ 'CIS': 'CIS',
988
+ 'CIS(D)': 'CISD',
989
+ 'CIS(Dinf)': 'CISD',
990
+ 'ADC(2)': 'MP2', # TODO: check paper to verify this mapping
991
+ 'CC2': 'CCSD',
992
+ 'CCSD': 'CCSD',
993
+ 'CCSD(T)': 'CCSD(T)',
994
+ }
995
+
996
+ self.metainfo_map = {
997
+ 'total energy': 'energy_total',
998
+ 'kinetic energy': 'energy_kinetic_electronic',
999
+ 'potential energy': 'x_turbomole_potential_energy_final',
1000
+ 'virial theorem': 'x_turbomole_virial_theorem',
1001
+ 'wavefunction norm': 'x_turbomole_wave_func_norm',
1002
+ 'Final CCSD(T) energy': 'energy_total',
1003
+ 'CCSD correlation energy': 'energy_current',
1004
+ 'Final CCSD(T0) energy': 'energy_total',
1005
+ 'Final CCSD energy': 'energy_total',
1006
+ 'correlation energy': 'energy_current',
1007
+ 'Final MP2 energy': 'energy_total',
1008
+ 'MP2 correlation energy (doubles)': 'energy_current',
1009
+ r'HXX\+RIRPA total energy': 'energy_total',
1010
+ 'RIRPA correlation energy': 'energy_current',
1011
+ 'HXX total energy': 'energy_total',
1012
+ 'rpa response function': 'x_turbomole_gw_use_rpa_response',
1013
+ 'eta (Hartree)': 'x_turbomole_gw_eta_factor',
1014
+ 'Maximum allowed trust radius': 'x_turbomole_geometry_optimization_trustregion_max',
1015
+ 'Minimum allowed trust radius': 'x_turbomole_geometry_optimization_trustregion_min',
1016
+ 'Initial trust radius': 'x_turbomole_geometry_optimization_trustregion_initial',
1017
+ 'Hessian update method': 'method',
1018
+ 'Threshold for energy change': 'convergence_tolerance_energy_difference',
1019
+ 'Threshold for max displacement element': 'convergence_tolerance_displacement_maximum',
1020
+ 'Threshold for max gradient element': 'convergence_tolerance_force_maximum',
1021
+ 'Threshold for RMS of displacement': 'x_turbomole_geometry_optimization_geometry_change_rms',
1022
+ 'Threshold for RMS of gradient': 'x_turbomole_geometry_optimization_threshold_force_rms',
1023
+ 't': 'temperature',
1024
+ 'p': 'pressure',
1025
+ 'entropy': 'energy_correction_entropy',
1026
+ 'energy': 'energy_total',
1027
+ 'cv': 'heat_capacity_c_v',
1028
+ 'cp': 'heat_capacity_c_p',
1029
+ }
1030
+
1031
+ def init_parser(self):
1032
+ self.out_parser.mainfile = self.filepath
1033
+ self.out_parser.logger = self.logger
1034
+ self.module = None
1035
+
1036
+ def get_number_of_atoms(self):
1037
+ return len(self.module.get('atomic_info', {}).get('info', {}).get('atom', []))
1038
+
1039
+ def get_number_of_spin_channels(self):
1040
+ nspin = 1
1041
+ if self.module.get('uhf'):
1042
+ nspin = 2
1043
+ gw_parameters = self.module.get('gw', {}).get('parameters', None)
1044
+ if gw_parameters is not None:
1045
+ nspin = gw_parameters.get('number of spin channels', 1)
1046
+ # TODO add other conditions
1047
+ return nspin
1048
+
1049
+ def get_electronic_structure_method(self):
1050
+ if self.module.get('wavefunction_model') is not None:
1051
+ return self.models_map.get(self.module.get('wavefunction_model'), None)
1052
+ if self.module.get('methods') is not None:
1053
+ return self.models_map.get(self.module.get('methods')[-1], None)
1054
+ if self.module.get('dft_functional') is not None:
1055
+ return 'DFT'
1056
+ if self.module.get('gw') is not None:
1057
+ return 'G0W0'
1058
+
1059
+ def parse_system(self):
1060
+ sec_run = self.archive.run[0]
1061
+ sec_system = System()
1062
+ sec_run.system.append(sec_system)
1063
+ sec_atoms = Atoms()
1064
+ sec_system.atoms = sec_atoms
1065
+
1066
+ info = self.module.get('atomic_info', {}).get('info', {})
1067
+ if info.get('coordinates') is not None:
1068
+ sec_atoms.positions = info.get('coordinates', [])
1069
+ if info.get('atom') is not None:
1070
+ sec_atoms.labels = info.get('atom', [])
1071
+ sec_atoms.periodic = [False, False, False]
1072
+ # TODO is it always non-periodic?
1073
+
1074
+ point_charges = self.module.get('embedding_point_charges', {})
1075
+ cluster_description = {
1076
+ 'redefined': 'periodic point charges for embedding',
1077
+ 'pc_cluster': 'removed point charge cluster',
1078
+ 'qm_cluster': 'shifted embedded QM cluster',
1079
+ }
1080
+ sec_system.systems_ref = []
1081
+ for name in cluster_description.keys():
1082
+ cluster = point_charges.get(name, None)
1083
+ if cluster is None:
1084
+ continue
1085
+ sec_system_cluster = System()
1086
+ sec_run.system.append(sec_system_cluster)
1087
+ sec_atoms = Atoms()
1088
+ sec_system_cluster.atoms = sec_atoms
1089
+ sec_atoms.positions = cluster.get('coordinates')
1090
+ sec_atoms.labels = cluster.get('labels')
1091
+ if name == 'redefined':
1092
+ sec_system_cluster.x_turbomole_pceem_charges = cluster.get('charges')
1093
+ sec_atoms.lattice_vectors = point_charges.get('lattice_vectors')
1094
+ sec_atoms.periodic = [True, True, True]
1095
+ # TODO is the reference correct or the other way around?
1096
+ sec_system.systems_ref.append(sec_system_cluster)
1097
+
1098
+ for key, val in point_charges.items():
1099
+ if key.startswith('pceem_') and val is not None:
1100
+ setattr(sec_system, 'x_turbomole_%s' % key, val)
1101
+
1102
+ return sec_system
1103
+
1104
+ def parse_scc(self):
1105
+ sec_run = self.archive.run[0]
1106
+ time_initial = (
1107
+ sec_run.calculation[-1].time_physical if sec_run.calculation else 0 * ureg.s
1108
+ )
1109
+ sec_scc = Calculation()
1110
+ sec_run.calculation.append(sec_scc)
1111
+
1112
+ n_atoms = self.get_number_of_atoms()
1113
+
1114
+ # energies
1115
+ sec_energy = Energy()
1116
+ sec_scc.energy = sec_energy
1117
+ for key, val in self.module.get('energies', {}).items():
1118
+ key = self.metainfo_map.get(key, None)
1119
+ if key is None:
1120
+ continue
1121
+ if key.startswith('energy_'):
1122
+ sec_energy.m_add_sub_section(
1123
+ getattr(Energy, key.replace('energy_', '').lower()),
1124
+ EnergyEntry(value=val),
1125
+ )
1126
+ else:
1127
+ setattr(sec_scc, key, val)
1128
+
1129
+ for key in ['zero_point', 'current', 'total']:
1130
+ val = self.module.get('energy_%s' % key)
1131
+ if val is not None:
1132
+ sec_energy.m_add_sub_section(
1133
+ getattr(Energy, key), EnergyEntry(value=val)
1134
+ )
1135
+
1136
+ # module-specific energies (will create additional scc, method)
1137
+ for name, energies in self.module.items():
1138
+ if not name.startswith('energies_') or energies is None:
1139
+ continue
1140
+ sec_scc_module = Calculation()
1141
+ sec_run.calculation.append(sec_scc_module)
1142
+ sec_scc_module_energy = Energy()
1143
+ sec_scc_module.energy = sec_scc_module_energy
1144
+ for key, val in energies.items():
1145
+ key = self.metainfo_map.get(key, None)
1146
+ if key is None:
1147
+ continue
1148
+ if key.startswith('energy_'):
1149
+ sec_scc_module_energy.m_add_sub_section(
1150
+ getattr(Energy, key.replace('energy_', '').lower()),
1151
+ EnergyEntry(value=val),
1152
+ )
1153
+ else:
1154
+ setattr(sec_scc_module, key, val)
1155
+ sec_method_module = Method()
1156
+ sec_run.method.append(sec_method_module)
1157
+ sec_method_module.electronic = Electronic(method=name.lstrip('energies_'))
1158
+ sec_scc_module.method_ref = sec_method_module
1159
+ # add reference to main sec_scc
1160
+ sec_scc_module.starting_calculation_ref = sec_scc
1161
+ sec_scc_module.calculations_ref = [sec_scc]
1162
+
1163
+ # forces
1164
+ energy_gradient = self.module.get('energy_gradient')
1165
+ if energy_gradient is not None:
1166
+ sec_scc.forces = Forces(total=ForcesEntry(value_raw=energy_gradient))
1167
+
1168
+ # thermodynamics
1169
+ thermodynamics = self.module.get('thermodynamics')
1170
+ if thermodynamics is not None:
1171
+ current_t, current_p = 0.0, 0.0
1172
+ # sec_scc_thermo = None
1173
+ for thermo in thermodynamics:
1174
+ if current_t != thermo.get('t', 0.0) or current_p != thermo.get(
1175
+ 'p', 0.0
1176
+ ):
1177
+ sec_scc_thermo = Calculation()
1178
+ sec_run.calculation.append(sec_scc_thermo)
1179
+ sec_scc_thermo.starting_calculation_ref = sec_scc
1180
+ sec_scc_thermo.calculations_ref = [sec_scc]
1181
+ sec_thermo = Thermodynamics()
1182
+ sec_scc_thermo.thermodynamics.append(sec_thermo)
1183
+ sec_scc_thermo_energy = Energy()
1184
+ sec_scc_thermo.energy = sec_scc_thermo_energy
1185
+ current_t, current_p = thermo.get('t', 0.0), thermo.get('p', 0.0)
1186
+ if sec_scc_thermo is not None:
1187
+ for key, val in thermo.items():
1188
+ key = self.metainfo_map.get(key, key)
1189
+ if key.startswith('energy_'):
1190
+ sec_scc_thermo_energy.m_add_sub_section(
1191
+ getattr(Energy, key.replace('energy_', '').lower()),
1192
+ EnergyEntry(value=val),
1193
+ )
1194
+ else:
1195
+ setattr(sec_thermo, key, val)
1196
+
1197
+ # hessian
1198
+ if self.module.get('hessian') is not None:
1199
+ sec_scc.hessian_matrix = self.module.get('hessian').to('J/m**2').magnitude
1200
+ elif self.module.get('hessian_file') is not None:
1201
+ # read if from file
1202
+ self.matrix_parser.mainfile = os.path.join(
1203
+ self.maindir, self.module.get('hessian_file')
1204
+ )
1205
+ try:
1206
+ hessian = np.reshape(
1207
+ np.array(self.matrix_parser.matrix, dtype=float),
1208
+ (n_atoms, 3, n_atoms, 3),
1209
+ )
1210
+ hessian = (
1211
+ np.transpose(hessian, axes=(0, 2, 1, 3))
1212
+ * ureg.hartree
1213
+ / ureg.bohr**2
1214
+ )
1215
+ sec_scc.hessian_matrix = hessian.to('J/m**2').magnitude
1216
+ except Exception:
1217
+ self.logger.warning('Cannot read hessian file.')
1218
+
1219
+ # vibrational frequencies
1220
+ vibration = self.module.get('normal_modes_vibrational_frequencies')
1221
+ if vibration is not None:
1222
+ for key, val in vibration.items():
1223
+ setattr(sec_scc, 'x_turbomole_vibrations_%s' % key, val)
1224
+ else:
1225
+ if self.module.get('normal_modes_file') is not None:
1226
+ # read from file
1227
+ self.matrix_parser.mainfile = os.path.join(
1228
+ self.maindir, self.module.get('normal_modes_file')
1229
+ )
1230
+ try:
1231
+ normal_modes = np.array(self.matrix_parser.matrix, dtype=float)
1232
+ sec_scc.x_turbomole_vibrations_normal_modes = np.transpose(
1233
+ np.reshape(normal_modes, (n_atoms, 3, len(normal_modes[0]))),
1234
+ axes=(2, 0, 1),
1235
+ )
1236
+ except Exception:
1237
+ self.logger.warning('Cannot read normal modes file.')
1238
+
1239
+ if self.module.get('vibrational_spectrum_file') is not None:
1240
+ self.vibrational_parser.mainfile = os.path.join(
1241
+ self.maindir, self.module.get('vibrational_spectrum_file', '')
1242
+ )
1243
+ try:
1244
+ spectrum = self.vibrational_parser.matrix
1245
+ sec_scc.x_turbomole_vibrations_mode_energies = np.array(
1246
+ [s[-4] for s in spectrum], dtype=float
1247
+ )
1248
+ sec_scc.x_turbomole_vibrations_intensities = np.array(
1249
+ [s[-3] for s in spectrum], dtype=float
1250
+ )
1251
+ sec_scc.x_turbomole_vibrations_infrared_activity = [
1252
+ s[-2] == 'YES' for s in spectrum
1253
+ ]
1254
+ sec_scc.x_turbomole_vibrations_raman_activity = [
1255
+ s[-1] == 'YES' for s in spectrum
1256
+ ]
1257
+
1258
+ except Exception:
1259
+ self.logger.warning('Cannot read vibrational spectrum file.')
1260
+
1261
+ # eigenvalues
1262
+ eigenvalue_files = self.module.get('eigenvalue_file')
1263
+ if eigenvalue_files is not None:
1264
+ eigenvalues = []
1265
+ occupation = []
1266
+ irrep = []
1267
+ try:
1268
+ for eigenvalue_file in eigenvalue_files:
1269
+ self.eigenvalues_parser.mainfile = os.path.join(
1270
+ self.maindir, eigenvalue_file
1271
+ )
1272
+ eigenvalues.append(
1273
+ np.hstack(self.eigenvalues_parser.get('eigenvalues', []))
1274
+ )
1275
+ occupation.append(
1276
+ np.hstack(self.eigenvalues_parser.get('occupation', []))
1277
+ )
1278
+ irrep.append(np.hstack(self.eigenvalues_parser.get('irrep', [])))
1279
+ sec_eigenvalues = BandEnergies()
1280
+ sec_scc.eigenvalues.append(sec_eigenvalues)
1281
+ values = (
1282
+ np.reshape(
1283
+ np.array(eigenvalues, dtype=float),
1284
+ (len(eigenvalue_files), 1, len(eigenvalues[0])),
1285
+ )
1286
+ * ureg.hartree
1287
+ )
1288
+ occupations = np.reshape(
1289
+ np.array(occupation, dtype=float),
1290
+ (len(eigenvalue_files), 1, len(occupation[0])),
1291
+ )
1292
+ irrep = np.reshape(
1293
+ np.array(irrep, dtype=np.dtype(np.int32)),
1294
+ (len(eigenvalue_files), 1, len(irrep[0])),
1295
+ )
1296
+ sec_eigenvalues.energies = values
1297
+ sec_eigenvalues.occupations = occupations
1298
+ sec_eigenvalues.x_turbomole_eigenvalues_irreducible_representation = irrep
1299
+ sec_eigenvalues.kpoints = [np.zeros(3)]
1300
+ except Exception:
1301
+ self.logger.warning('Cannot read eigenvalues.')
1302
+
1303
+ # self consistency
1304
+ self_consistency = self.module.get('self_consistency', {})
1305
+ # total energies for calculation of energy change
1306
+ energies = [0.0] + [
1307
+ iteration.get('energies', {}).get('energy_total_scf_iteration')
1308
+ for iteration in self_consistency.get('iteration', [])
1309
+ ]
1310
+ for n, iteration in enumerate(self_consistency.get('iteration', [])):
1311
+ time_initial_scf = (
1312
+ sec_scc.scf_iteration[-1].time_physical
1313
+ if sec_scc.scf_iteration
1314
+ else time_initial
1315
+ )
1316
+ sec_iteration = ScfIteration()
1317
+ sec_scc.scf_iteration.append(sec_iteration)
1318
+ sec_iteration_energy = Energy()
1319
+ sec_iteration.energy = sec_iteration_energy
1320
+
1321
+ for key, val in iteration.get('energies', {}).items():
1322
+ if key.startswith('energy_'):
1323
+ sec_iteration_energy.m_add_sub_section(
1324
+ getattr(Energy, key.replace('energy_', '').lower()),
1325
+ EnergyEntry(value=val),
1326
+ )
1327
+ else:
1328
+ setattr(sec_iteration, key, val)
1329
+ # energy change
1330
+ sec_iteration.energy_change = energies[n]
1331
+ # scf quantities
1332
+ for key in ['total', 'XC']:
1333
+ val = iteration.get('energy_%s' % key, None)
1334
+ if val is None:
1335
+ continue
1336
+ sec_iteration_energy.m_add_sub_section(
1337
+ getattr(Energy, key.lower()), EnergyEntry(value=val)
1338
+ )
1339
+ if iteration.get('time'):
1340
+ sec_iteration.time_calculation = iteration.get('time')
1341
+ sec_iteration.time_physical = (
1342
+ time_initial_scf + sec_iteration.time_calculation
1343
+ )
1344
+ # miscellaneous scf quantities
1345
+ scf_keys = [
1346
+ 'damping_scf_iteration',
1347
+ 'norm_diis_scf_iteration',
1348
+ 'delta_eigenvalues',
1349
+ 'norm_fia',
1350
+ 'norm_fock',
1351
+ ]
1352
+ for key in scf_keys:
1353
+ val = iteration.get(key, None)
1354
+ if val is None:
1355
+ continue
1356
+ if key == 'norm_fia' or key == 'norm_fock':
1357
+ setattr(
1358
+ sec_iteration,
1359
+ 'x_turbomole_%s_orbital_scf_iteration' % key,
1360
+ val.get('%s_orbital' % key),
1361
+ )
1362
+ val = val.get(key)
1363
+ key = '%s_scf_iteration' % key
1364
+ setattr(sec_iteration, 'x_turbomole_%s' % key, val)
1365
+ n_scf = self_consistency.get('number_of_scf_iterations', None)
1366
+ if n_scf is not None:
1367
+ sec_scc.n_scf_iterations = n_scf
1368
+
1369
+ # gw
1370
+ if self.module.get('gw') is not None:
1371
+ gw_metainfo_map = {
1372
+ 'Z_factor': 'qp_linearization_prefactor',
1373
+ 'eigenvalue_ks_GroundState': 'value_ks',
1374
+ 'eigenvalue_quasiParticle_energy': 'value_qp',
1375
+ 'eigenvalue_ExchangeCorrelation_perturbativeGW': 'value_xc',
1376
+ 'eigenvalue_ExactExchange_perturbativeGW': 'value_exchange',
1377
+ 'eigenvalue_correlation_perturbativeGW': 'value_correlation',
1378
+ 'eigenvalue_ks_ExchangeCorrelation': 'value_ks_xc',
1379
+ 'ExchangeCorrelation_perturbativeGW_derivation': 'x_turbomole_ExchangeCorrelation_perturbativeGW_derivation',
1380
+ }
1381
+ sec_eigs_gw = BandEnergies()
1382
+ sec_scc.eigenvalues.append(sec_eigs_gw)
1383
+ for key, name in gw_metainfo_map.items():
1384
+ val = [q.get(key) for q in self.module.gw.get('qp_states', [])]
1385
+ # TODO verify shape for spin polarized
1386
+ val = np.reshape(
1387
+ val, (1, len(self.module.gw.get('qp_states', [])), len(val[0]))
1388
+ )
1389
+ val = val * ureg.eV if name.startswith('value_') else val
1390
+ setattr(sec_eigs_gw, name, val)
1391
+
1392
+ # vdW
1393
+ energy_vdW = self.module.get('dft_d3', {}).get('energy_van_der_Waals')
1394
+ if energy_vdW is not None:
1395
+ sec_scc.energy.van_der_waals = EnergyEntry(value=energy_vdW, kind='DFTD3')
1396
+
1397
+ if self.module.wall_time is not None:
1398
+ sec_scc.time_calculation = self.module.wall_time * ureg.s
1399
+ sec_scc.time_physical = time_initial + sec_scc.time_calculation
1400
+ return sec_scc
1401
+
1402
+ def parse_method(self):
1403
+ sec_method = Method()
1404
+ self.archive.run[0].method.append(sec_method)
1405
+ sec_dft = DFT()
1406
+ sec_method.dft = sec_dft
1407
+ sec_electronic = Electronic()
1408
+ sec_method.electronic = sec_electronic
1409
+
1410
+ method = self.get_electronic_structure_method()
1411
+ if method is not None:
1412
+ sec_electronic.method = method
1413
+ sec_electronic.n_spin_channels = self.get_number_of_spin_channels()
1414
+ sec_smearing = Smearing()
1415
+ sec_electronic.smearing = sec_smearing
1416
+ for key, val in self.module.get('smearing', {}).items():
1417
+ setattr(sec_smearing, key, val)
1418
+
1419
+ atomic_info = self.module.get('atomic_info')
1420
+ if atomic_info is not None:
1421
+ info = atomic_info.get('info', {})
1422
+ atom_kind = list(set(info.get('atom', [])))
1423
+ for atom in atom_kind:
1424
+ sec_atom_kind = AtomParameters()
1425
+ sec_method.atom_parameters.append(sec_atom_kind)
1426
+ sec_atom_kind.atom_number = atomic_numbers.get(atom, 0)
1427
+ sec_atom_kind.label = atom
1428
+
1429
+ # Basis set
1430
+ # TODO: add ECP and MO support
1431
+ for basis_set in self.module.get('basis_set_info', []):
1432
+ atom = basis_set.get('atom', [])
1433
+ scope = 'density' if basis_set.auxiliary else 'wavefunction'
1434
+ bs = BasisSet(
1435
+ type='gaussians',
1436
+ )
1437
+ for atom in basis_set.get('atom', []):
1438
+ ac = BasisSetAtomCentered()
1439
+ symbol = atom[0].title()
1440
+ ac.name = atom[4]
1441
+ ac.atom_number = atomic_numbers.get(symbol, 0)
1442
+ if basis_set.spherical:
1443
+ ac.n_basis_functions = atom[3]
1444
+ bs.atom_centered.append(ac)
1445
+ em = BasisSetContainer(
1446
+ type='atom-centered orbitals',
1447
+ scope=[scope],
1448
+ basis_set=[bs],
1449
+ )
1450
+ sec_method.electrons_representation.append(em)
1451
+
1452
+ # XC Functionals
1453
+ sec_xc_functional = XCFunctional()
1454
+ sec_dft.xc_functional = sec_xc_functional
1455
+ dft_functional = self.module.get('dft_functional')
1456
+ if dft_functional is not None:
1457
+ for functional in self.xc_functional_map.get(
1458
+ dft_functional.get('functional'), ['HF_X']
1459
+ ):
1460
+ if '_X_' in functional or functional.endswith('_X'):
1461
+ sec_xc_functional.exchange.append(Functional(name=functional))
1462
+ elif '_C_' in functional or functional.endswith('_C'):
1463
+ sec_xc_functional.correlation.append(Functional(name=functional))
1464
+ elif 'HYB' in functional:
1465
+ sec_xc_functional.hybrid.append(Functional(name=functional))
1466
+ else:
1467
+ sec_xc_functional.contributions.append(Functional(name=functional))
1468
+
1469
+ if dft_functional.exchange is not None:
1470
+ sec_method.x_turbomole_functional_type_exchange = (
1471
+ dft_functional.exchange
1472
+ )
1473
+
1474
+ if dft_functional.correlation is not None:
1475
+ sec_method.x_turbomole_functional_type_correlation = (
1476
+ dft_functional.correlation
1477
+ )
1478
+
1479
+ # vdW method
1480
+ dftd3_version = self.module.get('dft_d3', {}).get('version', None)
1481
+ if dftd3_version is not None:
1482
+ sec_method.electronic.van_der_waals_method = 'DFT-D3'
1483
+ sec_method.x_turbomole_dft_d3_version = dftd3_version
1484
+
1485
+ if self.module.get('gw') is not None:
1486
+ sec_method.calculation_method_kind = 'perturbative'
1487
+ parameters = self.module.gw.get('parameters', {})
1488
+ for key, val in parameters.items():
1489
+ val = val * ureg.hartree if 'Hartree' in key else val
1490
+ key = self.metainfo_map.get(key, None)
1491
+ if key is None:
1492
+ continue
1493
+ setattr(sec_method, key, val)
1494
+ gw_type = parameters.get('type of gw 0:G0W0 1: GW0', 0)
1495
+ sec_method.x_turbomole_gw_approximation = ['G0W0', 'GW0'][gw_type]
1496
+
1497
+ # control
1498
+ self.control_parser.mainfile = os.path.join(self.maindir, 'control')
1499
+ for key, val in self.control_parser.items():
1500
+ if val is None:
1501
+ continue
1502
+ if key == 'drvopt':
1503
+ for drvopt_key, drvopt_val in val.items():
1504
+ setattr(
1505
+ sec_method,
1506
+ 'x_turbomole_controlIn_%s_status' % drvopt_key,
1507
+ drvopt_val,
1508
+ )
1509
+ else:
1510
+ setattr(sec_method, 'x_turbomole_controlIn_%s' % key, val)
1511
+
1512
+ return sec_method
1513
+
1514
+ def parse_workflow(self):
1515
+ options = self.module.get('options')
1516
+ if options is None:
1517
+ return
1518
+
1519
+ workflow = GeometryOptimization(method=GeometryOptimizationMethod())
1520
+ for key, val in options.items():
1521
+ if 'radius' in key or 'displacement' in key:
1522
+ val = val * ureg.bohr
1523
+ elif 'energy' in key:
1524
+ val = val * ureg.hartree
1525
+ elif 'gradient' in key or 'force' in key:
1526
+ val = val * ureg.hartree / ureg.bohr
1527
+ key = self.metainfo_map.get(key, None)
1528
+ if key is None:
1529
+ continue
1530
+ setattr(workflow.method, key, val)
1531
+ self.archive.workflow2 = workflow
1532
+
1533
+ def parse(self, filepath, archive, logger):
1534
+ self.filepath = os.path.abspath(filepath)
1535
+ self.archive = archive
1536
+ self.maindir = os.path.dirname(self.filepath)
1537
+ self.logger = logger if logger is not None else logging.getLogger(__name__)
1538
+
1539
+ self.init_parser()
1540
+
1541
+ sec_run = Run()
1542
+ self.archive.run.append(sec_run)
1543
+
1544
+ sec_run.program = Program(name='turbomole')
1545
+
1546
+ for header in ['program_version', 'x_turbomole_nodename']:
1547
+ value = [
1548
+ module_run.get(header)
1549
+ for module_run in self.out_parser.get('module_run', [])
1550
+ ]
1551
+ if len(set(value)) > 1:
1552
+ self.logger.warning('Multiple values found for header.')
1553
+ if value:
1554
+ if header == 'program_version':
1555
+ sec_run.program.version = value[0]
1556
+ else:
1557
+ setattr(sec_run, header, value[0])
1558
+
1559
+ time = [
1560
+ module_run.get('time')
1561
+ for module_run in self.out_parser.get('module_run', [])
1562
+ ]
1563
+ time = [t for t in time if len(t) == 2]
1564
+ if len(time) > 0:
1565
+ start = datetime.strptime(
1566
+ time[0][0], '%Y-%m-%d %H:%M:%S.%f'
1567
+ ) - datetime.utcfromtimestamp(0)
1568
+ end = datetime.strptime(
1569
+ time[-1][1], '%Y-%m-%d %H:%M:%S.%f'
1570
+ ) - datetime.utcfromtimestamp(0)
1571
+ sec_run.time_run = TimeRun(
1572
+ date_start=start.total_seconds(), date_end=end.total_seconds()
1573
+ )
1574
+
1575
+ for module_run in self.out_parser.get('module_run', []):
1576
+ for name, module in module_run.items():
1577
+ if name.startswith('module_') and module is not None:
1578
+ self.module = module
1579
+
1580
+ sec_method = self.parse_method()
1581
+ sec_system = self.parse_system()
1582
+ sec_scc = self.parse_scc()
1583
+ self.parse_workflow()
1584
+ sec_scc.method_ref = sec_method
1585
+ sec_scc.system_ref = sec_system