nomad-parser-plugins-workflow 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.
- nomad_parser_plugins_workflow-1.0.dist-info/LICENSE +202 -0
- nomad_parser_plugins_workflow-1.0.dist-info/METADATA +319 -0
- nomad_parser_plugins_workflow-1.0.dist-info/RECORD +58 -0
- nomad_parser_plugins_workflow-1.0.dist-info/WHEEL +5 -0
- nomad_parser_plugins_workflow-1.0.dist-info/entry_points.txt +11 -0
- nomad_parser_plugins_workflow-1.0.dist-info/top_level.txt +1 -0
- workflowparsers/__init__.py +314 -0
- workflowparsers/aflow/__init__.py +19 -0
- workflowparsers/aflow/__main__.py +31 -0
- workflowparsers/aflow/metainfo/__init__.py +19 -0
- workflowparsers/aflow/metainfo/aflow.py +1240 -0
- workflowparsers/aflow/parser.py +741 -0
- workflowparsers/asr/__init__.py +19 -0
- workflowparsers/asr/__main__.py +31 -0
- workflowparsers/asr/metainfo/__init__.py +19 -0
- workflowparsers/asr/metainfo/asr.py +306 -0
- workflowparsers/asr/parser.py +266 -0
- workflowparsers/atomate/__init__.py +19 -0
- workflowparsers/atomate/__main__.py +31 -0
- workflowparsers/atomate/metainfo/__init__.py +19 -0
- workflowparsers/atomate/metainfo/atomate.py +395 -0
- workflowparsers/atomate/parser.py +357 -0
- workflowparsers/elastic/__init__.py +19 -0
- workflowparsers/elastic/__main__.py +31 -0
- workflowparsers/elastic/metainfo/__init__.py +19 -0
- workflowparsers/elastic/metainfo/elastic.py +364 -0
- workflowparsers/elastic/parser.py +798 -0
- workflowparsers/fhivibes/__init__.py +19 -0
- workflowparsers/fhivibes/__main__.py +31 -0
- workflowparsers/fhivibes/metainfo/__init__.py +19 -0
- workflowparsers/fhivibes/metainfo/fhi_vibes.py +898 -0
- workflowparsers/fhivibes/parser.py +566 -0
- workflowparsers/lobster/__init__.py +19 -0
- workflowparsers/lobster/__main__.py +31 -0
- workflowparsers/lobster/metainfo/__init__.py +19 -0
- workflowparsers/lobster/metainfo/lobster.py +446 -0
- workflowparsers/lobster/parser.py +618 -0
- workflowparsers/phonopy/__init__.py +19 -0
- workflowparsers/phonopy/__main__.py +31 -0
- workflowparsers/phonopy/calculator.py +260 -0
- workflowparsers/phonopy/metainfo/__init__.py +19 -0
- workflowparsers/phonopy/metainfo/phonopy.py +83 -0
- workflowparsers/phonopy/parser.py +583 -0
- workflowparsers/quantum_espresso_epw/__init__.py +19 -0
- workflowparsers/quantum_espresso_epw/__main__.py +31 -0
- workflowparsers/quantum_espresso_epw/metainfo/__init__.py +19 -0
- workflowparsers/quantum_espresso_epw/metainfo/quantum_espresso_epw.py +579 -0
- workflowparsers/quantum_espresso_epw/parser.py +583 -0
- workflowparsers/quantum_espresso_phonon/__init__.py +19 -0
- workflowparsers/quantum_espresso_phonon/__main__.py +31 -0
- workflowparsers/quantum_espresso_phonon/metainfo/__init__.py +19 -0
- workflowparsers/quantum_espresso_phonon/metainfo/quantum_espresso_phonon.py +389 -0
- workflowparsers/quantum_espresso_phonon/parser.py +483 -0
- workflowparsers/quantum_espresso_xspectra/__init__.py +19 -0
- workflowparsers/quantum_espresso_xspectra/__main__.py +31 -0
- workflowparsers/quantum_espresso_xspectra/metainfo/__init__.py +19 -0
- workflowparsers/quantum_espresso_xspectra/metainfo/quantum_espresso_xspectra.py +290 -0
- workflowparsers/quantum_espresso_xspectra/parser.py +586 -0
|
@@ -0,0 +1,586 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright The NOMAD Authors.
|
|
3
|
+
#
|
|
4
|
+
# This file is part of NOMAD.
|
|
5
|
+
# See https://nomad-lab.eu for further info.
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
#
|
|
19
|
+
import logging
|
|
20
|
+
import os
|
|
21
|
+
import numpy as np
|
|
22
|
+
from datetime import datetime
|
|
23
|
+
|
|
24
|
+
from nomad.units import ureg
|
|
25
|
+
from nomad.parsing.file_parser import TextParser, Quantity, DataTextParser
|
|
26
|
+
from runschema.run import Run, Program, TimeRun
|
|
27
|
+
from runschema.method import (
|
|
28
|
+
Method,
|
|
29
|
+
AtomParameters,
|
|
30
|
+
Electronic,
|
|
31
|
+
Smearing,
|
|
32
|
+
Photon,
|
|
33
|
+
CoreHoleSpectra,
|
|
34
|
+
)
|
|
35
|
+
from runschema.system import System, Atoms
|
|
36
|
+
from runschema.calculation import Calculation, Spectra
|
|
37
|
+
from simulationworkflowschema import SinglePoint
|
|
38
|
+
|
|
39
|
+
from .metainfo.quantum_espresso_xspectra import (
|
|
40
|
+
x_qe_xspectra_input,
|
|
41
|
+
x_qe_xspectra_n_parallel,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
re_f = r'[-+]?\d+\.\d*(?:[Ee][-+]\d+)?'
|
|
46
|
+
re_n = r'[\n\r]'
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class MainfileParser(TextParser):
|
|
50
|
+
def init_quantities(self):
|
|
51
|
+
def to_positions(block):
|
|
52
|
+
labels, positions = [], []
|
|
53
|
+
for line in block.strip().splitlines():
|
|
54
|
+
line = line.split()
|
|
55
|
+
if not line:
|
|
56
|
+
continue
|
|
57
|
+
labels.append(line[1].strip(r'+|-'))
|
|
58
|
+
positions.append(line[-4:-1])
|
|
59
|
+
return labels, np.array(positions, np.dtype(np.float64))
|
|
60
|
+
|
|
61
|
+
def to_val(val_in):
|
|
62
|
+
val = [v.strip().lower() for v in val_in.strip().split(':')]
|
|
63
|
+
val[1] = val[1] == 'true' if val[1] in ['true', 'false'] else val[1]
|
|
64
|
+
return val
|
|
65
|
+
|
|
66
|
+
self._quantities = [
|
|
67
|
+
Quantity('program_version', r'Program XSpectra v.(\S+)', dtype=str),
|
|
68
|
+
Quantity(
|
|
69
|
+
'start_time', r'starts on +(\w+) at (.+)', flatten=False, dtype=str
|
|
70
|
+
),
|
|
71
|
+
Quantity(
|
|
72
|
+
'input',
|
|
73
|
+
r'Reading input_file\s+\-+([\s\S]+?)\-{50}',
|
|
74
|
+
sub_parser=TextParser(
|
|
75
|
+
quantities=[
|
|
76
|
+
Quantity(
|
|
77
|
+
'x_qe_xspectra_calculation',
|
|
78
|
+
r'calculation\: *(.+)',
|
|
79
|
+
flatten=False,
|
|
80
|
+
dtype=str,
|
|
81
|
+
),
|
|
82
|
+
Quantity(
|
|
83
|
+
'x_qe_xspectra_xepsilon',
|
|
84
|
+
rf'xepsilon +\[.+?\]\: +({re_f}) +({re_f}) +({re_f})',
|
|
85
|
+
dtype=np.dtype(np.float64),
|
|
86
|
+
),
|
|
87
|
+
Quantity(
|
|
88
|
+
'x_qe_xspectra_xonly_plot',
|
|
89
|
+
r'xonly_plot\: *(\S)',
|
|
90
|
+
str_operation=lambda x: x == 'T',
|
|
91
|
+
),
|
|
92
|
+
Quantity(
|
|
93
|
+
'x_qe_xspectra_filecore',
|
|
94
|
+
r'filecore \(core-wavefunction file\): *(\S+)',
|
|
95
|
+
dtype=str,
|
|
96
|
+
),
|
|
97
|
+
Quantity(
|
|
98
|
+
'x_qe_xspectra_main_plot_parameters',
|
|
99
|
+
rf'main plot parameters\:\s+([\s\S]+?){re_n} *{re_n}',
|
|
100
|
+
sub_parser=TextParser(
|
|
101
|
+
quantities=[
|
|
102
|
+
Quantity(
|
|
103
|
+
'key_val',
|
|
104
|
+
r'(\w+) *\[*.*\]*(\:) *(\S+)',
|
|
105
|
+
repeats=True,
|
|
106
|
+
str_operation=to_val,
|
|
107
|
+
)
|
|
108
|
+
]
|
|
109
|
+
),
|
|
110
|
+
),
|
|
111
|
+
]
|
|
112
|
+
),
|
|
113
|
+
),
|
|
114
|
+
Quantity(
|
|
115
|
+
'scf',
|
|
116
|
+
r'(Reading SCF save directory.+\s+\-+[\s\S]+?)\-{50}',
|
|
117
|
+
sub_parser=TextParser(
|
|
118
|
+
quantities=[
|
|
119
|
+
Quantity(
|
|
120
|
+
'x_qe_xspectra_save_directory',
|
|
121
|
+
r'Reading .*data from directory\:\s+(\S+)',
|
|
122
|
+
dtype=str,
|
|
123
|
+
),
|
|
124
|
+
Quantity('file', r'file *(\S+?):', dtype=str, repeats=True),
|
|
125
|
+
Quantity(
|
|
126
|
+
'wafefunctions',
|
|
127
|
+
r'wavefunctions\(.+\) * (.+)',
|
|
128
|
+
),
|
|
129
|
+
Quantity(
|
|
130
|
+
'n_parallel',
|
|
131
|
+
r'Parallelization info\s+\-+\s+sticks\:.+\s+'
|
|
132
|
+
r'((?:\w+ +\d+ +\d+ +\d+ +\d+ +\d+ +\d+\s+)+)',
|
|
133
|
+
str_operation=lambda x: [
|
|
134
|
+
line.strip().split()[1:]
|
|
135
|
+
for line in x.strip().splitlines()
|
|
136
|
+
],
|
|
137
|
+
dtype=np.dtype(np.int32),
|
|
138
|
+
),
|
|
139
|
+
]
|
|
140
|
+
),
|
|
141
|
+
),
|
|
142
|
+
Quantity(
|
|
143
|
+
'fermi_energy',
|
|
144
|
+
r'Getting the Fermi energy\s+\-+([\s\S]+?)\-{50}',
|
|
145
|
+
sub_parser=TextParser(
|
|
146
|
+
quantities=[
|
|
147
|
+
Quantity('homo', rf'ehomo *\[eV\]: *{re_f}', dtype=np.float64),
|
|
148
|
+
Quantity('lumo', rf'elumo *\[eV\]: *{re_f}', dtype=np.float64),
|
|
149
|
+
Quantity('ef', rf'ef *\[eV\]: *{re_f}', dtype=np.float64),
|
|
150
|
+
]
|
|
151
|
+
),
|
|
152
|
+
),
|
|
153
|
+
Quantity(
|
|
154
|
+
'bravais_lattice_index',
|
|
155
|
+
r'bravais\-lattice index *= *(\d+)',
|
|
156
|
+
dtype=np.int32,
|
|
157
|
+
),
|
|
158
|
+
Quantity(
|
|
159
|
+
'lattice_parameter',
|
|
160
|
+
rf'lattice parameter \(alat\) *= *({re_f}) *a\.u\.',
|
|
161
|
+
dtype=np.float64,
|
|
162
|
+
),
|
|
163
|
+
Quantity(
|
|
164
|
+
'unit_cell_volume',
|
|
165
|
+
rf'unit\-cell volume *= *({re_f}) \(a\.u\.\)\^3',
|
|
166
|
+
dtype=np.float64,
|
|
167
|
+
unit=ureg.bohr**3,
|
|
168
|
+
),
|
|
169
|
+
Quantity('n_atoms_cell', r'number of atoms/cell *= *(\d+)', dtype=np.int32),
|
|
170
|
+
Quantity(
|
|
171
|
+
'n_atomic_types', r'number of atomic types *= *(\d+)', dtype=np.int32
|
|
172
|
+
),
|
|
173
|
+
Quantity(
|
|
174
|
+
'kinetic_energy_cutoff',
|
|
175
|
+
rf'kinetic\-energy cut\-off *= *({re_f}) *Ry',
|
|
176
|
+
dtype=np.float64,
|
|
177
|
+
unit=ureg.rydberg,
|
|
178
|
+
),
|
|
179
|
+
Quantity(
|
|
180
|
+
'charge_density_cutoff',
|
|
181
|
+
rf'charge density cut\-off *= *({re_f}) *Ry',
|
|
182
|
+
dtype=np.float64,
|
|
183
|
+
unit=ureg.rydberg,
|
|
184
|
+
),
|
|
185
|
+
Quantity(
|
|
186
|
+
'convergence_threshold',
|
|
187
|
+
rf'convergence threshold *= *({re_f})',
|
|
188
|
+
dtype=np.float64,
|
|
189
|
+
),
|
|
190
|
+
Quantity('beta', rf'beta *= *({re_f})', dtype=np.float64),
|
|
191
|
+
Quantity(
|
|
192
|
+
'exchange_correlation', r'Exchange\-correlation *= *(.+)', dtype=str
|
|
193
|
+
),
|
|
194
|
+
Quantity(
|
|
195
|
+
'n_kohn_sham_states',
|
|
196
|
+
r'number of Kohn\-Sham states *= *(\d+)',
|
|
197
|
+
dtype=np.int32,
|
|
198
|
+
),
|
|
199
|
+
Quantity(
|
|
200
|
+
'crystal_axes',
|
|
201
|
+
rf'crystal axes: \(cart\. coord\. in units of alat\)\s*'
|
|
202
|
+
rf'((?:a\(\d+\) *= *\( *{re_f} *{re_f} *{re_f} *\)\s*)+)',
|
|
203
|
+
str_operation=lambda x: np.array(
|
|
204
|
+
[line.strip().split()[-4:-1] for line in x.strip().splitlines()],
|
|
205
|
+
dtype=np.dtype(np.float64),
|
|
206
|
+
),
|
|
207
|
+
),
|
|
208
|
+
Quantity(
|
|
209
|
+
'pseudopot',
|
|
210
|
+
rf'(PseudoPot\. #[\s\S]+?){re_n} *{re_n}',
|
|
211
|
+
repeats=True,
|
|
212
|
+
sub_parser=TextParser(
|
|
213
|
+
quantities=[
|
|
214
|
+
Quantity('element', r'for ([A-Z][a-z]*)'),
|
|
215
|
+
Quantity('file', r' read from file\:\s+(\S+)', dtype=str),
|
|
216
|
+
Quantity('md5_check_sum', r'MD5 check sum\: +(\S+)', dtype=str),
|
|
217
|
+
Quantity('type', r'Pseudo is (.+?),', flatten=False, dtype=str),
|
|
218
|
+
Quantity('zval', rf'Zval *= *({re_f})', dtype=np.float64),
|
|
219
|
+
Quantity(
|
|
220
|
+
'n_radial_grid_points',
|
|
221
|
+
r'Using radial grid of *(\d+) points',
|
|
222
|
+
dtype=np.int32,
|
|
223
|
+
),
|
|
224
|
+
Quantity(
|
|
225
|
+
'n_beta_functions', r'(\d+) beta functions', dtype=np.int32
|
|
226
|
+
),
|
|
227
|
+
Quantity(
|
|
228
|
+
'l', r'l\(\d+\) *= *(\d+)', dtype=np.int32, repeats=True
|
|
229
|
+
),
|
|
230
|
+
Quantity(
|
|
231
|
+
'n_q_coefficients',
|
|
232
|
+
r'Q\(r\) pseudized with (\d+) coefficients',
|
|
233
|
+
dtype=np.int32,
|
|
234
|
+
),
|
|
235
|
+
Quantity(
|
|
236
|
+
'q_coefficients',
|
|
237
|
+
rf'rinner *= *((?:{re_f}\s+)+)',
|
|
238
|
+
str_operation=lambda x: x.strip().split(),
|
|
239
|
+
dytpe=np.dtype(np.float64),
|
|
240
|
+
),
|
|
241
|
+
]
|
|
242
|
+
),
|
|
243
|
+
),
|
|
244
|
+
Quantity(
|
|
245
|
+
'cartesian_axes',
|
|
246
|
+
rf'positions \(alat units\)\s+((?:\d+ +[A-Z][a-z]*.+{re_f} +{re_f} +{re_f} +\)\s*)+)',
|
|
247
|
+
str_operation=to_positions,
|
|
248
|
+
),
|
|
249
|
+
Quantity('n_kpoints', r'number of k points *= *(\d+)', dtype=np.int32),
|
|
250
|
+
Quantity('smearing', rf'(\S+) smearing, width \(Ry\) *= *({re_f})'),
|
|
251
|
+
Quantity(
|
|
252
|
+
'dense_grid',
|
|
253
|
+
rf'(?:G\s+cutoff\s*=\s*({re_f})\s*\(|Dense\s*grid:)\s*(\d+)\s*'
|
|
254
|
+
r'G\-vectors\)*\s*FFT\s+(?:dimensions|grid):\s*\(\s*([\d ,]+)\)',
|
|
255
|
+
str_operation=lambda x: x.replace(',', ' ').split(),
|
|
256
|
+
),
|
|
257
|
+
Quantity(
|
|
258
|
+
'smooth_grid',
|
|
259
|
+
rf'(?:G\s+cutoff\s*=\s*({re_f})\s*\(|Smooth\s*grid:)\s*(\d+)\s*'
|
|
260
|
+
r'G\-vectors\s*(?:smooth grid|FFT dimensions)\s*:\s*\(\s*([\d ,]+)\)',
|
|
261
|
+
str_operation=lambda x: x.replace(',', ' ').split(),
|
|
262
|
+
),
|
|
263
|
+
Quantity(
|
|
264
|
+
'potential_file',
|
|
265
|
+
r'The potential is recalculated from file :\s+(\S+)',
|
|
266
|
+
dtype=str,
|
|
267
|
+
),
|
|
268
|
+
Quantity(
|
|
269
|
+
'negative rho',
|
|
270
|
+
rf'negative rho \(up, down\):\s*({re_f})\s*({re_f})',
|
|
271
|
+
dtype=np.dtype(np.float64),
|
|
272
|
+
),
|
|
273
|
+
Quantity(
|
|
274
|
+
'xanes',
|
|
275
|
+
r'Starting XANES calculation([\s\S]+?xanes +: +)',
|
|
276
|
+
sub_parser=TextParser(
|
|
277
|
+
quantities=[
|
|
278
|
+
Quantity(
|
|
279
|
+
'algorithm',
|
|
280
|
+
r'\s*Method of calculation based on the\s*([a-zA-Z\s]*) algorithm',
|
|
281
|
+
repeats=False,
|
|
282
|
+
),
|
|
283
|
+
Quantity(
|
|
284
|
+
'step_1',
|
|
285
|
+
r'(Begin STEP 1 [\s\S]+?End STEP 1)',
|
|
286
|
+
sub_parser=TextParser(
|
|
287
|
+
quantities=[
|
|
288
|
+
Quantity(
|
|
289
|
+
'k_calculation',
|
|
290
|
+
rf'((?:k\-point *# *1:|k\-point *:*1\s)[\s\S]+?){re_n} *{re_n}',
|
|
291
|
+
repeats=True,
|
|
292
|
+
sub_parser=TextParser(
|
|
293
|
+
quantities=[
|
|
294
|
+
Quantity(
|
|
295
|
+
'k_point',
|
|
296
|
+
rf'{re_f},* +{re_f},* +{re_f}',
|
|
297
|
+
dtype=np.dtype(np.float64),
|
|
298
|
+
),
|
|
299
|
+
Quantity(
|
|
300
|
+
'norm_initial_vector',
|
|
301
|
+
rf'[Nn]orm.+?vector[=:] *{re_f}',
|
|
302
|
+
dtype=np.float64,
|
|
303
|
+
),
|
|
304
|
+
Quantity(
|
|
305
|
+
'converged',
|
|
306
|
+
r'(=\> CONVERGED)',
|
|
307
|
+
str_operation=lambda x: True,
|
|
308
|
+
),
|
|
309
|
+
Quantity(
|
|
310
|
+
'converged',
|
|
311
|
+
r'(not converged)',
|
|
312
|
+
str_operation=lambda x: False,
|
|
313
|
+
),
|
|
314
|
+
Quantity(
|
|
315
|
+
'n_iter_error',
|
|
316
|
+
rf'iter +(\d+) with error= *{re_f}',
|
|
317
|
+
),
|
|
318
|
+
Quantity(
|
|
319
|
+
'n_iter_error',
|
|
320
|
+
rf'final error after *(\d+) *iterations\: (.+)',
|
|
321
|
+
),
|
|
322
|
+
]
|
|
323
|
+
),
|
|
324
|
+
)
|
|
325
|
+
]
|
|
326
|
+
),
|
|
327
|
+
),
|
|
328
|
+
Quantity(
|
|
329
|
+
'step_2',
|
|
330
|
+
r'(Begin STEP 2 [\s\S]+?End STEP 2)',
|
|
331
|
+
sub_parser=TextParser(
|
|
332
|
+
quantities=[
|
|
333
|
+
Quantity(
|
|
334
|
+
'energy_zero',
|
|
335
|
+
rf'(?:energy\-zero of the spectrum|xe0) \[eV\]: *({re_f})',
|
|
336
|
+
dtype=np.float64,
|
|
337
|
+
unit='eV',
|
|
338
|
+
),
|
|
339
|
+
Quantity(
|
|
340
|
+
'xemin',
|
|
341
|
+
rf'xemin \[eV\]: *({re_f})',
|
|
342
|
+
dtype=np.float64,
|
|
343
|
+
unit='eV',
|
|
344
|
+
),
|
|
345
|
+
Quantity(
|
|
346
|
+
'xemax',
|
|
347
|
+
rf'xemax \[eV\]: *({re_f})',
|
|
348
|
+
dtype=np.float64,
|
|
349
|
+
unit='eV',
|
|
350
|
+
),
|
|
351
|
+
Quantity(
|
|
352
|
+
'xnepoint', r'xnepoint: *(\d+)', dtype=np.int32
|
|
353
|
+
),
|
|
354
|
+
Quantity(
|
|
355
|
+
'broadening_parameter',
|
|
356
|
+
rf'constant broadening parameter \[eV\]: *{re_f}',
|
|
357
|
+
dtype=np.float64,
|
|
358
|
+
),
|
|
359
|
+
Quantity(
|
|
360
|
+
'energy_core_level',
|
|
361
|
+
rf'Core level energy \[eV\]: *{re_f}',
|
|
362
|
+
dtype=np.float64,
|
|
363
|
+
unit='eV',
|
|
364
|
+
),
|
|
365
|
+
Quantity(
|
|
366
|
+
'file',
|
|
367
|
+
r'Cross-section successfully written in (\S+)',
|
|
368
|
+
),
|
|
369
|
+
]
|
|
370
|
+
),
|
|
371
|
+
),
|
|
372
|
+
]
|
|
373
|
+
),
|
|
374
|
+
),
|
|
375
|
+
]
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
class QuantumEspressoXSpectraParser:
|
|
379
|
+
def __init__(self):
|
|
380
|
+
self.mainfile_parser = MainfileParser()
|
|
381
|
+
self.xanesdata_parser = DataTextParser()
|
|
382
|
+
|
|
383
|
+
def parse_system(self):
|
|
384
|
+
sec_run = self.archive.run[-1]
|
|
385
|
+
sec_system = System()
|
|
386
|
+
sec_run.system.append(sec_system)
|
|
387
|
+
sec_atoms = Atoms()
|
|
388
|
+
sec_system.atoms = sec_atoms
|
|
389
|
+
alat = self.mainfile_parser.get('lattice_parameter', 1)
|
|
390
|
+
crystal_axes = self.mainfile_parser.crystal_axes
|
|
391
|
+
if crystal_axes is not None:
|
|
392
|
+
sec_atoms.lattice_vectors = crystal_axes * alat * ureg.bohr
|
|
393
|
+
cartesian_axes = self.mainfile_parser.cartesian_axes
|
|
394
|
+
if cartesian_axes is not None:
|
|
395
|
+
sec_atoms.labels = self.mainfile_parser.cartesian_axes[0]
|
|
396
|
+
sec_atoms.positions = (
|
|
397
|
+
self.mainfile_parser.cartesian_axes[1] * alat * ureg.bohr
|
|
398
|
+
)
|
|
399
|
+
sec_atoms.periodic = [True, True, True]
|
|
400
|
+
|
|
401
|
+
system_keys = [
|
|
402
|
+
'bravais_lattice_index',
|
|
403
|
+
'lattice_parameter',
|
|
404
|
+
'unit_cell_volume',
|
|
405
|
+
'n_atoms_cell',
|
|
406
|
+
'n_atomic_sites',
|
|
407
|
+
]
|
|
408
|
+
for key in system_keys:
|
|
409
|
+
setattr(sec_system, f'x_qe_xspectra_{key}', self.mainfile_parser.get(key))
|
|
410
|
+
|
|
411
|
+
def parse_method(self):
|
|
412
|
+
scf = self.mainfile_parser.scf
|
|
413
|
+
|
|
414
|
+
sec_run = self.archive.run[-1]
|
|
415
|
+
sec_method = Method()
|
|
416
|
+
sec_run.method.append(sec_method)
|
|
417
|
+
|
|
418
|
+
# Smearing
|
|
419
|
+
smearing = self.mainfile_parser.smearing
|
|
420
|
+
if smearing is not None:
|
|
421
|
+
smearing_map = {'Methfessel-Paxton': 'methfessel-paxton'}
|
|
422
|
+
sec_method.electronic = Electronic(
|
|
423
|
+
smearing=Smearing(
|
|
424
|
+
kind=smearing_map.get(smearing[0]),
|
|
425
|
+
width=(smearing[1] * ureg.Ry).to_base_units().magnitude,
|
|
426
|
+
)
|
|
427
|
+
)
|
|
428
|
+
|
|
429
|
+
# Pseudopotentials
|
|
430
|
+
# TODO should be here or in the DFT entry??
|
|
431
|
+
for pseudopot in self.mainfile_parser.get('pseudopot', []):
|
|
432
|
+
sec_atom_parameters = AtomParameters()
|
|
433
|
+
sec_method.atom_parameters.append(sec_atom_parameters)
|
|
434
|
+
sec_atom_parameters.label = pseudopot.element
|
|
435
|
+
sec_atom_parameters.n_valence_electrons = pseudopot.zval
|
|
436
|
+
atom_keys = [
|
|
437
|
+
'file',
|
|
438
|
+
'md5_check_sum',
|
|
439
|
+
'type',
|
|
440
|
+
'n_radial_grid_points',
|
|
441
|
+
'n_l',
|
|
442
|
+
'l',
|
|
443
|
+
'n_q_coefficients',
|
|
444
|
+
'q_coefficients',
|
|
445
|
+
]
|
|
446
|
+
for key in atom_keys:
|
|
447
|
+
setattr(sec_atom_parameters, f'x_qe_xspectra_{key}', pseudopot.get(key))
|
|
448
|
+
|
|
449
|
+
# code-specific
|
|
450
|
+
if scf is not None and scf.n_parallel is not None:
|
|
451
|
+
sec_method.x_qe_xspectra_n_parallel_sticks = x_qe_xspectra_n_parallel(
|
|
452
|
+
x_qe_xspectra_n_parallel_min=scf.n_parallel[0][:3],
|
|
453
|
+
x_qe_xspectra_n_parallel_max=scf.n_parallel[1][:3],
|
|
454
|
+
x_qe_xspectra_n_parallel_sum=scf.n_parallel[2][:3],
|
|
455
|
+
)
|
|
456
|
+
sec_method.x_qe_xspectra_n_parallel_g_vectors = x_qe_xspectra_n_parallel(
|
|
457
|
+
x_qe_xspectra_n_parallel_min=scf.n_parallel[0][3:],
|
|
458
|
+
x_qe_xspectra_n_parallel_max=scf.n_parallel[1][3:],
|
|
459
|
+
x_qe_xspectra_n_parallel_sum=scf.n_parallel[2][3:],
|
|
460
|
+
)
|
|
461
|
+
|
|
462
|
+
method_keys = [
|
|
463
|
+
'kinetic_energy_cutoff',
|
|
464
|
+
'charge_density_cutoff',
|
|
465
|
+
'convergence_threshold',
|
|
466
|
+
'beta',
|
|
467
|
+
'exchange_correlation',
|
|
468
|
+
'n_kohn_sham_states',
|
|
469
|
+
]
|
|
470
|
+
for key in method_keys:
|
|
471
|
+
setattr(sec_method, f'x_qe_xspectra_{key}', self.mainfile_parser.get(key))
|
|
472
|
+
|
|
473
|
+
# Photon
|
|
474
|
+
sec_photon = Photon()
|
|
475
|
+
sec_method.photon.append(sec_photon)
|
|
476
|
+
if self.mainfile_parser.input.get('x_qe_xspectra_calculation', '') == 'hpsi':
|
|
477
|
+
self.logger.warning(
|
|
478
|
+
'Calculation ran in the debug option HPSI. Please, check your upload.'
|
|
479
|
+
)
|
|
480
|
+
return
|
|
481
|
+
sec_photon.multipole_type = self.mainfile_parser.input.get(
|
|
482
|
+
'x_qe_xspectra_calculation', ''
|
|
483
|
+
).split('_')[1]
|
|
484
|
+
sec_photon.polarization = self.mainfile_parser.input.get(
|
|
485
|
+
'x_qe_xspectra_xepsilon', []
|
|
486
|
+
)
|
|
487
|
+
|
|
488
|
+
# Core-hole
|
|
489
|
+
sec_method_core = Method()
|
|
490
|
+
sec_run.method.append(sec_method_core)
|
|
491
|
+
if sec_run.m_xpath('method[0]'):
|
|
492
|
+
sec_method_core.starting_method_ref = sec_run.method[0]
|
|
493
|
+
sec_core_hole = CoreHoleSpectra()
|
|
494
|
+
sec_method_core.core_hole = sec_core_hole
|
|
495
|
+
sec_core_hole.mode = (
|
|
496
|
+
'absorption' # XSPECTRA can only handle XAS/XANES -> absorption
|
|
497
|
+
)
|
|
498
|
+
sec_core_hole.solver = self.mainfile_parser.xanes.get('algorithm', [])[0]
|
|
499
|
+
# TODO talk with devs to get the edge info
|
|
500
|
+
# sec_core_hole.edge
|
|
501
|
+
if (
|
|
502
|
+
sec_run.x_qe_xspectra_input.x_qe_xspectra_main_plot_parameters.get(
|
|
503
|
+
'gamma_mode'
|
|
504
|
+
)
|
|
505
|
+
== 'constant'
|
|
506
|
+
):
|
|
507
|
+
sec_core_hole.broadening = (
|
|
508
|
+
sec_run.x_qe_xspectra_input.x_qe_xspectra_main_plot_parameters.get(
|
|
509
|
+
'using'
|
|
510
|
+
)
|
|
511
|
+
)
|
|
512
|
+
|
|
513
|
+
def parse_scc(self):
|
|
514
|
+
sec_run = self.archive.run[-1]
|
|
515
|
+
xanes_file = self.mainfile_parser.xanes.get('step_2', {}).get('file')
|
|
516
|
+
if xanes_file:
|
|
517
|
+
self.xanesdata_parser.mainfile = os.path.join(self.maindir, xanes_file)
|
|
518
|
+
data = self.xanesdata_parser.data
|
|
519
|
+
|
|
520
|
+
sec_scc = Calculation()
|
|
521
|
+
sec_run.calculation.append(sec_scc)
|
|
522
|
+
sec_scc.system_ref = sec_run.system[-1]
|
|
523
|
+
sec_scc.method_ref = sec_run.method[-1]
|
|
524
|
+
|
|
525
|
+
sec_spectra = Spectra()
|
|
526
|
+
sec_scc.spectra.append(sec_spectra)
|
|
527
|
+
for key, val in self.mainfile_parser.xanes.get('step_2', {}).items():
|
|
528
|
+
if key != 'file':
|
|
529
|
+
setattr(sec_spectra, f'x_qe_xspectra_{key}', val)
|
|
530
|
+
sec_spectra.type = (
|
|
531
|
+
self.mainfile_parser.input.get('x_qe_xspectra_calculation', '')
|
|
532
|
+
.split('_')[0]
|
|
533
|
+
.upper()
|
|
534
|
+
)
|
|
535
|
+
sec_spectra.n_energies = data.shape[0]
|
|
536
|
+
sec_spectra.excitation_energies = data[:, 0] * ureg.eV
|
|
537
|
+
# TODO check with devs, not sure if this expression is correct or whether it is simply about renormalizing by the unit_cell_volume
|
|
538
|
+
sec_spectra.intensities = data[:, 1]
|
|
539
|
+
sec_spectra.intensities_units = 'F*m^2/J'
|
|
540
|
+
# unit_cell_volume = self.mainfile_parser.get('unit_cell_volume').magnitude # in bohr^3
|
|
541
|
+
# sec_spectra.intensities = scipy.constants.fine_structure * data[:, 1] / (energies * unit_cell_volume)
|
|
542
|
+
|
|
543
|
+
def parse(self, filepath, archive, logger):
|
|
544
|
+
self.logger = logging.getLogger(__name__) if logger is None else logger
|
|
545
|
+
self.archive = archive
|
|
546
|
+
self.filepath = os.path.abspath(filepath)
|
|
547
|
+
self.maindir = os.path.dirname(self.filepath)
|
|
548
|
+
|
|
549
|
+
self.mainfile_parser.mainfile = self.filepath
|
|
550
|
+
|
|
551
|
+
sec_run = Run()
|
|
552
|
+
self.archive.run.append(sec_run)
|
|
553
|
+
sec_run.program = Program(
|
|
554
|
+
name='Quantum ESPRESSO XSPECTRA',
|
|
555
|
+
version=self.mainfile_parser.get('program_version', ''),
|
|
556
|
+
)
|
|
557
|
+
|
|
558
|
+
start_time = self.mainfile_parser.start_time
|
|
559
|
+
if start_time is not None:
|
|
560
|
+
date = datetime.strptime(
|
|
561
|
+
start_time.strip().replace(' ', ''), '%d%b%Y%H:%M:%S'
|
|
562
|
+
)
|
|
563
|
+
sec_run.time_run = TimeRun(
|
|
564
|
+
date_start=(date - datetime.utcfromtimestamp(0)).total_seconds()
|
|
565
|
+
)
|
|
566
|
+
|
|
567
|
+
input = self.mainfile_parser.input
|
|
568
|
+
if input is not None:
|
|
569
|
+
sec_input = x_qe_xspectra_input()
|
|
570
|
+
sec_run.x_qe_xspectra_input = sec_input
|
|
571
|
+
for key, val in input.items():
|
|
572
|
+
if key == 'x_qe_xspectra_main_plot_parameters':
|
|
573
|
+
val = {v[0].strip(): v[1] for v in val.get('key_val', [])}
|
|
574
|
+
setattr(sec_input, key, val)
|
|
575
|
+
|
|
576
|
+
# System
|
|
577
|
+
self.parse_system()
|
|
578
|
+
|
|
579
|
+
# Method
|
|
580
|
+
self.parse_method()
|
|
581
|
+
|
|
582
|
+
# Calculation
|
|
583
|
+
self.parse_scc()
|
|
584
|
+
|
|
585
|
+
# Workflow
|
|
586
|
+
archive.workflow2 = SinglePoint()
|