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,918 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright The NOMAD Authors.
|
|
3
|
+
#
|
|
4
|
+
# This file is part of NOMAD. See https://nomad-lab.eu for further info.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
from copy import deepcopy
|
|
20
|
+
from functools import cached_property
|
|
21
|
+
import logging
|
|
22
|
+
from typing import Optional
|
|
23
|
+
import numpy as np
|
|
24
|
+
from datetime import datetime
|
|
25
|
+
import re
|
|
26
|
+
import io
|
|
27
|
+
from os import path, listdir
|
|
28
|
+
|
|
29
|
+
from nomad.datamodel import EntryArchive
|
|
30
|
+
from nomad.units import ureg as units
|
|
31
|
+
from runschema.run import Run, Program, TimeRun
|
|
32
|
+
from runschema.calculation import (
|
|
33
|
+
Calculation,
|
|
34
|
+
ScfIteration,
|
|
35
|
+
Energy,
|
|
36
|
+
EnergyEntry,
|
|
37
|
+
BandEnergies,
|
|
38
|
+
Forces,
|
|
39
|
+
ForcesEntry,
|
|
40
|
+
Stress,
|
|
41
|
+
StressEntry,
|
|
42
|
+
)
|
|
43
|
+
from runschema.system import AtomsGroup, System, Atoms
|
|
44
|
+
from runschema.method import (
|
|
45
|
+
AtomParameters,
|
|
46
|
+
Method,
|
|
47
|
+
BasisSet,
|
|
48
|
+
DFT,
|
|
49
|
+
Pseudopotential,
|
|
50
|
+
XCFunctional,
|
|
51
|
+
Functional,
|
|
52
|
+
Electronic,
|
|
53
|
+
Smearing,
|
|
54
|
+
Scf,
|
|
55
|
+
BasisSetContainer,
|
|
56
|
+
CoreHole,
|
|
57
|
+
)
|
|
58
|
+
from nomad.parsing.file_parser import TextParser, Quantity
|
|
59
|
+
from simulationworkflowschema import (
|
|
60
|
+
GeometryOptimization,
|
|
61
|
+
GeometryOptimizationMethod,
|
|
62
|
+
MolecularDynamics,
|
|
63
|
+
MolecularDynamicsMethod,
|
|
64
|
+
)
|
|
65
|
+
from simulationworkflowschema.molecular_dynamics import ThermostatParameters
|
|
66
|
+
from nomad.quantum_states import RussellSaundersState
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
"""
|
|
70
|
+
This is parser for OpenMX DFT code.
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
# A = (1 * units.angstrom).to_base_units().magnitude
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def find_stdout(mainfile):
|
|
77
|
+
mainfile_dir = path.dirname(mainfile)
|
|
78
|
+
for file in listdir(mainfile_dir):
|
|
79
|
+
stdout_path = path.join(mainfile_dir, file)
|
|
80
|
+
if path.isfile(stdout_path):
|
|
81
|
+
with open(stdout_path) as input_file:
|
|
82
|
+
for index, line in enumerate(input_file):
|
|
83
|
+
if r'Welcome to OpenMX' in line:
|
|
84
|
+
return stdout_path
|
|
85
|
+
if index == 500:
|
|
86
|
+
break
|
|
87
|
+
return None
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def _j_mapping() -> dict[tuple[int, int], tuple[float, float]]:
|
|
91
|
+
"""Reproduce table 12 given in https://www.openmx-square.org/openmx_man3.9/node192.html"""
|
|
92
|
+
mapping: dict[tuple[int, int], tuple[float, float]] = {}
|
|
93
|
+
for ll in range(4):
|
|
94
|
+
second_index = 1
|
|
95
|
+
for jj in RussellSaundersState.generate_Js(
|
|
96
|
+
abs(ll + 0.5), abs(ll - 0.5), rising=False
|
|
97
|
+
):
|
|
98
|
+
for mj in RussellSaundersState.generate_MJs(jj, rising=False):
|
|
99
|
+
mapping[(ll, second_index)] = (jj, mj)
|
|
100
|
+
second_index += 1
|
|
101
|
+
return mapping
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
element = '[A-Z][a-z]?'
|
|
105
|
+
xc_functional_dictionary = {
|
|
106
|
+
'GGA-PBE': ['GGA_C_PBE', 'GGA_X_PBE'],
|
|
107
|
+
'LDA': ['LDA_X', 'LDA_C_PZ'],
|
|
108
|
+
'LSDA-CA': ['LDA_X', 'LDA_C_PZ'],
|
|
109
|
+
'LSDA-PW': ['LDA_X', 'LDA_C_PW'],
|
|
110
|
+
None: ['LDA_X', 'LDA_C_PZ'],
|
|
111
|
+
}
|
|
112
|
+
xc_functional_dictionary['PBE'] = xc_functional_dictionary['GGA-PBE']
|
|
113
|
+
xc_functional_dictionary['CA'] = xc_functional_dictionary['LSDA-CA']
|
|
114
|
+
|
|
115
|
+
scf_step_parser = TextParser(
|
|
116
|
+
quantities=[
|
|
117
|
+
Quantity('NormRD', r'NormRD=\s*([\d\.]+)', repeats=False),
|
|
118
|
+
Quantity('Uele', r'Uele=\s*([-\d\.]+)', repeats=False),
|
|
119
|
+
]
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
md_step_parser = TextParser(
|
|
123
|
+
quantities=[
|
|
124
|
+
Quantity(
|
|
125
|
+
'SCF',
|
|
126
|
+
r' (SCF=.+?Uele=\s*[-\d\.]+)',
|
|
127
|
+
sub_parser=scf_step_parser,
|
|
128
|
+
repeats=True,
|
|
129
|
+
),
|
|
130
|
+
Quantity('Utot', r'Utot\.\s+(-?\d+\.\d+)', repeats=False),
|
|
131
|
+
]
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
species_and_coordinates_parser = TextParser(
|
|
135
|
+
quantities=[
|
|
136
|
+
Quantity(
|
|
137
|
+
'atom',
|
|
138
|
+
rf'\s*\d+\s*({element}\d*)\s*([-\d\.]+)\s+([-\d\.]+)\s+([-\d\.]+)\s+[\d\.]+\s*[\d\.]+\s*',
|
|
139
|
+
repeats=True,
|
|
140
|
+
)
|
|
141
|
+
]
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
species_definition_parser = TextParser(
|
|
145
|
+
quantities=[
|
|
146
|
+
Quantity('species', rf'({element}\d*)\s+([-\w\.]+)\s+(\w+)', repeats=True),
|
|
147
|
+
]
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
core_hole_parser = TextParser(
|
|
151
|
+
quantities=[
|
|
152
|
+
Quantity(
|
|
153
|
+
'core_hole', rf'(\d+)\s+({element})\s+(\d+)', repeats=False
|
|
154
|
+
), # TODO: consider `repeats = True` case
|
|
155
|
+
]
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def convert_eigenvalues(string):
|
|
160
|
+
values = np.loadtxt(
|
|
161
|
+
io.StringIO(string), dtype=np.float64, usecols=(1, 2)
|
|
162
|
+
).transpose()
|
|
163
|
+
return values
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
eigenvalues_parser = TextParser(
|
|
167
|
+
quantities=[
|
|
168
|
+
Quantity(
|
|
169
|
+
'kpoints',
|
|
170
|
+
r'k1=\s*([-\.\d]+)\s+k2=\s*([-\.\d]+)\s+k3=\s*([-\.\d]+)',
|
|
171
|
+
repeats=True,
|
|
172
|
+
),
|
|
173
|
+
Quantity(
|
|
174
|
+
'eigenvalues',
|
|
175
|
+
r'((?:\d+\s+[-\.\d]+\s+[-\.\d]+\s+)+)',
|
|
176
|
+
str_operation=convert_eigenvalues,
|
|
177
|
+
repeats=True,
|
|
178
|
+
),
|
|
179
|
+
]
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
mainfile_parser = TextParser(
|
|
183
|
+
quantities=[
|
|
184
|
+
Quantity(
|
|
185
|
+
'date_start',
|
|
186
|
+
r'\s+([A-Z]{1}[a-z]{2}\s[A-Z]{1}[a-z]{2}\s\d{1,2}\s\d{2}:\d{2}:\d{2}\s\d{4})',
|
|
187
|
+
repeats=False,
|
|
188
|
+
flatten=False,
|
|
189
|
+
dtype=str,
|
|
190
|
+
),
|
|
191
|
+
Quantity(
|
|
192
|
+
'elapsed_time',
|
|
193
|
+
r'\s+Elapsed.Time.\s+([\d.]+)',
|
|
194
|
+
repeats=False,
|
|
195
|
+
),
|
|
196
|
+
Quantity(
|
|
197
|
+
'program_version',
|
|
198
|
+
r'This calculation was performed by OpenMX Ver. ([\d\.]+)\s*',
|
|
199
|
+
repeats=False,
|
|
200
|
+
),
|
|
201
|
+
Quantity(
|
|
202
|
+
'md_step',
|
|
203
|
+
r'(SCF history at MD[\s\S]+?Chemical potential \(Hartree\)\s+[-\d\.]+)',
|
|
204
|
+
sub_parser=md_step_parser,
|
|
205
|
+
repeats=True,
|
|
206
|
+
),
|
|
207
|
+
Quantity(
|
|
208
|
+
'atoms',
|
|
209
|
+
r'<Atoms.SpeciesAndCoordinates([\s\S]+)Atoms.SpeciesAndCoordinates>',
|
|
210
|
+
sub_parser=species_and_coordinates_parser,
|
|
211
|
+
repeats=False,
|
|
212
|
+
),
|
|
213
|
+
Quantity(
|
|
214
|
+
'species',
|
|
215
|
+
r'<Definition\.of\.Atomic\.Species([\s\S]+)Definition\.of\.Atomic\.Species>',
|
|
216
|
+
sub_parser=species_definition_parser,
|
|
217
|
+
),
|
|
218
|
+
Quantity(
|
|
219
|
+
'core_hole',
|
|
220
|
+
r'<Definition\.of\.Core\.Hole([\s\S]+)Definition\.of\.Core\.Hole>',
|
|
221
|
+
sub_parser=core_hole_parser,
|
|
222
|
+
),
|
|
223
|
+
Quantity(
|
|
224
|
+
'input_lattice_vectors',
|
|
225
|
+
r'(?i:<Atoms.UnitVectors\s+((?:-?\d+\.\d+\s+)+)Atoms.UnitVectors>)',
|
|
226
|
+
repeats=False,
|
|
227
|
+
),
|
|
228
|
+
Quantity('scf.XcType', r'scf.XcType\s+(\S+)', repeats=False),
|
|
229
|
+
Quantity(
|
|
230
|
+
'scf.SpinPolarization', r'scf.SpinPolarization\s+(\S+)', repeats=False
|
|
231
|
+
),
|
|
232
|
+
Quantity('scf.stress.tensor', r'scf.stress.tensor\s+(.*)', repeats=False),
|
|
233
|
+
Quantity(
|
|
234
|
+
'Atoms.SpeciesAndCoordinates.Unit',
|
|
235
|
+
r'(?i:Atoms.SpeciesAndCoordinates.Unit\s+([a-z]{2,4}))',
|
|
236
|
+
repeats=False,
|
|
237
|
+
),
|
|
238
|
+
Quantity(
|
|
239
|
+
'Atoms.UnitVectors.Unit',
|
|
240
|
+
r'(?i:Atoms.UnitVectors.Unit\s+([a-z]{2,3}))',
|
|
241
|
+
repeats=False,
|
|
242
|
+
),
|
|
243
|
+
Quantity('scf.Hubbard.U', r'(?i:scf.Hubbard.U\s+(on|off))', repeats=False),
|
|
244
|
+
Quantity('MD.maxIter', r'MD\.maxIter\s+(\d+)', repeats=False),
|
|
245
|
+
Quantity('MD.Type', r'(?i:MD\.Type\s+([a-z_\d]{3,6}))', repeats=False),
|
|
246
|
+
Quantity('MD.TimeStep', r'MD\.TimeStep\s+([\d\.e-]+)', repeats=False),
|
|
247
|
+
Quantity(
|
|
248
|
+
'MD.Opt.criterion', r'(?i:MD\.Opt\.criterion\s+([\d\.e-]+))', repeats=False
|
|
249
|
+
),
|
|
250
|
+
Quantity(
|
|
251
|
+
'MD.TempControl', r'<MD.TempControl([\s\S]+)MD.TempControl>', repeats=False
|
|
252
|
+
),
|
|
253
|
+
Quantity('scf.maxIter', r'scf.maxIter\s+(\d+)', repeats=False),
|
|
254
|
+
Quantity('scf.criterion', r'scf.criterion\s+([-\.eE\d]+)', repeats=False),
|
|
255
|
+
Quantity(
|
|
256
|
+
'scf.ElectronicTemperature',
|
|
257
|
+
r'scf.ElectronicTemperature\s+(\S+)',
|
|
258
|
+
repeats=False,
|
|
259
|
+
),
|
|
260
|
+
Quantity('scf.dftD', r'scf.dftD\s+([a-z]+)', repeats=False),
|
|
261
|
+
Quantity('version.dftD', r'version.dftD\s+([23])', repeats=False),
|
|
262
|
+
Quantity(
|
|
263
|
+
'have_timing',
|
|
264
|
+
r'Computational Time \(second\)([\s\S]+)Others.+',
|
|
265
|
+
repeats=False,
|
|
266
|
+
),
|
|
267
|
+
Quantity(
|
|
268
|
+
'eigenvalues',
|
|
269
|
+
r'Eigenvalues \(Hartree\) \S+ SCF KS-eq\.\s+\*{59}\s*\*{59}([^*]+)',
|
|
270
|
+
sub_parser=eigenvalues_parser,
|
|
271
|
+
repeats=False,
|
|
272
|
+
),
|
|
273
|
+
Quantity(
|
|
274
|
+
'elapsed.time',
|
|
275
|
+
r'Total Computational Time.*[0-9.]+\s+[0-9.]+\s+[0-9.]+\s+([0-9.]+)',
|
|
276
|
+
),
|
|
277
|
+
]
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
stdout_parser = TextParser(
|
|
281
|
+
quantities=[
|
|
282
|
+
Quantity(
|
|
283
|
+
'scf.stress.tensor',
|
|
284
|
+
r'Stress tensor \(Hartree/bohr\^3\)\s+\*{55}([^*]+)',
|
|
285
|
+
repeats=True,
|
|
286
|
+
),
|
|
287
|
+
Quantity(
|
|
288
|
+
'Uele',
|
|
289
|
+
r'\*{19} MD=\s*\d+\s+SCF=\s*1\s+\*{19}(?:.|\n)*?Uele\s+=\s+(-?\d+\.\d+)',
|
|
290
|
+
repeats=True,
|
|
291
|
+
),
|
|
292
|
+
Quantity(
|
|
293
|
+
'elapsed.time',
|
|
294
|
+
r'Total Computational Time.*[0-9.]+\s+[0-9.]+\s+[0-9.]+\s+([0-9.]+)',
|
|
295
|
+
),
|
|
296
|
+
]
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
def read_md_file(md_file):
|
|
301
|
+
result = []
|
|
302
|
+
with open(md_file, 'r') as f:
|
|
303
|
+
cell_vectors_re = re.compile(r'Cell_Vectors=((?:\s+-?\d+\.\d+)+)')
|
|
304
|
+
temperature_re = re.compile(r'Temperature=\s+(\d+\.\d+)')
|
|
305
|
+
time_re = re.compile(r'time=\s+(\d+\.\d+)')
|
|
306
|
+
for line in f:
|
|
307
|
+
line_list = line.split()
|
|
308
|
+
if len(line_list) == 1:
|
|
309
|
+
step_header = True
|
|
310
|
+
natoms = int(line_list[0])
|
|
311
|
+
result.append(
|
|
312
|
+
{
|
|
313
|
+
'species': [],
|
|
314
|
+
'positions': np.empty((natoms, 3), dtype=np.float64),
|
|
315
|
+
'velocities': np.empty((natoms, 3), dtype=np.float64),
|
|
316
|
+
'forces': np.empty((natoms, 3), dtype=np.float64),
|
|
317
|
+
}
|
|
318
|
+
)
|
|
319
|
+
atomindex = 0
|
|
320
|
+
elif step_header:
|
|
321
|
+
cell_vectors = cell_vectors_re.search(line)
|
|
322
|
+
if cell_vectors is not None:
|
|
323
|
+
cell_vectors = [float(v) for v in cell_vectors.group(1).split()]
|
|
324
|
+
result[-1]['cell_vectors'] = np.array(cell_vectors).reshape(3, 3)
|
|
325
|
+
temperature = temperature_re.search(line)
|
|
326
|
+
if temperature is not None:
|
|
327
|
+
temperature = temperature.group(1)
|
|
328
|
+
result[-1]['temperature'] = temperature
|
|
329
|
+
time = time_re.search(line)
|
|
330
|
+
if time is not None:
|
|
331
|
+
result[-1]['time'] = float(time.group(1))
|
|
332
|
+
step_header = False
|
|
333
|
+
else:
|
|
334
|
+
result[-1]['positions'][atomindex][0:3] = [
|
|
335
|
+
float(val) for val in line_list[1:4]
|
|
336
|
+
]
|
|
337
|
+
result[-1]['forces'][atomindex][0:3] = [
|
|
338
|
+
float(val) for val in line_list[4:7]
|
|
339
|
+
]
|
|
340
|
+
result[-1]['velocities'][atomindex][0:3] = [
|
|
341
|
+
float(val) for val in line_list[7:10]
|
|
342
|
+
]
|
|
343
|
+
result[-1]['species'].append(line_list[0])
|
|
344
|
+
atomindex += 1
|
|
345
|
+
f.close()
|
|
346
|
+
return result
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
def parse_md_file(i, mdfile_md_steps, system):
|
|
350
|
+
system.atoms = Atoms(
|
|
351
|
+
lattice_vectors=mdfile_md_steps[i].get('cell_vectors') * units.angstrom,
|
|
352
|
+
periodic=[True, True, True],
|
|
353
|
+
positions=mdfile_md_steps[i].get('positions') * units.angstrom,
|
|
354
|
+
labels=mdfile_md_steps[i].get('species'),
|
|
355
|
+
velocities=mdfile_md_steps[i].get('velocities') * units.meter / units.second,
|
|
356
|
+
)
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
def parse_structure(system, logger: logging.Logger):
|
|
360
|
+
atoms_units = mainfile_parser.get('Atoms.SpeciesAndCoordinates.Unit')
|
|
361
|
+
lattice_vectors = mainfile_parser.get('input_lattice_vectors')
|
|
362
|
+
lattice_units = mainfile_parser.get('Atoms.UnitVectors.Unit')
|
|
363
|
+
atoms = mainfile_parser.get('atoms').get('atom')
|
|
364
|
+
|
|
365
|
+
if atoms is not None and lattice_vectors is not None:
|
|
366
|
+
lattice_vectors = np.array(lattice_vectors).reshape(3, 3)
|
|
367
|
+
if atoms_units is not None:
|
|
368
|
+
if lattice_units.lower() == 'au':
|
|
369
|
+
lattice_vectors = lattice_vectors * units.bohr
|
|
370
|
+
lattice_units = units.bohr
|
|
371
|
+
elif lattice_units.lower() == 'ang':
|
|
372
|
+
lattice_vectors = lattice_vectors * units.angstrom
|
|
373
|
+
lattice_units = units.angstrom
|
|
374
|
+
else:
|
|
375
|
+
lattice_vectors = lattice_vectors * units.angstrom
|
|
376
|
+
atom_positions = [a[1:4] for a in atoms]
|
|
377
|
+
if atoms_units is not None:
|
|
378
|
+
if atoms_units.lower() == 'au':
|
|
379
|
+
atom_positions = atom_positions * units.bohr
|
|
380
|
+
if atoms_units.lower() == 'ang':
|
|
381
|
+
atom_positions = atom_positions * units.angstrom
|
|
382
|
+
elif atoms_units.lower() == 'frac':
|
|
383
|
+
# There are some problems with pint here so simple matrix vector multiplications
|
|
384
|
+
# doesn't work.
|
|
385
|
+
atom_positions = (
|
|
386
|
+
np.array(
|
|
387
|
+
[np.array(pos).dot(lattice_vectors) for pos in atom_positions]
|
|
388
|
+
)
|
|
389
|
+
* lattice_units
|
|
390
|
+
)
|
|
391
|
+
else:
|
|
392
|
+
# default unit is angstrom
|
|
393
|
+
atom_positions = atom_positions * units.angstrom
|
|
394
|
+
system.atoms = Atoms(
|
|
395
|
+
positions=atom_positions,
|
|
396
|
+
lattice_vectors=lattice_vectors,
|
|
397
|
+
periodic=[True, True, True],
|
|
398
|
+
labels=[a[0] for a in atoms],
|
|
399
|
+
)
|
|
400
|
+
else:
|
|
401
|
+
logger.warning('Failed to parse the input structure.')
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
def parse_temperature_profile(data, thermo_type):
|
|
405
|
+
steps = data[0]
|
|
406
|
+
thermostats = []
|
|
407
|
+
|
|
408
|
+
for i in range(steps):
|
|
409
|
+
if i == 0 and int(data[1]) == 1:
|
|
410
|
+
continue
|
|
411
|
+
|
|
412
|
+
thermostat = ThermostatParameters()
|
|
413
|
+
if 'VS' in thermo_type:
|
|
414
|
+
thermostat.thermostat_type = 'velocity_rescaling_woodcock'
|
|
415
|
+
cols = 4
|
|
416
|
+
if 'NH' in thermo_type:
|
|
417
|
+
thermostat.thermostat_type = 'nose_hoover'
|
|
418
|
+
cols = 2
|
|
419
|
+
|
|
420
|
+
if i == 0:
|
|
421
|
+
thermostat.reference_temperature_start = data[i * cols + 2] * units.K
|
|
422
|
+
thermostat.temperature_update_frame_start = 1
|
|
423
|
+
else:
|
|
424
|
+
thermostat.reference_temperature_start = data[(i - 1) * cols + 2] * units.K
|
|
425
|
+
thermostat.temperature_update_frame_start = data[(i - 1) * cols + 1]
|
|
426
|
+
thermostat.reference_temperature_end = data[i * cols + 2] * units.K
|
|
427
|
+
thermostat.temperature_update_frame_end = data[i * cols + 1]
|
|
428
|
+
|
|
429
|
+
if (
|
|
430
|
+
thermostat.reference_temperature_start
|
|
431
|
+
== thermostat.reference_temperature_end
|
|
432
|
+
):
|
|
433
|
+
thermostat.temperature_profile = 'constant'
|
|
434
|
+
else:
|
|
435
|
+
thermostat.temperature_profile = 'linear'
|
|
436
|
+
|
|
437
|
+
thermostats.append(thermostat)
|
|
438
|
+
return thermostats
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
class OpenmxParser:
|
|
442
|
+
def __init__(self):
|
|
443
|
+
pass
|
|
444
|
+
|
|
445
|
+
@cached_property
|
|
446
|
+
def atom_index_dict(self) -> dict[str, list[int]]:
|
|
447
|
+
"""Return the indexes by species label.
|
|
448
|
+
- column_index: the column index of the species labels (default = 0)"""
|
|
449
|
+
result: dict[str, list[int]] = {}
|
|
450
|
+
for index, item in enumerate(mainfile_parser.results['atoms'].results['atom']):
|
|
451
|
+
key, value = item[0], index
|
|
452
|
+
if key in result:
|
|
453
|
+
result[key].append(value)
|
|
454
|
+
else:
|
|
455
|
+
result[key] = [value]
|
|
456
|
+
return result
|
|
457
|
+
|
|
458
|
+
def parse_species(
|
|
459
|
+
self, definitions: list[str]
|
|
460
|
+
) -> tuple[Pseudopotential, Optional[CoreHole]]:
|
|
461
|
+
"""
|
|
462
|
+
Extract `Pseudopotential` and `CoreHole` (if present) from the atomic species definition.
|
|
463
|
+
An explanation of the format can be found at https://www.openmx-square.org/openmx_man3.9/node32.html
|
|
464
|
+
For an overview of all conventional potentials and partial atomic orbitals, see https://www.openmx-square.org/vps_pao2019/
|
|
465
|
+
and https://www.openmx-square.org/vps_pao_core2019/ for core-holes.
|
|
466
|
+
"""
|
|
467
|
+
l_quantum = '[spdf]'
|
|
468
|
+
remove_extension = lambda x: re.sub(r'(\.pao|\.vps)', '', x)
|
|
469
|
+
extract_method = lambda x: re.search(r'_([A-Z]+)19', x)
|
|
470
|
+
# extract_orbital = lambda x: re.search(rf'_(\d)({l_quantum})$', x)
|
|
471
|
+
extract_core_hole = lambda x: re.search(rf'_(\d)({l_quantum})_CH', x)
|
|
472
|
+
extract_elem_cutoff = lambda x: re.match(rf'({element})([\d\.]+)[_-]', x)
|
|
473
|
+
extract_lmax = lambda x: re.search(rf'({l_quantum})\d$', x)
|
|
474
|
+
|
|
475
|
+
definitions = deepcopy(definitions)
|
|
476
|
+
try:
|
|
477
|
+
definitions[1] = remove_extension(definitions[1])
|
|
478
|
+
definitions[2] = remove_extension(definitions[2])
|
|
479
|
+
except IndexError:
|
|
480
|
+
self.logger.error(f'Species definition must be of length 3: {definitions}')
|
|
481
|
+
return None, None
|
|
482
|
+
|
|
483
|
+
# evaluate pseudopotential
|
|
484
|
+
pseudopotential, core_hole = (
|
|
485
|
+
Pseudopotential(type='US MBK', norm_conserving=True),
|
|
486
|
+
None,
|
|
487
|
+
) # TODO: add basis set
|
|
488
|
+
pseudopotential.name = f'{definitions[1]} {definitions[2]}'
|
|
489
|
+
pseudopotential.cutoff = (
|
|
490
|
+
float(extract_elem_cutoff(definitions[1]).group(2)) * units.hartree
|
|
491
|
+
)
|
|
492
|
+
try:
|
|
493
|
+
pseudopotential.l_max = CoreHole.l_quantum_numbers[
|
|
494
|
+
extract_lmax(definitions[1]).group(1)
|
|
495
|
+
]
|
|
496
|
+
except KeyError:
|
|
497
|
+
self.logger.error(f'Unknown l-quantum symbol: {definitions[1]}')
|
|
498
|
+
try:
|
|
499
|
+
pseudopotential.xc_functional_name = xc_functional_dictionary[
|
|
500
|
+
extract_method(definitions[2]).group(1)
|
|
501
|
+
]
|
|
502
|
+
except KeyError:
|
|
503
|
+
self.logger.error(
|
|
504
|
+
f'Unknown exchange-correlation functional: {definitions[2]}'
|
|
505
|
+
)
|
|
506
|
+
|
|
507
|
+
# evaluate core_hole
|
|
508
|
+
quantum_nums_flag = extract_core_hole(
|
|
509
|
+
definitions[1]
|
|
510
|
+
) # this checks the PAO, the PP is only necessary for the final state
|
|
511
|
+
if quantum_nums_flag:
|
|
512
|
+
quantum_nums = quantum_nums_flag.groups()
|
|
513
|
+
try:
|
|
514
|
+
core_hole = CoreHole(
|
|
515
|
+
n_quantum_number=int(quantum_nums[0]),
|
|
516
|
+
l_quantum_number=CoreHole.l_quantum_numbers[quantum_nums[1]],
|
|
517
|
+
n_electrons_excited=1,
|
|
518
|
+
)
|
|
519
|
+
except KeyError:
|
|
520
|
+
self.logger.error(f'Unknown l-quantum symbol: {quantum_nums[1]}')
|
|
521
|
+
return pseudopotential, None
|
|
522
|
+
|
|
523
|
+
core_hole_flags = mainfile_parser.results.get('core_hole')
|
|
524
|
+
if core_hole_flags:
|
|
525
|
+
core_hole.dscf_state = 'final'
|
|
526
|
+
spinpol = mainfile_parser.get('scf.SpinPolarization', '').lower()
|
|
527
|
+
if spinpol == 'on':
|
|
528
|
+
# first all up, then all down: https://www.openmx-square.org/openmx_man3.9/node192.html
|
|
529
|
+
core_hole.ms_quantum_bool = not bool(
|
|
530
|
+
int(
|
|
531
|
+
core_hole_flags.results['core_hole'][2]
|
|
532
|
+
/ core_hole.get_l_degeneracy()
|
|
533
|
+
)
|
|
534
|
+
)
|
|
535
|
+
elif spinpol == 'nc':
|
|
536
|
+
(
|
|
537
|
+
core_hole.j_quantum_number,
|
|
538
|
+
core_hole.mj_quantum_number,
|
|
539
|
+
) = _j_mapping()[
|
|
540
|
+
core_hole.l_quantum_number,
|
|
541
|
+
core_hole_flags.results['core_hole'][3],
|
|
542
|
+
]
|
|
543
|
+
elif spinpol == 'off':
|
|
544
|
+
self.logger.warning(
|
|
545
|
+
"""
|
|
546
|
+
Unexpected spin-restricted setting when using final-state core-hole computation.
|
|
547
|
+
This is not recommended by the manual. For now assuming single-electron excitation of unspecified spin.
|
|
548
|
+
"""
|
|
549
|
+
)
|
|
550
|
+
else:
|
|
551
|
+
self.logger.warning('Spin-state not yet recognized')
|
|
552
|
+
else:
|
|
553
|
+
core_hole.dscf_state = 'initial' # this will be a hook in $\Delta$-SCF
|
|
554
|
+
|
|
555
|
+
return pseudopotential, core_hole
|
|
556
|
+
|
|
557
|
+
def parse_workflow(self):
|
|
558
|
+
md_type = mainfile_parser.get('MD.Type')
|
|
559
|
+
md_types_list = [
|
|
560
|
+
# FIXME: handle the various OptCx methods with constraints
|
|
561
|
+
['OPT', 'geometry_optimization', 'steepest_descent'],
|
|
562
|
+
['DIIS', 'geometry_optimization', 'diis'],
|
|
563
|
+
['BFGS', 'geometry_optimization', 'bfgs'],
|
|
564
|
+
# FIXME: not in https://gitlab.mpcdf.mpg.de/nomad-lab/nomad-meta-info/-/wikis/metainfo/geometry-optimization-method
|
|
565
|
+
['RF', 'geometry_optimization', 'rf'],
|
|
566
|
+
# FIXME: not in https://gitlab.mpcdf.mpg.de/nomad-lab/nomad-meta-info/-/wikis/metainfo/geometry-optimization-method
|
|
567
|
+
['EF', 'geometry_optimization', 'ef'],
|
|
568
|
+
['NVE', 'molecular_dynamics', 'NVE'],
|
|
569
|
+
['NVT_VS', 'molecular_dynamics', 'NVT'],
|
|
570
|
+
['NVT_NH', 'molecular_dynamics', 'NVT'],
|
|
571
|
+
]
|
|
572
|
+
if md_type is not None and 'nomd' not in md_type.lower():
|
|
573
|
+
md_type = md_type.upper()
|
|
574
|
+
workflow = None
|
|
575
|
+
for current_md_type in md_types_list:
|
|
576
|
+
if current_md_type[0] in md_type:
|
|
577
|
+
max_iters = mainfile_parser.get('MD.maxIter')
|
|
578
|
+
if current_md_type[1] == 'geometry_optimization':
|
|
579
|
+
workflow = GeometryOptimization(
|
|
580
|
+
method=GeometryOptimizationMethod()
|
|
581
|
+
)
|
|
582
|
+
workflow.method.method = current_md_type[2]
|
|
583
|
+
if max_iters is not None:
|
|
584
|
+
workflow.method.optimization_steps_maximum = max_iters
|
|
585
|
+
criterion = mainfile_parser.get('MD.Opt.criterion')
|
|
586
|
+
if criterion is not None:
|
|
587
|
+
workflow.method.convergence_tolerance_force_maximum = (
|
|
588
|
+
criterion * units.hartree / units.bohr
|
|
589
|
+
)
|
|
590
|
+
else:
|
|
591
|
+
workflow.method.convergence_tolerance_force_maximum = (
|
|
592
|
+
1e-4 * units.hartree / units.bohr
|
|
593
|
+
)
|
|
594
|
+
else:
|
|
595
|
+
md_temp_control = mainfile_parser.get('MD.TempControl')
|
|
596
|
+
if 'VS' in md_type:
|
|
597
|
+
thermostats = parse_temperature_profile(
|
|
598
|
+
md_temp_control, 'VS'
|
|
599
|
+
)
|
|
600
|
+
elif 'NH' in md_type:
|
|
601
|
+
thermostats = parse_temperature_profile(
|
|
602
|
+
md_temp_control, 'NH'
|
|
603
|
+
)
|
|
604
|
+
|
|
605
|
+
workflow = MolecularDynamics(
|
|
606
|
+
method=MolecularDynamicsMethod(
|
|
607
|
+
thermostat_parameters=thermostats
|
|
608
|
+
)
|
|
609
|
+
)
|
|
610
|
+
workflow.method.thermodynamic_ensemble = current_md_type[2]
|
|
611
|
+
# Everything is saved every time step
|
|
612
|
+
workflow.method.coordinate_save_frequency = 1
|
|
613
|
+
workflow.method.velocity_save_frequency = 1
|
|
614
|
+
workflow.method.force_save_frequency = 1
|
|
615
|
+
workflow.method.thermodynamics_save_frequency = 1
|
|
616
|
+
|
|
617
|
+
md_timestep = mainfile_parser.get('MD.TimeStep')
|
|
618
|
+
if md_timestep is not None:
|
|
619
|
+
workflow.method.integration_timestep = (
|
|
620
|
+
md_timestep * units.fs
|
|
621
|
+
)
|
|
622
|
+
|
|
623
|
+
if max_iters is not None:
|
|
624
|
+
workflow.method.n_steps = max_iters
|
|
625
|
+
|
|
626
|
+
self.archive.workflow2 = workflow
|
|
627
|
+
|
|
628
|
+
def parse_method(self):
|
|
629
|
+
# setup
|
|
630
|
+
sec_method = Method()
|
|
631
|
+
self.archive.run[-1].method.append(sec_method)
|
|
632
|
+
sec_method.atom_parameters = []
|
|
633
|
+
|
|
634
|
+
for species in mainfile_parser.results['species'].results['species']:
|
|
635
|
+
# add atom parameters
|
|
636
|
+
atom_parameters = AtomParameters(label=species[0])
|
|
637
|
+
(
|
|
638
|
+
atom_parameters.pseudopotential,
|
|
639
|
+
atom_parameters.core_hole,
|
|
640
|
+
) = self.parse_species(species)
|
|
641
|
+
sec_method.atom_parameters.append(atom_parameters)
|
|
642
|
+
|
|
643
|
+
# add basis set
|
|
644
|
+
sec_method.electrons_representation = [
|
|
645
|
+
BasisSetContainer(
|
|
646
|
+
type='atom-centered orbitals',
|
|
647
|
+
scope=['wavefunction'],
|
|
648
|
+
basis_set=[
|
|
649
|
+
BasisSet(
|
|
650
|
+
type='numeric AOs',
|
|
651
|
+
scope=['full-electron'], # TODO: double check
|
|
652
|
+
)
|
|
653
|
+
],
|
|
654
|
+
)
|
|
655
|
+
]
|
|
656
|
+
|
|
657
|
+
# DFT (+U)
|
|
658
|
+
sec_dft = DFT()
|
|
659
|
+
sec_electronic = Electronic()
|
|
660
|
+
sec_method.dft = sec_dft
|
|
661
|
+
sec_method.electronic = sec_electronic
|
|
662
|
+
sec_electronic.method = 'DFT'
|
|
663
|
+
# FIXME: add some testcase for DFT+U
|
|
664
|
+
scf_hubbard_u = mainfile_parser.get('scf.Hubbard.U')
|
|
665
|
+
if scf_hubbard_u is not None:
|
|
666
|
+
if scf_hubbard_u.lower() == 'on':
|
|
667
|
+
sec_electronic.method = 'DFT+U'
|
|
668
|
+
|
|
669
|
+
scf_xctype = mainfile_parser.get('scf.XcType')
|
|
670
|
+
sec_xc_functional = XCFunctional()
|
|
671
|
+
sec_dft.xc_functional = sec_xc_functional
|
|
672
|
+
for xc in xc_functional_dictionary[scf_xctype]:
|
|
673
|
+
if '_X_' in xc or xc.endswith('_X'):
|
|
674
|
+
sec_xc_functional.exchange.append(Functional(name=xc))
|
|
675
|
+
elif '_C_' in xc:
|
|
676
|
+
sec_xc_functional.correlation.append(Functional(name=xc))
|
|
677
|
+
elif '_HYB_' in xc:
|
|
678
|
+
sec_xc_functional.hybrid.append(Functional(name=xc))
|
|
679
|
+
else:
|
|
680
|
+
sec_xc_functional.contributions.append(Functional(name=xc))
|
|
681
|
+
|
|
682
|
+
spinpol = mainfile_parser.get('scf.SpinPolarization')
|
|
683
|
+
if spinpol.lower() == 'on':
|
|
684
|
+
sec_electronic.n_spin_channels = 2
|
|
685
|
+
self.spinpolarized = True
|
|
686
|
+
else:
|
|
687
|
+
sec_electronic.n_spin_channels = 1
|
|
688
|
+
self.spinpolarized = False
|
|
689
|
+
|
|
690
|
+
sec_smearing = Smearing()
|
|
691
|
+
sec_electronic.smearing = sec_smearing
|
|
692
|
+
sec_smearing.kind = 'fermi'
|
|
693
|
+
scf_ElectronicTemperature = mainfile_parser.get('scf.ElectronicTemperature')
|
|
694
|
+
if scf_ElectronicTemperature is not None:
|
|
695
|
+
sec_smearing.width = (
|
|
696
|
+
(scf_ElectronicTemperature * units.kelvin * units.k)
|
|
697
|
+
.to_base_units()
|
|
698
|
+
.magnitude
|
|
699
|
+
)
|
|
700
|
+
else:
|
|
701
|
+
sec_smearing.width = (
|
|
702
|
+
(300 * units.kelvin * units.k).to_base_units().magnitude
|
|
703
|
+
)
|
|
704
|
+
|
|
705
|
+
scf_maxiter = mainfile_parser.get('scf.maxIter')
|
|
706
|
+
sec_scf = Scf()
|
|
707
|
+
sec_method.scf = sec_scf
|
|
708
|
+
if scf_maxiter is not None:
|
|
709
|
+
sec_scf.n_max_iteration = scf_maxiter
|
|
710
|
+
|
|
711
|
+
scf_criterion = mainfile_parser.get('scf.criterion')
|
|
712
|
+
if scf_criterion is not None:
|
|
713
|
+
sec_scf.threshold_energy_change = scf_criterion * units.hartree
|
|
714
|
+
|
|
715
|
+
# vdw correction
|
|
716
|
+
scf_dftd = mainfile_parser.get('scf.dftD')
|
|
717
|
+
if scf_dftd == 'on':
|
|
718
|
+
dftf_ver = mainfile_parser.get('version.dftD')
|
|
719
|
+
# TODO: review the G06/G10 nomenclature after schema migration
|
|
720
|
+
if dftf_ver is None or dftf_ver == 2:
|
|
721
|
+
sec_electronic.van_der_waals_method = 'G06'
|
|
722
|
+
elif dftf_ver == 3:
|
|
723
|
+
sec_electronic.van_der_waals_method = 'G10'
|
|
724
|
+
else:
|
|
725
|
+
self.logger.warning('Unexpected version.dftD value.')
|
|
726
|
+
else:
|
|
727
|
+
sec_electronic.van_der_waals_method = ''
|
|
728
|
+
|
|
729
|
+
def parse_eigenvalues(self):
|
|
730
|
+
eigenvalues = BandEnergies()
|
|
731
|
+
self.archive.run[-1].calculation[-1].eigenvalues.append(eigenvalues)
|
|
732
|
+
values = mainfile_parser.get('eigenvalues')
|
|
733
|
+
if values is not None:
|
|
734
|
+
kpoints = values.get('kpoints')
|
|
735
|
+
if kpoints is not None:
|
|
736
|
+
eigenvalues.kpoints = kpoints
|
|
737
|
+
eigenvalues.n_kpoints = len(kpoints)
|
|
738
|
+
else:
|
|
739
|
+
eigenvalues.kpoints = [[0, 0, 0]]
|
|
740
|
+
eigenvalues.n_kpoints = 1
|
|
741
|
+
values = values.get('eigenvalues')
|
|
742
|
+
if values is not None:
|
|
743
|
+
if self.spinpolarized:
|
|
744
|
+
eigenvalues.energies = np.stack(values, axis=1) * units.hartree
|
|
745
|
+
else:
|
|
746
|
+
values = [i[0:1] for i in values]
|
|
747
|
+
eigenvalues.energies = np.stack(values, axis=1) * units.hartree
|
|
748
|
+
|
|
749
|
+
def parse(self, mainfile: str, archive: EntryArchive, logger):
|
|
750
|
+
self.archive = archive
|
|
751
|
+
self.logger = logger
|
|
752
|
+
|
|
753
|
+
# Use the previously defined parsers on the given mainfile
|
|
754
|
+
mainfile_parser.mainfile = mainfile
|
|
755
|
+
mainfile_parser.parse()
|
|
756
|
+
elapsed_time_mainfile = mainfile_parser.get('elapsed.time')
|
|
757
|
+
|
|
758
|
+
del mainfile_parser._file_handler
|
|
759
|
+
|
|
760
|
+
# Get system from the MD file
|
|
761
|
+
md_file = path.splitext(mainfile)[0] + '.md'
|
|
762
|
+
if path.isfile(md_file):
|
|
763
|
+
mdfile_md_steps = read_md_file(md_file)
|
|
764
|
+
else:
|
|
765
|
+
mdfile_md_steps = None
|
|
766
|
+
|
|
767
|
+
# Some basic values
|
|
768
|
+
sec_run = Run()
|
|
769
|
+
archive.run.append(sec_run)
|
|
770
|
+
|
|
771
|
+
sec_run.program = Program(
|
|
772
|
+
name='OpenMX', version=str(mainfile_parser.get('program_version'))
|
|
773
|
+
)
|
|
774
|
+
date_start = mainfile_parser.get('date_start')
|
|
775
|
+
date_start_timestamp = datetime.strptime(
|
|
776
|
+
date_start, '%a %b %d %H:%M:%S %Y'
|
|
777
|
+
).timestamp()
|
|
778
|
+
sec_run.time_run = TimeRun()
|
|
779
|
+
sec_run.time_run.date_start = date_start_timestamp
|
|
780
|
+
|
|
781
|
+
elapsed_time = mainfile_parser.get('elapsed_time')
|
|
782
|
+
if elapsed_time is not None:
|
|
783
|
+
date_end = date_start_timestamp + elapsed_time
|
|
784
|
+
sec_run.time_run.date_end = date_end
|
|
785
|
+
|
|
786
|
+
sec_run.clean_end = mainfile_parser.get('have_timing') is not None
|
|
787
|
+
|
|
788
|
+
self.parse_workflow()
|
|
789
|
+
|
|
790
|
+
self.parse_method()
|
|
791
|
+
|
|
792
|
+
mainfile_md_steps = mainfile_parser.get('md_step')
|
|
793
|
+
if mainfile_md_steps is not None:
|
|
794
|
+
n_md_steps = len(mainfile_md_steps)
|
|
795
|
+
n_mdfile_md_steps = 0
|
|
796
|
+
if mdfile_md_steps is not None:
|
|
797
|
+
n_mdfile_md_steps = len(mdfile_md_steps)
|
|
798
|
+
# Do some consistency checks between the out and md file.
|
|
799
|
+
ignore_md_file = False
|
|
800
|
+
if n_mdfile_md_steps > n_md_steps:
|
|
801
|
+
# This can happen when user runs two calculations in the same directory.
|
|
802
|
+
# In that case the out file contains the latter calculation but the md file
|
|
803
|
+
# would contain both calculations, so just take the corresponding number
|
|
804
|
+
# of steps from the end of the file.
|
|
805
|
+
mdfile_md_steps = mdfile_md_steps[-n_md_steps:]
|
|
806
|
+
elif n_mdfile_md_steps < n_md_steps:
|
|
807
|
+
# This is unlikely, but signals a problem with the md file, so just
|
|
808
|
+
# ignore it.
|
|
809
|
+
ignore_md_file = True
|
|
810
|
+
self.logger.warning('.md file does not contain enough MD steps')
|
|
811
|
+
|
|
812
|
+
# Stress tensor values are not written to outfile but only to stdout.
|
|
813
|
+
# That means we have to check if the stdout is actually present and
|
|
814
|
+
# look for the stress values there.
|
|
815
|
+
stress_tensor_enabled = mainfile_parser.get('scf.stress.tensor')
|
|
816
|
+
stdout_uele_list = []
|
|
817
|
+
stress_tensors = None
|
|
818
|
+
if stress_tensor_enabled == 'on':
|
|
819
|
+
# find_stdout returns path to correct stdout if it exists
|
|
820
|
+
# or None otherwise
|
|
821
|
+
stdout_path = find_stdout(mainfile)
|
|
822
|
+
|
|
823
|
+
if mainfile_md_steps is not None and stdout_path is not None:
|
|
824
|
+
mainfile_uele = mainfile_md_steps[0].get('SCF')[0].get('Uele')
|
|
825
|
+
stdout_parser.mainfile = stdout_path
|
|
826
|
+
stdout_parser.parse()
|
|
827
|
+
stdout_uele_list = stdout_parser.get('Uele')
|
|
828
|
+
stdout_uele = stdout_uele_list[0]
|
|
829
|
+
elapsed_time_stdout = stdout_parser.get('elapsed.time')
|
|
830
|
+
|
|
831
|
+
# It is possible there are multiple calculation in the same directory
|
|
832
|
+
# and thus multiple stdout files as well. We need to find the correct
|
|
833
|
+
# stdout to look for the stress values. A simple test is to check the
|
|
834
|
+
# total runtime and later also the uele consistency.
|
|
835
|
+
if (
|
|
836
|
+
elapsed_time_mainfile == elapsed_time_stdout
|
|
837
|
+
and abs(stdout_uele - mainfile_uele) < 1e-8
|
|
838
|
+
):
|
|
839
|
+
stress_tensors = stdout_parser.get('scf.stress.tensor')
|
|
840
|
+
|
|
841
|
+
if mainfile_md_steps is not None:
|
|
842
|
+
for i, md_step in enumerate(mainfile_md_steps):
|
|
843
|
+
system = System()
|
|
844
|
+
sec_run.system.append(system)
|
|
845
|
+
if not ignore_md_file:
|
|
846
|
+
parse_md_file(i, mdfile_md_steps, system)
|
|
847
|
+
elif i == 0:
|
|
848
|
+
# Get the initial position from out file as a fallback if the md file is missing.
|
|
849
|
+
parse_structure(system, logger)
|
|
850
|
+
|
|
851
|
+
sec_calc = Calculation()
|
|
852
|
+
sec_run.calculation.append(sec_calc)
|
|
853
|
+
sec_calc.system_ref = system
|
|
854
|
+
sec_calc.method_ref = sec_run.method[-1]
|
|
855
|
+
scf_steps = md_step.get('SCF')
|
|
856
|
+
if scf_steps is not None:
|
|
857
|
+
for scf_step in scf_steps:
|
|
858
|
+
scf = ScfIteration()
|
|
859
|
+
sec_calc.scf_iteration.append(scf)
|
|
860
|
+
u_ele = scf_step.get('Uele')
|
|
861
|
+
|
|
862
|
+
if u_ele is not None:
|
|
863
|
+
scf.energy = Energy(
|
|
864
|
+
sum_eigenvalues=EnergyEntry(value=u_ele * units.hartree)
|
|
865
|
+
)
|
|
866
|
+
|
|
867
|
+
if stress_tensors is not None:
|
|
868
|
+
stress_matrix = np.array(stress_tensors[i]).reshape(3, 3)
|
|
869
|
+
stress_matrix = stress_matrix * units.hartree / units.bohr**3
|
|
870
|
+
sec_calc.stress = Stress()
|
|
871
|
+
sec_calc.stress.total = StressEntry()
|
|
872
|
+
sec_calc.stress.total.value = stress_matrix
|
|
873
|
+
|
|
874
|
+
u_tot = md_step.get('Utot')
|
|
875
|
+
if u_tot is not None:
|
|
876
|
+
sec_calc.energy = Energy(
|
|
877
|
+
total=EnergyEntry(value=u_tot * units.hartree)
|
|
878
|
+
)
|
|
879
|
+
if not ignore_md_file:
|
|
880
|
+
forces = mdfile_md_steps[i].get('forces')
|
|
881
|
+
if forces is not None:
|
|
882
|
+
sec_calc.forces = Forces(
|
|
883
|
+
total=ForcesEntry(value=forces * units.hartree / units.bohr)
|
|
884
|
+
)
|
|
885
|
+
temperature = mdfile_md_steps[i].get('temperature')
|
|
886
|
+
if temperature is not None:
|
|
887
|
+
sec_calc.temperature = float(temperature) * units.kelvin
|
|
888
|
+
# Time is also printed for geometry optimizations, but it is meaningless there.
|
|
889
|
+
if isinstance(self.archive.workflow2, MolecularDynamics):
|
|
890
|
+
time = mdfile_md_steps[i].get('time')
|
|
891
|
+
if time is not None:
|
|
892
|
+
sec_calc.time = time * units.fs
|
|
893
|
+
|
|
894
|
+
# set core-hole atoms groups
|
|
895
|
+
try:
|
|
896
|
+
sec_system = sec_run[-1].system[-1]
|
|
897
|
+
sec_method = sec_run[-1].method[-1]
|
|
898
|
+
for atom_parameters in sec_method.atom_parameters:
|
|
899
|
+
if atom_parameters.core_hole is not None:
|
|
900
|
+
try:
|
|
901
|
+
sec_system.atoms_group.append(
|
|
902
|
+
AtomsGroup(
|
|
903
|
+
label='core-hole',
|
|
904
|
+
type='active_orbitals',
|
|
905
|
+
atom_indices=self.atom_index_dict[
|
|
906
|
+
atom_parameters.label
|
|
907
|
+
],
|
|
908
|
+
n_atoms=len(
|
|
909
|
+
self.atom_index_dict[atom_parameters.label]
|
|
910
|
+
),
|
|
911
|
+
)
|
|
912
|
+
)
|
|
913
|
+
except KeyError:
|
|
914
|
+
continue
|
|
915
|
+
except (IndexError, AttributeError):
|
|
916
|
+
pass
|
|
917
|
+
|
|
918
|
+
self.parse_eigenvalues()
|