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,2324 @@
|
|
|
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
|
+
from typing import Optional
|
|
21
|
+
import numpy as np
|
|
22
|
+
import logging
|
|
23
|
+
import re
|
|
24
|
+
import ase
|
|
25
|
+
from ase import io as aseio
|
|
26
|
+
from scipy.stats import norm
|
|
27
|
+
import MDAnalysis
|
|
28
|
+
|
|
29
|
+
from nomad.units import ureg
|
|
30
|
+
from nomad.metainfo import Definition
|
|
31
|
+
from .metainfo import cp2k, cp2k_general
|
|
32
|
+
from nomad.parsing.file_parser import TextParser, Quantity, FileParser, DataTextParser
|
|
33
|
+
from runschema.run import Run, Program
|
|
34
|
+
from runschema.method import (
|
|
35
|
+
Method,
|
|
36
|
+
DFT,
|
|
37
|
+
XCFunctional,
|
|
38
|
+
Functional,
|
|
39
|
+
BasisSet,
|
|
40
|
+
BasisSetContainer,
|
|
41
|
+
AtomParameters,
|
|
42
|
+
Scf,
|
|
43
|
+
Electronic,
|
|
44
|
+
BasisSetAtomCentered,
|
|
45
|
+
)
|
|
46
|
+
from runschema.system import System, Atoms
|
|
47
|
+
from runschema.calculation import (
|
|
48
|
+
Calculation,
|
|
49
|
+
Energy,
|
|
50
|
+
EnergyEntry,
|
|
51
|
+
Stress,
|
|
52
|
+
StressEntry,
|
|
53
|
+
ScfIteration,
|
|
54
|
+
Forces,
|
|
55
|
+
ForcesEntry,
|
|
56
|
+
Dos,
|
|
57
|
+
DosValues,
|
|
58
|
+
)
|
|
59
|
+
from simulationworkflowschema import (
|
|
60
|
+
SinglePoint,
|
|
61
|
+
GeometryOptimization,
|
|
62
|
+
GeometryOptimizationMethod,
|
|
63
|
+
MolecularDynamics,
|
|
64
|
+
MolecularDynamicsMethod,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
from .metainfo.cp2k_general import (
|
|
68
|
+
x_cp2k_section_quickstep_settings,
|
|
69
|
+
x_cp2k_section_startinformation,
|
|
70
|
+
x_cp2k_section_end_information,
|
|
71
|
+
x_cp2k_section_atomic_kinds,
|
|
72
|
+
x_cp2k_section_atomic_kind,
|
|
73
|
+
x_cp2k_section_kind_basis_set,
|
|
74
|
+
x_cp2k_section_total_numbers,
|
|
75
|
+
x_cp2k_section_maximum_angular_momentum,
|
|
76
|
+
x_cp2k_section_md_settings,
|
|
77
|
+
x_cp2k_section_restart_information,
|
|
78
|
+
x_cp2k_section_geometry_optimization,
|
|
79
|
+
x_cp2k_section_geometry_optimization_step,
|
|
80
|
+
x_cp2k_pdos_histogram,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
from ..utils import get_files
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
units_map = {
|
|
87
|
+
'hbar': ureg.hbar,
|
|
88
|
+
'hartree': ureg.hartree,
|
|
89
|
+
'angstrom': ureg.angstrom,
|
|
90
|
+
'au_t': ureg.hbar / ureg.hartree,
|
|
91
|
+
'fs': ureg.femtosecond,
|
|
92
|
+
'K': ureg.kelvin,
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def resolve_unit(unit_str, parts=[]):
|
|
97
|
+
unit_str = unit_str.lower().replace(' ', '')
|
|
98
|
+
parts = list(parts)
|
|
99
|
+
|
|
100
|
+
if unit_str in units_map:
|
|
101
|
+
return units_map[unit_str]
|
|
102
|
+
|
|
103
|
+
try:
|
|
104
|
+
return float(unit_str)
|
|
105
|
+
except Exception:
|
|
106
|
+
pass
|
|
107
|
+
|
|
108
|
+
if unit_str == '':
|
|
109
|
+
return 1
|
|
110
|
+
|
|
111
|
+
open_p = unit_str.rfind('(')
|
|
112
|
+
if open_p > -1:
|
|
113
|
+
n_groups = unit_str.count('(')
|
|
114
|
+
if n_groups != unit_str.count(')'):
|
|
115
|
+
return unit_str
|
|
116
|
+
for n in range(n_groups):
|
|
117
|
+
part = unit_str[open_p + 1 :]
|
|
118
|
+
part = part[: part.find(')')]
|
|
119
|
+
parts.append(resolve_unit(part, parts))
|
|
120
|
+
unit_str = unit_str.replace('(%s)' % part, '[%d]' % n)
|
|
121
|
+
open_p = unit_str.rfind('(')
|
|
122
|
+
return resolve_unit(unit_str, parts)
|
|
123
|
+
|
|
124
|
+
vals = unit_str.split('/')
|
|
125
|
+
if len(vals) > 1:
|
|
126
|
+
vals = [resolve_unit(v, parts) for v in vals]
|
|
127
|
+
val = vals[0]
|
|
128
|
+
for v in vals[1:]:
|
|
129
|
+
val /= v
|
|
130
|
+
return val
|
|
131
|
+
|
|
132
|
+
vals = unit_str.split('**')
|
|
133
|
+
if len(vals) > 1:
|
|
134
|
+
vals = [resolve_unit(v, parts) for v in vals]
|
|
135
|
+
val = vals[0]
|
|
136
|
+
for v in reversed(vals[1:]):
|
|
137
|
+
val = val**v
|
|
138
|
+
return val
|
|
139
|
+
|
|
140
|
+
vals = unit_str.split('^')
|
|
141
|
+
if len(vals) > 1:
|
|
142
|
+
vals = [resolve_unit(v, parts) for v in vals]
|
|
143
|
+
val = vals[0]
|
|
144
|
+
for v in reversed(vals[1:]):
|
|
145
|
+
val = val**v
|
|
146
|
+
return val
|
|
147
|
+
|
|
148
|
+
vals = unit_str.split('*')
|
|
149
|
+
if len(vals) > 1:
|
|
150
|
+
vals = [resolve_unit(v, parts) for v in vals]
|
|
151
|
+
unit = 1
|
|
152
|
+
for v in vals:
|
|
153
|
+
unit *= v
|
|
154
|
+
return unit
|
|
155
|
+
|
|
156
|
+
vals = unit_str.split('-1')
|
|
157
|
+
if len(vals) == 2:
|
|
158
|
+
return 1 / resolve_unit(vals[0], parts)
|
|
159
|
+
|
|
160
|
+
vals = re.match(r'\[(\d+)\]', unit_str)
|
|
161
|
+
if vals:
|
|
162
|
+
return parts[int(vals.group(1))]
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class Property:
|
|
166
|
+
def __init__(self, **kwargs):
|
|
167
|
+
self._data = kwargs
|
|
168
|
+
|
|
169
|
+
def __getattr__(self, key):
|
|
170
|
+
return self._data.get(key, None)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
class Trajectory(Property):
|
|
174
|
+
def __init__(self, **kwargs):
|
|
175
|
+
super().__init__(**kwargs)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
class XYZTrajParser(TextParser):
|
|
179
|
+
def __init__(self):
|
|
180
|
+
super().__init__()
|
|
181
|
+
|
|
182
|
+
def init_quantities(self):
|
|
183
|
+
def get_trajectory(val_in):
|
|
184
|
+
val = np.transpose([v.split() for v in val_in.strip().split('\n')])
|
|
185
|
+
positions = np.array(val[1:4], dtype=float).T
|
|
186
|
+
return Trajectory(labels=val[0], positions=positions)
|
|
187
|
+
|
|
188
|
+
self.quantities = [
|
|
189
|
+
Quantity(
|
|
190
|
+
'trajectory',
|
|
191
|
+
r'([A-Z][a-z]?[\w\.\-\s]+?)(?:\s+\d\n|\Z)',
|
|
192
|
+
str_operation=get_trajectory,
|
|
193
|
+
repeats=True,
|
|
194
|
+
),
|
|
195
|
+
Quantity('energy', r'E\s*=\s*(\S+)', repeats=True, dtype=float),
|
|
196
|
+
Quantity('iter', r'i += *(\d+)', repeats=True, dtype=int),
|
|
197
|
+
]
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
class TrajParser(FileParser):
|
|
201
|
+
def __init__(self, **kwargs):
|
|
202
|
+
super().__init__()
|
|
203
|
+
self._xyz_parser = XYZTrajParser()
|
|
204
|
+
self.format = None
|
|
205
|
+
self.units = None
|
|
206
|
+
self.type = kwargs.get('type', 'positions')
|
|
207
|
+
self._frequency = 1
|
|
208
|
+
|
|
209
|
+
@property
|
|
210
|
+
def trajectory(self):
|
|
211
|
+
if self._file_handler is None:
|
|
212
|
+
if self.format is None:
|
|
213
|
+
self.format = self.mainfile.split('.')[-1].lower()
|
|
214
|
+
|
|
215
|
+
result = None
|
|
216
|
+
labels = []
|
|
217
|
+
iter = []
|
|
218
|
+
# custom parser
|
|
219
|
+
if self.format == 'xyz':
|
|
220
|
+
self._xyz_parser.mainfile = self.mainfile
|
|
221
|
+
result = [
|
|
222
|
+
traj.positions for traj in self._xyz_parser.get('trajectory', [])
|
|
223
|
+
]
|
|
224
|
+
labels = [
|
|
225
|
+
traj.labels for traj in self._xyz_parser.get('trajectory', [])
|
|
226
|
+
]
|
|
227
|
+
iter = self._xyz_parser.get('iter', [])
|
|
228
|
+
|
|
229
|
+
try:
|
|
230
|
+
atoms_list = [
|
|
231
|
+
atoms for atoms in aseio.iread(self.mainfile, format=self.format)
|
|
232
|
+
]
|
|
233
|
+
result = [atoms.positions for atoms in atoms_list]
|
|
234
|
+
labels = [list(atoms.symbols) for atoms in atoms_list]
|
|
235
|
+
|
|
236
|
+
except Exception:
|
|
237
|
+
pass
|
|
238
|
+
|
|
239
|
+
if result is None:
|
|
240
|
+
try:
|
|
241
|
+
if self.format in ['xyz', 'xmol', 'atomic']:
|
|
242
|
+
coordinates = MDAnalysis.coordinates.XYZ.XYZReader(
|
|
243
|
+
self.mainfile
|
|
244
|
+
)
|
|
245
|
+
elif self.format == 'dcd':
|
|
246
|
+
coordinates = MDAnalysis.coordinates.DCD.DCDReader(
|
|
247
|
+
self.mainfile
|
|
248
|
+
)
|
|
249
|
+
elif self.format == 'pdb':
|
|
250
|
+
coordinates = MDAnalysis.coordinates.PDB.PDBReader(
|
|
251
|
+
self.mainfile
|
|
252
|
+
)
|
|
253
|
+
else:
|
|
254
|
+
coordinates = None
|
|
255
|
+
self.logger.error('Unsupported trajectory format.')
|
|
256
|
+
if coordinates is not None:
|
|
257
|
+
result = [traj.positions for traj in coordinates.trajectory]
|
|
258
|
+
except Exception:
|
|
259
|
+
self.logger.warning('Error loading trajectory file.')
|
|
260
|
+
|
|
261
|
+
if result is None:
|
|
262
|
+
return self._file_handler
|
|
263
|
+
|
|
264
|
+
result = result * self.units if self.units is not None else result
|
|
265
|
+
|
|
266
|
+
result = [Trajectory(**{self.type: res}) for res in result]
|
|
267
|
+
|
|
268
|
+
# add labels to trajectory
|
|
269
|
+
for n, labels_i in enumerate(labels):
|
|
270
|
+
result[n]._data.update({'labels': labels_i})
|
|
271
|
+
|
|
272
|
+
# add iter number to trajectory
|
|
273
|
+
for n, iter_i in enumerate(iter):
|
|
274
|
+
result[n]._data.update({'iter': iter_i})
|
|
275
|
+
|
|
276
|
+
self._results = {'iter': iter}
|
|
277
|
+
self._file_handler = result
|
|
278
|
+
|
|
279
|
+
return self._file_handler
|
|
280
|
+
|
|
281
|
+
def get_trajectory(self, frame):
|
|
282
|
+
trajectory = self.trajectory
|
|
283
|
+
if self.iter:
|
|
284
|
+
return trajectory[self.iter.index(frame)]
|
|
285
|
+
else:
|
|
286
|
+
return trajectory[frame // self._frequency]
|
|
287
|
+
|
|
288
|
+
def parse(self, key=None):
|
|
289
|
+
pass
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
re_float = r'[-+]?\d+\.?\d*(?:[Ee][-+]\d+)?'
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
class ForceParser(TextParser):
|
|
296
|
+
def __init__(self):
|
|
297
|
+
super().__init__()
|
|
298
|
+
|
|
299
|
+
def init_quantities(self):
|
|
300
|
+
self._quantities = [
|
|
301
|
+
Quantity(
|
|
302
|
+
'atom_forces',
|
|
303
|
+
rf'\d+\s*\d+\s*\w+\s*({re_float})\s*({re_float})\s*({re_float})',
|
|
304
|
+
repeats=True,
|
|
305
|
+
)
|
|
306
|
+
]
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
class XCFunctionalProperty(Property):
|
|
310
|
+
def __init__(self, name, **kwargs):
|
|
311
|
+
super().__init__(name=name, **kwargs)
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
class InpValue:
|
|
315
|
+
def __init__(self, name, **kwargs):
|
|
316
|
+
self._data = kwargs
|
|
317
|
+
self._name = name
|
|
318
|
+
self._dict = None
|
|
319
|
+
|
|
320
|
+
@property
|
|
321
|
+
def name(self):
|
|
322
|
+
return self._name
|
|
323
|
+
|
|
324
|
+
def add(self, key, val):
|
|
325
|
+
if key in self._data:
|
|
326
|
+
self._data[key] = (
|
|
327
|
+
self._data[key]
|
|
328
|
+
if isinstance(self._data[key], list)
|
|
329
|
+
else [self._data[key]]
|
|
330
|
+
)
|
|
331
|
+
self._data[key].append(val)
|
|
332
|
+
else:
|
|
333
|
+
self._data[key] = val
|
|
334
|
+
|
|
335
|
+
def to_dict(self):
|
|
336
|
+
if self._dict is None:
|
|
337
|
+
|
|
338
|
+
def extract(data):
|
|
339
|
+
out = dict()
|
|
340
|
+
for key, val in data.items():
|
|
341
|
+
if isinstance(val, InpValue):
|
|
342
|
+
val = extract(val.to_dict())
|
|
343
|
+
out[key] = val
|
|
344
|
+
return out
|
|
345
|
+
|
|
346
|
+
self._dict = extract(self._data)
|
|
347
|
+
|
|
348
|
+
return self._dict
|
|
349
|
+
|
|
350
|
+
def items(self):
|
|
351
|
+
for key, val in self._data.items():
|
|
352
|
+
yield key, val
|
|
353
|
+
|
|
354
|
+
def __getattr__(self, key):
|
|
355
|
+
return self._data.get(key, None)
|
|
356
|
+
|
|
357
|
+
def __repr__(self):
|
|
358
|
+
return self._name
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
class InpParser(FileParser):
|
|
362
|
+
def __init__(self):
|
|
363
|
+
super().__init__()
|
|
364
|
+
self._re_open = re.compile(r'&(\w+)\s*(.*?)[#!\n]')
|
|
365
|
+
self._re_close = re.compile(r'&END')
|
|
366
|
+
self._re_key_value = re.compile(r'(\w+)\s+(.+?)[#!\n]')
|
|
367
|
+
self._re_variable = re.compile(r'@SET (\w+)\s+(.+?)[#!\n]')
|
|
368
|
+
|
|
369
|
+
@property
|
|
370
|
+
def tree(self):
|
|
371
|
+
if self._file_handler is None:
|
|
372
|
+
|
|
373
|
+
def override(name, data):
|
|
374
|
+
if data[0] == 'PROJECT':
|
|
375
|
+
return 'PROJECT_NAME', data[1]
|
|
376
|
+
elif not data[0].isupper():
|
|
377
|
+
return 'DEFAULT_KEYWORD', ' '.join(data)
|
|
378
|
+
return data
|
|
379
|
+
|
|
380
|
+
self._variables = dict()
|
|
381
|
+
line = True
|
|
382
|
+
sections = [InpValue('tree')]
|
|
383
|
+
with self.open_mainfile_obj() as mainfile_obj:
|
|
384
|
+
while line:
|
|
385
|
+
line = mainfile_obj.readline()
|
|
386
|
+
# comments
|
|
387
|
+
strip = line.strip()
|
|
388
|
+
if not strip or strip[0] in ('#', '!'):
|
|
389
|
+
continue
|
|
390
|
+
variable = self._re_variable.search(line)
|
|
391
|
+
if variable:
|
|
392
|
+
self._variables['${%s}' % variable.group(1)] = variable.group(
|
|
393
|
+
2
|
|
394
|
+
).strip()
|
|
395
|
+
continue
|
|
396
|
+
close_section = self._re_close.search(line)
|
|
397
|
+
if close_section:
|
|
398
|
+
sections.pop(-1)
|
|
399
|
+
continue
|
|
400
|
+
open_section = self._re_open.search(line)
|
|
401
|
+
if open_section:
|
|
402
|
+
section = InpValue(open_section.group(1))
|
|
403
|
+
sections[-1].add(open_section.group(1), section)
|
|
404
|
+
sections.append(section)
|
|
405
|
+
if open_section.group(2):
|
|
406
|
+
sections[-1].add('VALUE', open_section.group(2))
|
|
407
|
+
continue
|
|
408
|
+
key_value = self._re_key_value.search(line)
|
|
409
|
+
if key_value:
|
|
410
|
+
key, val = key_value.group(1), key_value.group(2)
|
|
411
|
+
val = val.strip()
|
|
412
|
+
if val in self._variables:
|
|
413
|
+
val = self._variables[val]
|
|
414
|
+
key, val = override(sections[-1].name, [key, val])
|
|
415
|
+
sections[-1].add(key, val)
|
|
416
|
+
continue
|
|
417
|
+
self._file_handler = sections[0]
|
|
418
|
+
return self._file_handler
|
|
419
|
+
|
|
420
|
+
def parse(self, key):
|
|
421
|
+
if self._results is None:
|
|
422
|
+
self._results = dict()
|
|
423
|
+
|
|
424
|
+
source = self.tree.to_dict()
|
|
425
|
+
for sub_key in key.strip('/').split('/'):
|
|
426
|
+
val = source.get(sub_key, None)
|
|
427
|
+
source = val
|
|
428
|
+
if val is None:
|
|
429
|
+
break
|
|
430
|
+
self._results[key] = val
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
class CP2KOutParser(TextParser):
|
|
434
|
+
def __init__(self):
|
|
435
|
+
super().__init__()
|
|
436
|
+
|
|
437
|
+
def init_quantities(self):
|
|
438
|
+
def str_to_header(val_in):
|
|
439
|
+
val = val_in.split(' ', 1)
|
|
440
|
+
return [val[0].strip().replace(' ', '_').lower(), val[-1].strip()]
|
|
441
|
+
|
|
442
|
+
def md_extract(val_in):
|
|
443
|
+
result = re.search(
|
|
444
|
+
r' MD\| (?P<key>.+?)(?: \[(?P<unit>.+)\])? {2,}(?P<value>.+)', val_in
|
|
445
|
+
)
|
|
446
|
+
value = result.group('value')
|
|
447
|
+
unit = units_map.get(result.group('unit'))
|
|
448
|
+
key = result.group('key').strip().replace(' ', '_').lower()
|
|
449
|
+
if unit:
|
|
450
|
+
value = float(value) * unit
|
|
451
|
+
return [key, value]
|
|
452
|
+
|
|
453
|
+
def str_to_program(val_in):
|
|
454
|
+
val = val_in.split(' ', 2)
|
|
455
|
+
return [
|
|
456
|
+
'_'.join(val[:2]).lower(),
|
|
457
|
+
''.join([v.strip() for v in val[2].split('\n')]),
|
|
458
|
+
]
|
|
459
|
+
|
|
460
|
+
def str_to_atomic_coordinates(val_in):
|
|
461
|
+
val = [v.split() for v in val_in.split('\n')]
|
|
462
|
+
length_unit = val[0][0].lower()
|
|
463
|
+
val = np.transpose(np.array([v for v in val if len(v) == 9]))
|
|
464
|
+
labels = val[2]
|
|
465
|
+
positions = np.transpose(np.array(val[4:7], dtype=float)) * resolve_unit(
|
|
466
|
+
length_unit
|
|
467
|
+
)
|
|
468
|
+
atomic_numbers = {
|
|
469
|
+
element: int(val[3][n]) for n, element in enumerate(val[2])
|
|
470
|
+
}
|
|
471
|
+
return Trajectory(
|
|
472
|
+
labels=labels, positions=positions, atomic_numbers=atomic_numbers
|
|
473
|
+
)
|
|
474
|
+
|
|
475
|
+
def str_to_stress_eigenvalues(val_in):
|
|
476
|
+
val = [v.split() for v in val_in.strip().split('\n')]
|
|
477
|
+
val = np.array([v for v in val if v], dtype=float)
|
|
478
|
+
return val[0] * ureg.GPa, val[1:]
|
|
479
|
+
|
|
480
|
+
def str_to_iteration(val_in):
|
|
481
|
+
val = val_in.strip().split()
|
|
482
|
+
return {
|
|
483
|
+
'time_calculation': float(val[-4]) * ureg.s,
|
|
484
|
+
'energy_total': float(val[-2]) * ureg.hartree,
|
|
485
|
+
'energy_change': float(val[-1]) * ureg.hartree,
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
def str_to_information(val_in):
|
|
489
|
+
val = [v.split('=') for v in val_in.strip().split('\n')]
|
|
490
|
+
return {
|
|
491
|
+
v[0].strip().lower().replace(' ', '_').replace('.', ''): v[1]
|
|
492
|
+
for v in val
|
|
493
|
+
if len(v) == 2
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
n_orbital_basis_quantities = [
|
|
497
|
+
Quantity(
|
|
498
|
+
'basis_set_number_of_%s' % key.lower().replace(' ', '_'),
|
|
499
|
+
r'Number of %s:\s+(\d+)' % key,
|
|
500
|
+
dtype=int,
|
|
501
|
+
)
|
|
502
|
+
for key in [
|
|
503
|
+
'orbital shell sets',
|
|
504
|
+
'orbital shells',
|
|
505
|
+
'primitive Cartesian functions',
|
|
506
|
+
'Cartesian basis functions',
|
|
507
|
+
'spherical basis functions',
|
|
508
|
+
]
|
|
509
|
+
]
|
|
510
|
+
|
|
511
|
+
energy_quantities = [
|
|
512
|
+
Quantity(
|
|
513
|
+
'%s' % key.lower().replace(' ', '_').replace('-', '_'),
|
|
514
|
+
rf'%s:\s*({re_float})' % key,
|
|
515
|
+
dtype=float,
|
|
516
|
+
unit='hartree',
|
|
517
|
+
repeats=True,
|
|
518
|
+
)
|
|
519
|
+
for key in [
|
|
520
|
+
'Hartree energy',
|
|
521
|
+
'Exchange-correlation energy',
|
|
522
|
+
'Electronic kinetic energy',
|
|
523
|
+
'Total energy',
|
|
524
|
+
'Fermi energy',
|
|
525
|
+
]
|
|
526
|
+
]
|
|
527
|
+
# what is the difference between Total energy and ENERGY| Total
|
|
528
|
+
|
|
529
|
+
scf_wavefunction_optimization_quantities = [
|
|
530
|
+
Quantity(
|
|
531
|
+
'iteration',
|
|
532
|
+
rf'(\d+\s+\S+\s*\S*\s+{re_float}\s+{re_float}\s+{re_float}\s+{re_float}\s+{re_float})\n',
|
|
533
|
+
repeats=True,
|
|
534
|
+
convert=False,
|
|
535
|
+
str_operation=str_to_iteration,
|
|
536
|
+
),
|
|
537
|
+
# TODO add minimizer info
|
|
538
|
+
Quantity('converged', r'SCF run converged in\s*(\d+) steps', dtype=int),
|
|
539
|
+
# find example with cueb file
|
|
540
|
+
Quantity(
|
|
541
|
+
'cube_file',
|
|
542
|
+
r' The electron density is written in cube file format to the file:\s*(.+?\.cube)',
|
|
543
|
+
),
|
|
544
|
+
# TODO add mulliken, hirschfield
|
|
545
|
+
Quantity(
|
|
546
|
+
'energy_total',
|
|
547
|
+
rf'ENERGY\| Total FORCE_EVAL \( \w+ \) energy \(a\.u\.\):\s*({re_float})',
|
|
548
|
+
dtype=float,
|
|
549
|
+
unit='hartree',
|
|
550
|
+
),
|
|
551
|
+
Quantity(
|
|
552
|
+
'atom_forces',
|
|
553
|
+
rf'ATOMIC FORCES in \[a\.u\.\]\s*.+([\s\S]+?)SUM',
|
|
554
|
+
convert=False,
|
|
555
|
+
str_operation=lambda x: np.array(
|
|
556
|
+
np.transpose([v.split() for v in x.strip().split('\n')])[3:6],
|
|
557
|
+
dtype=float,
|
|
558
|
+
).T,
|
|
559
|
+
),
|
|
560
|
+
# TODO test stress cannot find example
|
|
561
|
+
Quantity(
|
|
562
|
+
'stress_tensor',
|
|
563
|
+
r' (?:NUMERICAL )?STRESS TENSOR \[GPa\]\s+X\s+Y\s+Z\s+([\d\.\-\s]+)',
|
|
564
|
+
str_operation=lambda x: np.array(
|
|
565
|
+
[v.split() for v in x.strip().split('\n')], dtype=float
|
|
566
|
+
),
|
|
567
|
+
convert=False,
|
|
568
|
+
unit='GPa',
|
|
569
|
+
),
|
|
570
|
+
Quantity(
|
|
571
|
+
'stress_tensor_one_third_of_trace',
|
|
572
|
+
rf' 1/3 Trace\(stress tensor\)\s*:\s*({re_float})',
|
|
573
|
+
dtype=float,
|
|
574
|
+
unit='GPa',
|
|
575
|
+
),
|
|
576
|
+
Quantity(
|
|
577
|
+
'stress_tensor_determinant',
|
|
578
|
+
rf'Det\(stress tensor\)\s*:\s*({re_float})',
|
|
579
|
+
dtype=float,
|
|
580
|
+
unit='GPa**3',
|
|
581
|
+
),
|
|
582
|
+
Quantity(
|
|
583
|
+
'stress_eigenvalues_eigenvectors',
|
|
584
|
+
r' EIGENVECTORS AND EIGENVALUES OF THE STRESS TENSOR\s*([\d\.\-\s]+)',
|
|
585
|
+
str_operation=str_to_stress_eigenvalues,
|
|
586
|
+
convert=False,
|
|
587
|
+
),
|
|
588
|
+
] + energy_quantities
|
|
589
|
+
|
|
590
|
+
geometry_optimization_quantities = [
|
|
591
|
+
Quantity(
|
|
592
|
+
'method',
|
|
593
|
+
r'\*{3}\s*((?:CONJUGATE GRADIENTS|L\-BFGS|BFGS))\s*\*{3}',
|
|
594
|
+
flatten=False,
|
|
595
|
+
),
|
|
596
|
+
Quantity(
|
|
597
|
+
'self_consistent',
|
|
598
|
+
r'SCF WAVEFUNCTION OPTIMIZATION([\s\S]+?)OPTIMIZ',
|
|
599
|
+
repeats=False,
|
|
600
|
+
sub_parser=TextParser(
|
|
601
|
+
quantities=scf_wavefunction_optimization_quantities
|
|
602
|
+
),
|
|
603
|
+
),
|
|
604
|
+
Quantity(
|
|
605
|
+
'optimization_step',
|
|
606
|
+
r'(ATION STEP:\s*\d+[\s\S]+?)(?:\-\s+OPTIMIZ|\Z)',
|
|
607
|
+
repeats=True,
|
|
608
|
+
sub_parser=TextParser(
|
|
609
|
+
quantities=[
|
|
610
|
+
# TODO parse atomic positions
|
|
611
|
+
Quantity('step', r'ATION STEP:\s*(\d+)'),
|
|
612
|
+
# I do not quite get why there can be multiple scfs in a step
|
|
613
|
+
Quantity(
|
|
614
|
+
'information',
|
|
615
|
+
r'Informations at step\s*=\s*\d+\s*\-+([\s\S]+?)\-{5}',
|
|
616
|
+
str_operation=str_to_information,
|
|
617
|
+
),
|
|
618
|
+
Quantity(
|
|
619
|
+
'self_consistent',
|
|
620
|
+
r'FUNCTION OPTIMIZATION([\s\S]+?)(?: SCF WAVE|\Z)',
|
|
621
|
+
repeats=True,
|
|
622
|
+
sub_parser=TextParser(
|
|
623
|
+
quantities=scf_wavefunction_optimization_quantities
|
|
624
|
+
),
|
|
625
|
+
),
|
|
626
|
+
]
|
|
627
|
+
),
|
|
628
|
+
),
|
|
629
|
+
]
|
|
630
|
+
|
|
631
|
+
molecular_dynamics_quantities = [
|
|
632
|
+
Quantity(
|
|
633
|
+
'initial',
|
|
634
|
+
r' INITIAL\| (.+? {2})=\s+(.+)',
|
|
635
|
+
str_operation=str_to_header,
|
|
636
|
+
repeats=True,
|
|
637
|
+
),
|
|
638
|
+
Quantity(
|
|
639
|
+
'md_step',
|
|
640
|
+
r'(SCF WAVEFUNCTION OPTIMIZATION[\s\S]+?ENSEMBLE TYPE[\s\S]+?\*{50})',
|
|
641
|
+
repeats=True,
|
|
642
|
+
sub_parser=TextParser(
|
|
643
|
+
quantities=[
|
|
644
|
+
Quantity('ensemble_type', r'ENSEMBLE TYPE\s*=\s*(.+)'),
|
|
645
|
+
Quantity('step', r'STEP NUMBER\s*=\s*(\d+)', dtype=int),
|
|
646
|
+
Quantity(
|
|
647
|
+
'time', rf'TIME \[fs\]\s*=\s*({re_float})', dtype=float
|
|
648
|
+
),
|
|
649
|
+
Quantity(
|
|
650
|
+
'conserved_quantity',
|
|
651
|
+
rf'CONSERVED QUANTITY \[hartree\]\s*=\s*({re_float})',
|
|
652
|
+
dtype=float,
|
|
653
|
+
unit='hartree',
|
|
654
|
+
),
|
|
655
|
+
Quantity(
|
|
656
|
+
'cpu_time',
|
|
657
|
+
rf'CPU TIME \[s\]\s*=\s*({re_float})\s*(re_float)',
|
|
658
|
+
dtype=float,
|
|
659
|
+
),
|
|
660
|
+
Quantity(
|
|
661
|
+
'energy_drift',
|
|
662
|
+
rf'ENERGY DRIFT PER ATOM \[K\]\s*=\s*({re_float})\s*({re_float})',
|
|
663
|
+
dtype=float,
|
|
664
|
+
unit='hartree',
|
|
665
|
+
),
|
|
666
|
+
Quantity(
|
|
667
|
+
'potential_energy',
|
|
668
|
+
rf'POTENTIAL ENERGY\[hartree\]\s*=\s*({re_float})\s*({re_float})',
|
|
669
|
+
dtype=float,
|
|
670
|
+
unit='hartree',
|
|
671
|
+
),
|
|
672
|
+
Quantity(
|
|
673
|
+
'kinetic_energy',
|
|
674
|
+
rf'KINETIC ENERGY\[hartree\]\s*=\s*({re_float})\s*({re_float})',
|
|
675
|
+
dtype=float,
|
|
676
|
+
unit='hartree',
|
|
677
|
+
),
|
|
678
|
+
Quantity(
|
|
679
|
+
'temperature',
|
|
680
|
+
rf'TEMPERATURE \[K\]\s*=\s*({re_float})\s*({re_float})',
|
|
681
|
+
dtype=float,
|
|
682
|
+
),
|
|
683
|
+
Quantity(
|
|
684
|
+
'pressure',
|
|
685
|
+
rf'PRESSURE \[bar\]\s*=\s*({re_float})\s*({re_float})',
|
|
686
|
+
dtype=float,
|
|
687
|
+
unit='bar',
|
|
688
|
+
),
|
|
689
|
+
Quantity(
|
|
690
|
+
'barostat_temperature',
|
|
691
|
+
rf'BAROSTAT TEMP\[K\]\s*=\s*({re_float})\s*({re_float})',
|
|
692
|
+
dtype=float,
|
|
693
|
+
),
|
|
694
|
+
Quantity(
|
|
695
|
+
'volume',
|
|
696
|
+
rf'VOLUME\[bohr\^3\]\s*=\s*({re_float})\s*({re_float})',
|
|
697
|
+
dtype=float,
|
|
698
|
+
unit='bohr**3',
|
|
699
|
+
),
|
|
700
|
+
Quantity(
|
|
701
|
+
'cell_length_instantaneous',
|
|
702
|
+
rf'CELL LNTHS\[bohr\]\s*=\s*({re_float})\s*({re_float})\s*({re_float})',
|
|
703
|
+
dtype=float,
|
|
704
|
+
),
|
|
705
|
+
Quantity(
|
|
706
|
+
'cell_length_average',
|
|
707
|
+
rf'AVE\. CELL LNTHS\[bohr\]\s*=\s*({re_float})\s*({re_float})\s*({re_float})',
|
|
708
|
+
dtype=float,
|
|
709
|
+
),
|
|
710
|
+
Quantity(
|
|
711
|
+
'cell_angle_instantaneous',
|
|
712
|
+
rf'CELL ANGLS\[deg\]\s*=\s*({re_float})\s*({re_float})\s*({re_float})',
|
|
713
|
+
dtype=float,
|
|
714
|
+
),
|
|
715
|
+
Quantity(
|
|
716
|
+
'cell_angle_average',
|
|
717
|
+
rf'AVE\. CELL ANGLS\[deg\]\s*=\s*({re_float})\s*({re_float})\s*({re_float})',
|
|
718
|
+
dtype=float,
|
|
719
|
+
),
|
|
720
|
+
Quantity(
|
|
721
|
+
'self_consistent',
|
|
722
|
+
r'(SCF WAVEFUNCTION OPTIMIZATION[\s\S]+?)\*{50}',
|
|
723
|
+
repeats=True,
|
|
724
|
+
sub_parser=TextParser(
|
|
725
|
+
quantities=scf_wavefunction_optimization_quantities
|
|
726
|
+
),
|
|
727
|
+
),
|
|
728
|
+
]
|
|
729
|
+
),
|
|
730
|
+
),
|
|
731
|
+
]
|
|
732
|
+
|
|
733
|
+
quickstep_quantities = [
|
|
734
|
+
Quantity(
|
|
735
|
+
'dft',
|
|
736
|
+
r' DFT\| (.+? {2}) +(.+)',
|
|
737
|
+
str_operation=str_to_header,
|
|
738
|
+
repeats=True,
|
|
739
|
+
),
|
|
740
|
+
Quantity('dft_u', r'(DFT\+U\|)'),
|
|
741
|
+
Quantity('mp2', r'(MP2\|)'),
|
|
742
|
+
Quantity('rpa', r'(RI-RPA\|)'),
|
|
743
|
+
Quantity('functional', r' FUNCTIONAL\| (\S+):', repeats=True),
|
|
744
|
+
Quantity(
|
|
745
|
+
'vdw',
|
|
746
|
+
r' vdW POTENTIAL\| .+?([A-Z]\. [A-Z].+? \(\d+\))',
|
|
747
|
+
flatten=False,
|
|
748
|
+
repeats=True,
|
|
749
|
+
),
|
|
750
|
+
Quantity(
|
|
751
|
+
'qs',
|
|
752
|
+
r' QS\| ((?:Method|Density cutoff)).*?:( {2}) +(.+)',
|
|
753
|
+
str_operation=str_to_header,
|
|
754
|
+
repeats=True,
|
|
755
|
+
),
|
|
756
|
+
Quantity(
|
|
757
|
+
'atomic_kind_information',
|
|
758
|
+
r' ATOMIC KIND INFORMATION([\s\S]+?)\n\n\n',
|
|
759
|
+
sub_parser=TextParser(
|
|
760
|
+
quantities=[
|
|
761
|
+
Quantity(
|
|
762
|
+
'atom',
|
|
763
|
+
r'(ic kind: [A-Z][a-z]?[\s\S]+?)(?:\d+\. Atom|\Z)',
|
|
764
|
+
repeats=True,
|
|
765
|
+
sub_parser=TextParser(
|
|
766
|
+
quantities=[
|
|
767
|
+
Quantity('kind_label', r'ic kind:\s*(\w+)'),
|
|
768
|
+
Quantity(
|
|
769
|
+
'kind_number_of_atoms',
|
|
770
|
+
r'Number of atoms:\s*(\d+)',
|
|
771
|
+
dtype=int,
|
|
772
|
+
),
|
|
773
|
+
Quantity(
|
|
774
|
+
'kind_basis_set_name',
|
|
775
|
+
r'Orbital Basis Set\s*(.+)',
|
|
776
|
+
),
|
|
777
|
+
Quantity(
|
|
778
|
+
'basis_set_norm_type',
|
|
779
|
+
r'Norm type:\s*(\d+)',
|
|
780
|
+
dtype=int,
|
|
781
|
+
),
|
|
782
|
+
]
|
|
783
|
+
+ n_orbital_basis_quantities
|
|
784
|
+
),
|
|
785
|
+
)
|
|
786
|
+
]
|
|
787
|
+
),
|
|
788
|
+
),
|
|
789
|
+
Quantity(
|
|
790
|
+
'total_maximum_numbers',
|
|
791
|
+
r' TOTAL NUMBERS AND MAXIMUM NUMBERS([\s\S]+?)\n\n\n',
|
|
792
|
+
sub_parser=TextParser(
|
|
793
|
+
quantities=[
|
|
794
|
+
Quantity(
|
|
795
|
+
'%s'
|
|
796
|
+
% key.lower()
|
|
797
|
+
.replace('the ', '')
|
|
798
|
+
.replace(' ', '_')
|
|
799
|
+
.replace('-', '_'),
|
|
800
|
+
r'\- %s:\s*(\d+)' % key,
|
|
801
|
+
dtype=int,
|
|
802
|
+
)
|
|
803
|
+
for key in [
|
|
804
|
+
'Atomic kinds',
|
|
805
|
+
'Atoms',
|
|
806
|
+
'Shell sets',
|
|
807
|
+
'Shells',
|
|
808
|
+
'Primitive Cartesian functions',
|
|
809
|
+
'Cartesian basis functions',
|
|
810
|
+
'Spherical basis functions',
|
|
811
|
+
'Orbital basis functions',
|
|
812
|
+
'Local part of the GTH pseudopotential',
|
|
813
|
+
'Non-local part of the GTH pseudopotential',
|
|
814
|
+
]
|
|
815
|
+
]
|
|
816
|
+
),
|
|
817
|
+
),
|
|
818
|
+
Quantity(
|
|
819
|
+
'atomic_coordinates',
|
|
820
|
+
r'(?i: atomic coordinates(?: in) (angstrom))([\s\S]+?)\n\n\n',
|
|
821
|
+
convert=False,
|
|
822
|
+
str_operation=str_to_atomic_coordinates,
|
|
823
|
+
), # TODO: if we always capture angstrom, then no need to extract the units...
|
|
824
|
+
Quantity(
|
|
825
|
+
'scf_parameters',
|
|
826
|
+
r' SCF PARAMETERS([\s\S]+?)\*{79}',
|
|
827
|
+
sub_parser=TextParser(
|
|
828
|
+
quantities=[
|
|
829
|
+
Quantity('n_max_iteration', r'max_scf:\s*(\d+)', dtype=int),
|
|
830
|
+
Quantity(
|
|
831
|
+
'threshold_energy_change',
|
|
832
|
+
rf'eps_scf:\s*({re_float})',
|
|
833
|
+
dtype=float,
|
|
834
|
+
unit='hartree',
|
|
835
|
+
),
|
|
836
|
+
Quantity(
|
|
837
|
+
'md',
|
|
838
|
+
r'( MD\| .+? {2} +.+)',
|
|
839
|
+
str_operation=md_extract,
|
|
840
|
+
convert=False,
|
|
841
|
+
repeats=True,
|
|
842
|
+
),
|
|
843
|
+
]
|
|
844
|
+
),
|
|
845
|
+
),
|
|
846
|
+
# TODO add mp2, rpa, gw
|
|
847
|
+
Quantity(
|
|
848
|
+
'single_point',
|
|
849
|
+
r'SCF WAVEFUNCTION OPTIMIZATION([\s\S]+?)(?:\-{50}\n\s*\-|MD_ENERGIES|\Z)',
|
|
850
|
+
repeats=False,
|
|
851
|
+
sub_parser=TextParser(
|
|
852
|
+
quantities=scf_wavefunction_optimization_quantities
|
|
853
|
+
),
|
|
854
|
+
),
|
|
855
|
+
Quantity(
|
|
856
|
+
'geometry_optimization',
|
|
857
|
+
r'STARTING.+?OPTIMIZATION([\s\S]+?(?:OPTIMIZATION COMPLETED|\Z))',
|
|
858
|
+
sub_parser=TextParser(quantities=geometry_optimization_quantities),
|
|
859
|
+
),
|
|
860
|
+
Quantity(
|
|
861
|
+
'molecular_dynamics',
|
|
862
|
+
r'(MD_ENERGIES\| Initialization proceeding[\s\S]+?\-{50}\n\s*\-)',
|
|
863
|
+
sub_parser=TextParser(quantities=molecular_dynamics_quantities),
|
|
864
|
+
),
|
|
865
|
+
]
|
|
866
|
+
|
|
867
|
+
self._quantities = [
|
|
868
|
+
Quantity(
|
|
869
|
+
'dbcsr',
|
|
870
|
+
r' (DBCSR)\| (.+? {2}) +(.+)',
|
|
871
|
+
str_operation=str_to_header,
|
|
872
|
+
repeats=True,
|
|
873
|
+
),
|
|
874
|
+
Quantity(
|
|
875
|
+
'program',
|
|
876
|
+
r'\*\*\s*PROGRAM ([\s\S]+?)(?:\*\*|\n\n|\Z)',
|
|
877
|
+
str_operation=str_to_program,
|
|
878
|
+
repeats=True,
|
|
879
|
+
),
|
|
880
|
+
Quantity(
|
|
881
|
+
'cp2k',
|
|
882
|
+
r' CP2K\| (.+? {2}) +(.+)',
|
|
883
|
+
str_operation=str_to_header,
|
|
884
|
+
repeats=True,
|
|
885
|
+
),
|
|
886
|
+
Quantity(
|
|
887
|
+
'global',
|
|
888
|
+
r' GLOBAL\| (.+? {2}) +(.+)',
|
|
889
|
+
str_operation=str_to_header,
|
|
890
|
+
repeats=True,
|
|
891
|
+
),
|
|
892
|
+
Quantity(
|
|
893
|
+
'restart',
|
|
894
|
+
r'RESTART INFORMATION\s*\*+\s*\*+([\s\S]+?)\*{79}',
|
|
895
|
+
sub_parser=TextParser(
|
|
896
|
+
quantities=[
|
|
897
|
+
Quantity('filename', r'RESTART FILE NAME: (\S+)'),
|
|
898
|
+
Quantity(
|
|
899
|
+
'quantities',
|
|
900
|
+
r'RESTARTED QUANTITIES:\s*\*\s*([\s\S]+?)\Z',
|
|
901
|
+
str_operation=lambda x: [
|
|
902
|
+
v.split('*')[1].strip() for v in x.strip().split('\n')
|
|
903
|
+
],
|
|
904
|
+
),
|
|
905
|
+
]
|
|
906
|
+
),
|
|
907
|
+
),
|
|
908
|
+
Quantity(
|
|
909
|
+
'lattice_vectors',
|
|
910
|
+
rf' CELL\| Vector [abc] \[angstrom\]:\s*({re_float})\s*({re_float})\s*({re_float})',
|
|
911
|
+
repeats=True,
|
|
912
|
+
),
|
|
913
|
+
# TODO add restart find example
|
|
914
|
+
Quantity(
|
|
915
|
+
'quickstep',
|
|
916
|
+
r'\.\.\. make the atoms dance([\s\S]+?(?:\-{79}\s*\- +\-|\Z))',
|
|
917
|
+
sub_parser=TextParser(quantities=quickstep_quantities),
|
|
918
|
+
),
|
|
919
|
+
Quantity(
|
|
920
|
+
'spin_polarized',
|
|
921
|
+
r'\| Spin unrestricted \(spin\-polarized\) Kohn\-Sham calculation *([a-zA-Z]+)',
|
|
922
|
+
repeats=False,
|
|
923
|
+
),
|
|
924
|
+
Quantity(
|
|
925
|
+
'qs_dftb',
|
|
926
|
+
r' ##### ##### # ###### ####### ####### ######\s*'
|
|
927
|
+
r' # # # # # # # # # # #\s*'
|
|
928
|
+
r' # # # # # # # # # #\s*'
|
|
929
|
+
r' # # ##### # # # ##### # ######\s*'
|
|
930
|
+
r' # # # # # # # # # # #\s*'
|
|
931
|
+
r' # # # # # # # # # # #\s*'
|
|
932
|
+
r' #### # ##### # ###### # # ######\s*'
|
|
933
|
+
r'([\s\S]+?(?:\-{79}\s*\-|\Z))',
|
|
934
|
+
sub_parser=TextParser(quantities=quickstep_quantities),
|
|
935
|
+
),
|
|
936
|
+
# TODO add other calculation types
|
|
937
|
+
]
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
class CP2KPDOSParser(DataTextParser):
|
|
941
|
+
def init_quantities(self):
|
|
942
|
+
self._quantities = [
|
|
943
|
+
Quantity(
|
|
944
|
+
'atom_kind',
|
|
945
|
+
r'\# *(?:Projected|P\.) DOS for atomic kind *([\da-zA-Z]+) *at',
|
|
946
|
+
),
|
|
947
|
+
Quantity('orbitals', r' *Occupation(.+)', repeats=False),
|
|
948
|
+
Quantity('iter', r' *at iteration step i *\= *(\d+)'),
|
|
949
|
+
]
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
class CP2KParser:
|
|
953
|
+
def __init__(self):
|
|
954
|
+
self.out_parser = CP2KOutParser()
|
|
955
|
+
self.inp_parser = InpParser()
|
|
956
|
+
self.pdos_parser = CP2KPDOSParser()
|
|
957
|
+
# use a custom xyz parser as the output of cp2k is sometimes not up to standard
|
|
958
|
+
self.traj_parser = TrajParser(type='positions')
|
|
959
|
+
self.velocities_parser = TrajParser(type='velocities')
|
|
960
|
+
self.cell_parser = DataTextParser()
|
|
961
|
+
self.energy_parser = DataTextParser()
|
|
962
|
+
self.force_parser = ForceParser()
|
|
963
|
+
self._method = None
|
|
964
|
+
self._calculation_type = None
|
|
965
|
+
|
|
966
|
+
# TODO add vdw parameter
|
|
967
|
+
self._metainfo_name_map = {
|
|
968
|
+
'started_at': 'start_time',
|
|
969
|
+
'started_on': 'start_host',
|
|
970
|
+
'started_by': 'start_user',
|
|
971
|
+
'process_id': 'process_id',
|
|
972
|
+
'started_in': 'start_path',
|
|
973
|
+
'ended_at': 'end_time',
|
|
974
|
+
'ran_on': 'end_host',
|
|
975
|
+
'ran_by': 'end_user',
|
|
976
|
+
'stopped_in': 'end_path',
|
|
977
|
+
'version_string:': 'program_version',
|
|
978
|
+
'source_code_revision_number:': 'svn_revision',
|
|
979
|
+
'program_compiled_at': 'program_compilation_datetime',
|
|
980
|
+
'program_compiled_on': 'program_compilation_host',
|
|
981
|
+
'input_file_name': 'input_filename',
|
|
982
|
+
'basis_set_file_name': 'basis_set_filename',
|
|
983
|
+
'geminal_file_name': 'geminal_filename',
|
|
984
|
+
'potential_file_name': 'potential_filename',
|
|
985
|
+
'mm_potential_file_name': 'mm_potential_filename',
|
|
986
|
+
'coordinate_file_name': 'coordinate_filename',
|
|
987
|
+
'preferred_diagonalization_lib.': 'preferred_diagonalization_library',
|
|
988
|
+
'spin_restricted_kohn-sham_(rks)_calculation': 'spin_restriction',
|
|
989
|
+
'multiplicity': 'spin_target_multiplicity',
|
|
990
|
+
'number_of_spin_states': 'number_of_spin_channels',
|
|
991
|
+
'charge': 'total_charge',
|
|
992
|
+
'self-interaction_correction_(sic)': 'self_interaction_correction_method',
|
|
993
|
+
'method': 'quickstep_method',
|
|
994
|
+
'density_cutoff': 'planewave_cutoff',
|
|
995
|
+
'temperature': 'target_temperature',
|
|
996
|
+
'temperature_tolerance': 'target_temperature_tolerance',
|
|
997
|
+
'pressure': 'target_pressure',
|
|
998
|
+
'print_md_information_every': 'print_frequency',
|
|
999
|
+
'potential_form:': 'vdw_name',
|
|
1000
|
+
'bj_damping:': 'bj_damping_name',
|
|
1001
|
+
'cutoff_radius_[bohr]:': 'cutoff_radius',
|
|
1002
|
+
'scaling_factor:': 'scaling_factor',
|
|
1003
|
+
'exp_prefactor_for_damping:': 'damping_factor',
|
|
1004
|
+
's6_scaling_factor:': 's6_scaling_factor',
|
|
1005
|
+
'sr6_scaling_factor:': 'sr6_scaling_factor',
|
|
1006
|
+
's8_scaling_factor:': 's6_scaling_factor',
|
|
1007
|
+
'cutoff_for_cn_calculation:': 'cn_cutoff',
|
|
1008
|
+
'optimization_method': 'method',
|
|
1009
|
+
'total_energy': 'energy',
|
|
1010
|
+
'real_energy_change': 'energy_change',
|
|
1011
|
+
'decrease_in_energy': 'energy_decrease',
|
|
1012
|
+
'conv_limit_for_step_size': 'step_size_convergence_limit',
|
|
1013
|
+
'convergence_in_step_size': 'step_size_convergence',
|
|
1014
|
+
'convergence_in_rms_step_size': 'rms_step_size_convergence',
|
|
1015
|
+
'conv_limit_for_gradients': 'gradient_convergence_limit',
|
|
1016
|
+
'conv_for_gradients': 'max_gradient_convergence',
|
|
1017
|
+
'conv_in_rms_gradients': 'rms_gradient_convergence',
|
|
1018
|
+
'exchange_correlation_energy': 'energy_XC',
|
|
1019
|
+
'electronic_kinetic_energy': 'energy_kinetic_electronic',
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
self._self_interaction_map = {
|
|
1023
|
+
'NO': None,
|
|
1024
|
+
'D SIC': 'SIC_AD',
|
|
1025
|
+
'Explicit Orbital SIC': 'SIC_EXPLICIT_ORBITALS',
|
|
1026
|
+
'SPZ/MAURI SIC': 'SIC_MAURI_SPZ',
|
|
1027
|
+
'US/MAURI SIC': 'SIC_MAURI_US',
|
|
1028
|
+
}
|
|
1029
|
+
self._optimization_method_map = {
|
|
1030
|
+
'CONJUGATE GRADIENTS': 'conjugate gradient',
|
|
1031
|
+
'BFGS': 'bfgs',
|
|
1032
|
+
'L-BFGS': 'bfgs',
|
|
1033
|
+
}
|
|
1034
|
+
self._file_extension_map = {
|
|
1035
|
+
'XYZ': 'xyz',
|
|
1036
|
+
'XMOL': 'xyz',
|
|
1037
|
+
'ATOMIC': 'xyz',
|
|
1038
|
+
'PDB': 'pdb',
|
|
1039
|
+
'DCD': 'dcd',
|
|
1040
|
+
}
|
|
1041
|
+
self._xc_functional_map = {
|
|
1042
|
+
'BLYP': [
|
|
1043
|
+
XCFunctionalProperty('GGA_X_B88'),
|
|
1044
|
+
XCFunctionalProperty('GGA_C_LYP'),
|
|
1045
|
+
],
|
|
1046
|
+
'LDA': [XCFunctionalProperty('LDA_XC_TETER93')],
|
|
1047
|
+
'PADE': [XCFunctionalProperty('LDA_XC_TETER93')],
|
|
1048
|
+
'PBE': [
|
|
1049
|
+
XCFunctionalProperty('GGA_X_PBE'),
|
|
1050
|
+
XCFunctionalProperty('GGA_C_PBE'),
|
|
1051
|
+
],
|
|
1052
|
+
'OLYP': [
|
|
1053
|
+
XCFunctionalProperty('GGA_X_OPTX'),
|
|
1054
|
+
XCFunctionalProperty('GGA_C_LYP'),
|
|
1055
|
+
],
|
|
1056
|
+
'HCTH120': [XCFunctionalProperty('GGA_XC_HCTH_120')],
|
|
1057
|
+
'PBE0': [XCFunctionalProperty('HYB_GGA_XC_PBEH')],
|
|
1058
|
+
'B3LYP': [XCFunctionalProperty('HYB_GGA_XC_B3LYP')],
|
|
1059
|
+
'TPSS': [
|
|
1060
|
+
XCFunctionalProperty('MGGA_X_TPSS'),
|
|
1061
|
+
XCFunctionalProperty('MGGA_C_TPSS'),
|
|
1062
|
+
],
|
|
1063
|
+
}
|
|
1064
|
+
self._ensemble_map = {
|
|
1065
|
+
'NVE': 'NVE',
|
|
1066
|
+
'NVT': 'NVT',
|
|
1067
|
+
'NPT_F': 'NPT',
|
|
1068
|
+
'NPT_I': 'NPT',
|
|
1069
|
+
}
|
|
1070
|
+
# TODO extend map
|
|
1071
|
+
self._vdw_map = {
|
|
1072
|
+
'S. Grimme, JCC 27: 1787 (2006)': 'G06',
|
|
1073
|
+
'S. Grimme et al, JCP 132: 154104 (2010)': 'G10',
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
self._settings = None
|
|
1077
|
+
|
|
1078
|
+
def init_parser(self):
|
|
1079
|
+
self.out_parser.mainfile = self.filepath
|
|
1080
|
+
self.inp_parser.mainfile = None
|
|
1081
|
+
self.pdos_parser.mainfile = None
|
|
1082
|
+
self.traj_parser.mainfile = None
|
|
1083
|
+
self.velocities_parser.mainfile = None
|
|
1084
|
+
self.energy_parser.mainfile = None
|
|
1085
|
+
self.force_parser.mainfile = None
|
|
1086
|
+
self.out_parser.logger = self.logger
|
|
1087
|
+
self.inp_parser.logger = self.logger
|
|
1088
|
+
self.pdos_parser.logger = self.logger
|
|
1089
|
+
self.traj_parser.logger = self.logger
|
|
1090
|
+
self.velocities_parser.logger = self.logger
|
|
1091
|
+
self.energy_parser.logger = self.logger
|
|
1092
|
+
self.force_parser.logger = self.logger
|
|
1093
|
+
self._settings = None
|
|
1094
|
+
self._method = None
|
|
1095
|
+
self._calculation_type = None
|
|
1096
|
+
|
|
1097
|
+
@property
|
|
1098
|
+
def settings(self):
|
|
1099
|
+
if self._settings is None:
|
|
1100
|
+
|
|
1101
|
+
def to_dict(data, repeats=True):
|
|
1102
|
+
data_dict = dict()
|
|
1103
|
+
for key, val in data:
|
|
1104
|
+
name = self._metainfo_name_map.get(key, key)
|
|
1105
|
+
if not repeats and name in data_dict:
|
|
1106
|
+
continue
|
|
1107
|
+
data_dict.setdefault(name, [])
|
|
1108
|
+
data_dict[name].append(val)
|
|
1109
|
+
for key, val in data_dict.items():
|
|
1110
|
+
data_dict[key] = val[0] if len(val) == 1 else val
|
|
1111
|
+
return data_dict
|
|
1112
|
+
|
|
1113
|
+
self._settings = dict()
|
|
1114
|
+
self._settings['dft'] = to_dict(
|
|
1115
|
+
self.out_parser.get(self._calculation_type, {}).get('dft', [])
|
|
1116
|
+
)
|
|
1117
|
+
self._settings['qs'] = to_dict(
|
|
1118
|
+
self.out_parser.get(self._calculation_type, {}).get('qs', [])
|
|
1119
|
+
)
|
|
1120
|
+
self._settings['vdw'] = self.out_parser.get(self._calculation_type, {}).get(
|
|
1121
|
+
'vdw', []
|
|
1122
|
+
)
|
|
1123
|
+
self._settings['dbcsr'] = to_dict(self.out_parser.get('dbcsr', []), False)
|
|
1124
|
+
self._settings['program'] = to_dict(self.out_parser.get('program', []))
|
|
1125
|
+
self._settings['cp2k'] = to_dict(self.out_parser.get('cp2k', []), False)
|
|
1126
|
+
self._settings['global'] = to_dict(self.out_parser.get('global', []), False)
|
|
1127
|
+
self._settings['md'] = to_dict(
|
|
1128
|
+
self.out_parser.get(self._calculation_type, {})
|
|
1129
|
+
.get('scf_parameters', {})
|
|
1130
|
+
.get('md', [])
|
|
1131
|
+
)
|
|
1132
|
+
self._settings['md_setup'] = to_dict(
|
|
1133
|
+
self.out_parser.get(self._calculation_type, {})
|
|
1134
|
+
.get('scf_parameters', {})
|
|
1135
|
+
.get('md_setup', [])
|
|
1136
|
+
)
|
|
1137
|
+
|
|
1138
|
+
return self._settings
|
|
1139
|
+
|
|
1140
|
+
def _normalize_filename(self, filename):
|
|
1141
|
+
if filename.startswith('='):
|
|
1142
|
+
filename = filename[1:]
|
|
1143
|
+
elif re.match(r'./', filename):
|
|
1144
|
+
pass
|
|
1145
|
+
else:
|
|
1146
|
+
project_name = self.inp_parser.get('GLOBAL/PROJECT_NAME')
|
|
1147
|
+
if filename:
|
|
1148
|
+
filename = '%s-%s' % (project_name, filename)
|
|
1149
|
+
else:
|
|
1150
|
+
filename = project_name
|
|
1151
|
+
return filename
|
|
1152
|
+
|
|
1153
|
+
def get_atomic_number(self, element: str) -> Optional[int]:
|
|
1154
|
+
"""Convert the element symbol to its corresponding atomic number.
|
|
1155
|
+
|
|
1156
|
+
Dependencies:
|
|
1157
|
+
- ase.data.atomic_numbers
|
|
1158
|
+
""" # TODO: migrate responsilbity to section normalizer
|
|
1159
|
+
|
|
1160
|
+
if match := re.match(r'([A-Z][a-z]?)', element):
|
|
1161
|
+
return ase.data.atomic_numbers.get(match.group(1), None)
|
|
1162
|
+
return None
|
|
1163
|
+
|
|
1164
|
+
def get_ensemble_type(self, frame):
|
|
1165
|
+
if self.sampling_method != 'molecular_dynamics':
|
|
1166
|
+
return
|
|
1167
|
+
|
|
1168
|
+
if frame == 0:
|
|
1169
|
+
return self.settings['md'].get('ensemble_type', '')
|
|
1170
|
+
else:
|
|
1171
|
+
calculation = self.out_parser.get(self._calculation_type, '')
|
|
1172
|
+
if not calculation:
|
|
1173
|
+
return calculation
|
|
1174
|
+
return calculation.molecular_dynamics.md_step[frame - 1].get(
|
|
1175
|
+
'ensemble_type', ''
|
|
1176
|
+
)
|
|
1177
|
+
|
|
1178
|
+
def get_time_step(self):
|
|
1179
|
+
return self.settings['md'].get('time_step')
|
|
1180
|
+
|
|
1181
|
+
def get_velocities(self, frame):
|
|
1182
|
+
if (
|
|
1183
|
+
self.out_parser.get(self._calculation_type, {}).get('molecular_dynamics')
|
|
1184
|
+
is not None
|
|
1185
|
+
):
|
|
1186
|
+
return
|
|
1187
|
+
|
|
1188
|
+
if self.velocities_parser.mainfile is None:
|
|
1189
|
+
frequency, filename = (
|
|
1190
|
+
self.settings['md'].get('velocities', '0 none').split()
|
|
1191
|
+
)
|
|
1192
|
+
frequency = int(frequency)
|
|
1193
|
+
if frequency == 0:
|
|
1194
|
+
filename = '%s-vel-1.xyz' % self.inp_parser.get('GLOBAL/PROJECT_NAME')
|
|
1195
|
+
frequency = 1
|
|
1196
|
+
|
|
1197
|
+
self.velocities_parser.mainfile = os.path.join(self.maindir, filename)
|
|
1198
|
+
self.velocities_parser.units = resolve_unit(
|
|
1199
|
+
self.inp_parser.get('MOTION/PRINT/VELOCITIES/UNIT', 'bohr*au_t^-1')
|
|
1200
|
+
)
|
|
1201
|
+
self.velocities_parser._frequency = frequency
|
|
1202
|
+
|
|
1203
|
+
if self.get_ensemble_type(frame).lower() == 'REFTRAJ':
|
|
1204
|
+
frame -= 1
|
|
1205
|
+
|
|
1206
|
+
if frame < 0:
|
|
1207
|
+
return
|
|
1208
|
+
|
|
1209
|
+
try:
|
|
1210
|
+
return self.velocities_parser.get_trajectory(frame)
|
|
1211
|
+
except Exception:
|
|
1212
|
+
self.logger.error('Error reading velocities.')
|
|
1213
|
+
|
|
1214
|
+
def get_trajectory(self, frame):
|
|
1215
|
+
trajectory = None
|
|
1216
|
+
|
|
1217
|
+
if frame == 0:
|
|
1218
|
+
coord = self.inp_parser.get('FORCE_EVAL/SUBSYS/COORD/DEFAULT_KEYWORD')
|
|
1219
|
+
units = resolve_unit(
|
|
1220
|
+
self.inp_parser.get('FORCE_EVAL/SUBSYS/COORD/UNIT', 'angstrom')
|
|
1221
|
+
)
|
|
1222
|
+
if coord is None:
|
|
1223
|
+
coord_filename = self.inp_parser.get(
|
|
1224
|
+
'FORCE_EVAL/SUBSYS/TOPOLOGY/COORD_FILE_NAME', ''
|
|
1225
|
+
)
|
|
1226
|
+
self.traj_parser.mainfile = os.path.join(
|
|
1227
|
+
self.maindir, coord_filename.strip()
|
|
1228
|
+
)
|
|
1229
|
+
self.traj_parser.units = units
|
|
1230
|
+
if self.traj_parser.trajectory:
|
|
1231
|
+
result = self.traj_parser.trajectory[0]
|
|
1232
|
+
# reset for output trajectory
|
|
1233
|
+
self.traj_parser.mainfile = None
|
|
1234
|
+
trajectory = result
|
|
1235
|
+
|
|
1236
|
+
else:
|
|
1237
|
+
coord = np.transpose([c.split() for c in coord])
|
|
1238
|
+
positions = np.array(coord[1:4], dtype=float).T * units
|
|
1239
|
+
scaled = 'T' in self.inp_parser.get(
|
|
1240
|
+
'FORCE_EVAL/SUBSYS/COORD/SCALED', 'False'
|
|
1241
|
+
)
|
|
1242
|
+
if scaled:
|
|
1243
|
+
trajectory = Trajectory(labels=coord[0], scaled_positions=positions)
|
|
1244
|
+
else:
|
|
1245
|
+
trajectory = Trajectory(labels=coord[0], positions=positions)
|
|
1246
|
+
|
|
1247
|
+
if trajectory is not None:
|
|
1248
|
+
return trajectory
|
|
1249
|
+
|
|
1250
|
+
if self.traj_parser.mainfile is None:
|
|
1251
|
+
# try to get it from md
|
|
1252
|
+
frequency, filename = (
|
|
1253
|
+
self.settings['md'].get('coordinates', '0 none').split()
|
|
1254
|
+
)
|
|
1255
|
+
frequency = int(frequency)
|
|
1256
|
+
if frequency == 0:
|
|
1257
|
+
filename = self.inp_parser.get(
|
|
1258
|
+
'MOTION/PRINT/TRAJECTORY/FILENAME', ''
|
|
1259
|
+
).strip()
|
|
1260
|
+
filename = self._normalize_filename(filename)
|
|
1261
|
+
traj_format = self.inp_parser.get(
|
|
1262
|
+
'MOTION/PRINT/TRAJECTORY/FORMAT', 'XYZ'
|
|
1263
|
+
).strip()
|
|
1264
|
+
traj_format = self._file_extension_map.get(traj_format, 'xyz')
|
|
1265
|
+
filename = f'{filename}-pos-1.{traj_format}'
|
|
1266
|
+
frequency = 1
|
|
1267
|
+
|
|
1268
|
+
self.traj_parser.mainfile = os.path.join(self.maindir, filename)
|
|
1269
|
+
self.traj_parser.units = resolve_unit(
|
|
1270
|
+
self.inp_parser.get('MOTION/PRINT/TRAJECTORY/UNIT', 'angstrom')
|
|
1271
|
+
)
|
|
1272
|
+
self.traj_parser._frequency = frequency
|
|
1273
|
+
|
|
1274
|
+
if self.get_ensemble_type(frame) == 'REFTRAJ':
|
|
1275
|
+
frame -= 1
|
|
1276
|
+
|
|
1277
|
+
if frame < 0:
|
|
1278
|
+
return
|
|
1279
|
+
|
|
1280
|
+
try:
|
|
1281
|
+
return self.traj_parser.get_trajectory(frame)
|
|
1282
|
+
except Exception:
|
|
1283
|
+
self.logger.error(
|
|
1284
|
+
'Error reading trajectory for the specific frame.',
|
|
1285
|
+
data={'frame': frame},
|
|
1286
|
+
)
|
|
1287
|
+
|
|
1288
|
+
def get_lattice_vectors(self, frame):
|
|
1289
|
+
lattice_vectors = None
|
|
1290
|
+
|
|
1291
|
+
if frame == 0:
|
|
1292
|
+
lattice_vectors = self.out_parser.get('lattice_vectors')
|
|
1293
|
+
if lattice_vectors is None:
|
|
1294
|
+
# get it from input
|
|
1295
|
+
cell = self.inp_parser.get('FORCE_EVAL/SUBSYS/CELL')
|
|
1296
|
+
# is this the unit for cell? how about for angles
|
|
1297
|
+
units = resolve_unit(
|
|
1298
|
+
self.inp_parser.get('FORCE_EVAL/SUBSYS/COORD/UNIT', 'angstrom')
|
|
1299
|
+
)
|
|
1300
|
+
if cell is None:
|
|
1301
|
+
return
|
|
1302
|
+
|
|
1303
|
+
if 'A' in cell and 'B' in cell and 'C' in cell:
|
|
1304
|
+
lattice_vectors = (
|
|
1305
|
+
np.array(
|
|
1306
|
+
[cell.get(c).split() for c in ('A', 'B', 'C')], dtype=float
|
|
1307
|
+
)
|
|
1308
|
+
* units
|
|
1309
|
+
)
|
|
1310
|
+
elif 'ABC' in cell:
|
|
1311
|
+
abc = (
|
|
1312
|
+
(np.array(cell.get('ABC').split(), dtype=float) * units)
|
|
1313
|
+
.to('angstrom')
|
|
1314
|
+
.magnitude
|
|
1315
|
+
)
|
|
1316
|
+
angles = np.array(
|
|
1317
|
+
cell.get('ALPHA_BETA_GAMMA', '90. 90. 90.').split(), dtype=float
|
|
1318
|
+
)
|
|
1319
|
+
lattice_vectors = (
|
|
1320
|
+
ase.geometry.cellpar_to_cell(np.hstack((abc, angles)))
|
|
1321
|
+
* ureg.angstrom
|
|
1322
|
+
)
|
|
1323
|
+
|
|
1324
|
+
else:
|
|
1325
|
+
units = resolve_unit(
|
|
1326
|
+
self.inp_parser.get('FORCE_EVAL/SUBSYS/COORD/UNIT', 'angstrom')
|
|
1327
|
+
)
|
|
1328
|
+
lattice_vectors = (
|
|
1329
|
+
np.array(lattice_vectors[:3], dtype=np.float64) * units
|
|
1330
|
+
)
|
|
1331
|
+
|
|
1332
|
+
if lattice_vectors is not None:
|
|
1333
|
+
return lattice_vectors
|
|
1334
|
+
|
|
1335
|
+
if self.cell_parser.mainfile is None:
|
|
1336
|
+
frequency, filename = (
|
|
1337
|
+
self.settings['md'].get('simulation_cell', '0 none').split()
|
|
1338
|
+
)
|
|
1339
|
+
frequency = int(frequency)
|
|
1340
|
+
if frequency == 0:
|
|
1341
|
+
# TODO test this I cannot find a sample output cell filee
|
|
1342
|
+
filename = self.inp_parser.get('MOTION/PRINT/CELL/FILENAME', '').strip()
|
|
1343
|
+
frequency = 1
|
|
1344
|
+
|
|
1345
|
+
if filename:
|
|
1346
|
+
self.cell_parser.mainfile = os.path.join(self.maindir, filename)
|
|
1347
|
+
self.cell_parser.units = resolve_unit(
|
|
1348
|
+
self.inp_parser.get('MOTION/PRINT/TRAJECTORY/UNIT', 'angstrom')
|
|
1349
|
+
)
|
|
1350
|
+
self.cell_parser._frequency = frequency
|
|
1351
|
+
else:
|
|
1352
|
+
if self.sampling_method == 'molecular_dynamics':
|
|
1353
|
+
# check that this is not an NPT
|
|
1354
|
+
ensemble_type = self.get_ensemble_type(frame)
|
|
1355
|
+
if ensemble_type[:3] == 'NPT':
|
|
1356
|
+
return
|
|
1357
|
+
return self.get_lattice_vectors(0)
|
|
1358
|
+
|
|
1359
|
+
# TODO how does the lattice file looks like during restart
|
|
1360
|
+
frame -= self._step_start - 1
|
|
1361
|
+
|
|
1362
|
+
if self.get_ensemble_type(frame) == 'REFTRAJ':
|
|
1363
|
+
frame -= 1
|
|
1364
|
+
|
|
1365
|
+
if frame % self.cell_parser._frequency != 0 or frame < 0:
|
|
1366
|
+
return
|
|
1367
|
+
|
|
1368
|
+
try:
|
|
1369
|
+
return self.cell_parser.data[
|
|
1370
|
+
frame // self.cell_parser._frequency
|
|
1371
|
+
] * resolve_unit(self.cell_parser.units)
|
|
1372
|
+
except Exception:
|
|
1373
|
+
self.logger.error('Error reading lattice vectors.')
|
|
1374
|
+
|
|
1375
|
+
def get_md_output(self, frame):
|
|
1376
|
+
if self.energy_parser.mainfile is None:
|
|
1377
|
+
frequency, filename = self.settings['md'].get('energies', '0, none').split()
|
|
1378
|
+
frequency = int(frequency)
|
|
1379
|
+
if frequency == 0:
|
|
1380
|
+
return dict()
|
|
1381
|
+
self.energy_parser.mainfile = os.path.join(self.maindir, filename)
|
|
1382
|
+
self.energy_parser._frequency = frequency
|
|
1383
|
+
self.energy_parser._step = (
|
|
1384
|
+
[d[0] for d in self.energy_parser.data]
|
|
1385
|
+
if self.energy_parser.data is not None
|
|
1386
|
+
else []
|
|
1387
|
+
)
|
|
1388
|
+
|
|
1389
|
+
if self.energy_parser.mainfile is None:
|
|
1390
|
+
return dict()
|
|
1391
|
+
|
|
1392
|
+
if self.get_ensemble_type(frame) == 'REFTRAJ':
|
|
1393
|
+
frame -= 1
|
|
1394
|
+
|
|
1395
|
+
if frame < 0:
|
|
1396
|
+
return dict()
|
|
1397
|
+
|
|
1398
|
+
try:
|
|
1399
|
+
data = self.energy_parser.data[self.energy_parser._step.index(frame)]
|
|
1400
|
+
return dict(
|
|
1401
|
+
step=data[0],
|
|
1402
|
+
time=data[1] * ureg.femtosecond,
|
|
1403
|
+
kinetic_energy_instantaneous=data[2] * ureg.hartree,
|
|
1404
|
+
temperature_instantaneous=data[3],
|
|
1405
|
+
potential_energy_instantaneous=data[4] * ureg.hartree,
|
|
1406
|
+
conserved_quantity=data[5] * ureg.hartree,
|
|
1407
|
+
cpu_time_instantaneous=data[6],
|
|
1408
|
+
)
|
|
1409
|
+
|
|
1410
|
+
except Exception:
|
|
1411
|
+
self.logger.error('Error reading MD energies.')
|
|
1412
|
+
return dict()
|
|
1413
|
+
|
|
1414
|
+
def get_forces(self, frame):
|
|
1415
|
+
filename = self.inp_parser.get('FORCE_EVAL/PRINT/FORCES/FILENAME', '').strip()
|
|
1416
|
+
filename = self._normalize_filename(filename)
|
|
1417
|
+
filename = '%s-1_%d.xyz' % (filename, frame)
|
|
1418
|
+
self.force_parser.mainfile = os.path.join(self.maindir, filename)
|
|
1419
|
+
return self.force_parser.get('atom_forces')
|
|
1420
|
+
|
|
1421
|
+
def get_xc_functionals(self):
|
|
1422
|
+
functionals = self.inp_parser.get('FORCE_EVAL/DFT/XC/XC_FUNCTIONAL/VALUE')
|
|
1423
|
+
if functionals is None or functionals == 'NO_SHORTCUT':
|
|
1424
|
+
functional_values = self.inp_parser.get(
|
|
1425
|
+
'FORCE_EVAL/DFT/XC/XC_FUNCTIONAL', {}
|
|
1426
|
+
)
|
|
1427
|
+
functionals = []
|
|
1428
|
+
for name, attrib in functional_values.items():
|
|
1429
|
+
name = name.upper()
|
|
1430
|
+
if name == 'VALUE':
|
|
1431
|
+
continue
|
|
1432
|
+
# get xc_func from mapping then apply read attributes
|
|
1433
|
+
# if func is not in mapping, create it
|
|
1434
|
+
values = self._xc_functional_map.get(name, [XCFunctionalProperty(name)])
|
|
1435
|
+
for n, value in enumerate(values):
|
|
1436
|
+
weight = (
|
|
1437
|
+
attrib.get('SCALE_X', None)
|
|
1438
|
+
if n == 0
|
|
1439
|
+
else attrib.get('SCALE_C', None)
|
|
1440
|
+
)
|
|
1441
|
+
value._data.update({'weight': weight})
|
|
1442
|
+
functionals.extend(values)
|
|
1443
|
+
else:
|
|
1444
|
+
names = [functionals] if not isinstance(functionals, list) else functionals
|
|
1445
|
+
functionals = []
|
|
1446
|
+
for name in names:
|
|
1447
|
+
name = name.upper()
|
|
1448
|
+
if name not in self._xc_functional_map:
|
|
1449
|
+
self.logger.error('Cannot resolve xc functional')
|
|
1450
|
+
continue
|
|
1451
|
+
functionals.extend(self._xc_functional_map.get(name))
|
|
1452
|
+
|
|
1453
|
+
return functionals
|
|
1454
|
+
|
|
1455
|
+
def parse_settings(self):
|
|
1456
|
+
"""
|
|
1457
|
+
Parses the initial settings of the CP2K calculation.
|
|
1458
|
+
"""
|
|
1459
|
+
sec_run = self.archive.run[-1]
|
|
1460
|
+
|
|
1461
|
+
cp2k_settings = self.settings.get('cp2k', {})
|
|
1462
|
+
if cp2k_settings:
|
|
1463
|
+
version = cp2k_settings.get('program_version')
|
|
1464
|
+
host = cp2k_settings.get('program_compilation_host')
|
|
1465
|
+
sec_run.program = Program(
|
|
1466
|
+
name='CP2K',
|
|
1467
|
+
version=version[0] if isinstance(version, list) else version,
|
|
1468
|
+
compilation_host=host[0] if isinstance(host, list) else host,
|
|
1469
|
+
)
|
|
1470
|
+
sec_run.x_cp2k_program_information = cp2k_settings
|
|
1471
|
+
|
|
1472
|
+
dbcsr_settings = self.settings.get('dbcsr', {})
|
|
1473
|
+
sec_run.x_cp2k_dbcsr = dbcsr_settings if dbcsr_settings else None
|
|
1474
|
+
global_settings = self.settings.get('global', {})
|
|
1475
|
+
sec_run.x_cp2k_global_settings = global_settings if global_settings else None
|
|
1476
|
+
|
|
1477
|
+
program_settings = self.settings.get('program', {})
|
|
1478
|
+
if program_settings:
|
|
1479
|
+
sec_startinformation = x_cp2k_section_startinformation()
|
|
1480
|
+
sec_run.x_cp2k_section_startinformation.append(sec_startinformation)
|
|
1481
|
+
sec_endinformation = x_cp2k_section_end_information()
|
|
1482
|
+
sec_run.x_cp2k_section_end_information.append(sec_endinformation)
|
|
1483
|
+
section = sec_startinformation
|
|
1484
|
+
for key, val in program_settings.items():
|
|
1485
|
+
if key == 'process_id':
|
|
1486
|
+
if isinstance(val, list):
|
|
1487
|
+
sec_startinformation.x_cp2k_start_id = val[0]
|
|
1488
|
+
sec_endinformation.x_cp2k_end_id = val[1]
|
|
1489
|
+
elif isinstance(val, int):
|
|
1490
|
+
self.logger.warning(
|
|
1491
|
+
'Calculation may not have properly terminated: did not encounter end "PROCESS ID".'
|
|
1492
|
+
)
|
|
1493
|
+
sec_startinformation.x_cp2k_start_id = val
|
|
1494
|
+
else:
|
|
1495
|
+
self.logger.warning(
|
|
1496
|
+
'Encountered "PROCESS ID" of unexpected format.'
|
|
1497
|
+
)
|
|
1498
|
+
pass
|
|
1499
|
+
continue
|
|
1500
|
+
section = (
|
|
1501
|
+
sec_endinformation
|
|
1502
|
+
if key.startswith('end')
|
|
1503
|
+
else sec_startinformation
|
|
1504
|
+
)
|
|
1505
|
+
val = val[0] if isinstance(val, list) else val
|
|
1506
|
+
section.m_set(section.m_get_quantity_definition(f'x_cp2k_{key}'), val)
|
|
1507
|
+
|
|
1508
|
+
restart = self.out_parser.get('restart')
|
|
1509
|
+
if restart is not None:
|
|
1510
|
+
sec_restart = x_cp2k_section_restart_information()
|
|
1511
|
+
sec_run.x_cp2k_section_restart_information.append(sec_restart)
|
|
1512
|
+
sec_restart.x_cp2k_restart_file_name = restart.get('filename')
|
|
1513
|
+
sec_restart.x_cp2k_restarted_quantity_name = ' '.join(
|
|
1514
|
+
restart.get('quantities')
|
|
1515
|
+
)
|
|
1516
|
+
|
|
1517
|
+
def parse_input(self):
|
|
1518
|
+
"""
|
|
1519
|
+
Parses input file from the settings.
|
|
1520
|
+
"""
|
|
1521
|
+
input_filename = self.settings.get('cp2k', {}).get('input_filename')
|
|
1522
|
+
project_name = self.settings.get('global', {}).get('project_name')
|
|
1523
|
+
if input_filename is None and project_name is None:
|
|
1524
|
+
return
|
|
1525
|
+
|
|
1526
|
+
# TODO is there a convenience function similar to Environment.all_defintions_by_name?
|
|
1527
|
+
definitions = {}
|
|
1528
|
+
for package in [cp2k.m_package, cp2k_general.m_package]:
|
|
1529
|
+
for content in package.m_all_contents():
|
|
1530
|
+
if isinstance(content, Definition):
|
|
1531
|
+
values = definitions.setdefault(content.name, [])
|
|
1532
|
+
values.append(content)
|
|
1533
|
+
|
|
1534
|
+
def override_keyword(name):
|
|
1535
|
+
# override keys to be compatible with metainfo name
|
|
1536
|
+
# TODO change metainfo name
|
|
1537
|
+
if name.endswith('_VALUE'):
|
|
1538
|
+
return name.replace('VALUE', 'SECTION_PARAMETERS')
|
|
1539
|
+
elif name.endswith('KIND_RI_AUX_BASIS'):
|
|
1540
|
+
return name.replace('BASIS', 'BASIS_SET')
|
|
1541
|
+
return name
|
|
1542
|
+
|
|
1543
|
+
def parse(name, data, section):
|
|
1544
|
+
if isinstance(data, InpValue):
|
|
1545
|
+
sec_def = definitions.get(name, [None])[0]
|
|
1546
|
+
if sec_def is not None:
|
|
1547
|
+
sub_section = sec_def.section_cls()
|
|
1548
|
+
sub_section_def = section.m_def.all_sub_sections_by_section.get(
|
|
1549
|
+
sec_def.section_cls.m_def
|
|
1550
|
+
)[0]
|
|
1551
|
+
|
|
1552
|
+
section.m_add_sub_section(sub_section_def, sub_section)
|
|
1553
|
+
for key, val in data.items():
|
|
1554
|
+
parse(f'{name}_{key}', val, sub_section)
|
|
1555
|
+
|
|
1556
|
+
elif isinstance(data, list) and data:
|
|
1557
|
+
for val in data:
|
|
1558
|
+
parse(name, val, section)
|
|
1559
|
+
|
|
1560
|
+
else:
|
|
1561
|
+
name = name.replace('_section', '')
|
|
1562
|
+
name = override_keyword(name)
|
|
1563
|
+
quantity_def = definitions.get(name, [None])[0]
|
|
1564
|
+
if quantity_def is not None:
|
|
1565
|
+
section.m_set(
|
|
1566
|
+
section.m_get_quantity_definition(name),
|
|
1567
|
+
data,
|
|
1568
|
+
)
|
|
1569
|
+
|
|
1570
|
+
input_files = get_files(
|
|
1571
|
+
input_filename, self.filepath, self.mainfile, deep=False
|
|
1572
|
+
)
|
|
1573
|
+
if not input_files:
|
|
1574
|
+
self.logger.warning(
|
|
1575
|
+
'Input *.inp file not found. We will attempt finding the restart file from '
|
|
1576
|
+
'the project_name appending a -1, <project_name>-1.restart.',
|
|
1577
|
+
data={'project_name': project_name},
|
|
1578
|
+
)
|
|
1579
|
+
# Patch to check if the input is .restart and CP2K appended a -1 after the name
|
|
1580
|
+
if project_name:
|
|
1581
|
+
project_filename = f'{project_name}-1.restart'
|
|
1582
|
+
input_files = get_files(
|
|
1583
|
+
project_filename, self.filepath, self.mainfile, deep=False
|
|
1584
|
+
)
|
|
1585
|
+
else:
|
|
1586
|
+
return
|
|
1587
|
+
if len(input_files) > 1:
|
|
1588
|
+
self.logger.warning(
|
|
1589
|
+
f'Multiple input files found. We will parse the first read file.'
|
|
1590
|
+
)
|
|
1591
|
+
self.inp_parser.mainfile = input_files[0]
|
|
1592
|
+
|
|
1593
|
+
parse('x_cp2k_section_input', self.inp_parser.tree, self.archive.run[-1])
|
|
1594
|
+
|
|
1595
|
+
def parse_scc(self, source):
|
|
1596
|
+
sec_run = self.archive.run[-1]
|
|
1597
|
+
if source is None:
|
|
1598
|
+
return
|
|
1599
|
+
time_initial = (
|
|
1600
|
+
sec_run.calculation[-1].time_physical if sec_run.calculation else 0 * ureg.s
|
|
1601
|
+
)
|
|
1602
|
+
sec_scc = Calculation()
|
|
1603
|
+
sec_run.calculation.append(sec_scc)
|
|
1604
|
+
|
|
1605
|
+
sec_energy = Energy()
|
|
1606
|
+
sec_scc.energy = sec_energy
|
|
1607
|
+
if source.get('energy_total') is not None:
|
|
1608
|
+
sec_energy.total = EnergyEntry(value=source.get('energy_total'))
|
|
1609
|
+
if source.get('electronic_kinetic_energy') is not None:
|
|
1610
|
+
sec_energy.kinetic_electronic = EnergyEntry(
|
|
1611
|
+
value=source.get('electronic_kinetic_energy')[-1]
|
|
1612
|
+
)
|
|
1613
|
+
if source.get('exchange_correlation_energy') is not None:
|
|
1614
|
+
sec_energy.xc = EnergyEntry(
|
|
1615
|
+
value=source.get('exchange_correlation_energy')[-1]
|
|
1616
|
+
)
|
|
1617
|
+
if source.get('fermi_energy') is not None:
|
|
1618
|
+
sec_energy.fermi = source.get('fermi_energy')[-1]
|
|
1619
|
+
sec_energy.highest_occupied = source.get('fermi_energy')[-1]
|
|
1620
|
+
|
|
1621
|
+
if source.get('stress_tensor') is not None:
|
|
1622
|
+
sec_stress = Stress()
|
|
1623
|
+
sec_scc.stress = sec_stress
|
|
1624
|
+
sec_stress.total = StressEntry(value=source.get('stress_tensor'))
|
|
1625
|
+
|
|
1626
|
+
# self consistency
|
|
1627
|
+
for iteration in source.get('iteration', []):
|
|
1628
|
+
time_initial = (
|
|
1629
|
+
sec_scc.scf_iteration[-1].time_physical
|
|
1630
|
+
if sec_scc.scf_iteration
|
|
1631
|
+
else time_initial
|
|
1632
|
+
)
|
|
1633
|
+
sec_scf = ScfIteration()
|
|
1634
|
+
sec_scc.scf_iteration.append(sec_scf)
|
|
1635
|
+
sec_scf_energy = Energy()
|
|
1636
|
+
sec_scf.energy = sec_scf_energy
|
|
1637
|
+
for key, val in iteration.items():
|
|
1638
|
+
if val is not None:
|
|
1639
|
+
if key == 'energy_change':
|
|
1640
|
+
sec_scf_energy.change = val
|
|
1641
|
+
elif key.startswith('energy_'):
|
|
1642
|
+
sec_scf_energy.m_add_sub_section(
|
|
1643
|
+
getattr(Energy, key.replace('energy_', '')),
|
|
1644
|
+
EnergyEntry(value=val),
|
|
1645
|
+
)
|
|
1646
|
+
elif key == 'time_calculation':
|
|
1647
|
+
sec_scf.time_calculation = val
|
|
1648
|
+
sec_scf.time_physical = val + time_initial
|
|
1649
|
+
else:
|
|
1650
|
+
sec_scf.m_set(sec_scf.m_get_quantity_definition(key), val)
|
|
1651
|
+
if sec_scc.scf_iteration:
|
|
1652
|
+
sec_scc.time_calculation = sum(
|
|
1653
|
+
[iteration.time_calculation for iteration in sec_scc.scf_iteration]
|
|
1654
|
+
)
|
|
1655
|
+
sec_scc.time_physical = sec_scc.scf_iteration[-1].time_physical
|
|
1656
|
+
|
|
1657
|
+
atom_forces = source.get('atom_forces', self.get_forces(source._frame))
|
|
1658
|
+
if atom_forces is not None:
|
|
1659
|
+
atom_forces = np.array(atom_forces, np.float64) * ureg.hartree / ureg.bohr
|
|
1660
|
+
sec_forces = Forces()
|
|
1661
|
+
sec_scc.forces = sec_forces
|
|
1662
|
+
sec_forces.total = ForcesEntry(value=atom_forces)
|
|
1663
|
+
|
|
1664
|
+
return sec_scc
|
|
1665
|
+
|
|
1666
|
+
def parse_system(self, trajectory):
|
|
1667
|
+
sec_run = self.archive.run[-1]
|
|
1668
|
+
|
|
1669
|
+
trajectory = 0 if trajectory is None else trajectory
|
|
1670
|
+
|
|
1671
|
+
if isinstance(trajectory, int):
|
|
1672
|
+
frame = trajectory
|
|
1673
|
+
trajectory = self.get_trajectory(frame)
|
|
1674
|
+
if trajectory is not None:
|
|
1675
|
+
trajectory._frame = frame
|
|
1676
|
+
if trajectory is None:
|
|
1677
|
+
return
|
|
1678
|
+
|
|
1679
|
+
sec_system = System()
|
|
1680
|
+
sec_run.system.append(sec_system)
|
|
1681
|
+
sec_atoms = Atoms()
|
|
1682
|
+
sec_system.atoms = sec_atoms
|
|
1683
|
+
|
|
1684
|
+
lattice_vectors = self.get_lattice_vectors(trajectory._frame)
|
|
1685
|
+
|
|
1686
|
+
if trajectory.positions is not None:
|
|
1687
|
+
sec_atoms.positions = trajectory.positions
|
|
1688
|
+
elif trajectory.scaled_positions is not None and lattice_vectors is not None:
|
|
1689
|
+
sec_atoms.positions = np.dot(trajectory.scaled_positions, lattice_vectors)
|
|
1690
|
+
|
|
1691
|
+
labels = (
|
|
1692
|
+
trajectory.labels
|
|
1693
|
+
if trajectory.labels is not None
|
|
1694
|
+
else self.out_parser.get(self._calculation_type).get('atomic_coordinates')
|
|
1695
|
+
)
|
|
1696
|
+
if labels is not None:
|
|
1697
|
+
sec_atoms.labels = labels
|
|
1698
|
+
|
|
1699
|
+
if lattice_vectors is not None:
|
|
1700
|
+
sec_atoms.lattice_vectors = lattice_vectors
|
|
1701
|
+
periodic = self.inp_parser.get(
|
|
1702
|
+
'FORCE_EVAL/SUBSYS/CELL/PERIODIC', 'xyz'
|
|
1703
|
+
).lower()
|
|
1704
|
+
sec_atoms.periodic = [v in periodic for v in ('x', 'y', 'z')]
|
|
1705
|
+
|
|
1706
|
+
# TODO test this I cannot find an example
|
|
1707
|
+
# velocities
|
|
1708
|
+
if self.sampling_method == 'molecular_dynamics':
|
|
1709
|
+
velocities = self.get_velocities(trajectory._frame)
|
|
1710
|
+
if velocities is not None:
|
|
1711
|
+
sec_atoms.velocities = velocities
|
|
1712
|
+
|
|
1713
|
+
return sec_system
|
|
1714
|
+
|
|
1715
|
+
def parse_dos(self, scc: Calculation, pdos_files: list[str]):
|
|
1716
|
+
"""Parses the projected DOS by resolving the histogram from the *.pdos files, and
|
|
1717
|
+
convoluting this data with a Gaussian distribution function.
|
|
1718
|
+
|
|
1719
|
+
Args:
|
|
1720
|
+
scc (Calculation): section calculation where the Dos is stored.
|
|
1721
|
+
pdos_files: list of *.pdos files with iteration step coinciding with the
|
|
1722
|
+
last converged SinglePoint calculation.
|
|
1723
|
+
"""
|
|
1724
|
+
# Parsing DOS and PDOS if .pdos files are present.
|
|
1725
|
+
if not pdos_files:
|
|
1726
|
+
return
|
|
1727
|
+
|
|
1728
|
+
def _gaussian_convolution_pdos(
|
|
1729
|
+
data: np.ndarray, width: float, delta_energy: float
|
|
1730
|
+
):
|
|
1731
|
+
"""Convolutes / smoothes the histogram data with a Gaussian distribution function as defined
|
|
1732
|
+
in scipy.stats.norm. The mesh of energies is also expanded (with delta_energy in eV)
|
|
1733
|
+
to resolve better the Gaussians.
|
|
1734
|
+
|
|
1735
|
+
Args:
|
|
1736
|
+
data (np.array): array containing the data read from the pdos file. Dimensions are (n_energies, n_columns)
|
|
1737
|
+
width (float): standard deviation or width of the Gaussian distribution.
|
|
1738
|
+
delta_energy (float): the spacing of the new energies mesh.
|
|
1739
|
+
|
|
1740
|
+
Returns:
|
|
1741
|
+
new_energies, convoluted_pdos: returns the new X and Y data for the convoluted PDOS.
|
|
1742
|
+
"""
|
|
1743
|
+
energies_eV = data[:, 1] * 27.211 # in eV
|
|
1744
|
+
orbital_contributions = data[:, 3:]
|
|
1745
|
+
|
|
1746
|
+
energy_min = np.min(energies_eV) - 2 * width
|
|
1747
|
+
energy_max = np.max(energies_eV) + 2 * width
|
|
1748
|
+
new_energies = np.arange(energy_min, energy_max, delta_energy)
|
|
1749
|
+
|
|
1750
|
+
n_orbitals = orbital_contributions.shape[1]
|
|
1751
|
+
|
|
1752
|
+
gaussian = norm(loc=0, scale=width)
|
|
1753
|
+
|
|
1754
|
+
convoluted_pdos = np.zeros((len(new_energies), n_orbitals))
|
|
1755
|
+
for i, new_energy in enumerate(new_energies):
|
|
1756
|
+
for j in range(n_orbitals):
|
|
1757
|
+
convoluted_pdos[i, j] = np.sum(
|
|
1758
|
+
orbital_contributions[:, j]
|
|
1759
|
+
* gaussian.pdf(new_energy - energies_eV)
|
|
1760
|
+
)
|
|
1761
|
+
return new_energies, np.transpose(convoluted_pdos)
|
|
1762
|
+
|
|
1763
|
+
# Unrestricted Kohn-Sham (spin-polarized) calculation
|
|
1764
|
+
n_spin_channels = 2 if self.out_parser.get('spin_polarized') == 'UKS' else 1
|
|
1765
|
+
# We resolve the number of atom parameters (or kinds) to check if they match the number of PDOS files
|
|
1766
|
+
if self.archive.m_xpath('run[-1].method[-1].atom_parameters') is None:
|
|
1767
|
+
self.logger.warning(
|
|
1768
|
+
'Could not extract the number of atom kinds from method.'
|
|
1769
|
+
)
|
|
1770
|
+
return
|
|
1771
|
+
n_atom_params = len(self.archive.run[-1].method[-1].atom_parameters)
|
|
1772
|
+
|
|
1773
|
+
# We sort in case the name has an implicit order (e.g. for different spin channels)
|
|
1774
|
+
pdos_files.sort()
|
|
1775
|
+
atoms = []
|
|
1776
|
+
for f in pdos_files:
|
|
1777
|
+
self.pdos_parser.mainfile = f
|
|
1778
|
+
atom_kind = self.pdos_parser.get('atom_kind')
|
|
1779
|
+
atoms.append(atom_kind)
|
|
1780
|
+
# This stores a list of tuples ordered depending on the atom_kind label. Useful
|
|
1781
|
+
# when dealing with spin-polarized calculations
|
|
1782
|
+
atom_kind_in_files_sorted = sorted(
|
|
1783
|
+
list(zip(pdos_files, atoms)), key=lambda x: x[1]
|
|
1784
|
+
)
|
|
1785
|
+
if (
|
|
1786
|
+
len(atom_kind_in_files_sorted) != (n_spin_channels * n_atom_params)
|
|
1787
|
+
and n_spin_channels == 2
|
|
1788
|
+
):
|
|
1789
|
+
self.logger.warning(
|
|
1790
|
+
'The number of PDOS files does not match the number of spin channels '
|
|
1791
|
+
'times the number of atom parameters. We cannot parse the PDOS.'
|
|
1792
|
+
)
|
|
1793
|
+
return
|
|
1794
|
+
|
|
1795
|
+
dos = (
|
|
1796
|
+
[Dos(spin_channel=0), Dos(spin_channel=1)]
|
|
1797
|
+
if n_spin_channels == 2
|
|
1798
|
+
else [Dos()]
|
|
1799
|
+
)
|
|
1800
|
+
|
|
1801
|
+
for index, (f, atom_kind) in enumerate(atom_kind_in_files_sorted):
|
|
1802
|
+
self.pdos_parser.mainfile = f
|
|
1803
|
+
if self.pdos_parser.data is None:
|
|
1804
|
+
self.logger.warning('Could not read the data from the *.pdos files.')
|
|
1805
|
+
break
|
|
1806
|
+
data = self.pdos_parser.data
|
|
1807
|
+
|
|
1808
|
+
# We assume alternate ordering depending on the spin channel
|
|
1809
|
+
sec_dos = dos[0] if index % 2 == 0 else dos[-1]
|
|
1810
|
+
|
|
1811
|
+
# We use the (updated 2017 Tiziano Müller) script provided by CP2K developers to resolve the
|
|
1812
|
+
# PDOS by convoluting the histogram stored in the .pdos files.
|
|
1813
|
+
# TODO implement a more automatic way of defining width if possible.
|
|
1814
|
+
width = 0.5 # in eV
|
|
1815
|
+
delta_energy = 0.01 # in eV
|
|
1816
|
+
convoluted_energies, convoluted_pdos = _gaussian_convolution_pdos(
|
|
1817
|
+
data, width, delta_energy
|
|
1818
|
+
)
|
|
1819
|
+
|
|
1820
|
+
# Setting up constant quantities independent of the pdos file and common for
|
|
1821
|
+
# the same spin channel files.
|
|
1822
|
+
data = np.transpose(data)
|
|
1823
|
+
if index == 0 or index == 1:
|
|
1824
|
+
sec_dos.n_energies = len(convoluted_energies)
|
|
1825
|
+
sec_dos.energies = convoluted_energies * ureg.eV
|
|
1826
|
+
try:
|
|
1827
|
+
homo_index = np.where(np.isclose(np.diff(data[2]), -1, atol=1e-1))[
|
|
1828
|
+
0
|
|
1829
|
+
][0]
|
|
1830
|
+
homo = data[1][homo_index]
|
|
1831
|
+
sec_dos.energy_fermi = homo * ureg.hartree
|
|
1832
|
+
scc.energy = Energy(fermi=homo * ureg.hartree)
|
|
1833
|
+
except Exception:
|
|
1834
|
+
pass
|
|
1835
|
+
|
|
1836
|
+
orbital_histogram = data[3:]
|
|
1837
|
+
atom_label = re.sub(r'\d', '', atom_kind)
|
|
1838
|
+
atom_index = re.sub(r'[a-zA-Z]', '', atom_kind)
|
|
1839
|
+
if self.pdos_parser.get('orbitals', []) is not None:
|
|
1840
|
+
orbital_labels = self.pdos_parser.get('orbitals', [])
|
|
1841
|
+
sec_dos_histogram = x_cp2k_pdos_histogram()
|
|
1842
|
+
scc.x_cp2k_pdos.append(sec_dos_histogram)
|
|
1843
|
+
sec_dos_histogram.x_cp2k_pdos_histogram_energies = (
|
|
1844
|
+
data[1] * ureg.hartree
|
|
1845
|
+
)
|
|
1846
|
+
sec_dos_histogram.x_cp2k_pdos_histogram_values = orbital_histogram
|
|
1847
|
+
sec_dos_histogram.x_cp2k_pdos_histogram_atom_label = atom_label
|
|
1848
|
+
sec_dos_histogram.x_cp2k_pdos_histogram_atom_index = (
|
|
1849
|
+
atom_index if atom_index else None
|
|
1850
|
+
)
|
|
1851
|
+
sec_dos_histogram.x_cp2k_pdos_histogram_orbital = orbital_labels
|
|
1852
|
+
sec_dos_histogram.x_cp2k_gaussian_width = width * ureg.eV
|
|
1853
|
+
sec_dos_histogram.x_cp2k_gaussian_delta_energy = delta_energy * ureg.eV
|
|
1854
|
+
for i, conv_pdos in enumerate(convoluted_pdos):
|
|
1855
|
+
sec_dos_orbital = DosValues()
|
|
1856
|
+
sec_dos.orbital_projected.append(sec_dos_orbital)
|
|
1857
|
+
sec_dos_orbital.value = conv_pdos / ureg.eV
|
|
1858
|
+
sec_dos_orbital.atom_label = atom_label
|
|
1859
|
+
sec_dos_orbital.atom_index = atom_index if atom_index else None
|
|
1860
|
+
sec_dos_orbital.orbital = orbital_labels[i]
|
|
1861
|
+
|
|
1862
|
+
self.logger.warning(
|
|
1863
|
+
f'We are convoluting the reported .pdos histogram with a Gaussian '
|
|
1864
|
+
f'distribution function (as defined in scipy.stats.norm).'
|
|
1865
|
+
)
|
|
1866
|
+
scc.dos_electronic = dos
|
|
1867
|
+
|
|
1868
|
+
def parse_configurations_quickstep(self):
|
|
1869
|
+
sec_run = self.archive.run[-1]
|
|
1870
|
+
quickstep = self.out_parser.get(self._calculation_type)
|
|
1871
|
+
|
|
1872
|
+
def parse_md_step(source):
|
|
1873
|
+
md_output = self.get_md_output(source._frame)
|
|
1874
|
+
md_output = md_output if md_output else source
|
|
1875
|
+
calc = sec_run.calculation[-1]
|
|
1876
|
+
|
|
1877
|
+
# Store to common metainfo
|
|
1878
|
+
energy_kinetic = md_output.get('kinetic_energy_instantaneous')
|
|
1879
|
+
if energy_kinetic:
|
|
1880
|
+
calc.energy.kinetic = EnergyEntry(value=energy_kinetic.to('joule'))
|
|
1881
|
+
potential_energy = md_output.get('potential_energy_instantaneous')
|
|
1882
|
+
if potential_energy:
|
|
1883
|
+
calc.energy.potential = EnergyEntry(value=potential_energy.to('joule'))
|
|
1884
|
+
step = md_output.get('step')
|
|
1885
|
+
if step:
|
|
1886
|
+
calc.step = int(step)
|
|
1887
|
+
time = md_output.get('time')
|
|
1888
|
+
if time:
|
|
1889
|
+
calc.time = time.to('second')
|
|
1890
|
+
volume = md_output.get('volume_instantaneous')
|
|
1891
|
+
if volume:
|
|
1892
|
+
calc.volume = volume.to('m**3')
|
|
1893
|
+
pressure = md_output.get('pressure_instantaneous')
|
|
1894
|
+
if pressure:
|
|
1895
|
+
calc.pressure = pressure.to('m**3')
|
|
1896
|
+
temperature = md_output.get('temperature_instantaneous')
|
|
1897
|
+
if temperature:
|
|
1898
|
+
calc.temperature = temperature
|
|
1899
|
+
|
|
1900
|
+
def parse_calculations(calculations):
|
|
1901
|
+
for n, calculation in enumerate(calculations):
|
|
1902
|
+
if calculation is None:
|
|
1903
|
+
continue
|
|
1904
|
+
|
|
1905
|
+
self_consistent = calculation.get('self_consistent', [])
|
|
1906
|
+
self_consistent = (
|
|
1907
|
+
[self_consistent]
|
|
1908
|
+
if not isinstance(self_consistent, list)
|
|
1909
|
+
else self_consistent
|
|
1910
|
+
)
|
|
1911
|
+
|
|
1912
|
+
# write only the last one to scc
|
|
1913
|
+
scf = self_consistent[-1] if self_consistent else calculation
|
|
1914
|
+
frame = calculation.get('step', n)
|
|
1915
|
+
scf._frame = frame
|
|
1916
|
+
sec_scc = self.parse_scc(scf)
|
|
1917
|
+
md = self.sampling_method == 'molecular_dynamics'
|
|
1918
|
+
if md:
|
|
1919
|
+
calculation._frame = frame
|
|
1920
|
+
parse_md_step(calculation)
|
|
1921
|
+
|
|
1922
|
+
if frame == 0:
|
|
1923
|
+
atomic_coord = quickstep.get('atomic_coordinates')
|
|
1924
|
+
if atomic_coord is not None:
|
|
1925
|
+
atomic_coord._frame = 0
|
|
1926
|
+
sec_system = self.parse_system(atomic_coord)
|
|
1927
|
+
else:
|
|
1928
|
+
sec_system = self.parse_system(frame)
|
|
1929
|
+
# Patch when dealing with GeometryOptimizations which have missing iteration frames
|
|
1930
|
+
if sec_system is None and n == len(calculations) - 1:
|
|
1931
|
+
self.logger.warning(
|
|
1932
|
+
'Could not parse system information for the last frame. '
|
|
1933
|
+
'We will attempt to parse the system information from (frame + 1).',
|
|
1934
|
+
data={'frame': frame},
|
|
1935
|
+
)
|
|
1936
|
+
sec_system = self.parse_system(frame + 1)
|
|
1937
|
+
if sec_system:
|
|
1938
|
+
sec_scc.system_ref = sec_system
|
|
1939
|
+
if self.archive.run[-1].method:
|
|
1940
|
+
sec_scc.method_ref = self.archive.run[-1].method[-1]
|
|
1941
|
+
|
|
1942
|
+
def get_pdos_files(n_optimization_steps: int):
|
|
1943
|
+
"""Reads the number of calculations and the pdos_files iteration integer, and
|
|
1944
|
+
return only the files coinciding with the SinglePoint calculation.
|
|
1945
|
+
|
|
1946
|
+
Args:
|
|
1947
|
+
n_optimization_steps (int): number of optimization steps.
|
|
1948
|
+
|
|
1949
|
+
Returns:
|
|
1950
|
+
pdos_files: list of *.pdos files with iteration step coinciding with the
|
|
1951
|
+
last converged SinglePoint calculation.
|
|
1952
|
+
"""
|
|
1953
|
+
pdos_files = get_files('*.pdos', self.filepath, self.mainfile)
|
|
1954
|
+
if pdos_files is not None:
|
|
1955
|
+
for i, file in enumerate(pdos_files):
|
|
1956
|
+
self.pdos_parser.mainfile = file
|
|
1957
|
+
iter_step = self.pdos_parser.get(
|
|
1958
|
+
'iter', n_optimization_steps
|
|
1959
|
+
) # added default to match ADD_LAST = NO
|
|
1960
|
+
if iter_step != n_optimization_steps:
|
|
1961
|
+
pdos_files.pop(i)
|
|
1962
|
+
return pdos_files
|
|
1963
|
+
|
|
1964
|
+
if (
|
|
1965
|
+
geometry_optimization := quickstep.get('geometry_optimization')
|
|
1966
|
+
) is not None:
|
|
1967
|
+
optimization_steps = geometry_optimization.get('optimization_step', [])
|
|
1968
|
+
# final scf
|
|
1969
|
+
single_point = quickstep.get('single_point')
|
|
1970
|
+
calculations = [geometry_optimization] + optimization_steps + [single_point]
|
|
1971
|
+
parse_calculations(calculations)
|
|
1972
|
+
# PDOS parsing
|
|
1973
|
+
if single_point and sec_run.calculation is not None:
|
|
1974
|
+
# The length of optimization_steps might differ from the real number of steps if
|
|
1975
|
+
# the run stopped and was reran.
|
|
1976
|
+
if optimization_steps is not None:
|
|
1977
|
+
n_optimization_steps = optimization_steps[-1].step
|
|
1978
|
+
if n_optimization_steps != len(optimization_steps):
|
|
1979
|
+
self.logger.warning(
|
|
1980
|
+
'The length of optimization steps sections in the *.out file, does '
|
|
1981
|
+
'not coincide with the last parsed optimization step number.',
|
|
1982
|
+
data={
|
|
1983
|
+
'length optimization_steps': len(optimization_steps),
|
|
1984
|
+
'last optimization step': n_optimization_steps,
|
|
1985
|
+
},
|
|
1986
|
+
)
|
|
1987
|
+
pdos_files = get_pdos_files(n_optimization_steps)
|
|
1988
|
+
self.parse_dos(sec_run.calculation[-1], pdos_files)
|
|
1989
|
+
elif (molecular_dynamics := quickstep.get('molecular_dynamics')) is not None:
|
|
1990
|
+
# initial self consistent
|
|
1991
|
+
single_point = quickstep.get('single_point')
|
|
1992
|
+
# md steps
|
|
1993
|
+
calculations = [single_point] + molecular_dynamics.get('md_step', [])
|
|
1994
|
+
parse_calculations(calculations)
|
|
1995
|
+
# PDOS parsing
|
|
1996
|
+
if single_point and sec_run.calculation is not None:
|
|
1997
|
+
pdos_files = get_pdos_files(0)
|
|
1998
|
+
self.parse_dos(sec_run.calculation[0], pdos_files)
|
|
1999
|
+
elif (single_point := quickstep.get('single_point')) is not None:
|
|
2000
|
+
atomic_coord = quickstep.get('atomic_coordinates')
|
|
2001
|
+
if atomic_coord is not None:
|
|
2002
|
+
atomic_coord._frame = 0
|
|
2003
|
+
else:
|
|
2004
|
+
self.logger.warning(
|
|
2005
|
+
'Could not parse system information for the SinglePoint calculation.'
|
|
2006
|
+
)
|
|
2007
|
+
parse_calculations([single_point])
|
|
2008
|
+
# PDOS parsing
|
|
2009
|
+
pdos_files = get_pdos_files(0)
|
|
2010
|
+
self.parse_dos(sec_run.calculation[-1], pdos_files)
|
|
2011
|
+
|
|
2012
|
+
def _parse_basis_set(self) -> list[BasisSet]:
|
|
2013
|
+
"""Scopes are based on https://10.1016/j.cpc.2004.12.014"""
|
|
2014
|
+
bs_gauss = BasisSet(
|
|
2015
|
+
scope=['kinetic energy', 'electron-core interaction'],
|
|
2016
|
+
type='gaussians',
|
|
2017
|
+
) # TODO: review partition in new parser
|
|
2018
|
+
atoms = (
|
|
2019
|
+
self.out_parser.get(self._calculation_type, {})
|
|
2020
|
+
.get('atomic_kind_information', {})
|
|
2021
|
+
.get('atom', [])
|
|
2022
|
+
)
|
|
2023
|
+
for atom in atoms:
|
|
2024
|
+
basis_set = atom.get('kind_basis_set_name', None)
|
|
2025
|
+
if basis_set is not None:
|
|
2026
|
+
ac = BasisSetAtomCentered()
|
|
2027
|
+
ac.atom_number = self.get_atomic_number(atom.kind_label)
|
|
2028
|
+
ac.name = basis_set
|
|
2029
|
+
bs_gauss.atom_centered.append(ac)
|
|
2030
|
+
|
|
2031
|
+
basis_sets: list[BasisSet] = []
|
|
2032
|
+
if bs_gauss.atom_centered:
|
|
2033
|
+
basis_sets.append(bs_gauss)
|
|
2034
|
+
pw_scope = ['Hartree energy', 'electron-electron interaction']
|
|
2035
|
+
else:
|
|
2036
|
+
pw_scope = ['valence']
|
|
2037
|
+
|
|
2038
|
+
bs_pw = BasisSet(
|
|
2039
|
+
scope=pw_scope,
|
|
2040
|
+
type='plane waves',
|
|
2041
|
+
)
|
|
2042
|
+
if (cutoff := self.settings.get('qs', {}).get('planewave_cutoff')) is not None:
|
|
2043
|
+
bs_pw.cutoff = cutoff * ureg.hartree
|
|
2044
|
+
basis_sets.append(bs_pw)
|
|
2045
|
+
return basis_sets
|
|
2046
|
+
|
|
2047
|
+
def parse_method_quickstep(self):
|
|
2048
|
+
sec_run = self.archive.run[-1]
|
|
2049
|
+
sec_method = Method()
|
|
2050
|
+
sec_run.method.append(sec_method)
|
|
2051
|
+
|
|
2052
|
+
sec_method.electrons_representation = [
|
|
2053
|
+
BasisSetContainer(
|
|
2054
|
+
type='gaussians + plane waves',
|
|
2055
|
+
scope=['wavefunction'],
|
|
2056
|
+
basis_set=self._parse_basis_set(),
|
|
2057
|
+
)
|
|
2058
|
+
]
|
|
2059
|
+
quickstep = self.out_parser.get(self._calculation_type, sec_method)
|
|
2060
|
+
|
|
2061
|
+
sec_dft = DFT()
|
|
2062
|
+
sec_method.dft = sec_dft
|
|
2063
|
+
# electronic structure method
|
|
2064
|
+
# TODO include methods
|
|
2065
|
+
if quickstep.get('dft') is not None:
|
|
2066
|
+
sec_method.electronic = Electronic(method='DFT')
|
|
2067
|
+
elif quickstep.get('dft_u') is not None:
|
|
2068
|
+
sec_method.electronic = Electronic(method='DFT+U')
|
|
2069
|
+
elif quickstep.get('mp2') is not None:
|
|
2070
|
+
sec_method.electronic = Electronic(method='MP2')
|
|
2071
|
+
elif quickstep.get('rpa') is not None:
|
|
2072
|
+
sec_method.electronic = Electronic(method='RPA')
|
|
2073
|
+
|
|
2074
|
+
# xc functionals
|
|
2075
|
+
sec_xc_functional = XCFunctional()
|
|
2076
|
+
sec_dft.xc_functional = sec_xc_functional
|
|
2077
|
+
for functional in self.get_xc_functionals():
|
|
2078
|
+
if '_X_' in functional.name:
|
|
2079
|
+
sec_xc_functional.exchange.append(
|
|
2080
|
+
Functional(name=functional.name, weight=functional.weight)
|
|
2081
|
+
)
|
|
2082
|
+
elif '_C_' in functional.name:
|
|
2083
|
+
sec_xc_functional.correlation.append(
|
|
2084
|
+
Functional(name=functional.name, weight=functional.weight)
|
|
2085
|
+
)
|
|
2086
|
+
else:
|
|
2087
|
+
sec_xc_functional.contributions.append(
|
|
2088
|
+
Functional(name=functional.name, weight=functional.weight)
|
|
2089
|
+
)
|
|
2090
|
+
|
|
2091
|
+
# van der Waals settings
|
|
2092
|
+
vdw = self.settings['vdw']
|
|
2093
|
+
if vdw:
|
|
2094
|
+
# TODO include vdw parameters
|
|
2095
|
+
for val in vdw:
|
|
2096
|
+
if (vdw_name := self._vdw_map.get(val)) is not None:
|
|
2097
|
+
sec_method.van_der_waals_method = vdw_name
|
|
2098
|
+
|
|
2099
|
+
stress_method = self.inp_parser.get('FORCE_EVAL/STRESS_TENSOR')
|
|
2100
|
+
if stress_method is not None:
|
|
2101
|
+
sec_method.stress_tensor_method = stress_method.replace('_', ' ').title()
|
|
2102
|
+
|
|
2103
|
+
sec_quickstep_settings = x_cp2k_section_quickstep_settings()
|
|
2104
|
+
sec_method.x_cp2k_section_quickstep_settings.append(sec_quickstep_settings)
|
|
2105
|
+
dft_settings = self.settings.get('dft', {})
|
|
2106
|
+
if dft_settings:
|
|
2107
|
+
sec_dft.x_cp2k_quickstep_settings = dft_settings
|
|
2108
|
+
si_correction = dft_settings.get('self_interaction_correction_method')
|
|
2109
|
+
if si_correction:
|
|
2110
|
+
val = self._self_interaction_map.get(si_correction)
|
|
2111
|
+
sec_dft.self_interaction_correction_method = val
|
|
2112
|
+
if self.settings['qs']:
|
|
2113
|
+
for key, val in self.settings['qs'].items():
|
|
2114
|
+
sec_quickstep_settings.m_set(
|
|
2115
|
+
sec_quickstep_settings.m_get_quantity_definition(f'x_cp2k_{key}'),
|
|
2116
|
+
val,
|
|
2117
|
+
)
|
|
2118
|
+
|
|
2119
|
+
atomic_kind_info = quickstep.get('atomic_kind_information', None)
|
|
2120
|
+
if atomic_kind_info is not None:
|
|
2121
|
+
sec_atom_kinds = x_cp2k_section_atomic_kinds()
|
|
2122
|
+
sec_quickstep_settings.x_cp2k_section_atomic_kinds.append(sec_atom_kinds)
|
|
2123
|
+
for atom in atomic_kind_info.get('atom', []):
|
|
2124
|
+
# why necessary to make a separate section
|
|
2125
|
+
sec_atom_kind = x_cp2k_section_atomic_kind()
|
|
2126
|
+
sec_atom_kinds.x_cp2k_section_atomic_kind.append(sec_atom_kind)
|
|
2127
|
+
sec_kind_basis_set = x_cp2k_section_kind_basis_set()
|
|
2128
|
+
sec_atom_kind.x_cp2k_section_kind_basis_set.append(sec_kind_basis_set)
|
|
2129
|
+
for key, val in atom.items():
|
|
2130
|
+
if val is None:
|
|
2131
|
+
continue
|
|
2132
|
+
if key in ['kind_label', 'kind_number_of_atoms']:
|
|
2133
|
+
sec_atom_kind.m_set(
|
|
2134
|
+
sec_atom_kind.m_get_quantity_definition(f'x_cp2k_{key}'),
|
|
2135
|
+
str(val),
|
|
2136
|
+
)
|
|
2137
|
+
else:
|
|
2138
|
+
sec_kind_basis_set.m_set(
|
|
2139
|
+
sec_kind_basis_set.m_get_quantity_definition(
|
|
2140
|
+
f'x_cp2k_{key}'
|
|
2141
|
+
),
|
|
2142
|
+
val,
|
|
2143
|
+
)
|
|
2144
|
+
|
|
2145
|
+
sec_method_atom_kind = AtomParameters()
|
|
2146
|
+
sec_method.atom_parameters.append(sec_method_atom_kind)
|
|
2147
|
+
atom_kind_label = re.sub(r'\d', '', atom.kind_label)
|
|
2148
|
+
sec_method_atom_kind.label = atom_kind_label
|
|
2149
|
+
sec_method_atom_kind.atom_number = self.get_atomic_number(
|
|
2150
|
+
atom_kind_label
|
|
2151
|
+
)
|
|
2152
|
+
|
|
2153
|
+
total_maximum_numbers = quickstep.get('total_maximum_numbers', None)
|
|
2154
|
+
if total_maximum_numbers is not None:
|
|
2155
|
+
sec_total = x_cp2k_section_total_numbers()
|
|
2156
|
+
sec_quickstep_settings.x_cp2k_section_total_numbers.append(sec_total)
|
|
2157
|
+
sec_maximum = x_cp2k_section_maximum_angular_momentum()
|
|
2158
|
+
sec_quickstep_settings.x_cp2k_section_maximum_angular_momentum.append(
|
|
2159
|
+
sec_maximum
|
|
2160
|
+
)
|
|
2161
|
+
for key, val in total_maximum_numbers.items():
|
|
2162
|
+
if val is None:
|
|
2163
|
+
continue
|
|
2164
|
+
if key in [
|
|
2165
|
+
'orbital_basis_functions',
|
|
2166
|
+
'local_part_of_gth_pseudopotential',
|
|
2167
|
+
'non_local_part_of_gth_pseudopotential',
|
|
2168
|
+
]:
|
|
2169
|
+
sec_maximum.m_set(
|
|
2170
|
+
sec_maximum.m_get_quantity_definition(f'x_cp2k_{key}'), val
|
|
2171
|
+
)
|
|
2172
|
+
else:
|
|
2173
|
+
sec_total.m_set(
|
|
2174
|
+
sec_total.m_get_quantity_definition(f'x_cp2k_{key}'), val
|
|
2175
|
+
)
|
|
2176
|
+
|
|
2177
|
+
sec_scf = Scf()
|
|
2178
|
+
sec_method.scf = sec_scf
|
|
2179
|
+
scf_parameters = quickstep.get('scf_parameters', None)
|
|
2180
|
+
if scf_parameters is not None:
|
|
2181
|
+
for key, val in scf_parameters.items():
|
|
2182
|
+
if val is None:
|
|
2183
|
+
continue
|
|
2184
|
+
if key == 'md':
|
|
2185
|
+
continue
|
|
2186
|
+
sec_scf.m_set(sec_scf.m_get_quantity_definition(key), val)
|
|
2187
|
+
|
|
2188
|
+
@property
|
|
2189
|
+
def sampling_method(self):
|
|
2190
|
+
if self._method is None:
|
|
2191
|
+
quickstep = self.out_parser.get(self._calculation_type, {})
|
|
2192
|
+
for method in [
|
|
2193
|
+
'single_point',
|
|
2194
|
+
'geometry_optimization',
|
|
2195
|
+
'molecular_dynamics',
|
|
2196
|
+
]:
|
|
2197
|
+
if quickstep.get(method) is not None:
|
|
2198
|
+
self._method = method
|
|
2199
|
+
return self._method
|
|
2200
|
+
|
|
2201
|
+
def parse_workflow(self):
|
|
2202
|
+
# TODO add vdW
|
|
2203
|
+
workflow = SinglePoint()
|
|
2204
|
+
|
|
2205
|
+
if self.sampling_method == 'geometry_optimization':
|
|
2206
|
+
workflow = GeometryOptimization(method=GeometryOptimizationMethod())
|
|
2207
|
+
optimization = self.out_parser.get(
|
|
2208
|
+
self._calculation_type
|
|
2209
|
+
).geometry_optimization
|
|
2210
|
+
if optimization.method is not None:
|
|
2211
|
+
method = self._optimization_method_map.get(optimization.method, '')
|
|
2212
|
+
if not method:
|
|
2213
|
+
self.logger.error('Cannot resolve optimization method.')
|
|
2214
|
+
workflow.method.method = method
|
|
2215
|
+
sec_geometry_opt = x_cp2k_section_geometry_optimization()
|
|
2216
|
+
workflow.x_cp2k_section_geometry_optimization.append(sec_geometry_opt)
|
|
2217
|
+
for step in optimization.get('optimization_step', []):
|
|
2218
|
+
information = step.information
|
|
2219
|
+
if information is None:
|
|
2220
|
+
continue
|
|
2221
|
+
sec_geometry_opt_step = x_cp2k_section_geometry_optimization_step()
|
|
2222
|
+
sec_geometry_opt.x_cp2k_section_geometry_optimization_step.append(
|
|
2223
|
+
sec_geometry_opt_step
|
|
2224
|
+
)
|
|
2225
|
+
for key, val in information.items():
|
|
2226
|
+
if val is None:
|
|
2227
|
+
continue
|
|
2228
|
+
|
|
2229
|
+
name = self._metainfo_name_map.get(key, key)
|
|
2230
|
+
if name.startswith('energy') and isinstance(val, float):
|
|
2231
|
+
val = (val * ureg.hartree).to('joule').magnitude
|
|
2232
|
+
elif 'step_size' in name and isinstance(val, float):
|
|
2233
|
+
val = (val * ureg.bohr).to('m').magnitude
|
|
2234
|
+
elif 'gradient' in name and isinstance(val, float):
|
|
2235
|
+
val = (val * ureg.hartree / ureg.bohr).to('joule/m').magnitude
|
|
2236
|
+
elif isinstance(val, str):
|
|
2237
|
+
val = val.strip()
|
|
2238
|
+
|
|
2239
|
+
setattr(sec_geometry_opt_step, f'x_cp2k_optimization_{name}', val)
|
|
2240
|
+
|
|
2241
|
+
if sec_geometry_opt.x_cp2k_section_geometry_optimization_step:
|
|
2242
|
+
geometry_change = sec_geometry_opt_step.x_cp2k_optimization_step_size_convergence_limit
|
|
2243
|
+
if geometry_change is not None:
|
|
2244
|
+
workflow.method.convergence_tolerance_displacement_maximum
|
|
2245
|
+
threshold_force = (
|
|
2246
|
+
sec_geometry_opt_step.x_cp2k_optimization_gradient_convergence_limit
|
|
2247
|
+
)
|
|
2248
|
+
if threshold_force is not None:
|
|
2249
|
+
workflow.method.convergence_tolerance_force_maximum = (
|
|
2250
|
+
threshold_force
|
|
2251
|
+
)
|
|
2252
|
+
|
|
2253
|
+
elif self.sampling_method == 'molecular_dynamics':
|
|
2254
|
+
# Parse common MD information
|
|
2255
|
+
workflow = MolecularDynamics(method=MolecularDynamicsMethod())
|
|
2256
|
+
workflow.method.thermodynamic_ensemble = self._ensemble_map.get(
|
|
2257
|
+
self.get_ensemble_type(0), None
|
|
2258
|
+
)
|
|
2259
|
+
workflow.method.integration_timestep = self.get_time_step()
|
|
2260
|
+
sec_md_settings = x_cp2k_section_md_settings()
|
|
2261
|
+
workflow.method.x_cp2k_section_md_settings.append(sec_md_settings)
|
|
2262
|
+
|
|
2263
|
+
# Parse code specific MD information
|
|
2264
|
+
ignored = {'time_step', 'ensemble_type', 'file_type'}
|
|
2265
|
+
for key, val in self.settings['md'].items():
|
|
2266
|
+
if val is None or key in ignored:
|
|
2267
|
+
continue
|
|
2268
|
+
if key in [
|
|
2269
|
+
'coordinates',
|
|
2270
|
+
'simulation_cell',
|
|
2271
|
+
'velocities',
|
|
2272
|
+
'energies',
|
|
2273
|
+
'dump',
|
|
2274
|
+
]:
|
|
2275
|
+
val = val.split()
|
|
2276
|
+
setattr(
|
|
2277
|
+
sec_md_settings, f'x_cp2k_md_{key}_print_frequency', int(val[0])
|
|
2278
|
+
)
|
|
2279
|
+
setattr(sec_md_settings, f'x_cp2k_md_{key}_filename', val[1])
|
|
2280
|
+
elif key == 'print_frequency':
|
|
2281
|
+
setattr(sec_md_settings, f'x_cp2k_md_{key}', int(val.split()[0]))
|
|
2282
|
+
else:
|
|
2283
|
+
setattr(sec_md_settings, f'x_cp2k_md_{key}', val)
|
|
2284
|
+
|
|
2285
|
+
self.archive.workflow2 = workflow
|
|
2286
|
+
|
|
2287
|
+
def parse(self, filepath, archive, logger):
|
|
2288
|
+
self.filepath = os.path.abspath(filepath)
|
|
2289
|
+
self.archive = archive
|
|
2290
|
+
self.maindir = os.path.dirname(self.filepath)
|
|
2291
|
+
self.mainfile = os.path.basename(self.filepath)
|
|
2292
|
+
self.logger = logger if logger is not None else logging.getLogger(__name__)
|
|
2293
|
+
|
|
2294
|
+
self.init_parser()
|
|
2295
|
+
|
|
2296
|
+
# identify calculation type, TODO add more
|
|
2297
|
+
calculation_types = ['quickstep', 'qs_dftb']
|
|
2298
|
+
for calculation_type in calculation_types:
|
|
2299
|
+
if self.out_parser.get(calculation_type) is not None:
|
|
2300
|
+
self._calculation_type = calculation_type
|
|
2301
|
+
break
|
|
2302
|
+
|
|
2303
|
+
self.archive.run.append(Run())
|
|
2304
|
+
self.parse_settings()
|
|
2305
|
+
self.parse_input()
|
|
2306
|
+
|
|
2307
|
+
# if restarts: STEP_START_VALUE > 0, initial scf calc done at STEP_START_VALUE - 1
|
|
2308
|
+
self._step_start = 1
|
|
2309
|
+
if run_type := self.inp_parser.get('GLOBAL/RUN_TYPE'):
|
|
2310
|
+
self._step_start = int(
|
|
2311
|
+
self.inp_parser.get(
|
|
2312
|
+
f'MOTION/{run_type}/STEP_START_VAL', self._step_start
|
|
2313
|
+
)
|
|
2314
|
+
)
|
|
2315
|
+
|
|
2316
|
+
if self._calculation_type in ['quickstep', 'qs_dftb']:
|
|
2317
|
+
self.parse_method_quickstep()
|
|
2318
|
+
self.parse_configurations_quickstep()
|
|
2319
|
+
|
|
2320
|
+
self.parse_workflow()
|
|
2321
|
+
|
|
2322
|
+
self.inp_parser.close()
|
|
2323
|
+
self.traj_parser.close()
|
|
2324
|
+
self.velocities_parser.close()
|