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.
- electronicparsers/__init__.py +1162 -0
- electronicparsers/abacus/__init__.py +20 -0
- electronicparsers/abacus/__main__.py +32 -0
- electronicparsers/abacus/metainfo/__init__.py +19 -0
- electronicparsers/abacus/metainfo/abacus.py +836 -0
- electronicparsers/abacus/nomad_plugin.yaml +44 -0
- electronicparsers/abacus/parser.py +1975 -0
- electronicparsers/abinit/__init__.py +19 -0
- electronicparsers/abinit/__main__.py +31 -0
- electronicparsers/abinit/metainfo/__init__.py +20 -0
- electronicparsers/abinit/metainfo/abinit.py +871 -0
- electronicparsers/abinit/metainfo/abinit_autogenerated.py +6794 -0
- electronicparsers/abinit/nomad_plugin.yaml +43 -0
- electronicparsers/abinit/parser.py +1922 -0
- electronicparsers/ams/__init__.py +19 -0
- electronicparsers/ams/__main__.py +31 -0
- electronicparsers/ams/metainfo/__init__.py +19 -0
- electronicparsers/ams/metainfo/ams.py +769 -0
- electronicparsers/ams/nomad_plugin.yaml +19 -0
- electronicparsers/ams/parser.py +1849 -0
- electronicparsers/ams/rkf.py +620 -0
- electronicparsers/atk/__init__.py +19 -0
- electronicparsers/atk/__main__.py +31 -0
- electronicparsers/atk/metainfo/__init__.py +19 -0
- electronicparsers/atk/metainfo/atk.py +71 -0
- electronicparsers/atk/nomad_plugin.yaml +34 -0
- electronicparsers/atk/parser.py +388 -0
- electronicparsers/bigdft/__init__.py +19 -0
- electronicparsers/bigdft/__main__.py +31 -0
- electronicparsers/bigdft/metainfo/__init__.py +18 -0
- electronicparsers/bigdft/nomad_plugin.yaml +19 -0
- electronicparsers/bigdft/parser.py +372 -0
- electronicparsers/castep/__init__.py +19 -0
- electronicparsers/castep/__main__.py +31 -0
- electronicparsers/castep/metainfo/__init__.py +19 -0
- electronicparsers/castep/metainfo/castep.py +2481 -0
- electronicparsers/castep/nomad_plugin.yaml +28 -0
- electronicparsers/castep/parser.py +1680 -0
- electronicparsers/charmm/__init__.py +19 -0
- electronicparsers/charmm/__main__.py +31 -0
- electronicparsers/charmm/metainfo/__init__.py +19 -0
- electronicparsers/charmm/metainfo/charmm.py +1931 -0
- electronicparsers/charmm/nomad_plugin.yaml +18 -0
- electronicparsers/charmm/parser.py +61 -0
- electronicparsers/cp2k/__init__.py +19 -0
- electronicparsers/cp2k/__main__.py +31 -0
- electronicparsers/cp2k/metainfo/__init__.py +19 -0
- electronicparsers/cp2k/metainfo/cp2k.py +59185 -0
- electronicparsers/cp2k/metainfo/cp2k_general.py +1014 -0
- electronicparsers/cp2k/nomad_plugin.yaml +49 -0
- electronicparsers/cp2k/parser.py +2324 -0
- electronicparsers/cpmd/__init__.py +19 -0
- electronicparsers/cpmd/__main__.py +31 -0
- electronicparsers/cpmd/metainfo/__init__.py +19 -0
- electronicparsers/cpmd/metainfo/cpmd.py +10733 -0
- electronicparsers/cpmd/metainfo/cpmd_general.py +988 -0
- electronicparsers/cpmd/nomad_plugin.yaml +19 -0
- electronicparsers/cpmd/parser.py +680 -0
- electronicparsers/crystal/__init__.py +19 -0
- electronicparsers/crystal/__main__.py +31 -0
- electronicparsers/crystal/metainfo/__init__.py +19 -0
- electronicparsers/crystal/metainfo/crystal.py +619 -0
- electronicparsers/crystal/nomad_plugin.yaml +36 -0
- electronicparsers/crystal/parser.py +1745 -0
- electronicparsers/dmol3/__init__.py +19 -0
- electronicparsers/dmol3/__main__.py +31 -0
- electronicparsers/dmol3/metainfo/__init__.py +19 -0
- electronicparsers/dmol3/metainfo/dmol3.py +664 -0
- electronicparsers/dmol3/nomad_plugin.yaml +19 -0
- electronicparsers/dmol3/parser.py +750 -0
- electronicparsers/edmft/__init__.py +19 -0
- electronicparsers/edmft/__main__.py +31 -0
- electronicparsers/edmft/metainfo/__init__.py +19 -0
- electronicparsers/edmft/metainfo/edmft.py +96 -0
- electronicparsers/edmft/nomad_plugin.yaml +53 -0
- electronicparsers/edmft/parser.py +912 -0
- electronicparsers/elk/__init__.py +19 -0
- electronicparsers/elk/__main__.py +31 -0
- electronicparsers/elk/metainfo/__init__.py +19 -0
- electronicparsers/elk/metainfo/elk.py +775 -0
- electronicparsers/elk/nomad_plugin.yaml +19 -0
- electronicparsers/elk/parser.py +493 -0
- electronicparsers/exciting/__init__.py +19 -0
- electronicparsers/exciting/__main__.py +31 -0
- electronicparsers/exciting/metainfo/__init__.py +19 -0
- electronicparsers/exciting/metainfo/exciting.py +2942 -0
- electronicparsers/exciting/nomad_plugin.yaml +83 -0
- electronicparsers/exciting/parser.py +3398 -0
- electronicparsers/fhiaims/__init__.py +19 -0
- electronicparsers/fhiaims/__main__.py +31 -0
- electronicparsers/fhiaims/metainfo/__init__.py +19 -0
- electronicparsers/fhiaims/metainfo/fhi_aims.py +1565 -0
- electronicparsers/fhiaims/nomad_plugin.yaml +52 -0
- electronicparsers/fhiaims/parser.py +2582 -0
- electronicparsers/fleur/__init__.py +19 -0
- electronicparsers/fleur/__main__.py +31 -0
- electronicparsers/fleur/metainfo/__init__.py +19 -0
- electronicparsers/fleur/metainfo/fleur.py +623 -0
- electronicparsers/fleur/nomad_plugin.yaml +19 -0
- electronicparsers/fleur/parser.py +952 -0
- electronicparsers/fplo/__init__.py +19 -0
- electronicparsers/fplo/__main__.py +31 -0
- electronicparsers/fplo/metainfo/__init__.py +19 -0
- electronicparsers/fplo/metainfo/fplo.py +188 -0
- electronicparsers/fplo/metainfo/fplo_input_autogenerated.py +2744 -0
- electronicparsers/fplo/metainfo/fplo_temporaries.py +319 -0
- electronicparsers/fplo/nomad_plugin.yaml +19 -0
- electronicparsers/fplo/parser.py +42 -0
- electronicparsers/gamess/__init__.py +19 -0
- electronicparsers/gamess/__main__.py +31 -0
- electronicparsers/gamess/metainfo/__init__.py +19 -0
- electronicparsers/gamess/metainfo/gamess.py +837 -0
- electronicparsers/gamess/nomad_plugin.yaml +19 -0
- electronicparsers/gamess/parser.py +941 -0
- electronicparsers/gaussian/__init__.py +19 -0
- electronicparsers/gaussian/__main__.py +31 -0
- electronicparsers/gaussian/metainfo/__init__.py +19 -0
- electronicparsers/gaussian/metainfo/gaussian.py +1707 -0
- electronicparsers/gaussian/nomad_plugin.yaml +18 -0
- electronicparsers/gaussian/parser.py +1556 -0
- electronicparsers/gpaw/__init__.py +19 -0
- electronicparsers/gpaw/__main__.py +31 -0
- electronicparsers/gpaw/metainfo/__init__.py +19 -0
- electronicparsers/gpaw/metainfo/gpaw.py +214 -0
- electronicparsers/gpaw/nomad_plugin.yaml +19 -0
- electronicparsers/gpaw/parser.py +671 -0
- electronicparsers/magres/__init__.py +19 -0
- electronicparsers/magres/__main__.py +31 -0
- electronicparsers/magres/metainfo/__init__.py +19 -0
- electronicparsers/magres/metainfo/magres.py +110 -0
- electronicparsers/magres/nomad_plugin.yaml +18 -0
- electronicparsers/magres/parser.py +505 -0
- electronicparsers/molcas/__init__.py +19 -0
- electronicparsers/molcas/__main__.py +31 -0
- electronicparsers/molcas/metainfo/__init__.py +19 -0
- electronicparsers/molcas/metainfo/molcas.py +151 -0
- electronicparsers/molcas/nomad_plugin.yaml +19 -0
- electronicparsers/molcas/parser.py +59 -0
- electronicparsers/mopac/__init__.py +19 -0
- electronicparsers/mopac/__main__.py +31 -0
- electronicparsers/mopac/metainfo/__init__.py +19 -0
- electronicparsers/mopac/metainfo/mopac.py +79 -0
- electronicparsers/mopac/nomad_plugin.yaml +19 -0
- electronicparsers/mopac/parser.py +304 -0
- electronicparsers/nwchem/__init__.py +19 -0
- electronicparsers/nwchem/__main__.py +31 -0
- electronicparsers/nwchem/metainfo/__init__.py +19 -0
- electronicparsers/nwchem/metainfo/nwchem.py +487 -0
- electronicparsers/nwchem/nomad_plugin.yaml +19 -0
- electronicparsers/nwchem/parser.py +757 -0
- electronicparsers/ocean/__init__.py +19 -0
- electronicparsers/ocean/__main__.py +31 -0
- electronicparsers/ocean/metainfo/__init__.py +19 -0
- electronicparsers/ocean/metainfo/ocean.py +410 -0
- electronicparsers/ocean/nomad_plugin.yaml +37 -0
- electronicparsers/ocean/parser.py +344 -0
- electronicparsers/octopus/__init__.py +19 -0
- electronicparsers/octopus/__main__.py +31 -0
- electronicparsers/octopus/metainfo/__init__.py +19 -0
- electronicparsers/octopus/metainfo/octopus.py +71 -0
- electronicparsers/octopus/metainfo/octopus_autogenerated.py +11647 -0
- electronicparsers/octopus/nomad_plugin.yaml +41 -0
- electronicparsers/octopus/parser.py +1214 -0
- electronicparsers/onetep/__init__.py +19 -0
- electronicparsers/onetep/__main__.py +31 -0
- electronicparsers/onetep/metainfo/__init__.py +19 -0
- electronicparsers/onetep/metainfo/onetep.py +3443 -0
- electronicparsers/onetep/nomad_plugin.yaml +19 -0
- electronicparsers/onetep/parser.py +577 -0
- electronicparsers/openmx/__init__.py +19 -0
- electronicparsers/openmx/__main__.py +31 -0
- electronicparsers/openmx/metainfo/__init__.py +19 -0
- electronicparsers/openmx/metainfo/openmx.py +24 -0
- electronicparsers/openmx/nomad_plugin.yaml +25 -0
- electronicparsers/openmx/parser.py +918 -0
- electronicparsers/orca/__init__.py +19 -0
- electronicparsers/orca/__main__.py +31 -0
- electronicparsers/orca/metainfo/__init__.py +19 -0
- electronicparsers/orca/metainfo/orca.py +1448 -0
- electronicparsers/orca/nomad_plugin.yaml +19 -0
- electronicparsers/orca/parser.py +1371 -0
- electronicparsers/psi4/__init__.py +19 -0
- electronicparsers/psi4/__main__.py +31 -0
- electronicparsers/psi4/metainfo/__init__.py +19 -0
- electronicparsers/psi4/metainfo/psi4.py +372 -0
- electronicparsers/psi4/nomad_plugin.yaml +27 -0
- electronicparsers/psi4/parser.py +1362 -0
- electronicparsers/qball/__init__.py +19 -0
- electronicparsers/qball/__main__.py +31 -0
- electronicparsers/qball/metainfo/__init__.py +19 -0
- electronicparsers/qball/metainfo/qball.py +27 -0
- electronicparsers/qball/nomad_plugin.yaml +25 -0
- electronicparsers/qball/parser.py +152 -0
- electronicparsers/qbox/__init__.py +19 -0
- electronicparsers/qbox/__main__.py +31 -0
- electronicparsers/qbox/metainfo/__init__.py +19 -0
- electronicparsers/qbox/metainfo/qbox.py +490 -0
- electronicparsers/qbox/nomad_plugin.yaml +19 -0
- electronicparsers/qbox/parser.py +508 -0
- electronicparsers/quantumespresso/__init__.py +19 -0
- electronicparsers/quantumespresso/__main__.py +31 -0
- electronicparsers/quantumespresso/metainfo/__init__.py +19 -0
- electronicparsers/quantumespresso/metainfo/quantum_espresso.py +3296 -0
- electronicparsers/quantumespresso/nomad_plugin.yaml +31 -0
- electronicparsers/quantumespresso/parser.py +3594 -0
- electronicparsers/siesta/__init__.py +19 -0
- electronicparsers/siesta/__main__.py +31 -0
- electronicparsers/siesta/metainfo/__init__.py +19 -0
- electronicparsers/siesta/metainfo/siesta.py +141 -0
- electronicparsers/siesta/metainfo/siesta_autogenerated.py +3365 -0
- electronicparsers/siesta/nomad_plugin.yaml +19 -0
- electronicparsers/siesta/parser.py +607 -0
- electronicparsers/soliddmft/__init__.py +19 -0
- electronicparsers/soliddmft/__main__.py +31 -0
- electronicparsers/soliddmft/metainfo/__init__.py +19 -0
- electronicparsers/soliddmft/metainfo/soliddmft.py +274 -0
- electronicparsers/soliddmft/nomad_plugin.yaml +26 -0
- electronicparsers/soliddmft/parser.py +727 -0
- electronicparsers/tbstudio/__init__.py +19 -0
- electronicparsers/tbstudio/__main__.py +31 -0
- electronicparsers/tbstudio/metainfo/__init__.py +19 -0
- electronicparsers/tbstudio/metainfo/tbstudio.py +34 -0
- electronicparsers/tbstudio/nomad_plugin.yaml +24 -0
- electronicparsers/tbstudio/parser.py +412 -0
- electronicparsers/turbomole/__init__.py +19 -0
- electronicparsers/turbomole/__main__.py +31 -0
- electronicparsers/turbomole/metainfo/__init__.py +19 -0
- electronicparsers/turbomole/metainfo/turbomole.py +727 -0
- electronicparsers/turbomole/nomad_plugin.yaml +18 -0
- electronicparsers/turbomole/parser.py +1585 -0
- electronicparsers/utils/__init__.py +20 -0
- electronicparsers/utils/magres_workflow.py +61 -0
- electronicparsers/utils/utils.py +636 -0
- electronicparsers/vasp/__init__.py +19 -0
- electronicparsers/vasp/__main__.py +31 -0
- electronicparsers/vasp/metainfo/__init__.py +19 -0
- electronicparsers/vasp/metainfo/vasp.py +169 -0
- electronicparsers/vasp/metainfo/vasp_incars.py +3428 -0
- electronicparsers/vasp/metainfo/vasp_incarsOut.py +3428 -0
- electronicparsers/vasp/metainfo/vasp_incarsUnknown.py +86 -0
- electronicparsers/vasp/nomad_plugin.yaml +28 -0
- electronicparsers/vasp/parser.py +2340 -0
- electronicparsers/w2dynamics/__init__.py +19 -0
- electronicparsers/w2dynamics/__main__.py +31 -0
- electronicparsers/w2dynamics/metainfo/__init__.py +19 -0
- electronicparsers/w2dynamics/metainfo/w2dynamics.py +1270 -0
- electronicparsers/w2dynamics/nomad_plugin.yaml +36 -0
- electronicparsers/w2dynamics/parser.py +674 -0
- electronicparsers/wannier90/__init__.py +19 -0
- electronicparsers/wannier90/__main__.py +31 -0
- electronicparsers/wannier90/metainfo/__init__.py +19 -0
- electronicparsers/wannier90/metainfo/wannier90.py +56 -0
- electronicparsers/wannier90/nomad_plugin.yaml +34 -0
- electronicparsers/wannier90/parser.py +671 -0
- electronicparsers/wien2k/__init__.py +19 -0
- electronicparsers/wien2k/__main__.py +31 -0
- electronicparsers/wien2k/metainfo/__init__.py +19 -0
- electronicparsers/wien2k/metainfo/wien2k.py +783 -0
- electronicparsers/wien2k/nomad_plugin.yaml +18 -0
- electronicparsers/wien2k/parser.py +1133 -0
- electronicparsers/yambo/__init__.py +19 -0
- electronicparsers/yambo/__main__.py +31 -0
- electronicparsers/yambo/metainfo/__init__.py +19 -0
- electronicparsers/yambo/metainfo/yambo.py +577 -0
- electronicparsers/yambo/nomad_plugin.yaml +31 -0
- electronicparsers/yambo/parser.py +896 -0
- nomad_parser_plugins_electronic-1.0.dist-info/LICENSE +202 -0
- nomad_parser_plugins_electronic-1.0.dist-info/METADATA +360 -0
- nomad_parser_plugins_electronic-1.0.dist-info/RECORD +272 -0
- nomad_parser_plugins_electronic-1.0.dist-info/WHEEL +5 -0
- nomad_parser_plugins_electronic-1.0.dist-info/entry_points.txt +43 -0
- nomad_parser_plugins_electronic-1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,3398 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright The NOMAD Authors.
|
|
3
|
+
#
|
|
4
|
+
# This file is part of NOMAD.
|
|
5
|
+
# See https://nomad-lab.eu for further info.
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
#
|
|
19
|
+
import numpy as np
|
|
20
|
+
import os
|
|
21
|
+
import re
|
|
22
|
+
import logging
|
|
23
|
+
|
|
24
|
+
from nomad.units import ureg
|
|
25
|
+
from nomad.parsing.file_parser import TextParser, Quantity, XMLParser, DataTextParser
|
|
26
|
+
from runschema.run import Run, Program
|
|
27
|
+
from runschema.method import (
|
|
28
|
+
Method,
|
|
29
|
+
DFT,
|
|
30
|
+
Electronic,
|
|
31
|
+
Smearing,
|
|
32
|
+
XCFunctional,
|
|
33
|
+
Functional,
|
|
34
|
+
Scf,
|
|
35
|
+
BasisSet,
|
|
36
|
+
KMesh,
|
|
37
|
+
FrequencyMesh,
|
|
38
|
+
Screening,
|
|
39
|
+
GW,
|
|
40
|
+
Photon,
|
|
41
|
+
BSE,
|
|
42
|
+
BasisSetContainer,
|
|
43
|
+
OrbitalAPW,
|
|
44
|
+
AtomParameters,
|
|
45
|
+
CoreHoleSpectra,
|
|
46
|
+
)
|
|
47
|
+
from runschema.system import System, Atoms
|
|
48
|
+
from runschema.calculation import (
|
|
49
|
+
Calculation,
|
|
50
|
+
Dos,
|
|
51
|
+
DosValues,
|
|
52
|
+
BandStructure,
|
|
53
|
+
BandEnergies,
|
|
54
|
+
Energy,
|
|
55
|
+
EnergyEntry,
|
|
56
|
+
Charges,
|
|
57
|
+
Forces,
|
|
58
|
+
ForcesEntry,
|
|
59
|
+
ScfIteration,
|
|
60
|
+
BandGap,
|
|
61
|
+
Spectra,
|
|
62
|
+
ElectronicStructureProvenance,
|
|
63
|
+
)
|
|
64
|
+
from simulationworkflowschema import (
|
|
65
|
+
SinglePoint,
|
|
66
|
+
GeometryOptimization,
|
|
67
|
+
GeometryOptimizationMethod,
|
|
68
|
+
)
|
|
69
|
+
from .metainfo.exciting import (
|
|
70
|
+
x_exciting_section_MT_charge_atom,
|
|
71
|
+
x_exciting_section_MT_moment_atom,
|
|
72
|
+
x_exciting_section_spin,
|
|
73
|
+
x_exciting_section_fermi_surface,
|
|
74
|
+
x_exciting_section_atoms_group,
|
|
75
|
+
x_exciting_exciton_calculation,
|
|
76
|
+
x_exciting_epsilon_calculation,
|
|
77
|
+
x_exciting_sigma_calculation,
|
|
78
|
+
x_exciting_loss_calculation,
|
|
79
|
+
x_exciting_freqgrid_parameters,
|
|
80
|
+
x_exciting_selfenergy_parameters,
|
|
81
|
+
x_exciting_wgrid_parameters,
|
|
82
|
+
x_exciting_mixbasis_parameters,
|
|
83
|
+
x_exciting_barecoul_parameters,
|
|
84
|
+
x_exciting_scrcoul_parameters,
|
|
85
|
+
)
|
|
86
|
+
from ..utils import get_files, BeyondDFTWorkflowsParser
|
|
87
|
+
from typing import Any, Iterable
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
re_float = r'[-+]?\d+\.\d*(?:[Ee][-+]\d+)?'
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class LinengyParser(TextParser):
|
|
94
|
+
"""Parse APW basis setup form Wigner-Seitz algorithm."""
|
|
95
|
+
|
|
96
|
+
def __init__(self):
|
|
97
|
+
super().__init__(None)
|
|
98
|
+
|
|
99
|
+
def init_quantities(self):
|
|
100
|
+
line_quantities = [
|
|
101
|
+
Quantity('lo_index', r'l\.o\.\s=\s+(\d+)'),
|
|
102
|
+
Quantity('l', r'l\s=\s+(\d+)'),
|
|
103
|
+
Quantity('order', r'order\s=\s+(\d+)'),
|
|
104
|
+
Quantity('e_param', r':\s+([\d\.\-])'),
|
|
105
|
+
]
|
|
106
|
+
elem = Quantity('element', r'\(([A-Z][a-z]?)\)')
|
|
107
|
+
|
|
108
|
+
apw_line = Quantity(
|
|
109
|
+
'apw_line',
|
|
110
|
+
r'\s+(l\s=.+)\n',
|
|
111
|
+
repeats=True,
|
|
112
|
+
sub_parser=TextParser(quantities=line_quantities),
|
|
113
|
+
)
|
|
114
|
+
lo_line = Quantity(
|
|
115
|
+
'lo_line',
|
|
116
|
+
r'\s+(l\.o\.\s=.+)\n',
|
|
117
|
+
repeats=True,
|
|
118
|
+
sub_parser=TextParser(quantities=line_quantities),
|
|
119
|
+
)
|
|
120
|
+
self._quantities = [
|
|
121
|
+
Quantity(
|
|
122
|
+
'species_block',
|
|
123
|
+
r'(Species[\s\S]+)',
|
|
124
|
+
repeats=True,
|
|
125
|
+
sub_parser=TextParser(quantities=[elem, apw_line, lo_line]),
|
|
126
|
+
)
|
|
127
|
+
]
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class SpeciesParser(TextParser):
|
|
131
|
+
"""Parse all muffin-tin parameters for each species."""
|
|
132
|
+
|
|
133
|
+
def __init__(self):
|
|
134
|
+
self.flag = 'key_val'
|
|
135
|
+
super().__init__(None)
|
|
136
|
+
|
|
137
|
+
def init_quantities(self):
|
|
138
|
+
re_tags = r'([\w\s\.\-\"\=]+)'
|
|
139
|
+
q_key_val = Quantity(self.flag, r'([a-zA-Z]+)\="([\w\.\-\+]+)"', repeats=True)
|
|
140
|
+
q_wf_l = Quantity('l', r'l="(\d)"')
|
|
141
|
+
q_wf = Quantity(
|
|
142
|
+
'wf',
|
|
143
|
+
r'<wf\s([\s\w\=\.\-\"]+)/>',
|
|
144
|
+
sub_parser=TextParser(quantities=[q_key_val]),
|
|
145
|
+
repeats=True,
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
self._quantities = [
|
|
149
|
+
Quantity(
|
|
150
|
+
'sp',
|
|
151
|
+
r'<sp\s([\s\S]+)</sp>', # TODO: check if a species file can contain multiple species
|
|
152
|
+
sub_parser=TextParser(quantities=[q_key_val]),
|
|
153
|
+
),
|
|
154
|
+
Quantity(
|
|
155
|
+
'muffinTin',
|
|
156
|
+
rf'<muffinTin{re_tags}/?>',
|
|
157
|
+
sub_parser=TextParser(quantities=[q_key_val]),
|
|
158
|
+
),
|
|
159
|
+
Quantity(
|
|
160
|
+
'atomicState',
|
|
161
|
+
rf'<atomicState{re_tags}/?>',
|
|
162
|
+
sub_parser=TextParser(quantities=[q_key_val]),
|
|
163
|
+
repeats=True,
|
|
164
|
+
),
|
|
165
|
+
Quantity(
|
|
166
|
+
'default',
|
|
167
|
+
r'(<default[\s\S]+?(</default>|/>))',
|
|
168
|
+
sub_parser=TextParser(quantities=[q_wf, q_key_val]),
|
|
169
|
+
),
|
|
170
|
+
Quantity(
|
|
171
|
+
'custom',
|
|
172
|
+
r'(<custom[\s\S]+?(</custom>|/>))',
|
|
173
|
+
sub_parser=TextParser(quantities=[q_wf, q_key_val]),
|
|
174
|
+
repeats=True,
|
|
175
|
+
),
|
|
176
|
+
Quantity(
|
|
177
|
+
'lo',
|
|
178
|
+
r'(<lo[\s\S]+?</lo>)',
|
|
179
|
+
sub_parser=TextParser(quantities=[q_wf, q_wf_l]),
|
|
180
|
+
repeats=True,
|
|
181
|
+
),
|
|
182
|
+
]
|
|
183
|
+
|
|
184
|
+
def to_dict(self) -> dict:
|
|
185
|
+
def _convert_key_val(key_vals): # TODO: generalize this functionality
|
|
186
|
+
try:
|
|
187
|
+
return {key_val[0]: key_val[1] for key_val in key_vals}
|
|
188
|
+
except IndexError:
|
|
189
|
+
return key_vals
|
|
190
|
+
|
|
191
|
+
def _supplant(val_map: dict[str, Any], flag: str = 'key_val') -> dict[str, Any]:
|
|
192
|
+
supplanted: dict[str, Any] = {}
|
|
193
|
+
for k, v in val_map.items():
|
|
194
|
+
if k == flag:
|
|
195
|
+
return _convert_key_val(v)
|
|
196
|
+
elif isinstance(v, dict):
|
|
197
|
+
supplanted[k] = _supplant(v)
|
|
198
|
+
elif isinstance(v, Iterable):
|
|
199
|
+
supplatend_v: list[dict[str, Any]] = []
|
|
200
|
+
for vv in v:
|
|
201
|
+
if isinstance(vv, dict):
|
|
202
|
+
supplatend_v.append(_supplant(vv))
|
|
203
|
+
else:
|
|
204
|
+
supplatend_v.append(vv)
|
|
205
|
+
supplanted[k] = supplatend_v
|
|
206
|
+
else:
|
|
207
|
+
supplanted[k] = v
|
|
208
|
+
return supplanted
|
|
209
|
+
|
|
210
|
+
results = super().to_dict()
|
|
211
|
+
return _supplant(results)
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
class GWInfoParser(TextParser):
|
|
215
|
+
def __init__(self):
|
|
216
|
+
super().__init__(None)
|
|
217
|
+
|
|
218
|
+
def init_quantities(self):
|
|
219
|
+
self._quantities = []
|
|
220
|
+
|
|
221
|
+
def str_to_frequency(val_in):
|
|
222
|
+
val = [v.split() for v in val_in.split('\n')]
|
|
223
|
+
val = np.transpose(np.array([v for v in val if len(v) == 3], float))
|
|
224
|
+
return dict(
|
|
225
|
+
number=np.array(val[0], dtype=int), values=val[1], weights=val[2]
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
# TODO Read also input parameters here if input_GW.xml does not exist
|
|
229
|
+
|
|
230
|
+
self._quantities.append(
|
|
231
|
+
Quantity(
|
|
232
|
+
'frequency_data',
|
|
233
|
+
r'frequency list:\s*\<\s*#\s*freqs\s*weight\s*>\s*([\d\.Ee\s\-]+)',
|
|
234
|
+
str_operation=str_to_frequency,
|
|
235
|
+
repeats=False,
|
|
236
|
+
)
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
self._quantities.append(
|
|
240
|
+
Quantity(
|
|
241
|
+
'fermi_energy',
|
|
242
|
+
r'\-\s*G0W0.+\-\s*\-+\s*[\s\S]*?Fermi [Ee]nergy\s*[:=](\s*-?[\d\.]+)\s',
|
|
243
|
+
unit=ureg.hartree,
|
|
244
|
+
repeats=False,
|
|
245
|
+
)
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
self._quantities.append(
|
|
249
|
+
Quantity(
|
|
250
|
+
'direct_band_gap',
|
|
251
|
+
r'\-\s*G0W0\s*\-\s*\-+\s*[\s\S]*?Direct BandGap\s*\((?P<__unit>\w+)\)\s*\:(\s*[\d\.]+)\s',
|
|
252
|
+
repeats=False,
|
|
253
|
+
)
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
self._quantities.append(
|
|
257
|
+
Quantity(
|
|
258
|
+
'fundamental_band_gap',
|
|
259
|
+
r'\-\s*G0W0\s*\-\s*\-+\s*[\s\S]*?Fundamental BandGap\s*\((?P<__unit>\w+)\)\s*\:(\s*[\d\.]+)\s',
|
|
260
|
+
repeats=False,
|
|
261
|
+
)
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
self._quantities.append(
|
|
265
|
+
Quantity(
|
|
266
|
+
'optical_band_gap',
|
|
267
|
+
r'\-\s*G0W0\s*\-\s*\-+\s*[\s\S]*?Optical BandGap\s*\((?P<__unit>\w+)\)\s*\:(\s*[\d\.]+)\s',
|
|
268
|
+
repeats=False,
|
|
269
|
+
)
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
class ExcitingEvalqpParser(TextParser):
|
|
274
|
+
def __init__(self):
|
|
275
|
+
super().__init__(None)
|
|
276
|
+
|
|
277
|
+
def init_quantities(self):
|
|
278
|
+
self._quantities = []
|
|
279
|
+
|
|
280
|
+
def str_to_eigenvalue(val_in):
|
|
281
|
+
val = val_in.strip().split('\n')
|
|
282
|
+
kpts = np.array(val[0].split(), dtype=float)
|
|
283
|
+
keys = val[1].split()
|
|
284
|
+
eigs = np.transpose(np.array([v.split() for v in val[2:]], dtype=float))
|
|
285
|
+
eigs = {keys[i]: eigs[i] for i in range(len(keys))}
|
|
286
|
+
return [kpts, eigs]
|
|
287
|
+
|
|
288
|
+
self._quantities.append(
|
|
289
|
+
Quantity(
|
|
290
|
+
'kpoints_eigenvalues',
|
|
291
|
+
r'\s*k\-point \#\s*\d+:\s*([\d\s\.\-]+)([ \w\(\)]+\n)([\s\d\.\-Ee]+)',
|
|
292
|
+
str_operation=str_to_eigenvalue,
|
|
293
|
+
repeats=True,
|
|
294
|
+
)
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
class BandstructureDatParser(DataTextParser):
|
|
299
|
+
def __init__(self, **kwargs):
|
|
300
|
+
super().__init__(**kwargs)
|
|
301
|
+
self._nspin = kwargs.get('nspin', None)
|
|
302
|
+
self._energy_unit = kwargs.get('energy_unit', None)
|
|
303
|
+
|
|
304
|
+
def reset(self):
|
|
305
|
+
super().reset()
|
|
306
|
+
# TODO make a parent clas for bandstructure dat and xml
|
|
307
|
+
self._nspin = None
|
|
308
|
+
self._nkpts_segment = None
|
|
309
|
+
self._neigs_segment = None
|
|
310
|
+
self._vertices = None
|
|
311
|
+
self._distances = None
|
|
312
|
+
self._band_energies = None
|
|
313
|
+
self._band_k_points = None
|
|
314
|
+
|
|
315
|
+
@property
|
|
316
|
+
def band_energies(self):
|
|
317
|
+
if self._band_energies is None:
|
|
318
|
+
if self.data is None:
|
|
319
|
+
return
|
|
320
|
+
|
|
321
|
+
data = np.transpose(self.data)
|
|
322
|
+
n_kpoints = int(max(data[1]))
|
|
323
|
+
bands = data[6:]
|
|
324
|
+
bands = np.reshape(
|
|
325
|
+
bands,
|
|
326
|
+
(
|
|
327
|
+
self.number_of_spin_channels,
|
|
328
|
+
self.number_of_band_segment_eigenvalues,
|
|
329
|
+
n_kpoints,
|
|
330
|
+
),
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
self._band_energies = []
|
|
334
|
+
start = 0
|
|
335
|
+
for nkpts_segment in self.number_of_k_points_per_segment:
|
|
336
|
+
end = start + nkpts_segment
|
|
337
|
+
band_energy = np.array(
|
|
338
|
+
[np.transpose(band)[start:end] for band in bands]
|
|
339
|
+
)
|
|
340
|
+
if self._energy_unit:
|
|
341
|
+
band_energy = band_energy * self._energy_unit
|
|
342
|
+
self._band_energies.append(band_energy)
|
|
343
|
+
start = end
|
|
344
|
+
|
|
345
|
+
return self._band_energies
|
|
346
|
+
|
|
347
|
+
@property
|
|
348
|
+
def band_k_points(self):
|
|
349
|
+
if self._band_k_points is None:
|
|
350
|
+
data = np.transpose(self.data)
|
|
351
|
+
self._band_k_points = []
|
|
352
|
+
start = 0
|
|
353
|
+
for nkpts_segment in self.number_of_k_points_per_segment:
|
|
354
|
+
end = start + nkpts_segment
|
|
355
|
+
self._band_k_points.append(np.transpose(data[2:5])[start:end])
|
|
356
|
+
start = end
|
|
357
|
+
|
|
358
|
+
return self._band_k_points
|
|
359
|
+
|
|
360
|
+
@property
|
|
361
|
+
def distances(self):
|
|
362
|
+
if self._distances is None:
|
|
363
|
+
data = np.transpose(self.data)
|
|
364
|
+
self._distances = data[5][: int(max(data[1]))]
|
|
365
|
+
|
|
366
|
+
return self._distances
|
|
367
|
+
|
|
368
|
+
@property
|
|
369
|
+
def number_of_spin_channels(self):
|
|
370
|
+
if self._nspin is None:
|
|
371
|
+
self._nspin = np.shape(np.transpose(self.data))[0] - 6
|
|
372
|
+
return self._nspin
|
|
373
|
+
|
|
374
|
+
@property
|
|
375
|
+
def number_of_k_points_per_segment(self):
|
|
376
|
+
if self._nkpts_segment is None:
|
|
377
|
+
self._nkpts_segment = []
|
|
378
|
+
count = 1
|
|
379
|
+
for i in range(1, len(self.distances)):
|
|
380
|
+
if self.distances[i] == self.distances[i - 1]:
|
|
381
|
+
self._nkpts_segment.append(count)
|
|
382
|
+
count = 1
|
|
383
|
+
else:
|
|
384
|
+
count += 1
|
|
385
|
+
self._nkpts_segment.append(count)
|
|
386
|
+
|
|
387
|
+
return self._nkpts_segment
|
|
388
|
+
|
|
389
|
+
@property
|
|
390
|
+
def number_of_band_segment_eigenvalues(self):
|
|
391
|
+
if self._neigs_segment is None:
|
|
392
|
+
data = np.transpose(self.data)
|
|
393
|
+
self._neigs_segment = int(max(data[0]))
|
|
394
|
+
return self._neigs_segment
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
class BandOutParser(DataTextParser):
|
|
398
|
+
def __init__(self, **kwargs):
|
|
399
|
+
super().__init__(**kwargs)
|
|
400
|
+
self._nspin = kwargs.get('nspin', None)
|
|
401
|
+
self._energy_unit = kwargs.get('energy_unit', None)
|
|
402
|
+
|
|
403
|
+
def reset(self):
|
|
404
|
+
super().reset()
|
|
405
|
+
self._nspin = None
|
|
406
|
+
self._distances = None
|
|
407
|
+
self._band_energies = None
|
|
408
|
+
self._neigs_segment = None
|
|
409
|
+
self._nkpts_segment = None
|
|
410
|
+
|
|
411
|
+
@property
|
|
412
|
+
def band_energies(self):
|
|
413
|
+
if self._band_energies is None:
|
|
414
|
+
data = np.transpose(self.data)
|
|
415
|
+
n_kpoints = np.where(data[0] == data[0][0])[0][1]
|
|
416
|
+
bands = data[1:]
|
|
417
|
+
bands = np.reshape(
|
|
418
|
+
bands,
|
|
419
|
+
(
|
|
420
|
+
self.number_of_spin_channels,
|
|
421
|
+
self.number_of_band_segment_eigenvalues,
|
|
422
|
+
n_kpoints,
|
|
423
|
+
),
|
|
424
|
+
)
|
|
425
|
+
|
|
426
|
+
self._band_energies = []
|
|
427
|
+
start = 0
|
|
428
|
+
for nkpts_segment in self.number_of_k_points_per_segment:
|
|
429
|
+
end = start + nkpts_segment
|
|
430
|
+
band_energy = np.array(
|
|
431
|
+
[np.transpose(band)[start:end] for band in bands]
|
|
432
|
+
)
|
|
433
|
+
if self._energy_unit:
|
|
434
|
+
band_energy = band_energy * self._energy_unit
|
|
435
|
+
self._band_energies.append(band_energy)
|
|
436
|
+
start = end
|
|
437
|
+
|
|
438
|
+
return self._band_energies
|
|
439
|
+
|
|
440
|
+
@property
|
|
441
|
+
def distances(self):
|
|
442
|
+
if self._distances is None:
|
|
443
|
+
dist = np.transpose(self.data)[0]
|
|
444
|
+
n_k_points = np.where(dist == dist[0])[0][1]
|
|
445
|
+
self._distances = dist[:n_k_points]
|
|
446
|
+
|
|
447
|
+
return self._distances
|
|
448
|
+
|
|
449
|
+
@property
|
|
450
|
+
def number_of_spin_channels(self):
|
|
451
|
+
if self._nspin is None:
|
|
452
|
+
self._nspin = np.shape(np.transpose(self.data)[1:])[0]
|
|
453
|
+
return self._nspin
|
|
454
|
+
|
|
455
|
+
@property
|
|
456
|
+
def number_of_k_points_per_segment(self):
|
|
457
|
+
if self._nkpts_segment is None:
|
|
458
|
+
self._nkpts_segment = []
|
|
459
|
+
count = 1
|
|
460
|
+
for i in range(1, len(self.distances)):
|
|
461
|
+
if self.distances[i] == self.distances[i - 1]:
|
|
462
|
+
self._nkpts_segment.append(count)
|
|
463
|
+
count = 1
|
|
464
|
+
else:
|
|
465
|
+
count += 1
|
|
466
|
+
self._nkpts_segment.append(count)
|
|
467
|
+
|
|
468
|
+
return self._nkpts_segment
|
|
469
|
+
|
|
470
|
+
@property
|
|
471
|
+
def number_of_band_segment_eigenvalues(self):
|
|
472
|
+
if self._neigs_segment is None:
|
|
473
|
+
data = np.transpose(self.data)[0]
|
|
474
|
+
self._neigs_segment = len(np.where(data == data[0])[0])
|
|
475
|
+
return self._neigs_segment
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
class BandstructureXMLParser(XMLParser):
|
|
479
|
+
def __init__(self, **kwargs):
|
|
480
|
+
# TODO make a parent class for dos and bandstructure
|
|
481
|
+
super().__init__(None)
|
|
482
|
+
self._distance_key = 'distance'
|
|
483
|
+
self._coord_key = 'coord'
|
|
484
|
+
self._energy_key = 'eval'
|
|
485
|
+
self._vertex_key = 'vertex'
|
|
486
|
+
self._band_key = 'band'
|
|
487
|
+
self._atom_key = 'atom'
|
|
488
|
+
self._nspin = kwargs.get('nspin', None)
|
|
489
|
+
self._energy_unit = kwargs.get('energy_unit', None)
|
|
490
|
+
|
|
491
|
+
def init_parameters(self):
|
|
492
|
+
self._nspin = None
|
|
493
|
+
self._nkpts_segment = None
|
|
494
|
+
self._neigs_segment = None
|
|
495
|
+
self._bands = None
|
|
496
|
+
self._vertices = None
|
|
497
|
+
self._distances = None
|
|
498
|
+
self._species = None
|
|
499
|
+
|
|
500
|
+
@property
|
|
501
|
+
def distances(self):
|
|
502
|
+
if self._distances is None:
|
|
503
|
+
if not self.bands:
|
|
504
|
+
return
|
|
505
|
+
|
|
506
|
+
self._distances = [
|
|
507
|
+
point.attrib.get(self._distance_key) for point in self.bands[0][0]
|
|
508
|
+
]
|
|
509
|
+
self._distances = np.array(self._distances, dtype=float)
|
|
510
|
+
|
|
511
|
+
return self._distances
|
|
512
|
+
|
|
513
|
+
@property
|
|
514
|
+
def bands(self):
|
|
515
|
+
if self._bands is None:
|
|
516
|
+
bands = self.root.findall('./%s' % self._band_key)
|
|
517
|
+
self._bands = []
|
|
518
|
+
if bands:
|
|
519
|
+
self._bands.append(bands)
|
|
520
|
+
# add atom-resolved
|
|
521
|
+
bands_atom = self.root.findall('./*/%s' % self._atom_key)
|
|
522
|
+
for band in bands_atom:
|
|
523
|
+
self._bands.append(band.findall('./%s' % self._band_key))
|
|
524
|
+
return self._bands
|
|
525
|
+
|
|
526
|
+
@property
|
|
527
|
+
def vertices(self):
|
|
528
|
+
if self._vertices is None:
|
|
529
|
+
self._vertices = self.root.findall('./%s' % self._vertex_key)
|
|
530
|
+
return self._vertices
|
|
531
|
+
|
|
532
|
+
@property
|
|
533
|
+
def number_of_spin_channels(self):
|
|
534
|
+
if self._nspin is None:
|
|
535
|
+
self._nspin = 1
|
|
536
|
+
return self._nspin
|
|
537
|
+
|
|
538
|
+
@property
|
|
539
|
+
def number_of_k_points_per_segment(self):
|
|
540
|
+
if self._nkpts_segment is None:
|
|
541
|
+
self._nkpts_segment = []
|
|
542
|
+
count = 1
|
|
543
|
+
for i in range(1, len(self.distances)):
|
|
544
|
+
if self.distances[i] == self.distances[i - 1]:
|
|
545
|
+
self._nkpts_segment.append(count)
|
|
546
|
+
count = 1
|
|
547
|
+
else:
|
|
548
|
+
count += 1
|
|
549
|
+
self._nkpts_segment.append(count)
|
|
550
|
+
|
|
551
|
+
return self._nkpts_segment
|
|
552
|
+
|
|
553
|
+
@property
|
|
554
|
+
def number_of_band_segment_eigenvalues(self):
|
|
555
|
+
if self._neigs_segment is None:
|
|
556
|
+
self._neigs_segment = len(self.bands[0]) // self.number_of_spin_channels
|
|
557
|
+
return self._neigs_segment
|
|
558
|
+
|
|
559
|
+
def parse(self, key):
|
|
560
|
+
if self._results is None:
|
|
561
|
+
self._results = dict()
|
|
562
|
+
|
|
563
|
+
if not self.bands:
|
|
564
|
+
return
|
|
565
|
+
|
|
566
|
+
if key == 'band_energies':
|
|
567
|
+
# TODO I am not certain about the format for the spin polarized case
|
|
568
|
+
# I cannot find an example bandstructure file
|
|
569
|
+
# atom-resolved bandstructure are added as separate section_k_band
|
|
570
|
+
res = []
|
|
571
|
+
for n in range(len(self.bands)):
|
|
572
|
+
res_n = []
|
|
573
|
+
start = 0
|
|
574
|
+
band_energies = np.zeros(
|
|
575
|
+
(
|
|
576
|
+
self.number_of_spin_channels,
|
|
577
|
+
self.number_of_band_segment_eigenvalues,
|
|
578
|
+
len(self.distances),
|
|
579
|
+
),
|
|
580
|
+
dtype=float,
|
|
581
|
+
)
|
|
582
|
+
|
|
583
|
+
for i in range(len(self.bands[n])):
|
|
584
|
+
band_energies[i % self.number_of_spin_channels][i] = np.array(
|
|
585
|
+
[e.attrib.get(self._energy_key) for e in self.bands[n][i]]
|
|
586
|
+
)
|
|
587
|
+
|
|
588
|
+
for nkpts_segment in self.number_of_k_points_per_segment:
|
|
589
|
+
end = start + nkpts_segment
|
|
590
|
+
band_energy = np.array(
|
|
591
|
+
[np.transpose(energy)[start:end] for energy in band_energies]
|
|
592
|
+
)
|
|
593
|
+
if self._energy_unit is not None:
|
|
594
|
+
band_energy = band_energy * self._energy_unit
|
|
595
|
+
res_n.append(band_energy)
|
|
596
|
+
start = end
|
|
597
|
+
res.append(res_n)
|
|
598
|
+
|
|
599
|
+
elif key == 'band_k_points':
|
|
600
|
+
res = []
|
|
601
|
+
for i in range(len(self.number_of_k_points_per_segment)):
|
|
602
|
+
start = np.array(
|
|
603
|
+
self.vertices[i].attrib.get(self._coord_key).split(), dtype=float
|
|
604
|
+
)
|
|
605
|
+
end = np.array(
|
|
606
|
+
self.vertices[i + 1].attrib.get(self._coord_key).split(),
|
|
607
|
+
dtype=float,
|
|
608
|
+
)
|
|
609
|
+
|
|
610
|
+
res.append(
|
|
611
|
+
np.linspace(start, end, self.number_of_k_points_per_segment[i])
|
|
612
|
+
)
|
|
613
|
+
|
|
614
|
+
elif key == 'band_segm_labels':
|
|
615
|
+
res = []
|
|
616
|
+
for i in range(len(self.vertices) - 1):
|
|
617
|
+
start = self.vertices[i].attrib.get('label')
|
|
618
|
+
end = self.vertices[i + 1].attrib.get('label')
|
|
619
|
+
res.append(
|
|
620
|
+
[
|
|
621
|
+
'\u0393' if start.lower() == 'gamma' else start,
|
|
622
|
+
'\u0393' if end.lower() == 'gamma' else end,
|
|
623
|
+
]
|
|
624
|
+
)
|
|
625
|
+
|
|
626
|
+
elif key == 'band_segm_start_end':
|
|
627
|
+
res = []
|
|
628
|
+
for i in range(len(self.number_of_k_points_per_segment)):
|
|
629
|
+
start = self.vertices[i].attrib.get(self._coord_key).split()
|
|
630
|
+
end = self.vertices[i + 1].attrib.get(self._coord_key).split()
|
|
631
|
+
res.append([start, end])
|
|
632
|
+
|
|
633
|
+
else:
|
|
634
|
+
res = None
|
|
635
|
+
|
|
636
|
+
self._results[key] = res
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
class DOSXMLParser(XMLParser):
|
|
640
|
+
def __init__(self, **kwargs):
|
|
641
|
+
super().__init__(None)
|
|
642
|
+
self._nspin_key = 'nspin'
|
|
643
|
+
self._totaldos_key = 'totaldos'
|
|
644
|
+
self._partialdos_key = 'partialdos'
|
|
645
|
+
self._diagram_key = 'diagram'
|
|
646
|
+
self._l_key = 'l'
|
|
647
|
+
self._m_key = 'm'
|
|
648
|
+
self._energy_key = 'e'
|
|
649
|
+
self._dos_key = 'dos'
|
|
650
|
+
self._unit_key = 'unit'
|
|
651
|
+
self._energy_unit = kwargs.get('energy_unit', None)
|
|
652
|
+
self._units_mapping = dict(hartree=ureg.hartree)
|
|
653
|
+
|
|
654
|
+
def init_parameters(self):
|
|
655
|
+
self._ndos = None
|
|
656
|
+
self._natoms = None
|
|
657
|
+
self._nspin = None
|
|
658
|
+
self._nlm = None
|
|
659
|
+
self._energies = None
|
|
660
|
+
self._total_dos = None
|
|
661
|
+
self._partial_dos = None
|
|
662
|
+
|
|
663
|
+
@property
|
|
664
|
+
def energy_unit(self):
|
|
665
|
+
if self._energy_unit is None:
|
|
666
|
+
axis = self.root.find('./axis')
|
|
667
|
+
if axis is None:
|
|
668
|
+
return
|
|
669
|
+
|
|
670
|
+
self._energy_unit = self._units_mapping.get(
|
|
671
|
+
axis.attrib.get(self._unit_key).lower(), 1
|
|
672
|
+
)
|
|
673
|
+
|
|
674
|
+
return self._energy_unit
|
|
675
|
+
|
|
676
|
+
@property
|
|
677
|
+
def number_of_spin_channels(self):
|
|
678
|
+
if self._nspin is None:
|
|
679
|
+
if not self.total_dos:
|
|
680
|
+
return
|
|
681
|
+
self._nspin = len(self.total_dos)
|
|
682
|
+
|
|
683
|
+
return self._nspin
|
|
684
|
+
|
|
685
|
+
@property
|
|
686
|
+
def number_of_atoms(self):
|
|
687
|
+
if self._natoms is None:
|
|
688
|
+
partial_dos = self.root.findall('./%s' % self._partialdos_key)
|
|
689
|
+
self._natoms = len(partial_dos)
|
|
690
|
+
|
|
691
|
+
return self._natoms
|
|
692
|
+
|
|
693
|
+
@property
|
|
694
|
+
def number_of_dos(self):
|
|
695
|
+
if self._ndos is None:
|
|
696
|
+
total_dos = self.root.find(
|
|
697
|
+
'./%s/%s' % (self._totaldos_key, self._diagram_key)
|
|
698
|
+
)
|
|
699
|
+
self._ndos = len(total_dos)
|
|
700
|
+
|
|
701
|
+
return self._ndos
|
|
702
|
+
|
|
703
|
+
@property
|
|
704
|
+
def number_of_lm(self):
|
|
705
|
+
if self._nlm is None:
|
|
706
|
+
if self.partial_dos is None:
|
|
707
|
+
return
|
|
708
|
+
|
|
709
|
+
self._nlm = 0
|
|
710
|
+
l_list = set([int(e.attrib.get(self._l_key)) for e in self.partial_dos])
|
|
711
|
+
for li in l_list:
|
|
712
|
+
self._nlm += 2 * li + 1
|
|
713
|
+
|
|
714
|
+
return self._nlm
|
|
715
|
+
|
|
716
|
+
@property
|
|
717
|
+
def total_dos(self):
|
|
718
|
+
if self._total_dos is None:
|
|
719
|
+
self._total_dos = self.root.findall(
|
|
720
|
+
'./%s/%s' % (self._totaldos_key, self._diagram_key)
|
|
721
|
+
)
|
|
722
|
+
return self._total_dos
|
|
723
|
+
|
|
724
|
+
@property
|
|
725
|
+
def partial_dos(self):
|
|
726
|
+
if self._partial_dos is None:
|
|
727
|
+
self._partial_dos = self.root.findall(
|
|
728
|
+
'./%s/%s' % (self._partialdos_key, self._diagram_key)
|
|
729
|
+
)
|
|
730
|
+
return self._partial_dos
|
|
731
|
+
|
|
732
|
+
@property
|
|
733
|
+
def energies(self):
|
|
734
|
+
if self._energies is None:
|
|
735
|
+
if self.total_dos is None:
|
|
736
|
+
return
|
|
737
|
+
|
|
738
|
+
self._energies = np.array(
|
|
739
|
+
[
|
|
740
|
+
float(point.attrib.get(self._energy_key))
|
|
741
|
+
for point in self.total_dos[0]
|
|
742
|
+
]
|
|
743
|
+
)
|
|
744
|
+
|
|
745
|
+
if self.energy_unit is not None:
|
|
746
|
+
self._energies = self._energies * self.energy_unit
|
|
747
|
+
|
|
748
|
+
return self._energies
|
|
749
|
+
|
|
750
|
+
def _get_dos(self, diagram):
|
|
751
|
+
dos = np.array(
|
|
752
|
+
[point.attrib.get(self._dos_key) for point in diagram], dtype=float
|
|
753
|
+
)
|
|
754
|
+
|
|
755
|
+
return dos
|
|
756
|
+
|
|
757
|
+
def parse(self, key):
|
|
758
|
+
if self._results is None:
|
|
759
|
+
self._results = dict()
|
|
760
|
+
|
|
761
|
+
if 'total' in key:
|
|
762
|
+
if not self.total_dos:
|
|
763
|
+
return
|
|
764
|
+
|
|
765
|
+
res = np.zeros((self.number_of_spin_channels, self.number_of_dos))
|
|
766
|
+
|
|
767
|
+
for i in range(len(self.total_dos)):
|
|
768
|
+
spin = self.total_dos[i].attrib.get(self._nspin_key, i)
|
|
769
|
+
res[i] = self._get_dos(self._total_dos[i])
|
|
770
|
+
|
|
771
|
+
if self.energy_unit is not None:
|
|
772
|
+
res = res * (1 / self.energy_unit)
|
|
773
|
+
|
|
774
|
+
elif 'partial' in key:
|
|
775
|
+
if not self.partial_dos:
|
|
776
|
+
return
|
|
777
|
+
|
|
778
|
+
res = np.zeros(
|
|
779
|
+
(
|
|
780
|
+
self.number_of_lm,
|
|
781
|
+
self.number_of_spin_channels,
|
|
782
|
+
self.number_of_atoms,
|
|
783
|
+
self.number_of_dos,
|
|
784
|
+
)
|
|
785
|
+
)
|
|
786
|
+
|
|
787
|
+
for i in range(len(self.partial_dos)):
|
|
788
|
+
spin = self.partial_dos[i].attrib.get(self._nspin_key, None)
|
|
789
|
+
if spin is None:
|
|
790
|
+
spin = (
|
|
791
|
+
i % (self.number_of_spin_channels * self.number_of_lm)
|
|
792
|
+
) // self.number_of_lm
|
|
793
|
+
else:
|
|
794
|
+
spin = int(spin) - 1
|
|
795
|
+
|
|
796
|
+
val_l = self.partial_dos[i].attrib.get(self._l_key, None)
|
|
797
|
+
val_m = self.partial_dos[i].attrib.get(self._m_key, None)
|
|
798
|
+
if val_l is None or val_m is None:
|
|
799
|
+
lm = i % self.number_of_lm
|
|
800
|
+
else:
|
|
801
|
+
lm = int(val_l) ** 2 + int(val_m) + int(val_l)
|
|
802
|
+
|
|
803
|
+
atom = i // (self.number_of_lm * self.number_of_spin_channels)
|
|
804
|
+
|
|
805
|
+
res[lm][spin][atom] = self._get_dos(self.partial_dos[i])
|
|
806
|
+
|
|
807
|
+
if self.energy_unit is not None:
|
|
808
|
+
res = res * (1 / self.energy_unit)
|
|
809
|
+
|
|
810
|
+
elif key == 'energies':
|
|
811
|
+
return self.energies
|
|
812
|
+
|
|
813
|
+
else:
|
|
814
|
+
res = None
|
|
815
|
+
|
|
816
|
+
self._results[key] = res
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
class ExcitingFermiSurfaceBxsfParser(TextParser):
|
|
820
|
+
def __init__(self):
|
|
821
|
+
super().__init__(None)
|
|
822
|
+
|
|
823
|
+
def init_quantities(self):
|
|
824
|
+
self._quantities = []
|
|
825
|
+
|
|
826
|
+
self._quantities.append(
|
|
827
|
+
Quantity(
|
|
828
|
+
'fermi_energy',
|
|
829
|
+
r'Fermi Energy:\s*([\d\.]+)\s*',
|
|
830
|
+
unit=ureg.hartree,
|
|
831
|
+
repeats=False,
|
|
832
|
+
)
|
|
833
|
+
)
|
|
834
|
+
|
|
835
|
+
def str_to_band_parameters(val_in):
|
|
836
|
+
val = val_in.strip().split('\n')
|
|
837
|
+
|
|
838
|
+
nbands = int(val[0])
|
|
839
|
+
mesh = np.array(val[1].split(), dtype=int)
|
|
840
|
+
origin = np.array(val[2].split(), dtype=float)
|
|
841
|
+
vector = np.array([v.split() for v in val[3:6]], dtype=float)
|
|
842
|
+
|
|
843
|
+
return [nbands, mesh, origin, vector]
|
|
844
|
+
|
|
845
|
+
self._quantities.append(
|
|
846
|
+
Quantity(
|
|
847
|
+
'band_parameters',
|
|
848
|
+
r'BANDGRID_3D_BANDS\s*([\d\.\-Ee\s]+)',
|
|
849
|
+
str_operation=str_to_band_parameters,
|
|
850
|
+
repeats=False,
|
|
851
|
+
)
|
|
852
|
+
)
|
|
853
|
+
|
|
854
|
+
self._quantities.append(
|
|
855
|
+
Quantity(
|
|
856
|
+
'fermi_surface',
|
|
857
|
+
r'BAND:\s*\d+\s*([\d\-\+\.Ee\s]+)\n *E*',
|
|
858
|
+
unit=ureg.hartree,
|
|
859
|
+
repeats=True,
|
|
860
|
+
)
|
|
861
|
+
)
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
class ExcitingEigenvalueParser(TextParser):
|
|
865
|
+
def __init__(self):
|
|
866
|
+
super().__init__(None)
|
|
867
|
+
|
|
868
|
+
def init_quantities(self):
|
|
869
|
+
self._quantities = []
|
|
870
|
+
self._quantities.append(
|
|
871
|
+
Quantity('k_points', r'\s*\d+\s*([\d\.Ee\- ]+):\s*k\-point', repeats=True)
|
|
872
|
+
)
|
|
873
|
+
|
|
874
|
+
def str_to_eigenvalues(val_in):
|
|
875
|
+
val = val_in[: val_in.rfind('\n \n')].strip()
|
|
876
|
+
val = np.array([v.split() for v in val.split('\n')], dtype=float)
|
|
877
|
+
val = np.transpose(val)
|
|
878
|
+
occs = val[-1]
|
|
879
|
+
eigs = val[-2]
|
|
880
|
+
|
|
881
|
+
nspin = 2 if occs[0] == 1.0 else 1
|
|
882
|
+
data = dict()
|
|
883
|
+
data['occupancies'] = np.reshape(occs, (nspin, len(occs) // nspin))
|
|
884
|
+
data['eigenvalues'] = np.reshape(eigs, (nspin, len(eigs) // nspin))
|
|
885
|
+
return data
|
|
886
|
+
|
|
887
|
+
self._quantities.append(
|
|
888
|
+
Quantity(
|
|
889
|
+
'eigenvalues_occupancies',
|
|
890
|
+
r'\(state\, eigenvalue and occupancy below\)\s*([\d\.Ee\-\s]+?(?:\n *\n))',
|
|
891
|
+
str_operation=str_to_eigenvalues,
|
|
892
|
+
repeats=True,
|
|
893
|
+
)
|
|
894
|
+
)
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
class ExcitingGWOutParser(TextParser):
|
|
898
|
+
def __init__(self, mainfile, logger):
|
|
899
|
+
super().__init__(mainfile, logger=logger)
|
|
900
|
+
|
|
901
|
+
def init_quantities(self):
|
|
902
|
+
self._quantities = []
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
class ExcitingInfoParser(TextParser):
|
|
906
|
+
def __init__(self):
|
|
907
|
+
super().__init__(None)
|
|
908
|
+
|
|
909
|
+
def init_quantities(self):
|
|
910
|
+
re_symbol = re.compile(r'([A-Z][a-z]?)')
|
|
911
|
+
|
|
912
|
+
def str_to_array(val_in):
|
|
913
|
+
val = [v.split(':')[-1].split() for v in val_in.strip().split('\n')]
|
|
914
|
+
val = val[0] if len(val) == 1 else val
|
|
915
|
+
return np.array(val, dtype=float)
|
|
916
|
+
|
|
917
|
+
def str_to_atom_properties_dict(val_in):
|
|
918
|
+
unit = None
|
|
919
|
+
if 'charge' in val_in:
|
|
920
|
+
unit = ureg.elementary_charge
|
|
921
|
+
elif 'moment' in val_in:
|
|
922
|
+
unit = ureg.elementary_charge * ureg.bohr
|
|
923
|
+
|
|
924
|
+
val = val_in.strip().split('\n')
|
|
925
|
+
|
|
926
|
+
properties = dict()
|
|
927
|
+
atom_resolved = []
|
|
928
|
+
species = None
|
|
929
|
+
for v in val:
|
|
930
|
+
v = v.strip().split(':')
|
|
931
|
+
if len(v) < 2:
|
|
932
|
+
continue
|
|
933
|
+
|
|
934
|
+
elif v[0].startswith('species'):
|
|
935
|
+
species = re.search(re_symbol, v[-1]).group(1)
|
|
936
|
+
|
|
937
|
+
elif v[0].startswith('atom'):
|
|
938
|
+
v[0] = v[0].split()
|
|
939
|
+
v[1] = [float(vi) for vi in v[1].split()]
|
|
940
|
+
v[1] = v[1][0] if len(v[1]) == 1 else v[1]
|
|
941
|
+
if species is None:
|
|
942
|
+
species = v[0][2]
|
|
943
|
+
atom_resolved.append(((species, v[1] * unit)))
|
|
944
|
+
|
|
945
|
+
else:
|
|
946
|
+
vi = [float(vii) for vii in v[1].split()]
|
|
947
|
+
# vi = vi[0] if len(vi) == 1 else vi
|
|
948
|
+
properties[v[0].strip()] = vi * unit
|
|
949
|
+
|
|
950
|
+
properties['atom_resolved'] = atom_resolved
|
|
951
|
+
return properties
|
|
952
|
+
|
|
953
|
+
def str_to_quantity_tolerances(val_in):
|
|
954
|
+
return val_in.strip().replace('(', '').replace(')', '').split()
|
|
955
|
+
|
|
956
|
+
def str_to_energy_dict(val_in):
|
|
957
|
+
val = val_in.strip().split('\n')
|
|
958
|
+
energies = dict()
|
|
959
|
+
for v in val:
|
|
960
|
+
v = v.split(':')
|
|
961
|
+
if len(v) < 2:
|
|
962
|
+
continue
|
|
963
|
+
energies[v[0].strip()] = float(v[1]) * ureg.hartree
|
|
964
|
+
return energies
|
|
965
|
+
|
|
966
|
+
self._quantities = [
|
|
967
|
+
Quantity(
|
|
968
|
+
'program_version',
|
|
969
|
+
r'\s*EXCITING\s*([\w\-\(\)\. ]+)\s*started',
|
|
970
|
+
repeats=False,
|
|
971
|
+
dtype=str,
|
|
972
|
+
flatten=False,
|
|
973
|
+
),
|
|
974
|
+
Quantity('hash_id', r'version hash id: +(\S+)', dtype=str),
|
|
975
|
+
]
|
|
976
|
+
|
|
977
|
+
initialization_quantities = [
|
|
978
|
+
Quantity(
|
|
979
|
+
'lattice_vectors',
|
|
980
|
+
r'Lattice vectors\s*[\(cartesian\)]*\s*:\s*([\-0-9\.\s]+)\n',
|
|
981
|
+
str_operation=str_to_array,
|
|
982
|
+
unit=ureg.bohr,
|
|
983
|
+
repeats=False,
|
|
984
|
+
convert=False,
|
|
985
|
+
),
|
|
986
|
+
Quantity(
|
|
987
|
+
'lattice_vectors_reciprocal',
|
|
988
|
+
r'Reciprocal lattice vectors\s*[\(cartesian\)]*\s*:\s*([\-0-9\.\s]+)\n',
|
|
989
|
+
str_operation=str_to_array,
|
|
990
|
+
unit=1 / ureg.bohr,
|
|
991
|
+
repeats=False,
|
|
992
|
+
convert=False,
|
|
993
|
+
),
|
|
994
|
+
]
|
|
995
|
+
|
|
996
|
+
self._system_keys_mapping = {
|
|
997
|
+
'x_exciting_unit_cell_volume': ('Unit cell volume', ureg.bohr**3),
|
|
998
|
+
'x_exciting_brillouin_zone_volume': (
|
|
999
|
+
'Brillouin zone volume',
|
|
1000
|
+
1 / ureg.bohr**3,
|
|
1001
|
+
),
|
|
1002
|
+
'x_exciting_number_of_atoms': ('Total number of atoms per unit cell', None),
|
|
1003
|
+
'x_exciting_spin_treatment': ('Spin treatment', None),
|
|
1004
|
+
'x_exciting_number_of_bravais_lattice_symmetries': (
|
|
1005
|
+
'Number of Bravais lattice symmetries',
|
|
1006
|
+
None,
|
|
1007
|
+
),
|
|
1008
|
+
'x_exciting_number_of_crystal_symmetries': (
|
|
1009
|
+
'Number of crystal symmetries',
|
|
1010
|
+
None,
|
|
1011
|
+
),
|
|
1012
|
+
'kpoint_grid': (r'k\-point grid', None),
|
|
1013
|
+
'kpoint_offset': (r'k\-point offset', None),
|
|
1014
|
+
'x_exciting_number_kpoints': (r'Total number of k\-points', None),
|
|
1015
|
+
'x_exciting_rgkmax': (r'R\^MT\_min \* \|G\+k\|\_max \(rgkmax\)', None),
|
|
1016
|
+
'x_exciting_species_rtmin': (r'Species with R\^MT\_min', None),
|
|
1017
|
+
'x_exciting_gkmax': (r'Maximum \|G\+k\| for APW functions', 1 / ureg.bohr),
|
|
1018
|
+
'x_exciting_gmaxvr': (
|
|
1019
|
+
r'Maximum \|G\| for potential and density',
|
|
1020
|
+
1 / ureg.bohr,
|
|
1021
|
+
),
|
|
1022
|
+
'x_exciting_gvector_size': (r'G\-vector grid sizes', None),
|
|
1023
|
+
'x_exciting_gvector_total': (r'Total number of G\-vectors', None),
|
|
1024
|
+
'x_exciting_lmaxapw': (r' APW functions', None),
|
|
1025
|
+
'x_exciting_nuclear_charge': (
|
|
1026
|
+
'Total nuclear charge',
|
|
1027
|
+
ureg.elementary_charge,
|
|
1028
|
+
),
|
|
1029
|
+
'x_exciting_electronic_charge': (
|
|
1030
|
+
'Total electronic charge',
|
|
1031
|
+
ureg.elementary_charge,
|
|
1032
|
+
),
|
|
1033
|
+
'x_exciting_core_charge_initial': (
|
|
1034
|
+
'Total core charge',
|
|
1035
|
+
ureg.elementary_charge,
|
|
1036
|
+
),
|
|
1037
|
+
'x_exciting_valence_charge_initial': (
|
|
1038
|
+
'Total valence charge',
|
|
1039
|
+
ureg.elementary_charge,
|
|
1040
|
+
),
|
|
1041
|
+
'x_exciting_wigner_radius': (r'Effective Wigner radius, r\_s', ureg.bohr),
|
|
1042
|
+
'x_exciting_empty_states': ('Number of empty states', None),
|
|
1043
|
+
'x_exciting_valence_states': ('Total number of valence states', None),
|
|
1044
|
+
'x_exciting_hamiltonian_size': ('Maximum Hamiltonian size', None),
|
|
1045
|
+
'x_exciting_pw': (r'Maximum number of plane\-waves', None),
|
|
1046
|
+
'x_exciting_lo': (r'Total number of local\-orbitals', None),
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
self._method_keys_mapping = {
|
|
1050
|
+
'smearing_kind': ('Smearing scheme', None),
|
|
1051
|
+
'smearing_width': ('Smearing width', None),
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
for name, key_unit in self._system_keys_mapping.items():
|
|
1055
|
+
initialization_quantities.append(
|
|
1056
|
+
Quantity(
|
|
1057
|
+
name,
|
|
1058
|
+
r'%s\s*:\s*([\s\S]*?)\n' % key_unit[0],
|
|
1059
|
+
unit=key_unit[1],
|
|
1060
|
+
repeats=False,
|
|
1061
|
+
)
|
|
1062
|
+
)
|
|
1063
|
+
|
|
1064
|
+
for name, key_unit in self._method_keys_mapping.items():
|
|
1065
|
+
initialization_quantities.append(
|
|
1066
|
+
Quantity(
|
|
1067
|
+
name,
|
|
1068
|
+
r'%s\s*:\s*([\s\S]*?)\n' % key_unit[0],
|
|
1069
|
+
unit=key_unit[1],
|
|
1070
|
+
repeats=False,
|
|
1071
|
+
)
|
|
1072
|
+
)
|
|
1073
|
+
|
|
1074
|
+
initialization_quantities.append(
|
|
1075
|
+
Quantity(
|
|
1076
|
+
'species',
|
|
1077
|
+
rf'(Species : *\d+ *\(\w+\)[\s\S]+?{re_float} *{re_float} *{re_float}\n\s*\n)',
|
|
1078
|
+
repeats=True,
|
|
1079
|
+
sub_parser=TextParser(
|
|
1080
|
+
quantities=[
|
|
1081
|
+
Quantity('number', r'Species : *(\d+)', dtype=np.int32),
|
|
1082
|
+
Quantity('symbol', r'\((\w+)\)'),
|
|
1083
|
+
Quantity('file', r'parameters loaded from *: *(.+)'),
|
|
1084
|
+
Quantity('name', r'name *: *(.+)'),
|
|
1085
|
+
Quantity(
|
|
1086
|
+
'nuclear_charge',
|
|
1087
|
+
rf'nuclear charge *: *({re_float})',
|
|
1088
|
+
dtype=np.float64,
|
|
1089
|
+
unit=ureg.elementary_charge,
|
|
1090
|
+
),
|
|
1091
|
+
Quantity(
|
|
1092
|
+
'electronic_charge',
|
|
1093
|
+
rf'electronic charge *: *({re_float})',
|
|
1094
|
+
dtype=np.float64,
|
|
1095
|
+
unit=ureg.elementary_charge,
|
|
1096
|
+
),
|
|
1097
|
+
Quantity(
|
|
1098
|
+
'atomic_mass',
|
|
1099
|
+
rf'atomic mass *: *({re_float})',
|
|
1100
|
+
dtype=np.float64,
|
|
1101
|
+
unit=ureg.electron_mass,
|
|
1102
|
+
),
|
|
1103
|
+
Quantity(
|
|
1104
|
+
'muffin_tin_radius',
|
|
1105
|
+
rf'muffin-tin radius *: *({re_float})',
|
|
1106
|
+
dtype=np.float64,
|
|
1107
|
+
unit=ureg.bohr,
|
|
1108
|
+
),
|
|
1109
|
+
Quantity(
|
|
1110
|
+
'radial_points',
|
|
1111
|
+
rf'radial points in muffin-tin *: *({re_float})',
|
|
1112
|
+
dtype=np.int32,
|
|
1113
|
+
),
|
|
1114
|
+
Quantity(
|
|
1115
|
+
'positions_format',
|
|
1116
|
+
r'atomic positions \((.+?)\)',
|
|
1117
|
+
flatten=False,
|
|
1118
|
+
),
|
|
1119
|
+
Quantity(
|
|
1120
|
+
'positions',
|
|
1121
|
+
rf'\d+ : *({re_float}) *({re_float}) *({re_float})',
|
|
1122
|
+
repeats=True,
|
|
1123
|
+
dtype=np.dtype(np.float64),
|
|
1124
|
+
),
|
|
1125
|
+
]
|
|
1126
|
+
),
|
|
1127
|
+
)
|
|
1128
|
+
)
|
|
1129
|
+
|
|
1130
|
+
initialization_quantities.append(
|
|
1131
|
+
Quantity(
|
|
1132
|
+
'potential_mixing',
|
|
1133
|
+
r'Using ([\w ]+) potential mixing',
|
|
1134
|
+
repeats=False,
|
|
1135
|
+
flatten=False,
|
|
1136
|
+
)
|
|
1137
|
+
)
|
|
1138
|
+
|
|
1139
|
+
initialization_quantities.append(
|
|
1140
|
+
Quantity(
|
|
1141
|
+
'xc_functional',
|
|
1142
|
+
r'(Exchange-correlation type[\s\S]+?\n *\n)',
|
|
1143
|
+
sub_parser=TextParser(
|
|
1144
|
+
quantities=[
|
|
1145
|
+
Quantity('type', r'Exchange-correlation type +: +(\S+)'),
|
|
1146
|
+
Quantity(
|
|
1147
|
+
'name_reference',
|
|
1148
|
+
r'\n *(.+?,.+)',
|
|
1149
|
+
str_operation=lambda x: [v.strip() for v in x.split(':')],
|
|
1150
|
+
),
|
|
1151
|
+
Quantity(
|
|
1152
|
+
'parameters',
|
|
1153
|
+
r'\n *(.+?:.+)',
|
|
1154
|
+
repeats=True,
|
|
1155
|
+
str_operation=lambda x: [v.strip() for v in x.split(':')],
|
|
1156
|
+
),
|
|
1157
|
+
]
|
|
1158
|
+
),
|
|
1159
|
+
)
|
|
1160
|
+
)
|
|
1161
|
+
|
|
1162
|
+
self._quantities.append(
|
|
1163
|
+
Quantity(
|
|
1164
|
+
'initialization',
|
|
1165
|
+
r'(?:All units are atomic|Starting initialization)([\s\S]+?)(?:Using|Ending initialization)',
|
|
1166
|
+
repeats=False,
|
|
1167
|
+
sub_parser=TextParser(quantities=initialization_quantities),
|
|
1168
|
+
)
|
|
1169
|
+
)
|
|
1170
|
+
|
|
1171
|
+
scf_quantities = [
|
|
1172
|
+
Quantity(
|
|
1173
|
+
'energy_total',
|
|
1174
|
+
r'[Tt]*otal energy\s*:\s*([\-\d\.Ee]+)',
|
|
1175
|
+
repeats=False,
|
|
1176
|
+
dtype=float,
|
|
1177
|
+
unit=ureg.hartree,
|
|
1178
|
+
),
|
|
1179
|
+
Quantity(
|
|
1180
|
+
'energy_contributions',
|
|
1181
|
+
r'(?:Energies|_)([\+\-\s\w\.\:]+?)\n *(?:DOS|Density)',
|
|
1182
|
+
str_operation=str_to_energy_dict,
|
|
1183
|
+
repeats=False,
|
|
1184
|
+
convert=False,
|
|
1185
|
+
),
|
|
1186
|
+
Quantity(
|
|
1187
|
+
'x_exciting_dos_fermi',
|
|
1188
|
+
r'DOS at Fermi energy \(states\/Ha\/cell\)\s*:\s*([\-\d\.Ee]+)',
|
|
1189
|
+
repeats=False,
|
|
1190
|
+
dtype=float,
|
|
1191
|
+
unit=1 / ureg.hartree,
|
|
1192
|
+
),
|
|
1193
|
+
Quantity(
|
|
1194
|
+
'charge_contributions',
|
|
1195
|
+
r'(?:Charges|Electron charges\s*\:*\s*)([\-\s\w\.\:\(\)]+?)\n *[A-Z\+]',
|
|
1196
|
+
str_operation=str_to_atom_properties_dict,
|
|
1197
|
+
repeats=False,
|
|
1198
|
+
convert=False,
|
|
1199
|
+
),
|
|
1200
|
+
Quantity(
|
|
1201
|
+
'moment_contributions',
|
|
1202
|
+
r'(?:Moments\s*\:*\s*)([\-\s\w\.\:\(\)]+?)\n *[A-Z\+]',
|
|
1203
|
+
str_operation=str_to_atom_properties_dict,
|
|
1204
|
+
repeats=False,
|
|
1205
|
+
convert=False,
|
|
1206
|
+
),
|
|
1207
|
+
]
|
|
1208
|
+
|
|
1209
|
+
self._miscellaneous_keys_mapping = {
|
|
1210
|
+
'x_exciting_gap': (r'Estimated fundamental gap', ureg.hartree),
|
|
1211
|
+
'time_physical': (r'Wall time \(seconds\)', ureg.s),
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
for name, key_unit in self._miscellaneous_keys_mapping.items():
|
|
1215
|
+
scf_quantities.append(
|
|
1216
|
+
Quantity(
|
|
1217
|
+
name,
|
|
1218
|
+
r'%s\s*\:*\s*([\-\d\.Ee]+)' % key_unit[0],
|
|
1219
|
+
repeats=False,
|
|
1220
|
+
unit=key_unit[1],
|
|
1221
|
+
)
|
|
1222
|
+
)
|
|
1223
|
+
|
|
1224
|
+
self._convergence_keys_mapping = {
|
|
1225
|
+
'x_exciting_effective_potential_convergence': (
|
|
1226
|
+
r'RMS change in effective potential \(target\)',
|
|
1227
|
+
ureg.hartree,
|
|
1228
|
+
),
|
|
1229
|
+
'x_exciting_energy_convergence': (
|
|
1230
|
+
r'Absolute change in total energy\s*\(target\)',
|
|
1231
|
+
ureg.hartree,
|
|
1232
|
+
),
|
|
1233
|
+
'x_exciting_charge_convergence': (
|
|
1234
|
+
r'Charge distance\s*\(target\)',
|
|
1235
|
+
ureg.elementary_charge,
|
|
1236
|
+
),
|
|
1237
|
+
'x_exciting_IBS_force_convergence': (
|
|
1238
|
+
r'Abs\. change in max\-nonIBS\-force\s*\(target\)',
|
|
1239
|
+
ureg.hartree / ureg.bohr,
|
|
1240
|
+
),
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
for name, key_unit in self._convergence_keys_mapping.items():
|
|
1244
|
+
scf_quantities.append(
|
|
1245
|
+
Quantity(
|
|
1246
|
+
name,
|
|
1247
|
+
r'%s\s*\:*\s*([\(\)\d\.\-\+Ee ]+)' % key_unit[0],
|
|
1248
|
+
str_operation=str_to_quantity_tolerances,
|
|
1249
|
+
unit=key_unit[1],
|
|
1250
|
+
repeats=False,
|
|
1251
|
+
)
|
|
1252
|
+
)
|
|
1253
|
+
|
|
1254
|
+
module_quantities = [
|
|
1255
|
+
Quantity(
|
|
1256
|
+
'scf_iteration',
|
|
1257
|
+
r'(?:I| i)teration number :([\s\S]+?)(?:\n *\n\+{10}|\+\-{10})',
|
|
1258
|
+
sub_parser=TextParser(quantities=scf_quantities),
|
|
1259
|
+
repeats=True,
|
|
1260
|
+
),
|
|
1261
|
+
Quantity(
|
|
1262
|
+
'final',
|
|
1263
|
+
r'(?:Convergence targets achieved\. Performing final SCF iteration|Reached self-consistent loops maximum)([\s\S]+?)(\n *\n\+{10})',
|
|
1264
|
+
sub_parser=TextParser(quantities=scf_quantities),
|
|
1265
|
+
repeats=False,
|
|
1266
|
+
),
|
|
1267
|
+
Quantity(
|
|
1268
|
+
'atomic_positions',
|
|
1269
|
+
r'(Atomic positions\s*\([\s\S]+?)\n\n',
|
|
1270
|
+
sub_parser=TextParser(
|
|
1271
|
+
quantities=[
|
|
1272
|
+
Quantity(
|
|
1273
|
+
'positions_format', r'Atomic positions\s*\(([a-z]+)\)'
|
|
1274
|
+
),
|
|
1275
|
+
Quantity(
|
|
1276
|
+
'symbols', r'atom\s*\d+\s*(\w+)', repeats=True, dtype=str
|
|
1277
|
+
),
|
|
1278
|
+
Quantity(
|
|
1279
|
+
'positions',
|
|
1280
|
+
r'\s*:\s*([\d\.\-]+\s*[\d\.\-]+\s*[\d\.\-]+)',
|
|
1281
|
+
repeats=True,
|
|
1282
|
+
dtype=float,
|
|
1283
|
+
),
|
|
1284
|
+
]
|
|
1285
|
+
),
|
|
1286
|
+
),
|
|
1287
|
+
Quantity(
|
|
1288
|
+
'forces',
|
|
1289
|
+
r'Total atomic forces including IBS \(\w+\)\s*\:(\s*atom[\-\s\w\.\:]*?)\n *Atomic',
|
|
1290
|
+
repeats=False,
|
|
1291
|
+
str_operation=str_to_array,
|
|
1292
|
+
dtype=float,
|
|
1293
|
+
unit=ureg.hartree / ureg.bohr,
|
|
1294
|
+
),
|
|
1295
|
+
]
|
|
1296
|
+
|
|
1297
|
+
self._quantities.append(
|
|
1298
|
+
Quantity(
|
|
1299
|
+
'groundstate',
|
|
1300
|
+
r'(?:Self\-consistent loop started|Groundstate module started)([\s\S]+?)Groundstate module stopped',
|
|
1301
|
+
sub_parser=TextParser(quantities=module_quantities),
|
|
1302
|
+
repeats=False,
|
|
1303
|
+
)
|
|
1304
|
+
)
|
|
1305
|
+
|
|
1306
|
+
optimization_quantities = [
|
|
1307
|
+
Quantity(
|
|
1308
|
+
'atomic_positions',
|
|
1309
|
+
r'(Atomic positions at this step\s*\([\s\S]+?)\n\n',
|
|
1310
|
+
sub_parser=TextParser(
|
|
1311
|
+
quantities=[
|
|
1312
|
+
Quantity(
|
|
1313
|
+
'positions_format',
|
|
1314
|
+
r'Atomic positions at this step\s*\(([a-z]+)\)',
|
|
1315
|
+
),
|
|
1316
|
+
Quantity(
|
|
1317
|
+
'symbols', r'atom\s*\d+\s*(\w+)', repeats=True, dtype=str
|
|
1318
|
+
),
|
|
1319
|
+
Quantity(
|
|
1320
|
+
'positions',
|
|
1321
|
+
r'\s*:\s*([\d\.\-]+\s*[\d\.\-]+\s*[\d\.\-]+)',
|
|
1322
|
+
repeats=True,
|
|
1323
|
+
dtype=float,
|
|
1324
|
+
),
|
|
1325
|
+
]
|
|
1326
|
+
),
|
|
1327
|
+
),
|
|
1328
|
+
Quantity(
|
|
1329
|
+
'forces',
|
|
1330
|
+
r'Total atomic forces including IBS \(\w+\)\s*\:(\s*atom[\-\s\w\.\:]*?)\n *Time',
|
|
1331
|
+
repeats=False,
|
|
1332
|
+
str_operation=str_to_array,
|
|
1333
|
+
convert=False,
|
|
1334
|
+
unit=ureg.hartree / ureg.bohr,
|
|
1335
|
+
),
|
|
1336
|
+
Quantity('step', r'Optimization step\s*(\d+)', repeats=False, dtype=int),
|
|
1337
|
+
Quantity('method', r'method\s*=\s*(\w+)', repeats=False, dtype=str),
|
|
1338
|
+
Quantity(
|
|
1339
|
+
'n_scf_iterations',
|
|
1340
|
+
r'Number of (?:total)* scf iterations\s*\:\s*(\d+)',
|
|
1341
|
+
repeats=False,
|
|
1342
|
+
dtype=int,
|
|
1343
|
+
),
|
|
1344
|
+
Quantity(
|
|
1345
|
+
'force_convergence',
|
|
1346
|
+
r'Maximum force magnitude\s*\(target\)\s*\:(\s*[\(\)\d\.\-\+Ee ]+)',
|
|
1347
|
+
str_operation=str_to_quantity_tolerances,
|
|
1348
|
+
unit=ureg.hartree / ureg.bohr,
|
|
1349
|
+
repeats=False,
|
|
1350
|
+
dtype=float,
|
|
1351
|
+
),
|
|
1352
|
+
Quantity(
|
|
1353
|
+
'energy_total',
|
|
1354
|
+
r'Total energy at this optimization step\s*\:\s*([\-\d\.Ee]+)',
|
|
1355
|
+
unit=ureg.hartree,
|
|
1356
|
+
repeats=False,
|
|
1357
|
+
dtype=float,
|
|
1358
|
+
),
|
|
1359
|
+
Quantity(
|
|
1360
|
+
'time_calculation',
|
|
1361
|
+
r'Time spent in this optimization step\s*\:\s*([\-\d\.Ee]+)\s*seconds',
|
|
1362
|
+
unit=ureg.s,
|
|
1363
|
+
repeats=False,
|
|
1364
|
+
dtype=float,
|
|
1365
|
+
),
|
|
1366
|
+
]
|
|
1367
|
+
|
|
1368
|
+
self._quantities.append(
|
|
1369
|
+
Quantity(
|
|
1370
|
+
'structure_optimization',
|
|
1371
|
+
r'Structure\-optimization module started([\s\S]+?)Structure\-optimization module stopped',
|
|
1372
|
+
sub_parser=TextParser(
|
|
1373
|
+
quantities=[
|
|
1374
|
+
Quantity(
|
|
1375
|
+
'optimization_step',
|
|
1376
|
+
r'(Optimization step\s*\d+[\s\S]+?(?:\n *\n\-{10}|Time spent in this optimization step\s*:\s*[\d\.]+ seconds))',
|
|
1377
|
+
sub_parser=TextParser(quantities=optimization_quantities),
|
|
1378
|
+
repeats=True,
|
|
1379
|
+
),
|
|
1380
|
+
Quantity(
|
|
1381
|
+
'final',
|
|
1382
|
+
r'Force convergence target achieved([\s\S]+?Opt)',
|
|
1383
|
+
sub_parser=TextParser(quantities=scf_quantities),
|
|
1384
|
+
repeats=False,
|
|
1385
|
+
),
|
|
1386
|
+
Quantity(
|
|
1387
|
+
'atomic_positions',
|
|
1388
|
+
r'(imized atomic positions\s*\([\s\S]+?)\n\n',
|
|
1389
|
+
sub_parser=TextParser(
|
|
1390
|
+
quantities=[
|
|
1391
|
+
Quantity(
|
|
1392
|
+
'positions_format',
|
|
1393
|
+
r'imized atomic positions\s*\(([a-z]+)\)',
|
|
1394
|
+
),
|
|
1395
|
+
Quantity(
|
|
1396
|
+
'symbols',
|
|
1397
|
+
r'atom\s*\d+\s*(\w+)',
|
|
1398
|
+
repeats=True,
|
|
1399
|
+
dtype=str,
|
|
1400
|
+
),
|
|
1401
|
+
Quantity(
|
|
1402
|
+
'positions',
|
|
1403
|
+
r'\s*:\s*([\d\.\-]+\s*[\d\.\-]+\s*[\d\.\-]+)',
|
|
1404
|
+
repeats=True,
|
|
1405
|
+
dtype=float,
|
|
1406
|
+
),
|
|
1407
|
+
]
|
|
1408
|
+
),
|
|
1409
|
+
),
|
|
1410
|
+
Quantity(
|
|
1411
|
+
'forces',
|
|
1412
|
+
r'Total atomic forces including IBS \(\w+\)\s*\:(\s*atom[\-\s\w\.\:]*?)\n *Atomic',
|
|
1413
|
+
repeats=False,
|
|
1414
|
+
str_operation=str_to_array,
|
|
1415
|
+
dtype=float,
|
|
1416
|
+
unit=ureg.hartree / ureg.bohr,
|
|
1417
|
+
),
|
|
1418
|
+
]
|
|
1419
|
+
),
|
|
1420
|
+
repeats=False,
|
|
1421
|
+
)
|
|
1422
|
+
)
|
|
1423
|
+
|
|
1424
|
+
self._quantities.append(
|
|
1425
|
+
Quantity(
|
|
1426
|
+
'hybrids',
|
|
1427
|
+
r'Hybrids module started([\s\S]+?)Hybrids module stopped',
|
|
1428
|
+
sub_parser=TextParser(quantities=module_quantities),
|
|
1429
|
+
)
|
|
1430
|
+
)
|
|
1431
|
+
|
|
1432
|
+
self._quantities.append(
|
|
1433
|
+
Quantity(
|
|
1434
|
+
'total_time',
|
|
1435
|
+
r' Total time spent \(seconds\) +: +([\d\.]+)',
|
|
1436
|
+
unit=ureg.s,
|
|
1437
|
+
repeats=False,
|
|
1438
|
+
dtype=float,
|
|
1439
|
+
)
|
|
1440
|
+
)
|
|
1441
|
+
|
|
1442
|
+
def get_atom_labels(self, section):
|
|
1443
|
+
labels = section.get('symbols')
|
|
1444
|
+
|
|
1445
|
+
if labels is None:
|
|
1446
|
+
# we get it by concatenating species symbols
|
|
1447
|
+
species = self.get('initialization', {}).get('species', [])
|
|
1448
|
+
labels = []
|
|
1449
|
+
for specie in species:
|
|
1450
|
+
labels += [specie.get('symbol')] * len(specie.get('positions'))
|
|
1451
|
+
return labels
|
|
1452
|
+
|
|
1453
|
+
def get_positions_format(self, section):
|
|
1454
|
+
positions_format = section.get('positions_format')
|
|
1455
|
+
|
|
1456
|
+
if positions_format is None:
|
|
1457
|
+
species = self.get_initialization_parameter('species', [])
|
|
1458
|
+
for specie in species:
|
|
1459
|
+
positions_format = specie.get('positions_format', None)
|
|
1460
|
+
if positions_format is not None:
|
|
1461
|
+
break
|
|
1462
|
+
|
|
1463
|
+
return positions_format
|
|
1464
|
+
|
|
1465
|
+
def get_atom_positions(self, section={}, positions=None, positions_format=None):
|
|
1466
|
+
positions = positions if positions is not None else section.get('positions')
|
|
1467
|
+
|
|
1468
|
+
if positions is None:
|
|
1469
|
+
species = self.get_initialization_parameter('species', [])
|
|
1470
|
+
if species:
|
|
1471
|
+
positions = np.vstack([s.get('positions') for s in species])
|
|
1472
|
+
|
|
1473
|
+
if positions is None:
|
|
1474
|
+
return
|
|
1475
|
+
|
|
1476
|
+
positions = np.array(positions)
|
|
1477
|
+
positions_format = (
|
|
1478
|
+
positions_format
|
|
1479
|
+
if positions_format is not None
|
|
1480
|
+
else self.get_positions_format(section)
|
|
1481
|
+
)
|
|
1482
|
+
|
|
1483
|
+
if positions_format == 'lattice':
|
|
1484
|
+
cell = self.get_initialization_parameter('lattice_vectors')
|
|
1485
|
+
if cell is None:
|
|
1486
|
+
return
|
|
1487
|
+
positions = np.dot(positions, cell.magnitude)
|
|
1488
|
+
|
|
1489
|
+
return positions * ureg.bohr
|
|
1490
|
+
|
|
1491
|
+
def get_scf_threshold(self, name):
|
|
1492
|
+
reference = self.get('groundstate', self.get('hybrids', {}))
|
|
1493
|
+
return reference.get('scf_iteration', [{}])[-1].get(name, [None, None])[-1]
|
|
1494
|
+
|
|
1495
|
+
def get_scf_quantity(self, name):
|
|
1496
|
+
n_scf = len(self.get('energy_total_scf_iteration', []))
|
|
1497
|
+
quantity = self.get('%s_scf_iteration' % name)
|
|
1498
|
+
if quantity is None:
|
|
1499
|
+
return
|
|
1500
|
+
|
|
1501
|
+
# this is really problematic if some scf steps dont have the quantity
|
|
1502
|
+
# the only thing that we can do is to assume that the first steps are the
|
|
1503
|
+
# ones with the missing quantity
|
|
1504
|
+
if len(quantity) < n_scf:
|
|
1505
|
+
quantity = [None] * (n_scf - len(quantity)) + quantity
|
|
1506
|
+
|
|
1507
|
+
return quantity
|
|
1508
|
+
|
|
1509
|
+
def get_xc_functional_name(self):
|
|
1510
|
+
# TODO expand list to include other xcf
|
|
1511
|
+
xc_functional_map = {
|
|
1512
|
+
2: ['LDA_C_PZ', 'LDA_X_PZ'],
|
|
1513
|
+
3: ['LDA_C_PW', 'LDA_X_PZ'],
|
|
1514
|
+
4: ['LDA_C_XALPHA'],
|
|
1515
|
+
5: ['LDA_C_VBH'],
|
|
1516
|
+
20: ['GGA_C_PBE', 'GGA_X_PBE'],
|
|
1517
|
+
21: ['GGA_C_PBE', 'GGA_X_PBE_R'],
|
|
1518
|
+
22: ['GGA_C_PBE_SOL', 'GGA_X_PBE_SOL'],
|
|
1519
|
+
26: ['GGA_C_PBE', 'GGA_X_WC'],
|
|
1520
|
+
30: ['GGA_C_AM05', 'GGA_C_AM05'],
|
|
1521
|
+
300: ['GGA_C_BGCP', 'GGA_X_PBE'],
|
|
1522
|
+
406: ['HYB_GGA_XC_PBEH'],
|
|
1523
|
+
408: ['HYB_GGA_XC_HSE03'],
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
xc_functional = self.get('initialization', {}).get('xc_functional', None)
|
|
1527
|
+
if xc_functional is None:
|
|
1528
|
+
return []
|
|
1529
|
+
|
|
1530
|
+
name = xc_functional_map.get(xc_functional.type, [])
|
|
1531
|
+
|
|
1532
|
+
return name
|
|
1533
|
+
|
|
1534
|
+
@property
|
|
1535
|
+
def n_optimization_steps(self):
|
|
1536
|
+
return len(self.get('structure_optimization', {}).get('optimization_step', []))
|
|
1537
|
+
|
|
1538
|
+
def get_number_of_spin_channels(self):
|
|
1539
|
+
spin_treatment = self.get('initialization', {}).get(
|
|
1540
|
+
'x_exciting_spin_treatment', 'spin-unpolarised'
|
|
1541
|
+
)
|
|
1542
|
+
n_spin = 1 if spin_treatment.lower() == 'spin-unpolarised' else 2
|
|
1543
|
+
return n_spin
|
|
1544
|
+
|
|
1545
|
+
def get_unit_cell_volume(self):
|
|
1546
|
+
return self.get('initialization', {}).get(
|
|
1547
|
+
'x_exciting_unit_cell_volume', 1.0 * ureg.bohr**3
|
|
1548
|
+
)
|
|
1549
|
+
|
|
1550
|
+
def get_initialization_parameter(self, key, default=None):
|
|
1551
|
+
return self.get('initialization', {}).get(key, default)
|
|
1552
|
+
|
|
1553
|
+
|
|
1554
|
+
class ExcitingParser(BeyondDFTWorkflowsParser):
|
|
1555
|
+
def __init__(self):
|
|
1556
|
+
self.info_parser = ExcitingInfoParser()
|
|
1557
|
+
self.dos_parser = DOSXMLParser(energy_unit=ureg.hartree)
|
|
1558
|
+
self.bandstructure_parser = BandstructureXMLParser(energy_unit=ureg.hartree)
|
|
1559
|
+
self.eigval_parser = ExcitingEigenvalueParser()
|
|
1560
|
+
self.fermisurf_parser = ExcitingFermiSurfaceBxsfParser()
|
|
1561
|
+
self.evalqp_parser = ExcitingEvalqpParser()
|
|
1562
|
+
self.dos_out_parser = DataTextParser()
|
|
1563
|
+
self.bandstructure_dat_parser = BandstructureDatParser(energy_unit=ureg.hartree)
|
|
1564
|
+
self.band_out_parser = BandOutParser(energy_unit=ureg.hartree)
|
|
1565
|
+
self.info_gw_parser = GWInfoParser()
|
|
1566
|
+
self.input_xml_parser = XMLParser()
|
|
1567
|
+
self.data_xs_parser = DataTextParser()
|
|
1568
|
+
self.data_clathrate_parser = DataTextParser(dtype=str)
|
|
1569
|
+
self.species_parser = SpeciesParser()
|
|
1570
|
+
self.linengy_parser = LinengyParser()
|
|
1571
|
+
self._child_archives = {}
|
|
1572
|
+
|
|
1573
|
+
# different names for different versions of exciting
|
|
1574
|
+
self._energy_keys_mapping = {
|
|
1575
|
+
'energy_total': ['Total energy', 'total energy'],
|
|
1576
|
+
'x_exciting_fermi_energy': ['Fermi energy', 'Fermi'],
|
|
1577
|
+
'energy_kinetic_electronic': ['Kinetic energy', 'electronic kinetic'],
|
|
1578
|
+
'energy_coulomb': ['Coulomb energy', 'Coulomb'],
|
|
1579
|
+
'x_exciting_coulomb_energy': ['Coulomb energy', 'Coulomb'],
|
|
1580
|
+
'energy_exchange': ['Exchange energy', 'exchange'],
|
|
1581
|
+
'x_exciting_exchange_energy': ['Exchange energy', 'exchange'],
|
|
1582
|
+
'energy_correlation': ['Correlation energy', 'correlation'],
|
|
1583
|
+
'x_exciting_correlation_energy': ['Correlation energy', 'correlation'],
|
|
1584
|
+
'energy_sum_eigenvalues': ['Sum of eigenvalues', 'sum of eigenvalues'],
|
|
1585
|
+
'x_exciting_effective_potential_energy': ['Effective potential energy'],
|
|
1586
|
+
'x_exciting_coulomb_potential_energy': [
|
|
1587
|
+
'Coulomb potential energy',
|
|
1588
|
+
'Coulomb potential',
|
|
1589
|
+
],
|
|
1590
|
+
'energy_xc_potential': ['xc potential energy', 'xc potential'],
|
|
1591
|
+
'energy_electrostatic': ['Hartree energy', 'Hartree'],
|
|
1592
|
+
'x_exciting_hartree_energy': ['Hartree energy', 'Hartree'],
|
|
1593
|
+
'x_exciting_electron_nuclear_energy': [
|
|
1594
|
+
'Electron-nuclear energy',
|
|
1595
|
+
'electron-nuclear ',
|
|
1596
|
+
],
|
|
1597
|
+
'x_exciting_nuclear_nuclear_energy': [
|
|
1598
|
+
'Nuclear-nuclear energy',
|
|
1599
|
+
'nuclear-nuclear',
|
|
1600
|
+
],
|
|
1601
|
+
'x_exciting_madelung_energy': ['Madelung energy', 'Madelung'],
|
|
1602
|
+
'x_exciting_core_electron_kinetic_energy': [
|
|
1603
|
+
'Core-electron kinetic energy',
|
|
1604
|
+
'core electron kinetic',
|
|
1605
|
+
],
|
|
1606
|
+
'x_exciting_dft_d2_dispersion_correction': ['DFT-D2 dispersion correction'],
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
self._electron_charge_keys_mapping = {
|
|
1610
|
+
'x_exciting_core_charge': ['core'],
|
|
1611
|
+
'x_exciting_core_leakage': ['core leakage'],
|
|
1612
|
+
'x_exciting_valence_charge': ['valence'],
|
|
1613
|
+
'x_exciting_interstitial_charge': ['interstitial'],
|
|
1614
|
+
'x_exciting_total_MT_charge': [
|
|
1615
|
+
'total charge in muffin-tins',
|
|
1616
|
+
'total in muffin-tins',
|
|
1617
|
+
],
|
|
1618
|
+
'charge_total': ['total charge'],
|
|
1619
|
+
'x_exciting_section_MT_charge_atom': ['atom_resolved'],
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
self._moment_keys_mapping = {
|
|
1623
|
+
'x_exciting_interstitial_moment': ['interstitial'],
|
|
1624
|
+
'x_exciting_total_MT_moment': ['total moment in muffin-tins'],
|
|
1625
|
+
'x_exciting_total_moment': ['total moment'],
|
|
1626
|
+
'x_exciting_section_MT_moment_atom': ['atom_resolved'],
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
self._xs_spectra_types = ['EPSILON', 'EXCITON', 'SIGMA', 'LOSS']
|
|
1630
|
+
|
|
1631
|
+
self._gw_input_default = {
|
|
1632
|
+
'coreflag': 'all',
|
|
1633
|
+
'ibgw': 1,
|
|
1634
|
+
'mblksiz': 0,
|
|
1635
|
+
'nbgw': 0,
|
|
1636
|
+
'nempty': 0,
|
|
1637
|
+
'ngridq': [0, 0, 0],
|
|
1638
|
+
'printSelfC': False,
|
|
1639
|
+
'printSpectralFunction': False,
|
|
1640
|
+
'qdepw': 'tet',
|
|
1641
|
+
'rpmat': False,
|
|
1642
|
+
'skipgnd': False,
|
|
1643
|
+
'taskname': 'g0w0',
|
|
1644
|
+
'vqloff': [0.0, 0.0, 0.0],
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
self._freqgrid_input_default = {
|
|
1648
|
+
'eta': 1.0e-3,
|
|
1649
|
+
'fconv': 'imfreq',
|
|
1650
|
+
'fgrid': 'gauleg2',
|
|
1651
|
+
'freqmax': 1.0,
|
|
1652
|
+
'freqmin': 0.0,
|
|
1653
|
+
'nomeg': 16,
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
self._freq_grid_map = {
|
|
1657
|
+
'eqdist': 'Equidistant',
|
|
1658
|
+
'gaulag': 'Gauss-Laguerre',
|
|
1659
|
+
'gauleg': 'Gauss-Legendre',
|
|
1660
|
+
'gauleg2': 'Gauss-Legendre',
|
|
1661
|
+
'clencurt2': 'Clenshaw-Curtis',
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
self._selfenergy_input_default = {
|
|
1665
|
+
'actype': 'pade',
|
|
1666
|
+
'eqpsolver': 0,
|
|
1667
|
+
'eshift': 0,
|
|
1668
|
+
'method': 'ac',
|
|
1669
|
+
'nempty': 0,
|
|
1670
|
+
'singularity': 'mbp',
|
|
1671
|
+
'swidth': 1.0e-4,
|
|
1672
|
+
'tol': 1.0e-12,
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
self._wgrid_input_default = {
|
|
1676
|
+
'size': 1000,
|
|
1677
|
+
'type': 'eqdist',
|
|
1678
|
+
'wmax': 1.0,
|
|
1679
|
+
'wmin': -1.0,
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
self._mixbasis_input_default = {'epsmb': 1.0e-4, 'gmb': 1.0, 'lmaxmb': 3}
|
|
1683
|
+
|
|
1684
|
+
self._barecoul_input_default = {
|
|
1685
|
+
'barcevtol': 0.1,
|
|
1686
|
+
'basis': 'mb',
|
|
1687
|
+
'cutofftype': None,
|
|
1688
|
+
'pwm': 2.0,
|
|
1689
|
+
'stctol': 1.0e-15,
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
self._scrcoul_input_default = {'omegap': 1.0, 'scrtype': 'rpa'}
|
|
1693
|
+
|
|
1694
|
+
self._bse_type_map = {
|
|
1695
|
+
'singlet': 'Singlet',
|
|
1696
|
+
'triplet': 'Triplet',
|
|
1697
|
+
'IP': 'IP',
|
|
1698
|
+
'RPA': 'RPA',
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
def file_exists(self, filename: str, fuzzy: bool = False) -> list[str]:
|
|
1702
|
+
"""Checks if a the given filename exists and is accessible in the same
|
|
1703
|
+
folder where the mainfile is stored. `fuzzy` toggles regex matching.
|
|
1704
|
+
"""
|
|
1705
|
+
mainfile = os.path.basename(self.info_parser.mainfile)
|
|
1706
|
+
suffix = mainfile.strip('INFO.OUT')
|
|
1707
|
+
target = filename.rsplit('.', 1)
|
|
1708
|
+
filepath = '%s%s' % (target[0], suffix)
|
|
1709
|
+
if target[1:]:
|
|
1710
|
+
filepath = '%s.%s' % (filepath, target[1])
|
|
1711
|
+
if fuzzy:
|
|
1712
|
+
filepaths = [
|
|
1713
|
+
file
|
|
1714
|
+
for file in os.listdir(self.info_parser.maindir)
|
|
1715
|
+
if re.match(filename, file)
|
|
1716
|
+
]
|
|
1717
|
+
return filepaths
|
|
1718
|
+
else:
|
|
1719
|
+
filepath = os.path.join(self.info_parser.maindir, filepath)
|
|
1720
|
+
if os.path.isfile(filepath):
|
|
1721
|
+
return [filepath]
|
|
1722
|
+
return []
|
|
1723
|
+
|
|
1724
|
+
def _parse_dos(self, sec_scc):
|
|
1725
|
+
if self.dos_parser.get('totaldos', None) is None:
|
|
1726
|
+
return
|
|
1727
|
+
|
|
1728
|
+
# Get fermi energy: it is used to un-shift the DOS to
|
|
1729
|
+
# the original scale in which also other energies are reported.
|
|
1730
|
+
energy_fermi = sec_scc.energy.fermi
|
|
1731
|
+
if energy_fermi is None:
|
|
1732
|
+
return
|
|
1733
|
+
energy_fermi = (energy_fermi.magnitude * ureg.joule).to('hartree')
|
|
1734
|
+
|
|
1735
|
+
totaldos = self.dos_parser.get('totaldos')
|
|
1736
|
+
n_spin_channels = len(totaldos)
|
|
1737
|
+
for spin in range(len(totaldos)):
|
|
1738
|
+
sec_dos = Dos()
|
|
1739
|
+
sec_scc.dos_electronic.append(sec_dos)
|
|
1740
|
+
sec_dos.spin_channel = spin if n_spin_channels == 2 else None
|
|
1741
|
+
sec_dos.n_energies = self.dos_parser.number_of_dos
|
|
1742
|
+
sec_dos.energies = self.dos_parser.energies + energy_fermi
|
|
1743
|
+
sec_dos_total = DosValues()
|
|
1744
|
+
sec_dos.total.append(sec_dos_total)
|
|
1745
|
+
sec_dos_total.value = totaldos[spin]
|
|
1746
|
+
|
|
1747
|
+
# TODO fix this partial DOS parsing --> it is wrong, probably it is the orbital_projected.
|
|
1748
|
+
partialdos = self.dos_parser.get('partialdos')
|
|
1749
|
+
if partialdos is None:
|
|
1750
|
+
return
|
|
1751
|
+
|
|
1752
|
+
partialdos = partialdos.to('1/joule').magnitude
|
|
1753
|
+
n_energies = self.dos_parser.number_of_dos
|
|
1754
|
+
n_lm = len(partialdos)
|
|
1755
|
+
n_atoms = partialdos.shape[2]
|
|
1756
|
+
partialdos = np.reshape(
|
|
1757
|
+
partialdos, (n_spin_channels, n_lm, n_atoms, n_energies)
|
|
1758
|
+
)
|
|
1759
|
+
lm_values = np.column_stack((np.arange(n_lm), np.zeros(n_lm, dtype=np.int32)))
|
|
1760
|
+
for spin in range(n_spin_channels):
|
|
1761
|
+
if sec_scc.dos_electronic is not None and sec_scc.dos_electronic[spin]:
|
|
1762
|
+
sec_dos = sec_scc.dos_electronic[spin]
|
|
1763
|
+
else:
|
|
1764
|
+
sec_dos = Dos()
|
|
1765
|
+
sec_scc.dos_electronic.append(sec_dos)
|
|
1766
|
+
sec_dos.spin_channel = spin if n_spin_channels == 2 else None
|
|
1767
|
+
for lm in range(n_lm):
|
|
1768
|
+
for atom in range(n_atoms):
|
|
1769
|
+
sec_dos_atom = DosValues()
|
|
1770
|
+
sec_dos.atom_projected.append(sec_dos_atom)
|
|
1771
|
+
sec_dos_atom.m_kind = 'spherical'
|
|
1772
|
+
sec_dos_atom.lm = lm_values[lm]
|
|
1773
|
+
sec_dos_atom.atom_index = atom
|
|
1774
|
+
sec_dos_atom.value = partialdos[spin][lm][atom]
|
|
1775
|
+
|
|
1776
|
+
def _parse_bandstructure(self, sec_scc):
|
|
1777
|
+
# we need to set nspin again as this is overwritten when setting mainfile
|
|
1778
|
+
self.bandstructure_parser._nspin = (
|
|
1779
|
+
self.info_parser.get_number_of_spin_channels()
|
|
1780
|
+
)
|
|
1781
|
+
|
|
1782
|
+
band_energies = self.bandstructure_parser.get('band_energies', [])
|
|
1783
|
+
|
|
1784
|
+
for n in range(len(band_energies)):
|
|
1785
|
+
# Get fermi energy: it is used to un-shift the band structure to
|
|
1786
|
+
# the original scale in which also other energies are reported.
|
|
1787
|
+
energy_fermi = sec_scc.energy.fermi
|
|
1788
|
+
if energy_fermi is None:
|
|
1789
|
+
continue
|
|
1790
|
+
energy_fermi = energy_fermi.to('hartree')
|
|
1791
|
+
|
|
1792
|
+
sec_k_band = BandStructure()
|
|
1793
|
+
sec_scc.band_structure_electronic.append(sec_k_band)
|
|
1794
|
+
sec_k_band.energy_fermi = energy_fermi
|
|
1795
|
+
|
|
1796
|
+
band_k_points = self.bandstructure_parser.get('band_k_points')
|
|
1797
|
+
nkpts_segment = self.bandstructure_parser.number_of_k_points_per_segment
|
|
1798
|
+
band_seg_labels = self.bandstructure_parser.get('band_segm_labels')
|
|
1799
|
+
for nb in range(len(band_energies[n])):
|
|
1800
|
+
sec_k_band_segment = BandEnergies()
|
|
1801
|
+
sec_k_band.segment.append(sec_k_band_segment)
|
|
1802
|
+
sec_k_band_segment.n_kpoints = nkpts_segment[nb]
|
|
1803
|
+
sec_k_band_segment.kpoints = band_k_points[nb]
|
|
1804
|
+
sec_k_band_segment.endpoints_labels = band_seg_labels[nb]
|
|
1805
|
+
sec_k_band_segment.energies = band_energies[n][nb] + energy_fermi
|
|
1806
|
+
|
|
1807
|
+
def _parse_eigenvalues(self, sec_scc):
|
|
1808
|
+
if self.eigval_parser.get('eigenvalues_occupancies', None) is None:
|
|
1809
|
+
return
|
|
1810
|
+
|
|
1811
|
+
nspin = self.info_parser.get_number_of_spin_channels()
|
|
1812
|
+
|
|
1813
|
+
def get_data(key):
|
|
1814
|
+
data = self.eigval_parser.get('eigenvalues_occupancies')
|
|
1815
|
+
# reshaping is not necessary as this is done in parser, however nspin is
|
|
1816
|
+
# determined from occupancies which is problematic sometimes
|
|
1817
|
+
res = np.hstack(
|
|
1818
|
+
[np.reshape(v[key], (nspin, np.size(v[key]) // nspin)) for v in data]
|
|
1819
|
+
)
|
|
1820
|
+
res = res.reshape((len(res), len(data), len(res[0]) // len(data)))
|
|
1821
|
+
|
|
1822
|
+
if key == 'eigenvalues':
|
|
1823
|
+
res = res * ureg.hartree
|
|
1824
|
+
return res
|
|
1825
|
+
|
|
1826
|
+
sec_eigenvalues = BandEnergies()
|
|
1827
|
+
sec_scc.eigenvalues.append(sec_eigenvalues)
|
|
1828
|
+
sec_eigenvalues.kpoints = self.eigval_parser.get('k_points')
|
|
1829
|
+
sec_eigenvalues.occupations = get_data('occupancies')
|
|
1830
|
+
sec_eigenvalues.energies = get_data('eigenvalues')
|
|
1831
|
+
|
|
1832
|
+
def _parse_fermisurface(self, sec_scc):
|
|
1833
|
+
fermi_surface = self.fermisurf_parser.get('fermi_surface', [None])[0]
|
|
1834
|
+
if fermi_surface is None:
|
|
1835
|
+
return
|
|
1836
|
+
|
|
1837
|
+
sec_fermisurface = x_exciting_section_fermi_surface()
|
|
1838
|
+
sec_scc.x_exciting_section_fermi_surface.append(sec_fermisurface)
|
|
1839
|
+
|
|
1840
|
+
band_parameters = self.fermisurf_parser.get('band_parameters', None)
|
|
1841
|
+
if band_parameters is not None:
|
|
1842
|
+
sec_fermisurface.x_exciting_number_of_bands_fermi_surface = band_parameters[
|
|
1843
|
+
0
|
|
1844
|
+
]
|
|
1845
|
+
sec_fermisurface.x_exciting_number_of_mesh_points_fermi_surface = (
|
|
1846
|
+
np.product(band_parameters[1])
|
|
1847
|
+
)
|
|
1848
|
+
sec_fermisurface.x_exciting_grid_fermi_surface = band_parameters[1]
|
|
1849
|
+
sec_fermisurface.x_exciting_origin_fermi_surface = band_parameters[2]
|
|
1850
|
+
sec_fermisurface.x_exciting_vectors_fermi_surface = band_parameters[3]
|
|
1851
|
+
|
|
1852
|
+
fermi_energy = self.fermisurf_parser.get('fermi_energy', None)
|
|
1853
|
+
if fermi_energy is not None:
|
|
1854
|
+
sec_fermisurface.x_exciting_fermi_energy_fermi_surface = fermi_energy
|
|
1855
|
+
|
|
1856
|
+
sec_fermisurface.x_exciting_values_fermi_surface = fermi_surface
|
|
1857
|
+
|
|
1858
|
+
def _parse_evalqp(self, sec_scc):
|
|
1859
|
+
data = self.evalqp_parser.get('kpoints_eigenvalues')
|
|
1860
|
+
if data is None:
|
|
1861
|
+
return
|
|
1862
|
+
|
|
1863
|
+
def get_data(key):
|
|
1864
|
+
if key == 'k_points':
|
|
1865
|
+
return np.array([d[0][:3] for d in data])
|
|
1866
|
+
elif key == 'Znk':
|
|
1867
|
+
return np.array([d[1].get(key, None) for d in data])
|
|
1868
|
+
else:
|
|
1869
|
+
energy = np.array([d[1].get(key, None) for d in data])
|
|
1870
|
+
if None in energy:
|
|
1871
|
+
return energy
|
|
1872
|
+
return np.array([d[1].get(key) for d in data]) * ureg.hartree
|
|
1873
|
+
|
|
1874
|
+
eigs_gw = get_data('E_GW')
|
|
1875
|
+
if eigs_gw[0] is None:
|
|
1876
|
+
return
|
|
1877
|
+
|
|
1878
|
+
nspin = self.info_parser.get_number_of_spin_channels()
|
|
1879
|
+
|
|
1880
|
+
def reshape(data):
|
|
1881
|
+
if data[0] is None:
|
|
1882
|
+
return
|
|
1883
|
+
return np.reshape(data, (nspin, len(data) // nspin, len(data[0])))
|
|
1884
|
+
|
|
1885
|
+
sec_gw_eigenvalues = BandEnergies()
|
|
1886
|
+
sec_scc.eigenvalues.append(sec_gw_eigenvalues)
|
|
1887
|
+
sec_gw_eigenvalues.qp_linearization_prefactor = reshape(get_data('Znk'))
|
|
1888
|
+
sec_gw_eigenvalues.n_bands = len(eigs_gw[0])
|
|
1889
|
+
sec_gw_eigenvalues.n_kpoints = len(eigs_gw)
|
|
1890
|
+
sec_gw_eigenvalues.kpoints = get_data('k_points')
|
|
1891
|
+
|
|
1892
|
+
sec_gw_eigenvalues.energies = reshape(eigs_gw)
|
|
1893
|
+
sec_gw_eigenvalues.value_exchange = reshape(get_data('Sx'))
|
|
1894
|
+
eigs_gw_C = reshape(get_data('Sc'))
|
|
1895
|
+
if eigs_gw_C is None:
|
|
1896
|
+
eigs_gw_C = reshape(get_data('Re(Sc)'))
|
|
1897
|
+
sec_gw_eigenvalues.value_correlation = eigs_gw_C
|
|
1898
|
+
sec_gw_eigenvalues.value_xc_potential = reshape(get_data('Vxc'))
|
|
1899
|
+
|
|
1900
|
+
def _parse_dos_out(self, sec_scc):
|
|
1901
|
+
data = self.dos_out_parser.data
|
|
1902
|
+
if data is None:
|
|
1903
|
+
return
|
|
1904
|
+
|
|
1905
|
+
# Get fermi energy: it is used to un-shift the DOS to
|
|
1906
|
+
# the original scale in which also other energies are reported.
|
|
1907
|
+
energy_fermi = sec_scc.energy.fermi
|
|
1908
|
+
if energy_fermi is None:
|
|
1909
|
+
return
|
|
1910
|
+
energy_fermi = (energy_fermi.magnitude * ureg.joule).to('hartree')
|
|
1911
|
+
|
|
1912
|
+
# TODO I am not sure about format for spin-polarized case! I assume it is
|
|
1913
|
+
# energy dos_up dos_down
|
|
1914
|
+
nspin = self.info_parser.get_number_of_spin_channels()
|
|
1915
|
+
|
|
1916
|
+
data = np.reshape(data, (nspin, len(data) // nspin, 2))
|
|
1917
|
+
data = np.transpose(data, axes=(2, 0, 1))
|
|
1918
|
+
dos = data[1] * (1 / ureg.hartree)
|
|
1919
|
+
for spin in range(nspin):
|
|
1920
|
+
sec_dos = Dos()
|
|
1921
|
+
sec_scc.dos_electronic.append(sec_dos)
|
|
1922
|
+
sec_dos.spin_channel = spin if nspin == 2 else None
|
|
1923
|
+
sec_dos.n_energies = len(data) // nspin
|
|
1924
|
+
sec_dos.energies = data[0][0] * ureg.hartree + energy_fermi
|
|
1925
|
+
sec_dos_values = DosValues()
|
|
1926
|
+
sec_dos.total.append(sec_dos_values)
|
|
1927
|
+
sec_dos_values.value = dos[spin]
|
|
1928
|
+
|
|
1929
|
+
# TODO add PDOS
|
|
1930
|
+
|
|
1931
|
+
def _parse_bandstructure_dat(self, sec_scc):
|
|
1932
|
+
self.bandstructure_dat_parser._nspin = (
|
|
1933
|
+
self.info_parser.get_number_of_spin_channels()
|
|
1934
|
+
)
|
|
1935
|
+
|
|
1936
|
+
band_energies = self.bandstructure_dat_parser.band_energies
|
|
1937
|
+
if band_energies is None:
|
|
1938
|
+
return
|
|
1939
|
+
|
|
1940
|
+
# Get fermi energy: it is used to un-shift the band structure to
|
|
1941
|
+
# the original scale in which also other energies are reported.
|
|
1942
|
+
energy_fermi = sec_scc.energy.fermi
|
|
1943
|
+
if energy_fermi is None:
|
|
1944
|
+
return
|
|
1945
|
+
energy_fermi = (energy_fermi.magnitude * ureg.joule).to('hartree')
|
|
1946
|
+
|
|
1947
|
+
sec_k_band = BandStructure()
|
|
1948
|
+
sec_scc.band_structure_electronic.append(sec_k_band)
|
|
1949
|
+
sec_k_band.energy_fermi = energy_fermi
|
|
1950
|
+
|
|
1951
|
+
band_k_points = self.bandstructure_dat_parser.band_k_points
|
|
1952
|
+
nkpts_segment = self.bandstructure_dat_parser.number_of_k_points_per_segment
|
|
1953
|
+
for nb in range(len(band_energies)):
|
|
1954
|
+
sec_k_band_segment = BandEnergies()
|
|
1955
|
+
sec_k_band.segment.append(sec_k_band_segment)
|
|
1956
|
+
sec_k_band_segment.n_kpoints = nkpts_segment[nb]
|
|
1957
|
+
sec_k_band_segment.kpoints = band_k_points[nb]
|
|
1958
|
+
sec_k_band_segment.energies = band_energies[nb] + energy_fermi
|
|
1959
|
+
|
|
1960
|
+
def _parse_band_out(self, sec_scc):
|
|
1961
|
+
self.band_out_parser._nspin = self.info_parser.get_number_of_spin_channels()
|
|
1962
|
+
|
|
1963
|
+
band_energies = self.band_out_parser.band_energies
|
|
1964
|
+
if band_energies is None:
|
|
1965
|
+
return
|
|
1966
|
+
|
|
1967
|
+
# Get fermi energy: it is used to un-shift the band structure to
|
|
1968
|
+
# the original scale in which also other energies are reported.
|
|
1969
|
+
energy_fermi = 0.0 * ureg.hartree
|
|
1970
|
+
if sec_scc.energy is not None:
|
|
1971
|
+
energy_fermi = sec_scc.energy.fermi
|
|
1972
|
+
energy_fermi = (energy_fermi.magnitude * ureg.joule).to('hartree')
|
|
1973
|
+
sec_k_band = BandStructure()
|
|
1974
|
+
sec_scc.band_structure_electronic.append(sec_k_band)
|
|
1975
|
+
sec_k_band.energy_fermi = energy_fermi
|
|
1976
|
+
|
|
1977
|
+
nkpts_segment = self.band_out_parser.number_of_k_points_per_segment
|
|
1978
|
+
for nb in range(len(band_energies)):
|
|
1979
|
+
sec_k_band_segment = BandEnergies()
|
|
1980
|
+
sec_k_band.segment.append(sec_k_band_segment)
|
|
1981
|
+
sec_k_band_segment.n_kpoints = nkpts_segment[nb]
|
|
1982
|
+
sec_k_band_segment.value = band_energies[nb] + energy_fermi
|
|
1983
|
+
|
|
1984
|
+
def _parse_species(self, sec_method):
|
|
1985
|
+
def _set_orbital(
|
|
1986
|
+
source: TextParser, l_quantum_number: int, order: int, type: str = ''
|
|
1987
|
+
) -> OrbitalAPW:
|
|
1988
|
+
if not type:
|
|
1989
|
+
type = re.sub(r'\+lo', '', source.get('type', 'lapw')).upper()
|
|
1990
|
+
return OrbitalAPW(
|
|
1991
|
+
l_quantum_number=l_quantum_number,
|
|
1992
|
+
type=type,
|
|
1993
|
+
order=order,
|
|
1994
|
+
energy_parameter=[source['trialEnergy']] * ureg.hartree
|
|
1995
|
+
if 'trialEnergy' in source
|
|
1996
|
+
else None,
|
|
1997
|
+
energy_parameter_n=[source['n']] if 'n' in source else None,
|
|
1998
|
+
update=bool(source['searchE']) if 'searchE' in source else None,
|
|
1999
|
+
) # TODO: verify with Hanna what happend is trialEnergy and n can coexist
|
|
2000
|
+
|
|
2001
|
+
type_order_mapping = {' ': 0, 'apw': 1, 'lap': 2}
|
|
2002
|
+
self.species_parser.parse()
|
|
2003
|
+
species_data = self.species_parser.to_dict()
|
|
2004
|
+
|
|
2005
|
+
# muffin-tin valence
|
|
2006
|
+
radius = float(species_data['muffinTin']['radius'])
|
|
2007
|
+
radialmeshPoints = int(species_data['muffinTin']['radialmeshPoints'])
|
|
2008
|
+
radial_spacing = radius / radialmeshPoints
|
|
2009
|
+
bs_val = BasisSet(
|
|
2010
|
+
scope=['muffin-tin'],
|
|
2011
|
+
radius=radius * ureg.bohr,
|
|
2012
|
+
radius_lin_spacing=radial_spacing * ureg.bohr,
|
|
2013
|
+
)
|
|
2014
|
+
lo_samplings = {lo['l']: lo.get('wf', []) for lo in species_data.get('lo', [])}
|
|
2015
|
+
lmax = self.input_xml_parser.get('xs/lmaxapw', 10)
|
|
2016
|
+
|
|
2017
|
+
for l_n in range(lmax + 1):
|
|
2018
|
+
source = species_data.get('default', {})
|
|
2019
|
+
for custom_settings in species_data.get('custom', []):
|
|
2020
|
+
if custom_settings['l'] == l_n:
|
|
2021
|
+
source = custom_settings
|
|
2022
|
+
break
|
|
2023
|
+
for order in range(type_order_mapping[source.get('type', 3 * ' ')[:3]]):
|
|
2024
|
+
bs_val.orbital.append(_set_orbital(source, l_n, order))
|
|
2025
|
+
|
|
2026
|
+
# Add lo's
|
|
2027
|
+
if source.get('type', 2 * ' ')[-2:] == 'lo':
|
|
2028
|
+
wfs = lo_samplings[l_n] if l_n in lo_samplings else [source]
|
|
2029
|
+
for wf in wfs:
|
|
2030
|
+
for order in range(wf.get('matchingOrder', 0), 2):
|
|
2031
|
+
bs_val.orbital.append(_set_orbital(wf, l_n, order, type='LO'))
|
|
2032
|
+
|
|
2033
|
+
# manage atom parameters
|
|
2034
|
+
if not sec_method.atom_parameters:
|
|
2035
|
+
sec_method.atom_parameters = []
|
|
2036
|
+
sp = species_data.get('sp', {})
|
|
2037
|
+
sec_method.atom_parameters.append(
|
|
2038
|
+
AtomParameters(
|
|
2039
|
+
atom_number=abs(sp.get('z')),
|
|
2040
|
+
label=sp.get('chemicalSymbol'),
|
|
2041
|
+
mass=sp.get('mass') * ureg.amu if sp.get('mass') else None,
|
|
2042
|
+
)
|
|
2043
|
+
)
|
|
2044
|
+
bs_val.atom_parameters = sec_method.atom_parameters[-1]
|
|
2045
|
+
|
|
2046
|
+
if not sec_method.electrons_representation:
|
|
2047
|
+
sec_method.electrons_representation = [
|
|
2048
|
+
BasisSetContainer(
|
|
2049
|
+
scope=['wavefunction'],
|
|
2050
|
+
basis_set=[
|
|
2051
|
+
BasisSet(
|
|
2052
|
+
type='plane waves',
|
|
2053
|
+
scope=['valence'],
|
|
2054
|
+
cutoff_fractional=self.input_xml_parser.get(
|
|
2055
|
+
'xs/cutoffapw', 7.0
|
|
2056
|
+
),
|
|
2057
|
+
),
|
|
2058
|
+
],
|
|
2059
|
+
)
|
|
2060
|
+
]
|
|
2061
|
+
sec_method.electrons_representation[0].basis_set.append(bs_val)
|
|
2062
|
+
|
|
2063
|
+
def parse_file(self, name, section, filepath=None):
|
|
2064
|
+
# TODO add support for info.xml, wannier.out
|
|
2065
|
+
if name.startswith('dos') and name.endswith('xml'):
|
|
2066
|
+
parser = self.dos_parser
|
|
2067
|
+
parser_function = self._parse_dos
|
|
2068
|
+
elif name.startswith('bandstructure') and name.endswith('xml'):
|
|
2069
|
+
parser = self.bandstructure_parser
|
|
2070
|
+
parser_function = self._parse_bandstructure
|
|
2071
|
+
elif name.startswith('EIGVAL') and name.endswith('OUT'):
|
|
2072
|
+
parser = self.eigval_parser
|
|
2073
|
+
parser_function = self._parse_eigenvalues
|
|
2074
|
+
elif (name.startswith('FERMISURF') or name.startswith('FS')) and name.endswith(
|
|
2075
|
+
'bxsf'
|
|
2076
|
+
):
|
|
2077
|
+
parser = self.fermisurf_parser
|
|
2078
|
+
parser_function = self._parse_fermisurface
|
|
2079
|
+
elif name.startswith('EVALQP') and (
|
|
2080
|
+
name.endswith('DAT') or name.endswith('TXT')
|
|
2081
|
+
):
|
|
2082
|
+
parser = self.evalqp_parser
|
|
2083
|
+
parser_function = self._parse_evalqp
|
|
2084
|
+
elif name.startswith('TDOS') and name.endswith('OUT'):
|
|
2085
|
+
parser = self.dos_out_parser
|
|
2086
|
+
parser_function = self._parse_dos_out
|
|
2087
|
+
elif name.startswith('bandstructure') and name.endswith('dat'):
|
|
2088
|
+
parser = self.bandstructure_dat_parser
|
|
2089
|
+
parser_function = self._parse_bandstructure_dat
|
|
2090
|
+
elif name.startswith('BAND') and name.endswith('OUT'):
|
|
2091
|
+
parser = self.band_out_parser
|
|
2092
|
+
parser_function = self._parse_band_out
|
|
2093
|
+
elif re.match(r'[A-Z][a-z]?\.xml', name):
|
|
2094
|
+
parser = self.species_parser
|
|
2095
|
+
parser_function = self._parse_species
|
|
2096
|
+
elif name.startswith('input') and name.endswith('xml'):
|
|
2097
|
+
parser = self.input_xml_parser
|
|
2098
|
+
if self._calculation_type == 'gw':
|
|
2099
|
+
parser_function = self._parse_input_gw
|
|
2100
|
+
elif self._calculation_type == 'xs':
|
|
2101
|
+
parser_function = self._parse_input_xs
|
|
2102
|
+
else:
|
|
2103
|
+
# TODO implement reading of parameters from input.xml for normal calculations
|
|
2104
|
+
# in addition to INFO.OUT
|
|
2105
|
+
return
|
|
2106
|
+
else:
|
|
2107
|
+
return
|
|
2108
|
+
|
|
2109
|
+
filepath = filepath if filepath is not None else self.filepath
|
|
2110
|
+
files = get_files(name, filepath, 'INFO.OUT')
|
|
2111
|
+
if len(files) > 1:
|
|
2112
|
+
self.logger.warning(
|
|
2113
|
+
'Found multiple files. Will read all!', data=dict(file=name)
|
|
2114
|
+
)
|
|
2115
|
+
|
|
2116
|
+
for n in range(len(files)):
|
|
2117
|
+
parser.mainfile = files[n]
|
|
2118
|
+
parser_function(section)
|
|
2119
|
+
|
|
2120
|
+
# free up memory
|
|
2121
|
+
parser.mainfile = None
|
|
2122
|
+
|
|
2123
|
+
def _parse_input_xs(self, sec_method):
|
|
2124
|
+
xstype = self.input_xml_parser.get('xs/xstype', None)
|
|
2125
|
+
if xstype is not None:
|
|
2126
|
+
sec_method.x_exciting_xs_xstype = xstype
|
|
2127
|
+
sec_method.x_exciting_electronic_structure_method = xstype
|
|
2128
|
+
|
|
2129
|
+
sec_method.x_exciting_xs_broadening = self.input_xml_parser.get(
|
|
2130
|
+
'xs/broad', 0.01, 'hartree'
|
|
2131
|
+
)
|
|
2132
|
+
sec_method.x_exciting_xs_gqmax = self.input_xml_parser.get(
|
|
2133
|
+
'xs/gqmax', 0.0, '1/bohr'
|
|
2134
|
+
)
|
|
2135
|
+
sec_method.x_exciting_xs_lmaxapw = self.input_xml_parser.get('xs/lmaxapw', 10)
|
|
2136
|
+
sec_method.x_exciting_xs_number_of_empty_states = self.input_xml_parser.get(
|
|
2137
|
+
'xs/nempty', 5
|
|
2138
|
+
)
|
|
2139
|
+
sec_method.x_exciting_xs_ngridq = self.input_xml_parser.get(
|
|
2140
|
+
'xs/ngridq', [1, 1, 1]
|
|
2141
|
+
)
|
|
2142
|
+
sec_method.x_exciting_xs_ngridk = self.input_xml_parser.get(
|
|
2143
|
+
'xs/ngridk', [1, 1, 1]
|
|
2144
|
+
)
|
|
2145
|
+
rgkmax = self.input_xml_parser.get('xs/rgkmax', None)
|
|
2146
|
+
if rgkmax is None:
|
|
2147
|
+
rgkmax = self.info_parser.get_initialization_parameter(
|
|
2148
|
+
'x_exciting_rgkmax', 0.0
|
|
2149
|
+
)
|
|
2150
|
+
sec_method.x_exciting_xs_rgkmax = rgkmax
|
|
2151
|
+
sec_method.x_exciting_xs_scissor = self.input_xml_parser.get('xs/scissor', 0.0)
|
|
2152
|
+
sec_method.x_exciting_xs_vkloff = self.input_xml_parser.get(
|
|
2153
|
+
'xs/vkloff', [0.0, 0.0, 0.0]
|
|
2154
|
+
)
|
|
2155
|
+
|
|
2156
|
+
if self.input_xml_parser.get('xs/energywindow') is not None:
|
|
2157
|
+
sec_method.x_exciting_xs_energywindow_values = self.input_xml_parser.get(
|
|
2158
|
+
'xs/energywindow/intv', np.array([-0.5, 0.5]), 'hartree'
|
|
2159
|
+
)
|
|
2160
|
+
sec_method.x_exciting_xs_energywindow_points = self.input_xml_parser.get(
|
|
2161
|
+
'xs/energywindow/points', 500
|
|
2162
|
+
)
|
|
2163
|
+
|
|
2164
|
+
if self.input_xml_parser.get('xs/screening') is not None:
|
|
2165
|
+
sec_method.x_exciting_xs_screening_number_of_empty_states = (
|
|
2166
|
+
self.input_xml_parser.get('xs/screening/nempty', 0)
|
|
2167
|
+
)
|
|
2168
|
+
sec_method.x_exciting_xs_screening_ngridk = self.input_xml_parser.get(
|
|
2169
|
+
'xs/screening/ngridk', [0, 0, 0]
|
|
2170
|
+
)
|
|
2171
|
+
rgkmax = self.input_xml_parser.get('xs/screening/rgkmax', None)
|
|
2172
|
+
if rgkmax is None:
|
|
2173
|
+
rgkmax = self.info_parser.get_initialization_parameter(
|
|
2174
|
+
'x_exciting_rgkmax', 0.0
|
|
2175
|
+
)
|
|
2176
|
+
sec_method.x_exciting_xs_screening_rgkmax = rgkmax
|
|
2177
|
+
sec_method.x_exciting_xs_screening_type = self.input_xml_parser.get(
|
|
2178
|
+
'xs/screening/screentype', 'full'
|
|
2179
|
+
)
|
|
2180
|
+
|
|
2181
|
+
if self.input_xml_parser.get('xs/BSE') is not None:
|
|
2182
|
+
sec_method.x_exciting_xs_bse_type = self.input_xml_parser.get(
|
|
2183
|
+
'xs/BSE/bsetype', 'singlet'
|
|
2184
|
+
)
|
|
2185
|
+
sec_method.x_exciting_xs_bse_antiresonant = self.input_xml_parser.get(
|
|
2186
|
+
'xs/BSE/aresbse', True
|
|
2187
|
+
)
|
|
2188
|
+
sec_method.x_exciting_xs_bse_angular_momentum_cutoff = (
|
|
2189
|
+
self.input_xml_parser.get('xs/BSE/lmaxdielt', 14)
|
|
2190
|
+
)
|
|
2191
|
+
rgkmax = self.input_xml_parser.get('xs/BSE/rgkmax', None)
|
|
2192
|
+
if rgkmax is None:
|
|
2193
|
+
rgkmax = self.info_parser.get_initialization_parameter(
|
|
2194
|
+
'x_exciting_rgkmax', 0
|
|
2195
|
+
)
|
|
2196
|
+
|
|
2197
|
+
sec_method.x_exciting_xs_bse_rgkmax = rgkmax
|
|
2198
|
+
sec_method.x_exciting_xs_bse_sciavbd = self.input_xml_parser.get(
|
|
2199
|
+
'xs/BSE/sciavbd', True
|
|
2200
|
+
)
|
|
2201
|
+
sec_method.x_exciting_xs_bse_sciavqbd = self.input_xml_parser.get(
|
|
2202
|
+
'xs/BSE/sciavqbd', False
|
|
2203
|
+
)
|
|
2204
|
+
sec_method.x_exciting_xs_bse_sciavqhd = self.input_xml_parser.get(
|
|
2205
|
+
'xs/BSE/sciavqhd', False
|
|
2206
|
+
)
|
|
2207
|
+
sec_method.x_exciting_xs_bse_sciavqwg = self.input_xml_parser.get(
|
|
2208
|
+
'xs/BSE/sciavqwg', False
|
|
2209
|
+
)
|
|
2210
|
+
sec_method.x_exciting_xs_bse_sciavtype = self.input_xml_parser.get(
|
|
2211
|
+
'xs/BSE/sciavtype', 'spherical'
|
|
2212
|
+
)
|
|
2213
|
+
sec_method.x_exciting_xs_bse_xas = self.input_xml_parser.get(
|
|
2214
|
+
'xs/BSE/xas', False
|
|
2215
|
+
)
|
|
2216
|
+
sec_method.x_exciting_xs_bse_number_of_bands = self.input_xml_parser.get(
|
|
2217
|
+
'xs/BSE/nstlbse', [0, 0, 0, 0]
|
|
2218
|
+
)
|
|
2219
|
+
if sec_method.x_exciting_xs_bse_xas:
|
|
2220
|
+
sec_method.x_exciting_xs_bse_xasatom = self.input_xml_parser.get(
|
|
2221
|
+
'xs/BSE/xasatom', 0
|
|
2222
|
+
)
|
|
2223
|
+
sec_method.x_exciting_xs_bse_xasedge = self.input_xml_parser.get(
|
|
2224
|
+
'xs/BSE/xasedge', 'K'
|
|
2225
|
+
)
|
|
2226
|
+
sec_method.x_exciting_xs_bse_xasspecies = self.input_xml_parser.get(
|
|
2227
|
+
'xs/BSE/xasspecies', 0
|
|
2228
|
+
)
|
|
2229
|
+
sec_method.x_exciting_xs_bse_xas_number_of_bands = (
|
|
2230
|
+
self.input_xml_parser.get('xs/BSE/nstlxas', [0, 0])
|
|
2231
|
+
)
|
|
2232
|
+
|
|
2233
|
+
if self.input_xml_parser.get('xs/tddft') is not None:
|
|
2234
|
+
sec_method.x_exciting_xs_tddft_analytic_continuation = (
|
|
2235
|
+
self.input_xml_parser.get('xs/tddft/acont', False)
|
|
2236
|
+
)
|
|
2237
|
+
sec_method.x_exciting_xs_tddft_anomalous_Hall_conductivity = (
|
|
2238
|
+
self.input_xml_parser.get('xs/tddft/ahc', False)
|
|
2239
|
+
)
|
|
2240
|
+
sec_method.x_exciting_xs_tddft_anti_resonant_dielectric = (
|
|
2241
|
+
self.input_xml_parser.get('xs/tddft/aresdf', False)
|
|
2242
|
+
)
|
|
2243
|
+
sec_method.x_exciting_xs_tddft_anti_resonant_xc_kernel = (
|
|
2244
|
+
self.input_xml_parser.get('xs/tddft/aresfxc', True)
|
|
2245
|
+
)
|
|
2246
|
+
sec_method.x_exciting_xs_tddft_drude = self.input_xml_parser.get(
|
|
2247
|
+
'xs/tddft/drude', [0.0, 0.0]
|
|
2248
|
+
)
|
|
2249
|
+
sec_method.x_exciting_xs_tddft_split_parameter = self.input_xml_parser.get(
|
|
2250
|
+
'xs/tddft/fxcbsesplit', 0.00001, 'hartree'
|
|
2251
|
+
)
|
|
2252
|
+
sec_method.x_exciting_xs_tddft_xc_kernel = self.input_xml_parser.get(
|
|
2253
|
+
'xs/tddft/fxctype', 'RPA'
|
|
2254
|
+
)
|
|
2255
|
+
sec_method.x_exciting_xs_tddft_finite_q_intraband_contribution = (
|
|
2256
|
+
self.input_xml_parser.get('xs/tddft/intraband', False)
|
|
2257
|
+
)
|
|
2258
|
+
sec_method.x_exciting_xs_tddft_diagonal_xc_kernel = (
|
|
2259
|
+
self.input_xml_parser.get('xs/tddft/kerndiag', False)
|
|
2260
|
+
)
|
|
2261
|
+
sec_method.x_exciting_xs_tddft_lmax_alda = self.input_xml_parser.get(
|
|
2262
|
+
'xs/tddft/lmaxalda', 3
|
|
2263
|
+
)
|
|
2264
|
+
sec_method.x_exciting_xs_tddft_macroscopic_dielectric_function_q_treatment = self.input_xml_parser.get(
|
|
2265
|
+
'xs/tddft/mdfqtype', 0
|
|
2266
|
+
)
|
|
2267
|
+
sec_method.x_exciting_xs_tddft_analytic_continuation_number_of_intervals = (
|
|
2268
|
+
self.input_xml_parser.get('xs/tddft/nwacont', 0)
|
|
2269
|
+
)
|
|
2270
|
+
sec_method.x_exciting_xs_tetra = self.input_xml_parser.get(
|
|
2271
|
+
'xs/tetra/tetradf', False
|
|
2272
|
+
)
|
|
2273
|
+
|
|
2274
|
+
if self.input_xml_parser.get('xs/qpointset') is not None:
|
|
2275
|
+
sec_method.x_exciting_xs_qpointset_qpoint = self.input_xml_parser.get(
|
|
2276
|
+
'xs/qpointset/qpoint'
|
|
2277
|
+
)
|
|
2278
|
+
|
|
2279
|
+
def _parse_xs_bse(self, path):
|
|
2280
|
+
sec_run = self._child_archives.get(path).run[-1]
|
|
2281
|
+
|
|
2282
|
+
def parse_exciton(data, sec_scc):
|
|
2283
|
+
# TODO remove n_components
|
|
2284
|
+
n_components = len(data)
|
|
2285
|
+
data = np.transpose(np.vstack(data))
|
|
2286
|
+
|
|
2287
|
+
sec_scc.x_exciting_xs_bse_number_of_components = n_components
|
|
2288
|
+
n_excitons = len(data[0]) // n_components
|
|
2289
|
+
scc_section = x_exciting_exciton_calculation()
|
|
2290
|
+
sec_scc.x_exciting_exciton = scc_section
|
|
2291
|
+
scc_section.x_exciting_xs_bse_number_of_excitons = n_excitons
|
|
2292
|
+
scc_section.x_exciting_xs_bse_exciton_energies = (
|
|
2293
|
+
np.reshape(data[1], (n_components, n_excitons)) * ureg.hartree
|
|
2294
|
+
)
|
|
2295
|
+
scc_section.x_exciting_xs_bse_exciton_binding_energies = (
|
|
2296
|
+
np.reshape(data[2], (n_components, n_excitons)) * ureg.hartree
|
|
2297
|
+
)
|
|
2298
|
+
scc_section.x_exciting_xs_bse_exciton_oscillator_strength = np.reshape(
|
|
2299
|
+
data[3], (n_components, n_excitons)
|
|
2300
|
+
)
|
|
2301
|
+
scc_section.x_exciting_xs_bse_exciton_amplitude_re = np.reshape(
|
|
2302
|
+
data[4], (n_components, n_excitons)
|
|
2303
|
+
)
|
|
2304
|
+
scc_section.x_exciting_xs_bse_exciton_amplitude_im = np.reshape(
|
|
2305
|
+
data[5], (n_components, n_excitons)
|
|
2306
|
+
)
|
|
2307
|
+
|
|
2308
|
+
def parse_epsilon(data, sec_scc):
|
|
2309
|
+
n_components = len(data)
|
|
2310
|
+
data = np.transpose(np.vstack(data))
|
|
2311
|
+
n_epsilon = len(data[0]) // n_components
|
|
2312
|
+
|
|
2313
|
+
sec_scc.x_exciting_xs_bse_number_of_energy_points = n_epsilon
|
|
2314
|
+
scc_section = x_exciting_epsilon_calculation()
|
|
2315
|
+
sec_scc.x_exciting_epsilon = scc_section
|
|
2316
|
+
scc_section.x_exciting_xs_bse_epsilon_energies = (
|
|
2317
|
+
np.reshape(data[0], (n_components, n_epsilon)) * ureg.hartree
|
|
2318
|
+
)
|
|
2319
|
+
scc_section.x_exciting_xs_bse_epsilon_re = np.reshape(
|
|
2320
|
+
data[1], (n_components, n_epsilon)
|
|
2321
|
+
)
|
|
2322
|
+
scc_section.x_exciting_xs_bse_epsilon_im = np.reshape(
|
|
2323
|
+
data[2], (n_components, n_epsilon)
|
|
2324
|
+
)
|
|
2325
|
+
|
|
2326
|
+
sec_spectra = Spectra()
|
|
2327
|
+
sec_scc.spectra.append(sec_spectra)
|
|
2328
|
+
sec_spectra.n_energies = n_epsilon
|
|
2329
|
+
sec_spectra.excitation_energies = data[0] * ureg.hartree
|
|
2330
|
+
sec_spectra.intensities = data[2]
|
|
2331
|
+
sec_spectra.intensities_units = 'F/m'
|
|
2332
|
+
|
|
2333
|
+
def parse_sigma(data, sec_scc):
|
|
2334
|
+
n_components = len(data)
|
|
2335
|
+
data = np.transpose(np.vstack(data))
|
|
2336
|
+
n_sigma = len(data[0]) // n_components
|
|
2337
|
+
|
|
2338
|
+
scc_section = x_exciting_sigma_calculation()
|
|
2339
|
+
sec_scc.x_exciting_sigma = scc_section
|
|
2340
|
+
scc_section.x_exciting_xs_bse_sigma_energies = (
|
|
2341
|
+
np.reshape(data[0], (n_components, n_sigma)) * ureg.hartree
|
|
2342
|
+
)
|
|
2343
|
+
scc_section.x_exciting_xs_bse_sigma_re = np.reshape(
|
|
2344
|
+
data[1], (n_components, n_sigma)
|
|
2345
|
+
)
|
|
2346
|
+
scc_section.x_exciting_xs_bse_sigma_im = np.reshape(
|
|
2347
|
+
data[2], (n_components, n_sigma)
|
|
2348
|
+
)
|
|
2349
|
+
|
|
2350
|
+
def parse_loss(data, sec_scc):
|
|
2351
|
+
n_components = len(data)
|
|
2352
|
+
data = np.transpose(np.vstack(data))
|
|
2353
|
+
n_loss = len(data[0]) // n_components
|
|
2354
|
+
|
|
2355
|
+
scc_section = x_exciting_loss_calculation()
|
|
2356
|
+
sec_scc.x_exciting_loss = scc_section
|
|
2357
|
+
scc_section.x_exciting_xs_bse_loss_energies = (
|
|
2358
|
+
np.reshape(data[0], (n_components, n_loss)) * ureg.hartree
|
|
2359
|
+
)
|
|
2360
|
+
scc_section.x_exciting_xs_bse_loss = np.reshape(
|
|
2361
|
+
data[1], (n_components, n_loss)
|
|
2362
|
+
)
|
|
2363
|
+
|
|
2364
|
+
file_ending = path.split('EPSILON')[
|
|
2365
|
+
-1
|
|
2366
|
+
] # Identifying files with the same ending but different type of calculation
|
|
2367
|
+
polarization_files = [
|
|
2368
|
+
f
|
|
2369
|
+
for f in get_files('*BSE*.OUT', self._xs_info_file, 'INFO.OUT')
|
|
2370
|
+
if f.endswith(file_ending)
|
|
2371
|
+
]
|
|
2372
|
+
for file in polarization_files:
|
|
2373
|
+
if sec_run.m_xpath('calculation'):
|
|
2374
|
+
sec_scc = sec_run.calculation[-1]
|
|
2375
|
+
else:
|
|
2376
|
+
sec_scc = Calculation()
|
|
2377
|
+
sec_run.calculation.append(sec_scc)
|
|
2378
|
+
self.data_xs_parser.mainfile = file
|
|
2379
|
+
if self.data_xs_parser.data is None:
|
|
2380
|
+
continue
|
|
2381
|
+
|
|
2382
|
+
quantity = os.path.basename(file).split('_')[0]
|
|
2383
|
+
if quantity.startswith('EXCITON'):
|
|
2384
|
+
parse_function = parse_exciton
|
|
2385
|
+
elif quantity.startswith('EPSILON'):
|
|
2386
|
+
parse_function = parse_epsilon
|
|
2387
|
+
elif quantity.startswith('SIGMA'):
|
|
2388
|
+
parse_function = parse_sigma
|
|
2389
|
+
elif quantity.startswith('LOSS'):
|
|
2390
|
+
parse_function = parse_loss
|
|
2391
|
+
|
|
2392
|
+
try:
|
|
2393
|
+
parse_function([self.data_xs_parser.data], sec_scc)
|
|
2394
|
+
# Specific tag for the spectra from EPSILON
|
|
2395
|
+
if quantity.startswith('EPSILON'):
|
|
2396
|
+
if self.input_xml_parser.get('xs/BSE/xas'):
|
|
2397
|
+
sec_scc.spectra[0].type = 'XAS'
|
|
2398
|
+
elif self.input_xml_parser.get('xs/BSE/xes'):
|
|
2399
|
+
sec_scc.spectra[0].type = 'XES'
|
|
2400
|
+
except Exception:
|
|
2401
|
+
self.logger.error('Error setting BSE data.')
|
|
2402
|
+
|
|
2403
|
+
# refs
|
|
2404
|
+
sec_scc.system_ref = sec_run.system[-1]
|
|
2405
|
+
sec_scc.method_ref = sec_run.method[-1]
|
|
2406
|
+
|
|
2407
|
+
def _parse_xs_tddft(self):
|
|
2408
|
+
sec_run = self.archive.run[-1]
|
|
2409
|
+
|
|
2410
|
+
def get_data(path):
|
|
2411
|
+
# all files related to quantity at all qpoints
|
|
2412
|
+
files = get_files(
|
|
2413
|
+
os.path.basename(path).replace('001', '*'),
|
|
2414
|
+
self._xs_info_file,
|
|
2415
|
+
'INFO.OUT',
|
|
2416
|
+
)
|
|
2417
|
+
data = [[], [], []]
|
|
2418
|
+
data_q = []
|
|
2419
|
+
for f in files:
|
|
2420
|
+
self.data_xs_parser.mainfile = f
|
|
2421
|
+
if self.data_xs_parser.data is None:
|
|
2422
|
+
continue
|
|
2423
|
+
data_q.append(self.data_xs_parser.data)
|
|
2424
|
+
if data_q:
|
|
2425
|
+
data_q = np.transpose(data_q, axes=(2, 0, 1))
|
|
2426
|
+
for j in range(len(data)):
|
|
2427
|
+
data[j].append(data_q[j])
|
|
2428
|
+
|
|
2429
|
+
return data
|
|
2430
|
+
|
|
2431
|
+
def get_xs_calculation(path):
|
|
2432
|
+
segments = os.path.basename(path).split('_', 1)
|
|
2433
|
+
if segments[0] not in self._xs_spectra_types:
|
|
2434
|
+
return
|
|
2435
|
+
|
|
2436
|
+
archive = None
|
|
2437
|
+
for key in self._child_archives.keys():
|
|
2438
|
+
if key.endswith(segments[-1]):
|
|
2439
|
+
archive = self._child_archives[key]
|
|
2440
|
+
break
|
|
2441
|
+
|
|
2442
|
+
if archive is None:
|
|
2443
|
+
return
|
|
2444
|
+
|
|
2445
|
+
if archive.run:
|
|
2446
|
+
sec_run = archive.run[0]
|
|
2447
|
+
else:
|
|
2448
|
+
sec_run = Run()
|
|
2449
|
+
archive.run.append(sec_run)
|
|
2450
|
+
if sec_run.calculation:
|
|
2451
|
+
sec_scc = sec_run.calculation[0]
|
|
2452
|
+
else:
|
|
2453
|
+
sec_scc = Calculation()
|
|
2454
|
+
return sec_scc
|
|
2455
|
+
|
|
2456
|
+
for path in get_files('*_OC*001.OUT', self.filepath, 'INFO.OUT'):
|
|
2457
|
+
sec_scc = get_xs_calculation(path)
|
|
2458
|
+
if not sec_scc:
|
|
2459
|
+
continue
|
|
2460
|
+
|
|
2461
|
+
data = get_data(path)
|
|
2462
|
+
|
|
2463
|
+
if not data[0]:
|
|
2464
|
+
continue
|
|
2465
|
+
|
|
2466
|
+
basename = os.path.basename(path)
|
|
2467
|
+
quantity = basename.split('_')[0]
|
|
2468
|
+
|
|
2469
|
+
if quantity == 'EPSILON' and '_FXC' in basename:
|
|
2470
|
+
sec_scc = Calculation()
|
|
2471
|
+
sec_run.calculation.append(sec_scc)
|
|
2472
|
+
sec_scc.x_exciting_xs_tddft_number_of_epsilon_values = len(
|
|
2473
|
+
data[0][0][0]
|
|
2474
|
+
)
|
|
2475
|
+
sec_scc.x_exciting_xs_tddft_epsilon_energies = (
|
|
2476
|
+
data[0][0][0] * ureg.hartree
|
|
2477
|
+
)
|
|
2478
|
+
sec_scc.x_exciting_xs_tddft_dielectric_function_local_field = data[1:]
|
|
2479
|
+
|
|
2480
|
+
elif quantity == 'EPSILON' and '_NLF_FXC' in basename:
|
|
2481
|
+
sec_scc.x_exciting_xs_tddft_dielectric_function_no_local_field = data[
|
|
2482
|
+
1:3
|
|
2483
|
+
]
|
|
2484
|
+
|
|
2485
|
+
elif quantity == 'LOSS' and '_FXC' in basename:
|
|
2486
|
+
sec_scc.x_exciting_xs_tddft_loss_function_local_field = data[1]
|
|
2487
|
+
|
|
2488
|
+
elif quantity == 'LOSS' and '_NLF_FXC' in basename:
|
|
2489
|
+
sec_scc.x_exciting_xs_tddft_loss_function_no_local_field = data[1]
|
|
2490
|
+
|
|
2491
|
+
elif quantity == 'SIGMA' and '_FXC' in basename:
|
|
2492
|
+
sec_scc.x_exciting_xs_tddft_sigma_local_field = data[1:3]
|
|
2493
|
+
|
|
2494
|
+
elif quantity == 'SIGMA' and '_NLF_FXC' in basename:
|
|
2495
|
+
sec_scc.x_exciting_xs_tddft_sigma_no_local_field = data[1:3]
|
|
2496
|
+
|
|
2497
|
+
def parse_polarization(self, path):
|
|
2498
|
+
sec_run = self._child_archives.get(path).run[-1]
|
|
2499
|
+
sec_photon = Photon()
|
|
2500
|
+
sec_run.method.append(Method(photon=[sec_photon]))
|
|
2501
|
+
# TODO check with developers if this is correct
|
|
2502
|
+
sec_photon.momentum_transfer = sec_run.method[0].get(
|
|
2503
|
+
'x_exciting_xs_qpointset_qpoint'
|
|
2504
|
+
)
|
|
2505
|
+
|
|
2506
|
+
def parse_xs(self):
|
|
2507
|
+
sec_run = self.archive.run[-1]
|
|
2508
|
+
sec_method = Method()
|
|
2509
|
+
sec_run.method.append(sec_method)
|
|
2510
|
+
if sec_run.m_xpath('method[0]'):
|
|
2511
|
+
sec_method.starting_method_ref = sec_run.method[0]
|
|
2512
|
+
|
|
2513
|
+
# Code-specific
|
|
2514
|
+
self.parse_file('input.xml', sec_method, self._xs_info_file)
|
|
2515
|
+
|
|
2516
|
+
# BSE
|
|
2517
|
+
sec_bse = BSE()
|
|
2518
|
+
sec_method.bse = sec_bse
|
|
2519
|
+
sec_bse.type = self._bse_type_map[sec_run.method[-1].x_exciting_xs_bse_type]
|
|
2520
|
+
sec_bse.solver = 'Full-diagonalization'
|
|
2521
|
+
sec_bse.n_empty_states = sec_run.method[-1].x_exciting_xs_number_of_empty_states
|
|
2522
|
+
sec_bse.broadening = sec_run.method[-1].x_exciting_xs_broadening
|
|
2523
|
+
# KMesh
|
|
2524
|
+
sec_k_mesh = KMesh()
|
|
2525
|
+
sec_method.k_mesh = sec_k_mesh
|
|
2526
|
+
sec_k_mesh.grid = sec_run.method[
|
|
2527
|
+
-1
|
|
2528
|
+
].x_exciting_xs_ngridk # TODO change to output parsing
|
|
2529
|
+
# QMesh
|
|
2530
|
+
sec_q_mesh = KMesh(grid=sec_run.method[-1].x_exciting_xs_ngridq)
|
|
2531
|
+
sec_bse.m_add_sub_section(BSE.q_mesh, sec_q_mesh)
|
|
2532
|
+
# FrequencyMesh
|
|
2533
|
+
n_freqs = sec_run.method[-1].x_exciting_xs_energywindow_points
|
|
2534
|
+
freqs = sec_run.method[-1].x_exciting_xs_energywindow_values
|
|
2535
|
+
values = [
|
|
2536
|
+
freqs[0] + i * (freqs[-1] - freqs[0]) / n_freqs for i in range(n_freqs)
|
|
2537
|
+
]
|
|
2538
|
+
sec_freq_mesh = FrequencyMesh(dimensionality=1, n_points=n_freqs, points=values)
|
|
2539
|
+
sec_method.m_add_sub_section(Method.frequency_mesh, sec_freq_mesh)
|
|
2540
|
+
# Screening
|
|
2541
|
+
sec_screening = Screening(
|
|
2542
|
+
type=sec_run.method[-1].x_exciting_xs_screening_type,
|
|
2543
|
+
n_empty_states=sec_run.method[
|
|
2544
|
+
-1
|
|
2545
|
+
].x_exciting_xs_screening_number_of_empty_states,
|
|
2546
|
+
)
|
|
2547
|
+
sec_k_mesh_screening = KMesh(
|
|
2548
|
+
grid=sec_run.method[-1].x_exciting_xs_screening_ngridk
|
|
2549
|
+
)
|
|
2550
|
+
sec_screening.m_add_sub_section(Screening.k_mesh, sec_k_mesh_screening)
|
|
2551
|
+
|
|
2552
|
+
# CoreHole
|
|
2553
|
+
if sec_run.method[-1].x_exciting_xs_bse_xas:
|
|
2554
|
+
sec_core_hole = CoreHoleSpectra(
|
|
2555
|
+
mode='absorption',
|
|
2556
|
+
broadening=sec_run.method[-1].x_exciting_xs_broadening,
|
|
2557
|
+
)
|
|
2558
|
+
sec_bse.m_add_sub_section(BSE.core_hole, sec_core_hole)
|
|
2559
|
+
# TODO wait for new changes in metainfo for CoreHole
|
|
2560
|
+
# sec_core.edge = sec_run.method[0].get('x_exciting_xs_bse_xasedge')
|
|
2561
|
+
|
|
2562
|
+
def parse_spectra(self, path):
|
|
2563
|
+
input_file = get_files('input.xml', self._xs_info_file, 'INFO.OUT')
|
|
2564
|
+
if not input_file:
|
|
2565
|
+
return
|
|
2566
|
+
self.input_xml_parser.mainfile = input_file[0]
|
|
2567
|
+
xstype = self.input_xml_parser.get('xs/xstype', '')
|
|
2568
|
+
if xstype.lower() == 'bse':
|
|
2569
|
+
self._parse_xs_bse(path)
|
|
2570
|
+
elif xstype.lower() == 'tddft':
|
|
2571
|
+
self._parse_xs_tddft()
|
|
2572
|
+
|
|
2573
|
+
def parse_photons(self, path):
|
|
2574
|
+
sec_run = Run()
|
|
2575
|
+
self._child_archives.get(path).run.append(sec_run)
|
|
2576
|
+
|
|
2577
|
+
# Program
|
|
2578
|
+
sec_run.program = Program(
|
|
2579
|
+
name='exciting', version=self.info_parser.get('program_version', '').strip()
|
|
2580
|
+
)
|
|
2581
|
+
|
|
2582
|
+
# System
|
|
2583
|
+
sec_run.system = self.archive.run[-1].system
|
|
2584
|
+
|
|
2585
|
+
# Photon method
|
|
2586
|
+
self.parse_polarization(path)
|
|
2587
|
+
|
|
2588
|
+
# Calculation
|
|
2589
|
+
self.parse_spectra(path)
|
|
2590
|
+
|
|
2591
|
+
# Workflow
|
|
2592
|
+
workflow = SinglePoint()
|
|
2593
|
+
workflow.name = 'SinglePoint'
|
|
2594
|
+
self._child_archives.get(path).workflow2 = workflow
|
|
2595
|
+
|
|
2596
|
+
def _parse_input_gw(self, sec_gw):
|
|
2597
|
+
def parse_exciting_gw_inputs(source, path, target):
|
|
2598
|
+
for keys in source.keys():
|
|
2599
|
+
setattr(
|
|
2600
|
+
target,
|
|
2601
|
+
f'x_exciting_{keys}',
|
|
2602
|
+
self.input_xml_parser.get(f'{path}/{keys}', source[keys]),
|
|
2603
|
+
)
|
|
2604
|
+
|
|
2605
|
+
parse_exciting_gw_inputs(self._gw_input_default, 'gw', sec_gw)
|
|
2606
|
+
sec_freqgrid = x_exciting_freqgrid_parameters()
|
|
2607
|
+
sec_gw.x_exciting_freqgrid = sec_freqgrid
|
|
2608
|
+
parse_exciting_gw_inputs(
|
|
2609
|
+
self._freqgrid_input_default, 'gw/freqgrid', sec_freqgrid
|
|
2610
|
+
)
|
|
2611
|
+
sec_selfenergy = x_exciting_selfenergy_parameters()
|
|
2612
|
+
sec_gw.x_exciting_selfenergy = sec_selfenergy
|
|
2613
|
+
parse_exciting_gw_inputs(
|
|
2614
|
+
self._selfenergy_input_default, 'gw/selfenergy', sec_selfenergy
|
|
2615
|
+
)
|
|
2616
|
+
sec_wgrid = x_exciting_wgrid_parameters()
|
|
2617
|
+
sec_gw.x_exciting_wgrid = sec_wgrid
|
|
2618
|
+
parse_exciting_gw_inputs(self._wgrid_input_default, 'gw/wgrid', sec_wgrid)
|
|
2619
|
+
sec_mixbasis = x_exciting_mixbasis_parameters()
|
|
2620
|
+
sec_gw.x_exciting_mixbasis = sec_mixbasis
|
|
2621
|
+
parse_exciting_gw_inputs(
|
|
2622
|
+
self._barecoul_input_default, 'gw/mixbasis', sec_mixbasis
|
|
2623
|
+
)
|
|
2624
|
+
sec_barecoul = x_exciting_barecoul_parameters()
|
|
2625
|
+
sec_gw.x_exciting_barecoul = sec_barecoul
|
|
2626
|
+
parse_exciting_gw_inputs(
|
|
2627
|
+
self._barecoul_input_default, 'gw/barecoul', sec_barecoul
|
|
2628
|
+
)
|
|
2629
|
+
sec_scrcoul = x_exciting_scrcoul_parameters()
|
|
2630
|
+
sec_gw.x_exciting_scrcoul = sec_scrcoul
|
|
2631
|
+
parse_exciting_gw_inputs(self._scrcoul_input_default, 'gw/scrcoul', sec_scrcoul)
|
|
2632
|
+
|
|
2633
|
+
gmaxvr = self.info_parser.get_initialization_parameter('x_exciting_gmaxvr', 0)
|
|
2634
|
+
gmb = self.input_xml_parser.get('gw/mixbasis/gmb', 1.0)
|
|
2635
|
+
sec_gw.x_exciting_mixed_basis_gmax = gmb * gmaxvr
|
|
2636
|
+
pwm = self.input_xml_parser.get('gw/barecoul/pwm', 2.0)
|
|
2637
|
+
sec_gw.x_exciting_bare_coulomb_gmax = pwm * gmb * gmaxvr
|
|
2638
|
+
|
|
2639
|
+
def parse_gw(self):
|
|
2640
|
+
sec_run = self.archive.run[-1]
|
|
2641
|
+
|
|
2642
|
+
# GW Method
|
|
2643
|
+
sec_method = Method()
|
|
2644
|
+
sec_run.method.append(sec_method)
|
|
2645
|
+
sec_gw = GW()
|
|
2646
|
+
sec_method.gw = sec_gw
|
|
2647
|
+
|
|
2648
|
+
# parse input xml files: code-specific metainfo
|
|
2649
|
+
for f in ['input_gw.xml', 'input-gw.xml', 'input.xml']:
|
|
2650
|
+
self.parse_file(f, sec_gw)
|
|
2651
|
+
|
|
2652
|
+
# GW
|
|
2653
|
+
sec_gw.type = 'G0W0'
|
|
2654
|
+
# KMesh
|
|
2655
|
+
sec_k_mesh = KMesh()
|
|
2656
|
+
sec_method.k_mesh = sec_k_mesh
|
|
2657
|
+
sec_k_mesh.grid = sec_gw.x_exciting_ngridq
|
|
2658
|
+
# QMesh same as KMesh
|
|
2659
|
+
sec_gw.m_add_sub_section(GW.q_mesh, sec_k_mesh)
|
|
2660
|
+
# Analytical continuation
|
|
2661
|
+
if sec_gw.x_exciting_selfenergy.x_exciting_actype == 'pade':
|
|
2662
|
+
sec_gw.analytical_continuation = (
|
|
2663
|
+
sec_gw.x_exciting_selfenergy.x_exciting_actype
|
|
2664
|
+
)
|
|
2665
|
+
else:
|
|
2666
|
+
if sec_gw.x_exciting_selfenergy.x_exciting_method == 'cd':
|
|
2667
|
+
sec_gw.analytical_continuation = 'contour_deformation'
|
|
2668
|
+
else:
|
|
2669
|
+
if sec_gw.x_exciting_scrcoul.x_exciting_scrtype == 'ppm':
|
|
2670
|
+
sec_gw.analytical_continuation = 'ppm_GodbyNeeds'
|
|
2671
|
+
else:
|
|
2672
|
+
self.logger.warning(
|
|
2673
|
+
'Could not find the analytical continuation method.'
|
|
2674
|
+
)
|
|
2675
|
+
# FrequencyMesh
|
|
2676
|
+
n_freqs = sec_gw.x_exciting_freqgrid.x_exciting_nomeg
|
|
2677
|
+
freqmax = sec_gw.x_exciting_freqgrid.x_exciting_freqmax
|
|
2678
|
+
freqmin = sec_gw.x_exciting_freqgrid.x_exciting_freqmin
|
|
2679
|
+
freq_points = [
|
|
2680
|
+
freqmin + i * (freqmax - freqmin) / n_freqs for i in range(n_freqs)
|
|
2681
|
+
] * ureg.hartree
|
|
2682
|
+
smearing = (
|
|
2683
|
+
sec_gw.x_exciting_freqgrid.x_exciting_eta
|
|
2684
|
+
if sec_gw.x_exciting_qdepw == 'sum'
|
|
2685
|
+
else None
|
|
2686
|
+
)
|
|
2687
|
+
sec_freq_mesh = FrequencyMesh(
|
|
2688
|
+
dimensionality=1,
|
|
2689
|
+
sampling_method=self._freq_grid_map.get(
|
|
2690
|
+
sec_gw.x_exciting_freqgrid.x_exciting_fgrid
|
|
2691
|
+
),
|
|
2692
|
+
n_points=n_freqs,
|
|
2693
|
+
points=[freq_points],
|
|
2694
|
+
smearing=smearing,
|
|
2695
|
+
)
|
|
2696
|
+
sec_method.m_add_sub_section(Method.frequency_mesh, sec_freq_mesh)
|
|
2697
|
+
# Screening
|
|
2698
|
+
sec_screening = Screening(
|
|
2699
|
+
type=sec_gw.x_exciting_scrcoul.x_exciting_scrtype,
|
|
2700
|
+
n_empty_states=sec_gw.x_exciting_nempty,
|
|
2701
|
+
k_mesh=sec_k_mesh,
|
|
2702
|
+
q_mesh=sec_k_mesh,
|
|
2703
|
+
frequency_mesh=sec_freq_mesh,
|
|
2704
|
+
)
|
|
2705
|
+
sec_gw.m_add_sub_section(GW.screening, sec_screening)
|
|
2706
|
+
# Other parameters
|
|
2707
|
+
sec_gw.interval_qp_corrections = [
|
|
2708
|
+
sec_gw.x_exciting_ibgw,
|
|
2709
|
+
sec_gw.x_exciting_nbgw,
|
|
2710
|
+
]
|
|
2711
|
+
if sec_screening.n_empty_states == 0:
|
|
2712
|
+
sec_gw.n_empty_states = sec_gw.x_exciting_selfenergy.x_exciting_nempty
|
|
2713
|
+
else:
|
|
2714
|
+
sec_gw.n_empty_states = sec_screening.n_empty_states
|
|
2715
|
+
|
|
2716
|
+
# GW Calculation
|
|
2717
|
+
sec_scc = Calculation()
|
|
2718
|
+
sec_run.calculation.append(sec_scc)
|
|
2719
|
+
# parse properties
|
|
2720
|
+
self.info_gw_parser.mainfile = self._gw_info_file
|
|
2721
|
+
|
|
2722
|
+
fermi_energy = self.info_gw_parser.get('fermi_energy', None)
|
|
2723
|
+
if fermi_energy is not None:
|
|
2724
|
+
sec_scc.energy = Energy(fermi=fermi_energy)
|
|
2725
|
+
|
|
2726
|
+
gw_files = ['EVALQP.DAT', 'EVALQP.TXT', 'TDOS-QP.OUT']
|
|
2727
|
+
|
|
2728
|
+
# Parse GW band structure from one of the files:
|
|
2729
|
+
bs_files = ['bandstructure-qp.dat', 'BAND-QP.OUT']
|
|
2730
|
+
for fname in bs_files:
|
|
2731
|
+
if self.file_exists(fname):
|
|
2732
|
+
gw_files.append(fname)
|
|
2733
|
+
break
|
|
2734
|
+
|
|
2735
|
+
for f in gw_files:
|
|
2736
|
+
self.parse_file(f, sec_scc)
|
|
2737
|
+
|
|
2738
|
+
# example band gap setup
|
|
2739
|
+
gw_band_gap = self.info_gw_parser.get(
|
|
2740
|
+
'direct_band_gap', self.info_gw_parser.get('fundamental_band_gap')
|
|
2741
|
+
)
|
|
2742
|
+
if gw_band_gap is not None:
|
|
2743
|
+
sec_gap = BandGap()
|
|
2744
|
+
sec_scc.band_gap.append(sec_gap)
|
|
2745
|
+
sec_gap.value = gw_band_gap
|
|
2746
|
+
sec_gap_provenance = ElectronicStructureProvenance()
|
|
2747
|
+
sec_gap.provenance = sec_gap_provenance
|
|
2748
|
+
sec_gap_provenance.label = 'parser'
|
|
2749
|
+
|
|
2750
|
+
sec_scc.method_ref = sec_method
|
|
2751
|
+
self.parse_system(self.info_parser.get('groundstate'))
|
|
2752
|
+
sec_scc.system_ref = sec_run.system[-1]
|
|
2753
|
+
|
|
2754
|
+
def parse_workflow(self):
|
|
2755
|
+
workflow = SinglePoint()
|
|
2756
|
+
workflow.name = 'SinglePoint'
|
|
2757
|
+
structure_optimization = self.info_parser.get('structure_optimization')
|
|
2758
|
+
if structure_optimization is not None:
|
|
2759
|
+
workflow = GeometryOptimization(method=GeometryOptimizationMethod())
|
|
2760
|
+
workflow.name = 'GeometryOptimization'
|
|
2761
|
+
threshold_force = structure_optimization.get('optimization_step', [{}])[
|
|
2762
|
+
0
|
|
2763
|
+
].get('force_convergence', [0.0, 0.0])[-1]
|
|
2764
|
+
workflow.method.convergence_tolerance_force_maximum = threshold_force
|
|
2765
|
+
self.archive.workflow2 = workflow
|
|
2766
|
+
|
|
2767
|
+
def parse_method(self):
|
|
2768
|
+
sec_run = self.archive.run[-1]
|
|
2769
|
+
sec_method = Method()
|
|
2770
|
+
sec_run.method.append(sec_method)
|
|
2771
|
+
|
|
2772
|
+
if sec_method.k_mesh is None: # TODO revise need in the future
|
|
2773
|
+
k_mesh = KMesh()
|
|
2774
|
+
sec_method.k_mesh = k_mesh
|
|
2775
|
+
k_mesh.grid = self.info_parser.get_initialization_parameter(
|
|
2776
|
+
'kpoint_grid', default=[1] * 3
|
|
2777
|
+
)
|
|
2778
|
+
k_mesh.offset = self.info_parser.get_initialization_parameter(
|
|
2779
|
+
'kpoint_offset', default=[0.0] * 3
|
|
2780
|
+
)
|
|
2781
|
+
|
|
2782
|
+
# Atom parameters
|
|
2783
|
+
species_files = self.file_exists(
|
|
2784
|
+
r'[A-Z][a-z]?\.xml', fuzzy=True
|
|
2785
|
+
) # try species_scf.xml is present?
|
|
2786
|
+
for species_file in species_files:
|
|
2787
|
+
self.parse_file(species_file, sec_method)
|
|
2788
|
+
|
|
2789
|
+
# XC functional
|
|
2790
|
+
sec_dft = DFT()
|
|
2791
|
+
sec_method.dft = sec_dft
|
|
2792
|
+
sec_electronic = Electronic()
|
|
2793
|
+
sec_method.electronic = sec_electronic
|
|
2794
|
+
sec_electronic.method = 'DFT'
|
|
2795
|
+
|
|
2796
|
+
smearing_kind_map = {
|
|
2797
|
+
'Gaussian': 'gaussian',
|
|
2798
|
+
'Methfessel-Paxton': 'methfessel-paxton',
|
|
2799
|
+
'Fermi-Dirac': 'fermi',
|
|
2800
|
+
'Extended': 'tetrahedra',
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2803
|
+
sec_smearing = Smearing()
|
|
2804
|
+
sec_electronic.smearing = sec_smearing
|
|
2805
|
+
smearing_kind = self.info_parser.get_initialization_parameter('smearing_kind')
|
|
2806
|
+
if smearing_kind is not None:
|
|
2807
|
+
if not isinstance(smearing_kind, str):
|
|
2808
|
+
smearing_kind = smearing_kind[0]
|
|
2809
|
+
smearing_kind = smearing_kind_map[smearing_kind]
|
|
2810
|
+
sec_smearing.kind = smearing_kind
|
|
2811
|
+
smearing_width = self.info_parser.get_initialization_parameter('smearing_width')
|
|
2812
|
+
if smearing_width is not None:
|
|
2813
|
+
smearing_width = (smearing_width * ureg.hartree).to('joule')
|
|
2814
|
+
# TODO smearing with should have units of energy
|
|
2815
|
+
sec_smearing.width = smearing_width.magnitude
|
|
2816
|
+
|
|
2817
|
+
for name in self.info_parser._convergence_keys_mapping.keys():
|
|
2818
|
+
threshold = self.info_parser.get_scf_threshold(name)
|
|
2819
|
+
if threshold is None:
|
|
2820
|
+
continue
|
|
2821
|
+
|
|
2822
|
+
metainfo_name = 'x_exciting_scf_threshold_%s_change' % name.split('_')[-2]
|
|
2823
|
+
setattr(sec_method, metainfo_name, threshold)
|
|
2824
|
+
# additionally, set threshold to global metainfo. This is killing me!
|
|
2825
|
+
if metainfo_name == 'x_exciting_scf_threshold_energy_change':
|
|
2826
|
+
sec_method.scf = Scf(threshold_energy_change=threshold)
|
|
2827
|
+
|
|
2828
|
+
sec_xc_functional = XCFunctional()
|
|
2829
|
+
sec_dft.xc_functional = sec_xc_functional
|
|
2830
|
+
self.parse_xc_functional(sec_xc_functional)
|
|
2831
|
+
|
|
2832
|
+
sec_electronic.n_spin_channels = self.info_parser.get_number_of_spin_channels()
|
|
2833
|
+
|
|
2834
|
+
if self._calculation_type == 'volume_optimization':
|
|
2835
|
+
sec_method.x_exciting_volume_optimization = True
|
|
2836
|
+
|
|
2837
|
+
def parse_xc_functional(self, section):
|
|
2838
|
+
xc_functional_names = self.info_parser.get_xc_functional_name()
|
|
2839
|
+
if not xc_functional_names:
|
|
2840
|
+
# get it from input.xml
|
|
2841
|
+
input_file = get_files('input.xml', self.filepath, 'INFO.OUT')
|
|
2842
|
+
for f in input_file:
|
|
2843
|
+
self.input_xml_parser.mainfile = f
|
|
2844
|
+
correlation = self.input_xml_parser.get('libxc/correlation', None)
|
|
2845
|
+
xc_functional_names.append(correlation)
|
|
2846
|
+
exchange = self.input_xml_parser.get('libxc/exchange', None)
|
|
2847
|
+
xc_functional_names.append(exchange)
|
|
2848
|
+
|
|
2849
|
+
for name in xc_functional_names:
|
|
2850
|
+
if name is None:
|
|
2851
|
+
continue
|
|
2852
|
+
if '_X_' in name:
|
|
2853
|
+
section.exchange.append(Functional(name=name))
|
|
2854
|
+
elif '_C_' in name:
|
|
2855
|
+
section.correlation.append(Functional(name=name))
|
|
2856
|
+
elif 'HYB' in name:
|
|
2857
|
+
section.hybrid.append(Functional(name=name))
|
|
2858
|
+
else:
|
|
2859
|
+
section.contributions.append(Functional(name=name))
|
|
2860
|
+
|
|
2861
|
+
if not xc_functional_names:
|
|
2862
|
+
# simply write parameters
|
|
2863
|
+
xc_functional = self.info_parser.get('initialization', {}).get(
|
|
2864
|
+
'xc_functional'
|
|
2865
|
+
)
|
|
2866
|
+
if xc_functional is not None:
|
|
2867
|
+
section.name = xc_functional.get('name_reference', [None, None])[0]
|
|
2868
|
+
section.reference = xc_functional.get('name_reference', [None, None])[1]
|
|
2869
|
+
|
|
2870
|
+
def parse_scc(self, section):
|
|
2871
|
+
sec_run = self.archive.run[-1]
|
|
2872
|
+
|
|
2873
|
+
final = (
|
|
2874
|
+
section if section.get('energy_total') is not None else section.get('final')
|
|
2875
|
+
)
|
|
2876
|
+
if final is None:
|
|
2877
|
+
# get it from last scf_iteration or optimization_step
|
|
2878
|
+
final = section.get('scf_iteration', [None])[-1]
|
|
2879
|
+
final = (
|
|
2880
|
+
section.get('optimization_step', [None])[-1] if final is None else final
|
|
2881
|
+
)
|
|
2882
|
+
if final is None:
|
|
2883
|
+
return
|
|
2884
|
+
|
|
2885
|
+
time_initial = (
|
|
2886
|
+
sec_run.calculation[-1].time_physical if sec_run.calculation else 0 * ureg.s
|
|
2887
|
+
)
|
|
2888
|
+
|
|
2889
|
+
sec_scc = Calculation()
|
|
2890
|
+
sec_run.calculation.append(sec_scc)
|
|
2891
|
+
k_grid = self.info_parser.get('k_grid')
|
|
2892
|
+
if k_grid is not None:
|
|
2893
|
+
sec_kmesh = KMesh()
|
|
2894
|
+
sec_scc.k_mesh = sec_kmesh
|
|
2895
|
+
sec_kmesh.grid = k_grid
|
|
2896
|
+
sec_kmesh.offset = self.info_parser.get('k_offset', [0.0] * 3)
|
|
2897
|
+
|
|
2898
|
+
def parse_scf(iteration, msection):
|
|
2899
|
+
energy_total = iteration.get('energy_total')
|
|
2900
|
+
sec_energy = Energy()
|
|
2901
|
+
msection.energy = sec_energy
|
|
2902
|
+
if energy_total is not None:
|
|
2903
|
+
sec_energy.total = EnergyEntry(value=energy_total)
|
|
2904
|
+
|
|
2905
|
+
x_exciting_dos_fermi = iteration.get('x_exciting_dos_fermi')
|
|
2906
|
+
if x_exciting_dos_fermi is not None:
|
|
2907
|
+
setattr(msection, 'x_exciting_dos_fermi', x_exciting_dos_fermi)
|
|
2908
|
+
|
|
2909
|
+
# energy contributions
|
|
2910
|
+
energy_contributions = iteration.get('energy_contributions', {})
|
|
2911
|
+
for key, names in self._energy_keys_mapping.items():
|
|
2912
|
+
val = None
|
|
2913
|
+
for name in names:
|
|
2914
|
+
val = energy_contributions.get(name, None)
|
|
2915
|
+
if val is not None:
|
|
2916
|
+
break
|
|
2917
|
+
if val is None:
|
|
2918
|
+
continue
|
|
2919
|
+
if key.startswith('energy_'):
|
|
2920
|
+
sec_energy.m_add_sub_section(
|
|
2921
|
+
getattr(Energy, key.replace('energy_', '')),
|
|
2922
|
+
EnergyEntry(value=val),
|
|
2923
|
+
)
|
|
2924
|
+
else:
|
|
2925
|
+
setattr(msection, key, val)
|
|
2926
|
+
|
|
2927
|
+
if key == 'x_exciting_fermi_energy':
|
|
2928
|
+
sec_energy.fermi = val
|
|
2929
|
+
|
|
2930
|
+
# charge contributions
|
|
2931
|
+
charge_contributions = iteration.get('charge_contributions', {})
|
|
2932
|
+
for key, names in self._electron_charge_keys_mapping.items():
|
|
2933
|
+
val = None
|
|
2934
|
+
for name in names:
|
|
2935
|
+
val = charge_contributions.get(name, None)
|
|
2936
|
+
if val is not None:
|
|
2937
|
+
break
|
|
2938
|
+
if val is None:
|
|
2939
|
+
continue
|
|
2940
|
+
if key == 'x_exciting_section_MT_charge_atom':
|
|
2941
|
+
for n in range(len(val)):
|
|
2942
|
+
sec_mt_charge_atom = x_exciting_section_MT_charge_atom()
|
|
2943
|
+
section_def = msection.m_def.all_sub_sections_by_section.get(
|
|
2944
|
+
x_exciting_section_MT_charge_atom.m_def
|
|
2945
|
+
)[0]
|
|
2946
|
+
msection.m_add_sub_section(section_def, sec_mt_charge_atom)
|
|
2947
|
+
sec_mt_charge_atom.x_exciting_MT_charge_atom_index = n + 1
|
|
2948
|
+
sec_mt_charge_atom.x_exciting_MT_charge_atom_symbol = val[n][0]
|
|
2949
|
+
sec_mt_charge_atom.x_exciting_MT_charge_atom_value = val[n][1]
|
|
2950
|
+
sec_charges = Charges()
|
|
2951
|
+
msection.charges.append(sec_charges)
|
|
2952
|
+
sec_charges.value = [
|
|
2953
|
+
val[n][1].magnitude for n in range(len(val))
|
|
2954
|
+
] * val[0][1].units
|
|
2955
|
+
sec_charges.total = charge_contributions.get('total charge')[-1]
|
|
2956
|
+
elif key == 'charge_total':
|
|
2957
|
+
pass
|
|
2958
|
+
else:
|
|
2959
|
+
quantity_def = msection.m_def.all_quantities.get(key)
|
|
2960
|
+
if quantity_def:
|
|
2961
|
+
msection.m_set(quantity_def, val[-1])
|
|
2962
|
+
|
|
2963
|
+
# moment contributions
|
|
2964
|
+
moment_contributions = iteration.get('moment_contributions', {})
|
|
2965
|
+
for key, names in self._moment_keys_mapping.items():
|
|
2966
|
+
val = None
|
|
2967
|
+
for name in names:
|
|
2968
|
+
val = moment_contributions.get(name, None)
|
|
2969
|
+
if val is not None:
|
|
2970
|
+
break
|
|
2971
|
+
if val is None:
|
|
2972
|
+
continue
|
|
2973
|
+
if key == 'x_exciting_section_MT_moment_atom':
|
|
2974
|
+
for n in range(len(val)):
|
|
2975
|
+
sec_mt_moment_atom = x_exciting_section_MT_moment_atom()
|
|
2976
|
+
section_def = msection.m_def.all_sub_sections_by_section.get(
|
|
2977
|
+
x_exciting_section_MT_moment_atom.m_def
|
|
2978
|
+
)[0]
|
|
2979
|
+
msection.m_add_sub_section(section_def, sec_mt_moment_atom)
|
|
2980
|
+
sec_mt_moment_atom.x_exciting_MT_moment_atom_index = n + 1
|
|
2981
|
+
sec_mt_moment_atom.x_exciting_MT_moment_atom_symbol = val[n][0]
|
|
2982
|
+
moment = val[n][1].magnitude
|
|
2983
|
+
if isinstance(moment, float):
|
|
2984
|
+
moment = [moment]
|
|
2985
|
+
sec_mt_moment_atom.x_exciting_MT_moment_atom_value = (
|
|
2986
|
+
moment * val[n][1].units
|
|
2987
|
+
)
|
|
2988
|
+
else:
|
|
2989
|
+
quantity_def = msection.m_def.all_quantities.get(key)
|
|
2990
|
+
if quantity_def:
|
|
2991
|
+
msection.m_set(
|
|
2992
|
+
quantity_def, [val] if isinstance(val, float) else val
|
|
2993
|
+
)
|
|
2994
|
+
|
|
2995
|
+
# convergence values
|
|
2996
|
+
for name in self.info_parser._convergence_keys_mapping.keys():
|
|
2997
|
+
val = iteration.get(name)
|
|
2998
|
+
if val is None:
|
|
2999
|
+
continue
|
|
3000
|
+
|
|
3001
|
+
quantity_def = msection.m_def.all_quantities.get(name)
|
|
3002
|
+
if quantity_def:
|
|
3003
|
+
msection.m_set(quantity_def, val)
|
|
3004
|
+
|
|
3005
|
+
# other metainfo
|
|
3006
|
+
for name in self.info_parser._miscellaneous_keys_mapping.keys():
|
|
3007
|
+
val = iteration.get(name)
|
|
3008
|
+
if val is None:
|
|
3009
|
+
continue
|
|
3010
|
+
quantity_def = msection.m_def.all_quantities.get(name)
|
|
3011
|
+
if quantity_def:
|
|
3012
|
+
msection.m_set(quantity_def, val)
|
|
3013
|
+
|
|
3014
|
+
# energy, moment, charge contributions
|
|
3015
|
+
parse_scf(final, sec_scc)
|
|
3016
|
+
|
|
3017
|
+
# forces
|
|
3018
|
+
forces = section.get('forces')
|
|
3019
|
+
if forces is not None:
|
|
3020
|
+
sec_forces = Forces()
|
|
3021
|
+
sec_scc.forces = sec_forces
|
|
3022
|
+
sec_forces.total = ForcesEntry(
|
|
3023
|
+
value=np.reshape(forces, (np.size(forces) // 3, 3))
|
|
3024
|
+
)
|
|
3025
|
+
|
|
3026
|
+
# scf iterations
|
|
3027
|
+
scf_iterations = section.get('scf_iteration', [])
|
|
3028
|
+
for scf_iteration in scf_iterations:
|
|
3029
|
+
time_initial_scf = (
|
|
3030
|
+
sec_scc.scf_iteration[-1].time_physical
|
|
3031
|
+
if sec_scc.scf_iteration
|
|
3032
|
+
else time_initial
|
|
3033
|
+
)
|
|
3034
|
+
sec_scf_iteration = ScfIteration()
|
|
3035
|
+
sec_scc.scf_iteration.append(sec_scf_iteration)
|
|
3036
|
+
parse_scf(scf_iteration, sec_scf_iteration)
|
|
3037
|
+
if sec_scf_iteration.time_physical:
|
|
3038
|
+
sec_scf_iteration.time_calculation = (
|
|
3039
|
+
sec_scf_iteration.time_physical - time_initial_scf
|
|
3040
|
+
)
|
|
3041
|
+
|
|
3042
|
+
sec_scc.time_calculation = section.get('time_calculation', 0)
|
|
3043
|
+
sec_scc.time_physical = time_initial + sec_scc.time_calculation
|
|
3044
|
+
|
|
3045
|
+
if not sec_scc.time_calculation and sec_scc.scf_iteration:
|
|
3046
|
+
sec_scc.time_physical = sec_scc.scf_iteration[-1].time_physical
|
|
3047
|
+
sec_scc.time_calculation = sum(
|
|
3048
|
+
[
|
|
3049
|
+
scf.time_calculation if scf.time_calculation else 0
|
|
3050
|
+
for scf in sec_scc.scf_iteration
|
|
3051
|
+
]
|
|
3052
|
+
)
|
|
3053
|
+
|
|
3054
|
+
return sec_scc
|
|
3055
|
+
|
|
3056
|
+
def parse_system(self, section):
|
|
3057
|
+
sec_run = self.archive.run[-1]
|
|
3058
|
+
|
|
3059
|
+
positions = self.info_parser.get_atom_positions(
|
|
3060
|
+
section.get('atomic_positions', {})
|
|
3061
|
+
)
|
|
3062
|
+
lattice_vectors = self.info_parser.get_initialization_parameter(
|
|
3063
|
+
'lattice_vectors'
|
|
3064
|
+
)
|
|
3065
|
+
atom_labels = self.info_parser.get_atom_labels(
|
|
3066
|
+
section.get('atomic_positions', {})
|
|
3067
|
+
)
|
|
3068
|
+
input_file = get_files('input.xml', self.filepath, 'INFO.OUT')
|
|
3069
|
+
|
|
3070
|
+
if positions is None:
|
|
3071
|
+
# get it from input.xml
|
|
3072
|
+
for f in input_file:
|
|
3073
|
+
self.input_xml_parser.mainfile = f
|
|
3074
|
+
positions = self.input_xml_parser.get('structure/species/atom/coord')
|
|
3075
|
+
lattice_vectors = self.input_xml_parser.get(
|
|
3076
|
+
'structure/crystal/basevect', np.eye(3)
|
|
3077
|
+
)
|
|
3078
|
+
species = self.input_xml_parser.get('structure/species/speciesfile')
|
|
3079
|
+
|
|
3080
|
+
if positions is None or lattice_vectors is None or species is None:
|
|
3081
|
+
continue
|
|
3082
|
+
lattice_vectors = np.array(lattice_vectors, dtype=float)
|
|
3083
|
+
lattice_vectors *= self.input_xml_parser.get(
|
|
3084
|
+
'structure/crystal/scale', 1.0
|
|
3085
|
+
)
|
|
3086
|
+
positions = np.dot(positions, lattice_vectors) * ureg.bohr
|
|
3087
|
+
lattice_vectors = lattice_vectors * ureg.bohr
|
|
3088
|
+
|
|
3089
|
+
atoms = self.input_xml_parser.get('structure/species/atom')
|
|
3090
|
+
atom_labels = []
|
|
3091
|
+
for n in range(len(atoms)):
|
|
3092
|
+
atom_labels.extend([species[n].split('.')[0]] * len(atoms[n]))
|
|
3093
|
+
|
|
3094
|
+
if positions is None or atom_labels is None:
|
|
3095
|
+
return
|
|
3096
|
+
|
|
3097
|
+
sec_system = System()
|
|
3098
|
+
sec_run.system.append(sec_system)
|
|
3099
|
+
|
|
3100
|
+
sec_atoms = Atoms()
|
|
3101
|
+
sec_system.atoms = sec_atoms
|
|
3102
|
+
sec_atoms.positions = positions
|
|
3103
|
+
sec_atoms.labels = atom_labels
|
|
3104
|
+
sec_atoms.periodic = [True] * 3
|
|
3105
|
+
# TODO confirm no cell optimization in exciting
|
|
3106
|
+
sec_atoms.lattice_vectors = lattice_vectors
|
|
3107
|
+
|
|
3108
|
+
lattice_vectors_reciprocal = self.info_parser.get_initialization_parameter(
|
|
3109
|
+
'lattice_vectors_reciprocal'
|
|
3110
|
+
)
|
|
3111
|
+
sec_atoms.lattice_vectors_reciprocal = lattice_vectors_reciprocal
|
|
3112
|
+
|
|
3113
|
+
if len(sec_run.system) > 1:
|
|
3114
|
+
return sec_system
|
|
3115
|
+
|
|
3116
|
+
for name in self.info_parser._system_keys_mapping.keys():
|
|
3117
|
+
val = self.info_parser.get_initialization_parameter(name)
|
|
3118
|
+
if val is None:
|
|
3119
|
+
continue
|
|
3120
|
+
|
|
3121
|
+
if name == 'x_exciting_spin_treatment':
|
|
3122
|
+
sub_sec = x_exciting_section_spin()
|
|
3123
|
+
sec_system.x_exciting_section_spin.append(sub_sec)
|
|
3124
|
+
sub_sec.x_exciting_spin_treatment = val
|
|
3125
|
+
elif name == 'x_exciting_species_rtmin':
|
|
3126
|
+
setattr(sec_system, name, ' '.join([str(v) for v in val]))
|
|
3127
|
+
else:
|
|
3128
|
+
try:
|
|
3129
|
+
setattr(sec_system, name, val)
|
|
3130
|
+
except Exception:
|
|
3131
|
+
self.logger.warning('Error setting metainfo.')
|
|
3132
|
+
|
|
3133
|
+
# species
|
|
3134
|
+
species = self.info_parser.get_initialization_parameter('species', [])
|
|
3135
|
+
for specie in species:
|
|
3136
|
+
sec_atoms_group = x_exciting_section_atoms_group()
|
|
3137
|
+
sec_system.x_exciting_section_atoms_group.append(sec_atoms_group)
|
|
3138
|
+
sec_atoms_group.x_exciting_geometry_atom_labels = specie.get('symbol')
|
|
3139
|
+
sec_atoms_group.x_exciting_geometry_atom_number = str(specie.get('number'))
|
|
3140
|
+
sec_atoms_group.x_exciting_muffin_tin_points = specie.get('radial_points')
|
|
3141
|
+
sec_atoms_group.x_exciting_muffin_tin_radius = specie.get(
|
|
3142
|
+
'muffin_tin_radius'
|
|
3143
|
+
)
|
|
3144
|
+
positions_format = specie.get('positions_format')
|
|
3145
|
+
sec_atoms_group.x_exciting_atom_position_format = positions_format
|
|
3146
|
+
positions = specie.get('positions')
|
|
3147
|
+
positions = self.info_parser.get_atom_positions(
|
|
3148
|
+
positions=positions, positions_format=positions_format
|
|
3149
|
+
).to('m')
|
|
3150
|
+
sec_atoms_group.x_exciting_geometry_atom_positions = positions.magnitude
|
|
3151
|
+
|
|
3152
|
+
# clathrate info
|
|
3153
|
+
clathrate_file = get_files('str.out', self.filepath, 'INFO.OUT')
|
|
3154
|
+
if clathrate_file:
|
|
3155
|
+
sec_system.x_exciting_clathrates = True
|
|
3156
|
+
self.data_clathrate_parser.mainfile = clathrate_file[0]
|
|
3157
|
+
if self.data_clathrate_parser.data:
|
|
3158
|
+
data = np.transpose(self.data_clathrate_parser.data)
|
|
3159
|
+
sec_system.x_exciting_clathrates_atom_coordinates = np.transpose(
|
|
3160
|
+
np.array(data[:3], dtype=float)
|
|
3161
|
+
)
|
|
3162
|
+
sec_system.x_exciting_clathrates_atom_labels = list(data[3])
|
|
3163
|
+
else:
|
|
3164
|
+
sec_system.x_exciting_clathrates = False
|
|
3165
|
+
|
|
3166
|
+
potential_mixing = self.info_parser.get_initialization_parameter(
|
|
3167
|
+
'potential_mixing'
|
|
3168
|
+
)
|
|
3169
|
+
if potential_mixing is not None:
|
|
3170
|
+
sec_system.x_exciting_potential_mixing = potential_mixing
|
|
3171
|
+
|
|
3172
|
+
return sec_system
|
|
3173
|
+
|
|
3174
|
+
def parse_configurations(self):
|
|
3175
|
+
sec_run = self.archive.run[-1]
|
|
3176
|
+
|
|
3177
|
+
def parse_configuration(section):
|
|
3178
|
+
if not section:
|
|
3179
|
+
return
|
|
3180
|
+
|
|
3181
|
+
sec_scc = self.parse_scc(section)
|
|
3182
|
+
if sec_scc is None:
|
|
3183
|
+
return
|
|
3184
|
+
|
|
3185
|
+
sec_system = self.parse_system(section)
|
|
3186
|
+
if sec_system is not None:
|
|
3187
|
+
sec_scc.system_ref = sec_system
|
|
3188
|
+
|
|
3189
|
+
sec_scc.method_ref = sec_run.method[-1]
|
|
3190
|
+
|
|
3191
|
+
return sec_scc
|
|
3192
|
+
|
|
3193
|
+
# groundstate and hybrids calculation
|
|
3194
|
+
for module in ['groundstate', 'hybrids']:
|
|
3195
|
+
sec_scc = parse_configuration(self.info_parser.get(module))
|
|
3196
|
+
if sec_scc is None:
|
|
3197
|
+
continue
|
|
3198
|
+
# add data to scc
|
|
3199
|
+
# TODO add support for more output files and properties
|
|
3200
|
+
exciting_files = ['EIGVAL.OUT', 'FERMISURF.bxsf', 'FS.bxsf']
|
|
3201
|
+
|
|
3202
|
+
# Parse DFT DOS from one of the files
|
|
3203
|
+
dos_files = ['dos.xml', 'TDOS.OUT']
|
|
3204
|
+
for fname in dos_files:
|
|
3205
|
+
if self.file_exists(fname):
|
|
3206
|
+
exciting_files.append(fname)
|
|
3207
|
+
break
|
|
3208
|
+
|
|
3209
|
+
# Parse DFT band structure from one of the files
|
|
3210
|
+
bs_files = ['bandstructure.xml', 'BAND.OUT', 'bandstructure.dat']
|
|
3211
|
+
for fname in bs_files:
|
|
3212
|
+
if self.file_exists(fname):
|
|
3213
|
+
exciting_files.append(fname)
|
|
3214
|
+
break
|
|
3215
|
+
|
|
3216
|
+
for f in exciting_files:
|
|
3217
|
+
self.parse_file(f, sec_scc)
|
|
3218
|
+
|
|
3219
|
+
# structure optimization
|
|
3220
|
+
structure_optimization = self.info_parser.get('structure_optimization', {})
|
|
3221
|
+
for optimization_step in structure_optimization.get('optimization_step', []):
|
|
3222
|
+
sec_scc = parse_configuration(optimization_step)
|
|
3223
|
+
|
|
3224
|
+
if optimization_step.get('method') is not None:
|
|
3225
|
+
sec_scc.x_exciting_geometry_optimization_method = optimization_step.get(
|
|
3226
|
+
'method'
|
|
3227
|
+
)
|
|
3228
|
+
|
|
3229
|
+
if optimization_step.get('step') is not None:
|
|
3230
|
+
sec_scc.x_exciting_geometry_optimization_step = optimization_step.get(
|
|
3231
|
+
'step'
|
|
3232
|
+
)
|
|
3233
|
+
|
|
3234
|
+
force_convergence = optimization_step.get('force_convergence')
|
|
3235
|
+
if force_convergence is not None:
|
|
3236
|
+
sec_scc.x_exciting_maximum_force_magnitude = force_convergence[0]
|
|
3237
|
+
sec_scc.x_exciting_geometry_optimization_threshold_force = (
|
|
3238
|
+
force_convergence[1]
|
|
3239
|
+
)
|
|
3240
|
+
|
|
3241
|
+
time_initial = (
|
|
3242
|
+
sec_run.calculation[-1].time_physical if sec_run.calculation else 0 * ureg.s
|
|
3243
|
+
)
|
|
3244
|
+
sec_scc = parse_configuration(structure_optimization)
|
|
3245
|
+
|
|
3246
|
+
if sec_scc is None:
|
|
3247
|
+
return
|
|
3248
|
+
|
|
3249
|
+
if not sec_scc.time_calculation and self.info_parser.total_time is not None:
|
|
3250
|
+
sec_scc.time_physical = self.info_parser.total_time
|
|
3251
|
+
sec_scc.time_calculation = sec_scc.time_physical - time_initial
|
|
3252
|
+
|
|
3253
|
+
# volume optimizations
|
|
3254
|
+
volume_index = 1
|
|
3255
|
+
while True:
|
|
3256
|
+
info_volume = get_files(
|
|
3257
|
+
f"run_dir{str(volume_index).rjust(2, '0')}/INFO.OUT",
|
|
3258
|
+
self.filepath,
|
|
3259
|
+
'INFO.OUT',
|
|
3260
|
+
)
|
|
3261
|
+
if not info_volume:
|
|
3262
|
+
break
|
|
3263
|
+
sec_scc.calculations_path.append(info_volume[0])
|
|
3264
|
+
|
|
3265
|
+
def init_parser(self):
|
|
3266
|
+
self.info_parser.mainfile = self.filepath
|
|
3267
|
+
self.info_parser.logger = self.logger
|
|
3268
|
+
self.dos_parser.logger = self.logger
|
|
3269
|
+
self.bandstructure_parser.logger = self.logger
|
|
3270
|
+
self.eigval_parser.logger = self.logger
|
|
3271
|
+
self.fermisurf_parser.logger = self.logger
|
|
3272
|
+
self.evalqp_parser.logger = self.logger
|
|
3273
|
+
self.dos_out_parser.logger = self.logger
|
|
3274
|
+
self.bandstructure_dat_parser.logger = self.logger
|
|
3275
|
+
self.band_out_parser.logger = self.logger
|
|
3276
|
+
self.info_gw_parser.logger = self.logger
|
|
3277
|
+
self.input_xml_parser.logger = self.logger
|
|
3278
|
+
self.data_xs_parser.logger = self.logger
|
|
3279
|
+
self.data_clathrate_parser.logger = self.logger
|
|
3280
|
+
self._archives_ref = []
|
|
3281
|
+
|
|
3282
|
+
def get_mainfile_keys(self, **kwargs):
|
|
3283
|
+
filepath = kwargs.get('filename')
|
|
3284
|
+
basename = os.path.basename(filepath)
|
|
3285
|
+
dirname = os.path.dirname(filepath)
|
|
3286
|
+
if os.path.isfile(os.path.join(dirname, f'GW_{basename}')):
|
|
3287
|
+
return ['GW', 'GW_workflow']
|
|
3288
|
+
xs_files = get_files(
|
|
3289
|
+
basename.replace('INFO.OUT', 'INFOXS.OUT'), filepath, 'INFO.OUT'
|
|
3290
|
+
)
|
|
3291
|
+
if xs_files:
|
|
3292
|
+
re_xs_mainfile = re.compile(r'.+\d\d\d\.OUT')
|
|
3293
|
+
spectra_files = []
|
|
3294
|
+
for prefix in self._xs_spectra_types:
|
|
3295
|
+
spectra_files = get_files(f'{prefix}_*.OUT', filepath, 'INFO.OUT')
|
|
3296
|
+
if spectra_files:
|
|
3297
|
+
# remove files for qpoints other than first
|
|
3298
|
+
files = ['XS_workflow'] + xs_files
|
|
3299
|
+
for f in spectra_files:
|
|
3300
|
+
if re_xs_mainfile.match(f):
|
|
3301
|
+
if '001' in f:
|
|
3302
|
+
files.append(f)
|
|
3303
|
+
else:
|
|
3304
|
+
files.append(f)
|
|
3305
|
+
return files
|
|
3306
|
+
return True
|
|
3307
|
+
|
|
3308
|
+
def parse(self, filepath, archive, logger, **kwargs):
|
|
3309
|
+
self.filepath = filepath
|
|
3310
|
+
self.archive = archive
|
|
3311
|
+
self.logger = logger if logger is not None else logging
|
|
3312
|
+
|
|
3313
|
+
self._calculation_type = None
|
|
3314
|
+
basename = os.path.basename(filepath)
|
|
3315
|
+
dirname = os.path.dirname(filepath)
|
|
3316
|
+
if basename.startswith('GW'):
|
|
3317
|
+
self._calculation_type = 'gw'
|
|
3318
|
+
# read method params from INFO.OUT
|
|
3319
|
+
self._gw_info_file = filepath
|
|
3320
|
+
self.filepath = os.path.join(dirname, basename.lstrip('GW_'))
|
|
3321
|
+
elif basename.startswith('INFOXS'):
|
|
3322
|
+
self._calculation_type = 'xs'
|
|
3323
|
+
self._xs_info_file = filepath
|
|
3324
|
+
info_file = get_files('INFO.OUT', self.filepath, 'INFO.OUT', deep=False)
|
|
3325
|
+
if info_file:
|
|
3326
|
+
self.filepath = os.path.join(info_file[0])
|
|
3327
|
+
# self.filepath = os.path.join(dirname, basename.replace('INFOXS', 'INFO'))
|
|
3328
|
+
|
|
3329
|
+
if not os.path.isfile(self.filepath):
|
|
3330
|
+
return
|
|
3331
|
+
|
|
3332
|
+
self.init_parser()
|
|
3333
|
+
|
|
3334
|
+
sec_run = Run()
|
|
3335
|
+
self.archive.run.append(sec_run)
|
|
3336
|
+
|
|
3337
|
+
sec_run.program = Program(
|
|
3338
|
+
name='exciting',
|
|
3339
|
+
version=self.info_parser.get('program_version', '').strip(),
|
|
3340
|
+
version_internal=self.info_parser.hash_id,
|
|
3341
|
+
)
|
|
3342
|
+
|
|
3343
|
+
# method goes first since reference needed for sec_scc
|
|
3344
|
+
if self._calculation_type == 'gw':
|
|
3345
|
+
self.parse_gw()
|
|
3346
|
+
self.parse_workflow()
|
|
3347
|
+
elif self._calculation_type == 'xs':
|
|
3348
|
+
self.parse_system(self.info_parser.get('groundstate'))
|
|
3349
|
+
self.parse_xs()
|
|
3350
|
+
|
|
3351
|
+
for child in self._child_archives:
|
|
3352
|
+
self.parse_photons(child)
|
|
3353
|
+
# putting together all photons in the same xs_archive
|
|
3354
|
+
self.parse_photon_workflow()
|
|
3355
|
+
else:
|
|
3356
|
+
self.parse_method()
|
|
3357
|
+
self.parse_configurations()
|
|
3358
|
+
self.parse_workflow()
|
|
3359
|
+
|
|
3360
|
+
# GW archives
|
|
3361
|
+
gw_archive = self._child_archives.get('GW')
|
|
3362
|
+
if gw_archive is not None:
|
|
3363
|
+
# parse gw single point
|
|
3364
|
+
p = ExcitingParser()
|
|
3365
|
+
p.parse(os.path.join(dirname, f'GW_{basename}'), gw_archive, logger)
|
|
3366
|
+
|
|
3367
|
+
# parse gw workflow
|
|
3368
|
+
gw_workflow_archive = self._child_archives.get('GW_workflow')
|
|
3369
|
+
try:
|
|
3370
|
+
self.parse_gw_workflow(gw_archive, gw_workflow_archive)
|
|
3371
|
+
except Exception:
|
|
3372
|
+
self.logger.error('Error parsing the automatic GW workflow')
|
|
3373
|
+
|
|
3374
|
+
# XS archives
|
|
3375
|
+
xs_archives = []
|
|
3376
|
+
for xs_info_file, xs_archive in self._child_archives.items():
|
|
3377
|
+
if 'INFOXS.OUT' in xs_info_file:
|
|
3378
|
+
# parse xs single point
|
|
3379
|
+
xs_dirname = os.path.dirname(xs_info_file)
|
|
3380
|
+
p = ExcitingParser()
|
|
3381
|
+
p._child_archives = {
|
|
3382
|
+
key: archive
|
|
3383
|
+
for key, archive in self._child_archives.items()
|
|
3384
|
+
if key.startswith(xs_dirname)
|
|
3385
|
+
and os.path.basename(key).split('_')[0] in self._xs_spectra_types
|
|
3386
|
+
}
|
|
3387
|
+
|
|
3388
|
+
p.parse(xs_info_file, xs_archive, logger)
|
|
3389
|
+
xs_archives.append(xs_archive)
|
|
3390
|
+
|
|
3391
|
+
# parse xs workflow (DFT + all photons)
|
|
3392
|
+
# TODO generalize to include GW step
|
|
3393
|
+
xs_workflow_archive = self._child_archives.get('XS_workflow')
|
|
3394
|
+
if xs_workflow_archive:
|
|
3395
|
+
try:
|
|
3396
|
+
self.parse_xs_workflow(xs_archives, xs_workflow_archive)
|
|
3397
|
+
except Exception:
|
|
3398
|
+
self.logger.error('Error parsing the automatic XS workflow')
|