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,952 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright The NOMAD Authors.
|
|
3
|
+
#
|
|
4
|
+
# This file is part of NOMAD.
|
|
5
|
+
# See https://nomad-lab.eu for further info.
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
#
|
|
19
|
+
import os
|
|
20
|
+
import logging
|
|
21
|
+
import numpy as np
|
|
22
|
+
from datetime import datetime
|
|
23
|
+
import re
|
|
24
|
+
|
|
25
|
+
from nomad.units import ureg
|
|
26
|
+
from nomad.parsing.file_parser import TextParser, Quantity
|
|
27
|
+
from runschema.run import Run, Program, TimeRun
|
|
28
|
+
from runschema.system import System, Atoms
|
|
29
|
+
from runschema.method import (
|
|
30
|
+
Method,
|
|
31
|
+
BasisSet,
|
|
32
|
+
DFT,
|
|
33
|
+
XCFunctional,
|
|
34
|
+
Functional,
|
|
35
|
+
Electronic,
|
|
36
|
+
Smearing,
|
|
37
|
+
AtomParameters,
|
|
38
|
+
BasisSetContainer,
|
|
39
|
+
OrbitalAPW,
|
|
40
|
+
)
|
|
41
|
+
from runschema.calculation import (
|
|
42
|
+
Calculation,
|
|
43
|
+
ScfIteration,
|
|
44
|
+
Energy,
|
|
45
|
+
EnergyEntry,
|
|
46
|
+
Forces,
|
|
47
|
+
ForcesEntry,
|
|
48
|
+
BandEnergies,
|
|
49
|
+
)
|
|
50
|
+
from .metainfo.fleur import x_fleur_header
|
|
51
|
+
from typing import Any
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
re_n = r'[\n\r]'
|
|
55
|
+
re_f = r'[-+]?\d*\.\d*(?:[DdEe][-+]\d+)?'
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _eval(exp, variables=dict()):
|
|
59
|
+
# TODO implementation can be improved
|
|
60
|
+
operators = {
|
|
61
|
+
'**': lambda x, y: x**y,
|
|
62
|
+
'*': lambda x, y: x * y,
|
|
63
|
+
'/': lambda x, y: x / y,
|
|
64
|
+
'+': lambda x, y: x + y,
|
|
65
|
+
'-': lambda x, y: x + y,
|
|
66
|
+
}
|
|
67
|
+
exp = exp.replace(' ', '')
|
|
68
|
+
if not exp:
|
|
69
|
+
return 0
|
|
70
|
+
|
|
71
|
+
for key, operation in operators.items():
|
|
72
|
+
if key not in exp:
|
|
73
|
+
continue
|
|
74
|
+
|
|
75
|
+
segments = exp.rsplit(key, 1)
|
|
76
|
+
if len(segments) == 2:
|
|
77
|
+
return operation(
|
|
78
|
+
_eval(segments[0], variables), _eval(segments[1], variables)
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
value = variables.get(exp)
|
|
82
|
+
if value:
|
|
83
|
+
return value
|
|
84
|
+
|
|
85
|
+
try:
|
|
86
|
+
return float(exp)
|
|
87
|
+
except Exception as e:
|
|
88
|
+
raise e
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class XMLParser(TextParser):
|
|
92
|
+
def init_quantities(self):
|
|
93
|
+
re_bulk_lattice = re.compile(r'bulkLattice scale="(.+?)"(?: latnam="(.+?)")*')
|
|
94
|
+
re_lattice_constant = re.compile(r'<(.+?) scale="(.+?)"\>(.+?)\<\/')
|
|
95
|
+
re_lattice_vector = re.compile(rf'\<row\-(\d)\>(\S+ +\S+ +\S+)\<')
|
|
96
|
+
|
|
97
|
+
def to_cell(val_in):
|
|
98
|
+
bulk = re_bulk_lattice.findall(val_in)
|
|
99
|
+
lattice_constant = re_lattice_constant.findall(val_in)
|
|
100
|
+
|
|
101
|
+
if re_bulk_lattice:
|
|
102
|
+
scale, lattice = bulk[0]
|
|
103
|
+
if lattice == 'squ':
|
|
104
|
+
if not lattice_constant:
|
|
105
|
+
return
|
|
106
|
+
# TODO why is c specified for squ lattice
|
|
107
|
+
a = float(lattice_constant[0][1]) * float(lattice_constant[0][2])
|
|
108
|
+
return np.diag((a, a, a)) * float(scale) * ureg.bohr
|
|
109
|
+
|
|
110
|
+
else:
|
|
111
|
+
lattice_vector = re_lattice_vector.findall(val_in)
|
|
112
|
+
if not lattice_vector:
|
|
113
|
+
return
|
|
114
|
+
|
|
115
|
+
cell = np.zeros((3, 3))
|
|
116
|
+
for vector in lattice_vector:
|
|
117
|
+
cell[int(vector[0]) - 1][:] = vector[1].split()
|
|
118
|
+
return cell * ureg.bohr
|
|
119
|
+
|
|
120
|
+
embedded_key = Quantity(
|
|
121
|
+
'key_val',
|
|
122
|
+
r' (\S+=)\"(.+?)\"',
|
|
123
|
+
str_operation=lambda x: x.split('='),
|
|
124
|
+
repeats=True,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
self._quantities = [
|
|
128
|
+
Quantity(
|
|
129
|
+
'header',
|
|
130
|
+
r'\<programVersion([\s\S]+?)\<\/programVersion\>',
|
|
131
|
+
sub_parser=TextParser(
|
|
132
|
+
quantities=[
|
|
133
|
+
Quantity(
|
|
134
|
+
'program_version',
|
|
135
|
+
r'version=\"(fleur \S+)\"',
|
|
136
|
+
dtype=str,
|
|
137
|
+
flatten=False,
|
|
138
|
+
),
|
|
139
|
+
Quantity(
|
|
140
|
+
'x_fleur_precision', r'precision type=\"(\S+)\"', dtype=str
|
|
141
|
+
),
|
|
142
|
+
Quantity(
|
|
143
|
+
'x_fleur_structure_class',
|
|
144
|
+
r'\<targetStructureClass\>(.+?)\<',
|
|
145
|
+
dtype=str,
|
|
146
|
+
),
|
|
147
|
+
Quantity(
|
|
148
|
+
'x_fleur_additional_flags',
|
|
149
|
+
r'\<additionalCompilerFlags\>(.+?)\<',
|
|
150
|
+
dtype=str,
|
|
151
|
+
),
|
|
152
|
+
]
|
|
153
|
+
),
|
|
154
|
+
),
|
|
155
|
+
Quantity(
|
|
156
|
+
'start_time',
|
|
157
|
+
r'date="(.+?)" time="(.+?)" zone="(.+?)"',
|
|
158
|
+
flatten=False,
|
|
159
|
+
dtype=str,
|
|
160
|
+
),
|
|
161
|
+
Quantity(
|
|
162
|
+
'input',
|
|
163
|
+
r'\<inputData\>([\s\S]+?)\<\/inputData\>',
|
|
164
|
+
sub_parser=TextParser(
|
|
165
|
+
quantities=[
|
|
166
|
+
Quantity(
|
|
167
|
+
'parameters',
|
|
168
|
+
r'\<calculationSetup\>([\s\S]+?)\<\/calculationSetup\>',
|
|
169
|
+
sub_parser=TextParser(quantities=[embedded_key]),
|
|
170
|
+
),
|
|
171
|
+
Quantity(
|
|
172
|
+
'cell',
|
|
173
|
+
r'\<cell\>([\s\S]+?)\<\/cell\>',
|
|
174
|
+
str_operation=to_cell,
|
|
175
|
+
),
|
|
176
|
+
Quantity(
|
|
177
|
+
'xc_functional',
|
|
178
|
+
r'<xcFunctional name="(.+?)" relativisticCorrections="(.)"',
|
|
179
|
+
dtype=str,
|
|
180
|
+
),
|
|
181
|
+
Quantity(
|
|
182
|
+
'species',
|
|
183
|
+
r'\<species([\s\S]+?)\<\/species\>',
|
|
184
|
+
repeats=True,
|
|
185
|
+
sub_parser=TextParser(quantities=[embedded_key]),
|
|
186
|
+
),
|
|
187
|
+
Quantity(
|
|
188
|
+
'atom',
|
|
189
|
+
r'\<atomGroup([\s\S]+?)\<\/atomGroup\>',
|
|
190
|
+
repeats=True,
|
|
191
|
+
# TODO parse more quantities
|
|
192
|
+
sub_parser=TextParser(
|
|
193
|
+
quantities=[
|
|
194
|
+
Quantity(
|
|
195
|
+
'species', r'species="([A-Z][a-z]*)', dtype=str
|
|
196
|
+
),
|
|
197
|
+
Quantity(
|
|
198
|
+
'position',
|
|
199
|
+
r'\<relPos.*?\>(.+?)\<\/relPos\>',
|
|
200
|
+
str_operation=lambda x: [
|
|
201
|
+
_eval(v) for v in x.strip().split()
|
|
202
|
+
],
|
|
203
|
+
),
|
|
204
|
+
]
|
|
205
|
+
),
|
|
206
|
+
),
|
|
207
|
+
Quantity(
|
|
208
|
+
'output_parameters',
|
|
209
|
+
r'\<output([\s\S]+?)\<\/output\>',
|
|
210
|
+
sub_parser=TextParser(quantities=[embedded_key]),
|
|
211
|
+
),
|
|
212
|
+
]
|
|
213
|
+
),
|
|
214
|
+
),
|
|
215
|
+
Quantity(
|
|
216
|
+
'numerical_parameters',
|
|
217
|
+
r'\<numericalParameters\>([\s\S]+?)\<\/numericalParameters\>',
|
|
218
|
+
sub_parser=TextParser(
|
|
219
|
+
quantities=[
|
|
220
|
+
Quantity(
|
|
221
|
+
'key_val',
|
|
222
|
+
r' (\S+=)\"(.+?)\"',
|
|
223
|
+
str_operation=lambda x: x.split('='),
|
|
224
|
+
repeats=True,
|
|
225
|
+
)
|
|
226
|
+
]
|
|
227
|
+
),
|
|
228
|
+
),
|
|
229
|
+
Quantity(
|
|
230
|
+
'scf_iteration',
|
|
231
|
+
r'\<iteration([\s\S]+?)\<\/iteration\>',
|
|
232
|
+
repeats=True,
|
|
233
|
+
sub_parser=TextParser(
|
|
234
|
+
quantities=[
|
|
235
|
+
Quantity(
|
|
236
|
+
'energy_total',
|
|
237
|
+
rf'totalEnergy +value=" *({re_f})',
|
|
238
|
+
dtype=np.float64,
|
|
239
|
+
unit=ureg.hartree,
|
|
240
|
+
),
|
|
241
|
+
Quantity(
|
|
242
|
+
'energy_sum_eigenvalues',
|
|
243
|
+
rf'sumOfEigenvalues +value=" *({re_f})',
|
|
244
|
+
dtype=np.float64,
|
|
245
|
+
unit=ureg.hartree,
|
|
246
|
+
),
|
|
247
|
+
Quantity(
|
|
248
|
+
'energy_x_fleur_density_coulomb_potential',
|
|
249
|
+
rf'densityCoulombPotentialIntegral +value=" *({re_f})',
|
|
250
|
+
dtype=np.float64,
|
|
251
|
+
unit=ureg.hartree,
|
|
252
|
+
),
|
|
253
|
+
Quantity(
|
|
254
|
+
'energy_x_fleur_density_effective_potential',
|
|
255
|
+
rf'densityEffectivePotentialIntegral +value=" *({re_f})',
|
|
256
|
+
dtype=np.float64,
|
|
257
|
+
unit=ureg.hartree,
|
|
258
|
+
),
|
|
259
|
+
Quantity(
|
|
260
|
+
'energy_x_fleur_charge_density_xc',
|
|
261
|
+
rf'chargeDenXCDenIntegral +value=" *({re_f})',
|
|
262
|
+
dtype=np.float64,
|
|
263
|
+
unit=ureg.hartree,
|
|
264
|
+
),
|
|
265
|
+
Quantity(
|
|
266
|
+
'energy_free',
|
|
267
|
+
rf'freeEnergy +value=" *({re_f})',
|
|
268
|
+
dtype=np.float64,
|
|
269
|
+
unit=ureg.hartree,
|
|
270
|
+
),
|
|
271
|
+
Quantity(
|
|
272
|
+
'energy_total_t0',
|
|
273
|
+
rf'extrapolationTo0K +value=" *({re_f})',
|
|
274
|
+
dtype=np.float64,
|
|
275
|
+
unit=ureg.hartree,
|
|
276
|
+
),
|
|
277
|
+
Quantity(
|
|
278
|
+
'fermi',
|
|
279
|
+
rf'FermiEnergy +value=" *({re_f})',
|
|
280
|
+
dtype=np.float64,
|
|
281
|
+
unit=ureg.hartree,
|
|
282
|
+
),
|
|
283
|
+
Quantity(
|
|
284
|
+
'eigenvalues_kpts',
|
|
285
|
+
r'\<eigenvaluesAt([\s\S]+?\<)\/eigenvaluesAt\>',
|
|
286
|
+
repeats=True,
|
|
287
|
+
sub_parser=TextParser(
|
|
288
|
+
quantities=[
|
|
289
|
+
Quantity(
|
|
290
|
+
'kpt',
|
|
291
|
+
rf'spin="1" ikpt="\d+" k_x="({re_f})" k_y="({re_f})" k_z="({re_f})"',
|
|
292
|
+
dtype=np.dtype(np.float64),
|
|
293
|
+
),
|
|
294
|
+
Quantity(
|
|
295
|
+
'energies',
|
|
296
|
+
rf'\>([\s\S]+?)\<',
|
|
297
|
+
dtype=np.dtype(np.float64),
|
|
298
|
+
),
|
|
299
|
+
]
|
|
300
|
+
),
|
|
301
|
+
),
|
|
302
|
+
# TODO parse other quantities
|
|
303
|
+
]
|
|
304
|
+
),
|
|
305
|
+
),
|
|
306
|
+
]
|
|
307
|
+
|
|
308
|
+
def get_xc_functional(self):
|
|
309
|
+
xc_functional = self.get('input', {}).get('xc_functional')
|
|
310
|
+
if xc_functional is not None:
|
|
311
|
+
return f'{xc_functional[0]} {"non-" if xc_functional[1] == "F" else ""}relativistic correction'
|
|
312
|
+
|
|
313
|
+
def get_system(self):
|
|
314
|
+
input = self.input
|
|
315
|
+
if not input:
|
|
316
|
+
return None, None, None
|
|
317
|
+
|
|
318
|
+
cell = input.cell
|
|
319
|
+
atoms = input.get('atom', [])
|
|
320
|
+
labels = [atom.species for atom in atoms]
|
|
321
|
+
positions = np.dot([atom.position for atom in atoms], cell)
|
|
322
|
+
return labels, positions, cell
|
|
323
|
+
|
|
324
|
+
def get_basis_sets(self) -> list[BasisSet]:
|
|
325
|
+
"""Extract `species` xml tags, add semantics,
|
|
326
|
+
and map their settings into as series of `muffin-tin` BasisSets."""
|
|
327
|
+
|
|
328
|
+
# https://www.flapw.de/MaX-6.0/documentation/fleurInputFile/
|
|
329
|
+
# https://www.flapw.de/MaX-6.0/documentation/localOrbitalSetup/
|
|
330
|
+
def to_dict(key_vals: list[list[Any]]) -> dict[str, Any]:
|
|
331
|
+
return {key_val[0]: key_val[1] for key_val in key_vals}
|
|
332
|
+
|
|
333
|
+
def develop_range(val_in: str) -> list[int]:
|
|
334
|
+
if '-' in val_in:
|
|
335
|
+
start, end = val_in.split('-')
|
|
336
|
+
return list(range(int(start), int(end) + 1))
|
|
337
|
+
elif ',' in val_in:
|
|
338
|
+
return [int(val) for val in val_in.split(',')]
|
|
339
|
+
else:
|
|
340
|
+
return [int(val_in)]
|
|
341
|
+
|
|
342
|
+
def roll_out_lo(
|
|
343
|
+
val_in: dict[str, str],
|
|
344
|
+
) -> list[dict[tuple[int, int], list[Any]]]:
|
|
345
|
+
los = []
|
|
346
|
+
for l_n in develop_range(val_in['l']):
|
|
347
|
+
for n in develop_range(val_in['n']):
|
|
348
|
+
order = int(val_in['eDeriv'])
|
|
349
|
+
los.append({(l_n, order): [n, val_in['type']]})
|
|
350
|
+
return los
|
|
351
|
+
|
|
352
|
+
# function variables
|
|
353
|
+
basis_sets: list[BasisSet] = []
|
|
354
|
+
l_mapping = ['s', 'p', 'd', 'f']
|
|
355
|
+
bool_mapping = {'T': True, 'F': False}
|
|
356
|
+
order_mapping = {'APW': 1, 'LAPW': 2}
|
|
357
|
+
input_parameters_reformatted = {
|
|
358
|
+
key_val[0]: key_val[1]
|
|
359
|
+
for key_val in self.input.get('parameters').get('key_val')
|
|
360
|
+
}
|
|
361
|
+
# muffin-tin
|
|
362
|
+
species = self.get('input', {}).get('species', [])
|
|
363
|
+
for specie in species:
|
|
364
|
+
specie = to_dict(specie.get('key_val', []))
|
|
365
|
+
mt: list[BasisSet] = []
|
|
366
|
+
for _ in range(2):
|
|
367
|
+
mt.append(
|
|
368
|
+
BasisSet(
|
|
369
|
+
scope=['muffin-tin'],
|
|
370
|
+
radius=specie.get('radius') * ureg.bohr,
|
|
371
|
+
spherical_harmonics_cutoff=specie.get('lmax'),
|
|
372
|
+
radius_log_spacing=float(specie.get('logIncrement')),
|
|
373
|
+
n_grid_points=int(specie.get('gridPoints')),
|
|
374
|
+
)
|
|
375
|
+
)
|
|
376
|
+
# valence muffin-tin + local orbitals
|
|
377
|
+
n_max = None
|
|
378
|
+
for l_test in l_mapping[::-1]:
|
|
379
|
+
n_prospective = int(specie.get(l_test))
|
|
380
|
+
if n_prospective:
|
|
381
|
+
# TODO check n_max supposed to be int but l_test is str
|
|
382
|
+
n_max = l_test
|
|
383
|
+
break
|
|
384
|
+
los = []
|
|
385
|
+
for lo in specie.get('lo', []):
|
|
386
|
+
los += roll_out_lo(to_dict(lo.get('key_val', [])))
|
|
387
|
+
for l_n in range(int(specie.get('lmax')) + 1):
|
|
388
|
+
apw_type = 'APW' if l_n == specie.get('lmaxAPW', -1) else 'LAPW'
|
|
389
|
+
n_quantum = specie.get(l_mapping[min(l_n, len(l_mapping) - 1)], n_max)
|
|
390
|
+
for order in range(5): # TODO: find a better option than hard-coding
|
|
391
|
+
if order <= order_mapping[apw_type]:
|
|
392
|
+
orbital = [
|
|
393
|
+
OrbitalAPW(
|
|
394
|
+
type=apw_type,
|
|
395
|
+
energy_parameter_n=n_quantum,
|
|
396
|
+
l_quantum_number=l_n,
|
|
397
|
+
core_level=False,
|
|
398
|
+
order=order,
|
|
399
|
+
)
|
|
400
|
+
]
|
|
401
|
+
if (l_n, order) in [lo.keys() for lo in los]:
|
|
402
|
+
orbital.append(
|
|
403
|
+
OrbitalAPW(
|
|
404
|
+
type='LO',
|
|
405
|
+
energy_parameter_n=lo[(l_n, order)][0],
|
|
406
|
+
l_quantum_number=l_n,
|
|
407
|
+
core_level=False,
|
|
408
|
+
order=order,
|
|
409
|
+
x_fleur_lo_type=lo[(l_n, order)][1],
|
|
410
|
+
)
|
|
411
|
+
)
|
|
412
|
+
mt[0].orbital = [*mt[0].orbital, *orbital]
|
|
413
|
+
mt[0].scope.append('valence')
|
|
414
|
+
# core muffin-tin
|
|
415
|
+
n_counter = 1
|
|
416
|
+
nl_counter = specie.get('coreStates', 0)
|
|
417
|
+
while nl_counter > 0:
|
|
418
|
+
for l_n in range(n_counter):
|
|
419
|
+
j = l_n + 0.5
|
|
420
|
+
while j > 0:
|
|
421
|
+
mt[1].orbital.append(
|
|
422
|
+
OrbitalAPW(
|
|
423
|
+
type='spherical Dirac',
|
|
424
|
+
n_quantum_number=n_counter,
|
|
425
|
+
l_quantum_number=l_n,
|
|
426
|
+
j_quantum_number=j,
|
|
427
|
+
occupation=2 * j + 1,
|
|
428
|
+
core_level=True,
|
|
429
|
+
)
|
|
430
|
+
)
|
|
431
|
+
j -= 1
|
|
432
|
+
nl_counter -= 1
|
|
433
|
+
n_counter += 1
|
|
434
|
+
mt[1].scope.append('core')
|
|
435
|
+
# general core settings
|
|
436
|
+
core_application = {
|
|
437
|
+
'coretail': 'ctail',
|
|
438
|
+
'coretail_cutoff': 'coretail_lmax',
|
|
439
|
+
} # TODO: add 'relativistic_core': 'kcrel'?
|
|
440
|
+
for key, val in core_application.items():
|
|
441
|
+
try:
|
|
442
|
+
q = input_parameters_reformatted[val].strip()
|
|
443
|
+
except KeyError:
|
|
444
|
+
continue
|
|
445
|
+
try:
|
|
446
|
+
q = bool_mapping[q]
|
|
447
|
+
except KeyError:
|
|
448
|
+
pass
|
|
449
|
+
setattr(mt[1], f'x_fleur_{key}', q)
|
|
450
|
+
mt[1].frozen_core = bool_mapping[
|
|
451
|
+
input_parameters_reformatted['frcor'].strip()
|
|
452
|
+
]
|
|
453
|
+
# write out muffin tin
|
|
454
|
+
basis_sets.append(mt[0])
|
|
455
|
+
basis_sets.append(mt[1])
|
|
456
|
+
return basis_sets
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
class OutParser(TextParser):
|
|
460
|
+
def init_quantities(self):
|
|
461
|
+
def to_atoms(val_in):
|
|
462
|
+
labels, positions = [], []
|
|
463
|
+
for val in val_in.strip().splitlines():
|
|
464
|
+
val = val.split()
|
|
465
|
+
labels.append(val[1])
|
|
466
|
+
positions.append(val[6:9])
|
|
467
|
+
return labels, np.array(positions, dtype=np.float64) * ureg.bohr
|
|
468
|
+
|
|
469
|
+
def to_key_val(val_in):
|
|
470
|
+
val = val_in.strip().replace('D', 'E').split('=')
|
|
471
|
+
key, val = val[0].strip(), val[1].split()
|
|
472
|
+
return [key, val[0] if len(val) == 1 else val]
|
|
473
|
+
|
|
474
|
+
key_val_quantity = Quantity(
|
|
475
|
+
'key_val',
|
|
476
|
+
r'([\w \-\/]+\s*=\s*[\d\.\-\+\w ]+)',
|
|
477
|
+
str_operation=to_key_val,
|
|
478
|
+
repeats=True,
|
|
479
|
+
)
|
|
480
|
+
|
|
481
|
+
self._quantities = [
|
|
482
|
+
Quantity(
|
|
483
|
+
'header',
|
|
484
|
+
r'(This output is generated[\s\S]+?Additional flags.+)',
|
|
485
|
+
sub_parser=TextParser(
|
|
486
|
+
quantities=[
|
|
487
|
+
Quantity(
|
|
488
|
+
'program_version',
|
|
489
|
+
r'This output is generated by (fleur\S+)',
|
|
490
|
+
dtype=str,
|
|
491
|
+
),
|
|
492
|
+
Quantity('x_fleur_precision', r'(\S+) precision', dtype=str),
|
|
493
|
+
Quantity(
|
|
494
|
+
'x_fleur_with_inversion',
|
|
495
|
+
r'(\S+) INVERSION',
|
|
496
|
+
dtype=lambda x: x == 'with',
|
|
497
|
+
),
|
|
498
|
+
Quantity(
|
|
499
|
+
'x_fleur_with_soc',
|
|
500
|
+
r'(\S+) SOC',
|
|
501
|
+
dtype=lambda x: x == 'with',
|
|
502
|
+
),
|
|
503
|
+
Quantity(
|
|
504
|
+
'x_fleur_additional_flags',
|
|
505
|
+
r'Additional flags are: +(.+)',
|
|
506
|
+
str_operation=lambda x: x.strip(),
|
|
507
|
+
dtype=str,
|
|
508
|
+
),
|
|
509
|
+
]
|
|
510
|
+
),
|
|
511
|
+
),
|
|
512
|
+
Quantity(
|
|
513
|
+
'input',
|
|
514
|
+
r'(Your parameters\:[\s\S]+?fleur)',
|
|
515
|
+
sub_parser=TextParser(
|
|
516
|
+
quantities=[
|
|
517
|
+
Quantity(
|
|
518
|
+
'input_parameters',
|
|
519
|
+
r'dump of inp-file +\-+([\s\S]+?)Local',
|
|
520
|
+
sub_parser=TextParser(quantities=[key_val_quantity]),
|
|
521
|
+
),
|
|
522
|
+
Quantity(
|
|
523
|
+
'parameters',
|
|
524
|
+
r'(parameter *\([\s\S]+?)fleur',
|
|
525
|
+
sub_parser=TextParser(quantities=[key_val_quantity]),
|
|
526
|
+
),
|
|
527
|
+
]
|
|
528
|
+
),
|
|
529
|
+
),
|
|
530
|
+
Quantity(
|
|
531
|
+
'system',
|
|
532
|
+
r'([\w ]+\s+lattice=[\s\S]+?)input of',
|
|
533
|
+
sub_parser=TextParser(
|
|
534
|
+
quantities=[
|
|
535
|
+
Quantity(
|
|
536
|
+
'parameters',
|
|
537
|
+
rf'(lattice[\s\S]+?){re_n} *{re_n}',
|
|
538
|
+
sub_parser=TextParser(quantities=[key_val_quantity]),
|
|
539
|
+
),
|
|
540
|
+
Quantity(
|
|
541
|
+
'x_fleur_unit_cell_volume',
|
|
542
|
+
rf'the volume of the unit cell omega\-tilda= +({re_f})',
|
|
543
|
+
dtype=np.float64,
|
|
544
|
+
),
|
|
545
|
+
Quantity(
|
|
546
|
+
'x_fleur_unit_cell_volume_omega',
|
|
547
|
+
rf'the volume of the unit cell omega= +({re_f})',
|
|
548
|
+
dtype=np.float64,
|
|
549
|
+
),
|
|
550
|
+
Quantity(
|
|
551
|
+
'exchange_correlation',
|
|
552
|
+
r'exchange\-correlation: (.+)',
|
|
553
|
+
flatten=False,
|
|
554
|
+
dtype=str,
|
|
555
|
+
),
|
|
556
|
+
Quantity(
|
|
557
|
+
'x_fleur_k_max', rf'k_max *= *({re_f})', dtype=np.float64
|
|
558
|
+
),
|
|
559
|
+
Quantity(
|
|
560
|
+
'x_fleur_G_max', rf'G_max *= *({re_f})', dtype=np.float64
|
|
561
|
+
),
|
|
562
|
+
Quantity(
|
|
563
|
+
'x_fleur_vol_interstitial',
|
|
564
|
+
rf'volume of interstitial region= +({re_f})',
|
|
565
|
+
dtype=np.float64,
|
|
566
|
+
),
|
|
567
|
+
Quantity(
|
|
568
|
+
'x_fleur_nr_of_atom_types',
|
|
569
|
+
rf'number of atom types= +(\d+)',
|
|
570
|
+
dtype=np.int32,
|
|
571
|
+
),
|
|
572
|
+
Quantity(
|
|
573
|
+
'cell',
|
|
574
|
+
r'bravais matrices of real and reciprocal lattices\s+'
|
|
575
|
+
# rf'((?:{re_f} +{re_f} +{re_f} +{re_f} +{re_f} +{re_f}\s+))',
|
|
576
|
+
rf'({re_f} +{re_f} +{re_f}) +{re_f} +{re_f} +{re_f}\s+'
|
|
577
|
+
rf'({re_f} +{re_f} +{re_f}) +{re_f} +{re_f} +{re_f}\s+'
|
|
578
|
+
rf'({re_f} +{re_f} +{re_f}) +{re_f} +{re_f} +{re_f}\s+',
|
|
579
|
+
dtype=np.dtype(np.float64),
|
|
580
|
+
shape=(3, 3),
|
|
581
|
+
unit=ureg.bohr,
|
|
582
|
+
),
|
|
583
|
+
Quantity(
|
|
584
|
+
'atoms',
|
|
585
|
+
r'no\. +type +int\.\-coord\. +cart\.coord\. +rmt +jri +dx +lmax\s+'
|
|
586
|
+
rf'((?:\d+ +[A-Z][a-z] +\d+.+\s+)+)',
|
|
587
|
+
str_operation=to_atoms,
|
|
588
|
+
),
|
|
589
|
+
]
|
|
590
|
+
),
|
|
591
|
+
),
|
|
592
|
+
Quantity(
|
|
593
|
+
'electronic',
|
|
594
|
+
r'(parameters for eigenvalues[\s\S]+?)Local',
|
|
595
|
+
sub_parser=TextParser(
|
|
596
|
+
quantities=[
|
|
597
|
+
Quantity(
|
|
598
|
+
'eigenvalues_parameters',
|
|
599
|
+
rf'parameters for eigenvalues:([\s\S]+?){re_n} *{re_n}',
|
|
600
|
+
sub_parser=TextParser(quantities=[key_val_quantity]),
|
|
601
|
+
),
|
|
602
|
+
Quantity(
|
|
603
|
+
'smearing',
|
|
604
|
+
r'gauss\-integration is used += +(\S)',
|
|
605
|
+
str_operation=lambda x: 'gaussian' if x == 'T' else 'fermi',
|
|
606
|
+
),
|
|
607
|
+
Quantity(
|
|
608
|
+
'width',
|
|
609
|
+
rf'(?:width|broadening) += +({re_f})',
|
|
610
|
+
dtype=np.float64,
|
|
611
|
+
),
|
|
612
|
+
Quantity(
|
|
613
|
+
'x_fleur_nr_of_valence_electrons',
|
|
614
|
+
rf'number of valence electrons= +({re_f})',
|
|
615
|
+
dtype=np.float64,
|
|
616
|
+
),
|
|
617
|
+
]
|
|
618
|
+
),
|
|
619
|
+
),
|
|
620
|
+
Quantity(
|
|
621
|
+
'electic_field_parameters',
|
|
622
|
+
rf'parameters for external electric field:([\s\S]+?){re_n} *{re_n}',
|
|
623
|
+
sub_parser=TextParser(
|
|
624
|
+
quantities=[
|
|
625
|
+
Quantity(
|
|
626
|
+
'x_fleur_tot_elec_charge',
|
|
627
|
+
rf'total electronic charge += +({re_f})',
|
|
628
|
+
dtype=np.float64,
|
|
629
|
+
),
|
|
630
|
+
Quantity(
|
|
631
|
+
'x_fleur_tot_nucl_charge',
|
|
632
|
+
rf'total nuclear charge += +({re_f})',
|
|
633
|
+
dtype=np.float64,
|
|
634
|
+
),
|
|
635
|
+
]
|
|
636
|
+
),
|
|
637
|
+
),
|
|
638
|
+
Quantity(
|
|
639
|
+
'scf_iteration',
|
|
640
|
+
r'(it= +\d+[\s\S]+?it= +\d+ +is completed)',
|
|
641
|
+
repeats=True,
|
|
642
|
+
sub_parser=TextParser(
|
|
643
|
+
quantities=[
|
|
644
|
+
Quantity(
|
|
645
|
+
'energy_sum_eigenvalues',
|
|
646
|
+
rf'sum of eigenvalues = +({re_f})',
|
|
647
|
+
dtype=np.float64,
|
|
648
|
+
unit=ureg.hartree,
|
|
649
|
+
),
|
|
650
|
+
Quantity(
|
|
651
|
+
'energy_x_fleur_density_coulomb_potential',
|
|
652
|
+
rf'density\-coulomb potential int +({re_f}) htr',
|
|
653
|
+
dtype=np.float64,
|
|
654
|
+
unit=ureg.hartree,
|
|
655
|
+
),
|
|
656
|
+
Quantity(
|
|
657
|
+
'energy_x_fleur_density_effective_potential',
|
|
658
|
+
rf'density-effective potential i +({re_f}) htr',
|
|
659
|
+
dtype=np.float64,
|
|
660
|
+
unit=ureg.hartree,
|
|
661
|
+
),
|
|
662
|
+
Quantity(
|
|
663
|
+
'energy_x_fleur_charge_density_xc',
|
|
664
|
+
rf'charge density\-ex\.\-corr\.energ +({re_f}) htr',
|
|
665
|
+
dtype=np.float64,
|
|
666
|
+
unit=ureg.hartree,
|
|
667
|
+
),
|
|
668
|
+
Quantity(
|
|
669
|
+
'energy_total',
|
|
670
|
+
rf'total energy= +({re_f}) htr',
|
|
671
|
+
dtype=np.float64,
|
|
672
|
+
unit=ureg.hartree,
|
|
673
|
+
),
|
|
674
|
+
Quantity(
|
|
675
|
+
'energy_free',
|
|
676
|
+
rf'free energy= +({re_f}) htr',
|
|
677
|
+
dtype=np.float64,
|
|
678
|
+
unit=ureg.hartree,
|
|
679
|
+
),
|
|
680
|
+
Quantity(
|
|
681
|
+
'energy_total_t0',
|
|
682
|
+
rf'total electron energy= +({re_f}) htr',
|
|
683
|
+
dtype=np.float64,
|
|
684
|
+
unit=ureg.hartree,
|
|
685
|
+
),
|
|
686
|
+
Quantity(
|
|
687
|
+
'forces',
|
|
688
|
+
rf'FX_TOT= *({re_f}) FY_TOT= *({re_f}) FZ_TOT= *({re_f})',
|
|
689
|
+
repeats=True,
|
|
690
|
+
),
|
|
691
|
+
Quantity(
|
|
692
|
+
'kpoints',
|
|
693
|
+
rf'k=\( +({re_f} +{re_f} +{re_f})\):',
|
|
694
|
+
repeats=True,
|
|
695
|
+
dtype=np.dtype(np.float64),
|
|
696
|
+
),
|
|
697
|
+
Quantity(
|
|
698
|
+
'eigenvalues',
|
|
699
|
+
r'the *\d+ eigenvalues are:\s+([\s\d\.\-]+)',
|
|
700
|
+
repeats=True,
|
|
701
|
+
dtype=np.dtype(np.float64),
|
|
702
|
+
),
|
|
703
|
+
Quantity(
|
|
704
|
+
'fermi',
|
|
705
|
+
rf'new fermi energy +: +({re_f}) htr',
|
|
706
|
+
unit=ureg.hartree,
|
|
707
|
+
dtype=np.float64,
|
|
708
|
+
),
|
|
709
|
+
Quantity(
|
|
710
|
+
'x_fleur_n_occupied_states',
|
|
711
|
+
r'number of occ\. states +: +(\d+)',
|
|
712
|
+
dtype=np.int32,
|
|
713
|
+
),
|
|
714
|
+
Quantity(
|
|
715
|
+
'x_fleur_valence_charge',
|
|
716
|
+
rf'valence charge +: +({re_f})',
|
|
717
|
+
dtype=np.float64,
|
|
718
|
+
),
|
|
719
|
+
]
|
|
720
|
+
),
|
|
721
|
+
),
|
|
722
|
+
]
|
|
723
|
+
|
|
724
|
+
def get_xc_functional(self):
|
|
725
|
+
return self.get('system', {}).get('exchange_correlation')
|
|
726
|
+
|
|
727
|
+
def get_system(self):
|
|
728
|
+
system = self.get('system')
|
|
729
|
+
if not system:
|
|
730
|
+
return None, None, None
|
|
731
|
+
|
|
732
|
+
atoms = system.get('atoms', [None, None])
|
|
733
|
+
return atoms[0], atoms[1], system.cell
|
|
734
|
+
|
|
735
|
+
def get_atom_parameters(self) -> list[AtomParameters]:
|
|
736
|
+
return []
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
class FleurParser:
|
|
740
|
+
def __init__(self):
|
|
741
|
+
self._out_parser = OutParser()
|
|
742
|
+
self._xml_parser = XMLParser()
|
|
743
|
+
self._xc_map = {
|
|
744
|
+
'pbe': ['GGA_X_PBE', 'GGA_C_PBE'],
|
|
745
|
+
'rpbe': ['GGA_X_PBE', 'GGA_C_PBE'],
|
|
746
|
+
'Rpbe': ['GGA_X_RPBE'],
|
|
747
|
+
'pw91': ['GGA_X_PW91', 'GGA_C_PW91'],
|
|
748
|
+
'l91': ['LDA_C_PW', 'LDA_C_PW_RPA', 'LDA_C_PW_MOD', 'LDA_C_OB_PW'],
|
|
749
|
+
'vwn': [
|
|
750
|
+
'LDA_C_VWN',
|
|
751
|
+
'LDA_C_VWN_1',
|
|
752
|
+
'LDA_C_VWN_2',
|
|
753
|
+
'LDA_C_VWN_3',
|
|
754
|
+
'LDA_C_VWN_4',
|
|
755
|
+
'LDA_C_VWN_RPA',
|
|
756
|
+
],
|
|
757
|
+
'bh': ['LDA_C_VBH'],
|
|
758
|
+
'pz': ['LDA_C_PZ'],
|
|
759
|
+
'x-a': [],
|
|
760
|
+
'mjw': [],
|
|
761
|
+
'wign': [],
|
|
762
|
+
'hl': [],
|
|
763
|
+
'xal': [],
|
|
764
|
+
'relativistic': [],
|
|
765
|
+
}
|
|
766
|
+
# TODO implement xml parser
|
|
767
|
+
|
|
768
|
+
def init_parser(self):
|
|
769
|
+
self.parser = (
|
|
770
|
+
self._xml_parser if self.filepath.endswith('.xml') else self._out_parser
|
|
771
|
+
)
|
|
772
|
+
self.parser.mainfile = self.filepath
|
|
773
|
+
self.parser.logger = self.logger
|
|
774
|
+
|
|
775
|
+
def parse(self, filepath, archive, logger):
|
|
776
|
+
self.filepath = os.path.abspath(filepath)
|
|
777
|
+
self.archive = archive
|
|
778
|
+
self.logger = logging.getLogger(__name__) if logger is None else logger
|
|
779
|
+
self.maindir = os.path.dirname(self.filepath)
|
|
780
|
+
self.init_parser()
|
|
781
|
+
|
|
782
|
+
header = self.parser.get('header', {})
|
|
783
|
+
sec_run = Run()
|
|
784
|
+
self.archive.run.append(sec_run)
|
|
785
|
+
sec_run.program = Program(name='fleur', version=header.get('program_version'))
|
|
786
|
+
sec_header = x_fleur_header()
|
|
787
|
+
sec_run.x_fleur_header.append(sec_header)
|
|
788
|
+
for key, val in header.items():
|
|
789
|
+
if key.startswith('x_fleur'):
|
|
790
|
+
setattr(sec_header, key, val)
|
|
791
|
+
|
|
792
|
+
if self.parser.start_time:
|
|
793
|
+
dt = datetime.strptime(self.parser.start_time, '%Y/%m/%d %H:%M:%S %z')
|
|
794
|
+
sec_run.time_run = TimeRun(date_start=dt.timestamp())
|
|
795
|
+
|
|
796
|
+
sec_method = Method()
|
|
797
|
+
sec_run.method.append(sec_method)
|
|
798
|
+
input = self.parser.get('input')
|
|
799
|
+
if input is not None:
|
|
800
|
+
for key in ['parameters', 'input_parameters']:
|
|
801
|
+
setattr(
|
|
802
|
+
sec_method,
|
|
803
|
+
f'x_fleur_{key}',
|
|
804
|
+
{
|
|
805
|
+
key: list(float(v) for v in val)
|
|
806
|
+
if isinstance(val, np.ndarray)
|
|
807
|
+
else val
|
|
808
|
+
for key, val in input.get(key, {}).get('key_val', [])
|
|
809
|
+
},
|
|
810
|
+
)
|
|
811
|
+
if not sec_method.x_fleur_parameters:
|
|
812
|
+
sec_method.x_fleur_parameters = {}
|
|
813
|
+
sec_method.x_fleur_parameters.update(input.get('output_parameters', {}))
|
|
814
|
+
sec_method.x_fleur_parameters.update(
|
|
815
|
+
self.parser.get('numerical_parameters', {})
|
|
816
|
+
)
|
|
817
|
+
|
|
818
|
+
# Electronic_model
|
|
819
|
+
input_parameters_reformatted = {
|
|
820
|
+
key_val[0]: key_val[1] for key_val in input.get('parameters').get('key_val')
|
|
821
|
+
}
|
|
822
|
+
for cutoff in ('Kmax', 'Gmax'): # TODO: add 'GmaxXC'
|
|
823
|
+
if cutoff not in input_parameters_reformatted.keys():
|
|
824
|
+
continue
|
|
825
|
+
em = BasisSetContainer()
|
|
826
|
+
if cutoff == 'Kmax':
|
|
827
|
+
em.scope = ['wavefunction']
|
|
828
|
+
elif cutoff == 'Gmax':
|
|
829
|
+
em.scope = ['density']
|
|
830
|
+
# interstitial region
|
|
831
|
+
k_cutoff = input_parameters_reformatted[cutoff] / ureg.bohr
|
|
832
|
+
e_cutoff = ureg.h_bar**2 / ureg.electron_mass * k_cutoff**2 / 2
|
|
833
|
+
em.basis_set.append(
|
|
834
|
+
BasisSet(
|
|
835
|
+
scope=['interstitial', 'valence'],
|
|
836
|
+
type='plane waves', # Actually stars: symmetrized plane waves according to the unit cell
|
|
837
|
+
cutoff=e_cutoff, # TODO: check units
|
|
838
|
+
)
|
|
839
|
+
)
|
|
840
|
+
em.basis_set = [*em.basis_set, *self.parser.get_basis_sets()]
|
|
841
|
+
sec_method.electrons_representation.append(em)
|
|
842
|
+
|
|
843
|
+
electronic = self.parser.electronic
|
|
844
|
+
if electronic is not None:
|
|
845
|
+
sec_method.x_fleur_eigenvalues_parameters = {
|
|
846
|
+
key: val
|
|
847
|
+
for key, val in electronic.get('eigenvalues_parameters', {}).get(
|
|
848
|
+
'key_val'
|
|
849
|
+
)
|
|
850
|
+
}
|
|
851
|
+
sec_method.electronic = Electronic(
|
|
852
|
+
smearing=Smearing(kind=electronic.smearing, width=electronic.width)
|
|
853
|
+
)
|
|
854
|
+
|
|
855
|
+
exchange_correlation = self.parser.get_xc_functional()
|
|
856
|
+
if exchange_correlation is not None:
|
|
857
|
+
exchange_correlation = [
|
|
858
|
+
xc.strip() for xc in exchange_correlation.strip().split(' ', 1)
|
|
859
|
+
]
|
|
860
|
+
sec_method.dft = DFT()
|
|
861
|
+
sec_xc_functional = XCFunctional()
|
|
862
|
+
sec_method.dft.xc_functional = sec_xc_functional
|
|
863
|
+
for xc_functional in self._xc_map.get(exchange_correlation[0], []):
|
|
864
|
+
if '_X_' in xc_functional or xc_functional.endswith('_X'):
|
|
865
|
+
sec_xc_functional.exchange.append(Functional(name=xc_functional))
|
|
866
|
+
elif '_C_' in xc_functional or xc_functional.endswith('_C'):
|
|
867
|
+
sec_xc_functional.correlation.append(Functional(name=xc_functional))
|
|
868
|
+
elif 'HYB' in xc_functional:
|
|
869
|
+
sec_xc_functional.hybrid.append(Functional(name=xc_functional))
|
|
870
|
+
else:
|
|
871
|
+
sec_xc_functional.contributions.append(
|
|
872
|
+
Functional(name=xc_functional)
|
|
873
|
+
)
|
|
874
|
+
|
|
875
|
+
sec_xc_functional.x_fleur_xc_correction = exchange_correlation[1]
|
|
876
|
+
|
|
877
|
+
electric_field = self.parser.electic_field_parameters
|
|
878
|
+
if electric_field is not None:
|
|
879
|
+
for key, val in electric_field.items():
|
|
880
|
+
setattr(sec_method, key, val)
|
|
881
|
+
|
|
882
|
+
labels, positions, lattice_vectors = self.parser.get_system()
|
|
883
|
+
sec_system = System()
|
|
884
|
+
sec_run.system.append(sec_system)
|
|
885
|
+
sec_system.x_fleur_parameters = dict()
|
|
886
|
+
if labels is not None:
|
|
887
|
+
sec_system.atoms = Atoms(
|
|
888
|
+
lattice_vectors=lattice_vectors, labels=labels, positions=positions
|
|
889
|
+
)
|
|
890
|
+
|
|
891
|
+
system = self.parser.get('system', {})
|
|
892
|
+
sec_system.x_fleur_parameters = {
|
|
893
|
+
key: val for key, val in system.get('parameters', {}).get('key_val', [])
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
for key, val in system.items():
|
|
897
|
+
if key.startswith('x_fleur'):
|
|
898
|
+
setattr(sec_system, key, val)
|
|
899
|
+
|
|
900
|
+
sec_scc = Calculation()
|
|
901
|
+
sec_run.calculation.append(sec_scc)
|
|
902
|
+
sec_scc.system_ref = sec_system
|
|
903
|
+
|
|
904
|
+
scf = None
|
|
905
|
+
nspin = sec_method.x_fleur_parameters.get(
|
|
906
|
+
'jspins', sec_system.x_fleur_parameters.get('jspins', 1)
|
|
907
|
+
)
|
|
908
|
+
for scf in self.parser.get('scf_iteration', []):
|
|
909
|
+
sec_scf = ScfIteration()
|
|
910
|
+
sec_scc.scf_iteration.append(sec_scf)
|
|
911
|
+
sec_scf_energy = Energy()
|
|
912
|
+
sec_scf.energy = sec_scf_energy
|
|
913
|
+
sec_eigenvalues = BandEnergies()
|
|
914
|
+
sec_scf.eigenvalues.append(sec_eigenvalues)
|
|
915
|
+
|
|
916
|
+
for key, val in scf.items():
|
|
917
|
+
if val is None:
|
|
918
|
+
continue
|
|
919
|
+
if key.startswith('energy_'):
|
|
920
|
+
setattr(
|
|
921
|
+
sec_scf_energy,
|
|
922
|
+
key.replace('energy_', ''),
|
|
923
|
+
EnergyEntry(value=val),
|
|
924
|
+
)
|
|
925
|
+
elif key == 'forces':
|
|
926
|
+
sec_scf.forces = Forces(
|
|
927
|
+
total=ForcesEntry(value=val * ureg.hartree / ureg.bohr)
|
|
928
|
+
)
|
|
929
|
+
elif key == 'fermi':
|
|
930
|
+
sec_scf_energy.fermi = val
|
|
931
|
+
elif key == 'kpoints':
|
|
932
|
+
sec_eigenvalues.kpoints = val
|
|
933
|
+
elif key == 'eigenvalues':
|
|
934
|
+
sec_eigenvalues.energies = (
|
|
935
|
+
np.reshape(val, (nspin, len(val) // nspin, len(val[0])))
|
|
936
|
+
* ureg.hartree
|
|
937
|
+
)
|
|
938
|
+
elif key == 'eigenvalues_kpts':
|
|
939
|
+
sec_eigenvalues.kpoints = [v.kpt for v in val]
|
|
940
|
+
# it seems that it only shows the eigenvalues for spin 1
|
|
941
|
+
energies = [v.energies for v in val]
|
|
942
|
+
sec_eigenvalues.energies = (
|
|
943
|
+
np.reshape(energies, (1, len(energies), len(energies[0])))
|
|
944
|
+
* ureg.hartree
|
|
945
|
+
)
|
|
946
|
+
elif key.startswith('x_fleur'):
|
|
947
|
+
setattr(sec_scf, key, val)
|
|
948
|
+
|
|
949
|
+
if scf is not None:
|
|
950
|
+
sec_scc.energy = sec_scf.energy
|
|
951
|
+
sec_scc.forces = sec_scf.forces
|
|
952
|
+
sec_scc.eigenvalues.append(sec_scf.eigenvalues[0])
|