nomad-parser-plugins-atomistic 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.
Files changed (80) hide show
  1. atomisticparsers/__init__.py +400 -0
  2. atomisticparsers/amber/__init__.py +19 -0
  3. atomisticparsers/amber/__main__.py +31 -0
  4. atomisticparsers/amber/metainfo/__init__.py +19 -0
  5. atomisticparsers/amber/metainfo/amber.py +495 -0
  6. atomisticparsers/amber/parser.py +42 -0
  7. atomisticparsers/asap/__init__.py +19 -0
  8. atomisticparsers/asap/__main__.py +31 -0
  9. atomisticparsers/asap/metainfo/__init__.py +19 -0
  10. atomisticparsers/asap/metainfo/asap.py +75 -0
  11. atomisticparsers/asap/parser.py +197 -0
  12. atomisticparsers/bopfox/__init__.py +19 -0
  13. atomisticparsers/bopfox/__main__.py +31 -0
  14. atomisticparsers/bopfox/metainfo/__init__.py +19 -0
  15. atomisticparsers/bopfox/metainfo/bopfox.py +225 -0
  16. atomisticparsers/bopfox/parser.py +808 -0
  17. atomisticparsers/dftbplus/__init__.py +19 -0
  18. atomisticparsers/dftbplus/__main__.py +31 -0
  19. atomisticparsers/dftbplus/metainfo/__init__.py +19 -0
  20. atomisticparsers/dftbplus/metainfo/dftbplus.py +217 -0
  21. atomisticparsers/dftbplus/parser.py +500 -0
  22. atomisticparsers/dlpoly/__init__.py +19 -0
  23. atomisticparsers/dlpoly/__main__.py +31 -0
  24. atomisticparsers/dlpoly/metainfo/__init__.py +19 -0
  25. atomisticparsers/dlpoly/metainfo/dl_poly.py +312 -0
  26. atomisticparsers/dlpoly/parser.py +798 -0
  27. atomisticparsers/gromacs/__init__.py +19 -0
  28. atomisticparsers/gromacs/__main__.py +31 -0
  29. atomisticparsers/gromacs/metainfo/__init__.py +19 -0
  30. atomisticparsers/gromacs/metainfo/gromacs.py +2388 -0
  31. atomisticparsers/gromacs/parser.py +1581 -0
  32. atomisticparsers/gromos/__init__.py +19 -0
  33. atomisticparsers/gromos/__main__.py +31 -0
  34. atomisticparsers/gromos/metainfo/__init__.py +19 -0
  35. atomisticparsers/gromos/metainfo/gromos.py +1995 -0
  36. atomisticparsers/gromos/parser.py +58 -0
  37. atomisticparsers/gulp/__init__.py +19 -0
  38. atomisticparsers/gulp/__main__.py +31 -0
  39. atomisticparsers/gulp/metainfo/__init__.py +19 -0
  40. atomisticparsers/gulp/metainfo/gulp.py +1117 -0
  41. atomisticparsers/gulp/parser.py +1316 -0
  42. atomisticparsers/h5md/__init__.py +19 -0
  43. atomisticparsers/h5md/__main__.py +31 -0
  44. atomisticparsers/h5md/metainfo/__init__.py +19 -0
  45. atomisticparsers/h5md/metainfo/h5md.py +239 -0
  46. atomisticparsers/h5md/parser.py +901 -0
  47. atomisticparsers/lammps/__init__.py +19 -0
  48. atomisticparsers/lammps/__main__.py +31 -0
  49. atomisticparsers/lammps/metainfo/__init__.py +19 -0
  50. atomisticparsers/lammps/metainfo/lammps.py +1417 -0
  51. atomisticparsers/lammps/parser.py +1753 -0
  52. atomisticparsers/libatoms/__init__.py +19 -0
  53. atomisticparsers/libatoms/__main__.py +31 -0
  54. atomisticparsers/libatoms/metainfo/__init__.py +19 -0
  55. atomisticparsers/libatoms/metainfo/lib_atoms.py +251 -0
  56. atomisticparsers/libatoms/parser.py +38 -0
  57. atomisticparsers/namd/__init__.py +19 -0
  58. atomisticparsers/namd/__main__.py +31 -0
  59. atomisticparsers/namd/metainfo/__init__.py +19 -0
  60. atomisticparsers/namd/metainfo/namd.py +1605 -0
  61. atomisticparsers/namd/parser.py +312 -0
  62. atomisticparsers/tinker/__init__.py +19 -0
  63. atomisticparsers/tinker/__main__.py +31 -0
  64. atomisticparsers/tinker/metainfo/__init__.py +18 -0
  65. atomisticparsers/tinker/metainfo/tinker.py +1363 -0
  66. atomisticparsers/tinker/parser.py +685 -0
  67. atomisticparsers/utils/__init__.py +22 -0
  68. atomisticparsers/utils/mdanalysis.py +662 -0
  69. atomisticparsers/utils/parsers.py +226 -0
  70. atomisticparsers/xtb/__init__.py +19 -0
  71. atomisticparsers/xtb/__main__.py +32 -0
  72. atomisticparsers/xtb/metainfo/__init__.py +19 -0
  73. atomisticparsers/xtb/metainfo/xtb.py +256 -0
  74. atomisticparsers/xtb/parser.py +979 -0
  75. nomad_parser_plugins_atomistic-1.0.dist-info/LICENSE +202 -0
  76. nomad_parser_plugins_atomistic-1.0.dist-info/METADATA +327 -0
  77. nomad_parser_plugins_atomistic-1.0.dist-info/RECORD +80 -0
  78. nomad_parser_plugins_atomistic-1.0.dist-info/WHEEL +5 -0
  79. nomad_parser_plugins_atomistic-1.0.dist-info/entry_points.txt +15 -0
  80. nomad_parser_plugins_atomistic-1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,197 @@
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
+
20
+ import os
21
+ import logging
22
+ import numpy as np
23
+ from ase.io.trajectory import Trajectory
24
+
25
+ from nomad.units import ureg
26
+ from nomad.parsing.file_parser import FileParser
27
+ from runschema.run import Run, Program
28
+ from runschema.method import Method, ForceField, Model
29
+ from simulationworkflowschema import GeometryOptimization, GeometryOptimizationMethod
30
+ from atomisticparsers.utils import MDParser
31
+ from .metainfo.asap import MolecularDynamics # pylint: disable=unused-import
32
+
33
+
34
+ class TrajParser(FileParser):
35
+ def __init__(self):
36
+ super().__init__()
37
+
38
+ @property
39
+ def traj(self):
40
+ if self._file_handler is None:
41
+ try:
42
+ self._file_handler = Trajectory(self.mainfile, 'r')
43
+ # check if traj file is really asap
44
+ if 'calculator' in self._file_handler.backend.keys():
45
+ if self._file_handler.backend.calculator.name != 'emt': # pylint: disable=E1101
46
+ self.logger.error('Trajectory is not ASAP.')
47
+ self._file_handler = None
48
+ except Exception:
49
+ self.logger.error('Error reading trajectory file.')
50
+ return self._file_handler
51
+
52
+ def get_version(self):
53
+ if hasattr(self.traj, 'ase_version') and self.traj.ase_version:
54
+ return self.traj.ase_version
55
+ else:
56
+ return '3.x.x'
57
+
58
+ def parse(self):
59
+ pass
60
+
61
+
62
+ class AsapParser(MDParser):
63
+ def __init__(self):
64
+ self.traj_parser = TrajParser()
65
+ super().__init__()
66
+
67
+ def parse_method(self):
68
+ traj = self.traj_parser.traj
69
+ sec_method = Method()
70
+ self.archive.run[0].method.append(sec_method)
71
+
72
+ if traj[0].calc is not None:
73
+ sec_method.force_field = ForceField(model=[Model(name=traj[0].calc.name)])
74
+
75
+ description = traj.description if hasattr(traj, 'description') else dict()
76
+ if not description:
77
+ return
78
+
79
+ calc_type = description.get('type')
80
+ if calc_type == 'optimization':
81
+ workflow = GeometryOptimization(method=GeometryOptimizationMethod())
82
+ workflow.x_asap_maxstep = description.get('maxstep', 0)
83
+ workflow.method.method = description.get('optimizer', '').lower()
84
+ self.archive.workflow2 = workflow
85
+ elif calc_type == 'molecular-dynamics':
86
+ data = {}
87
+ data['x_asap_timestep'] = description.get('timestep', 0)
88
+ data['x_asap_temperature'] = description.get('temperature', 0)
89
+ md_type = description.get('md-type', '')
90
+ thermodynamic_ensemble = None
91
+ if 'Langevin' in md_type:
92
+ data['x_asap_langevin_friction'] = description.get('friction', 0)
93
+ thermodynamic_ensemble = 'NVT'
94
+ elif 'NVT' in md_type:
95
+ thermodynamic_ensemble = 'NVT'
96
+ elif 'Verlet' in md_type:
97
+ thermodynamic_ensemble = 'NVE'
98
+ elif 'NPT' in md_type:
99
+ thermodynamic_ensemble = 'NPT'
100
+ data['method'] = {'thermodynamic_ensemble': thermodynamic_ensemble}
101
+ self.parse_md_workflow(data)
102
+
103
+ def write_to_archive(self) -> None:
104
+ self.traj_parser.mainfile = self.mainfile
105
+ if self.traj_parser.traj is None:
106
+ return
107
+
108
+ sec_run = Run()
109
+ self.archive.run.append(sec_run)
110
+ sec_run.program = Program(name='ASAP', version=self.traj_parser.get_version())
111
+
112
+ # TODO do we build the topology and method for each frame
113
+ self.parse_method()
114
+
115
+ # set up md parser
116
+ self.n_atoms = max(
117
+ [traj.get_global_number_of_atoms() for traj in self.traj_parser.traj]
118
+ )
119
+ steps = [
120
+ (traj.description if hasattr(traj, 'description') else dict()).get(
121
+ 'interval', 1
122
+ )
123
+ * n
124
+ for n, traj in enumerate(self.traj_parser.traj)
125
+ ]
126
+ self.trajectory_steps = steps
127
+ self.thermodynamics_steps = steps
128
+
129
+ def get_constraint_name(constraint):
130
+ def index():
131
+ d = constraint['kwargs'].get('direction')
132
+ return ((d / np.linalg.norm(d)) ** 2).argsort()[2]
133
+
134
+ name = constraint.get('name')
135
+ if name == 'FixedPlane':
136
+ return ['fix_yz', 'fix_xz', 'fix_xy'][index()]
137
+ elif name == 'FixedLine':
138
+ return ['fix_x', 'fix_y', 'fix_z'][index()]
139
+ elif name == 'FixAtoms':
140
+ return 'fix_xyz'
141
+ else:
142
+ return name
143
+
144
+ for step in self.trajectory_steps:
145
+ traj = self.traj_parser.traj[steps.index(step)]
146
+ lattice_vectors = traj.get_cell() * ureg.angstrom
147
+ labels = traj.get_chemical_symbols()
148
+ positions = traj.get_positions() * ureg.angstrom
149
+ periodic = traj.get_pbc()
150
+ if (velocities := traj.get_velocities()) is not None:
151
+ velocities = velocities * (ureg.angstrom / ureg.fs)
152
+
153
+ constraints = []
154
+ for constraint in traj.constraints:
155
+ as_dict = constraint.todict()
156
+ indices = as_dict['kwargs'].get('a', as_dict['kwargs'].get('indices'))
157
+ indices = (
158
+ indices
159
+ if isinstance(indices, (np.ndarray, list))
160
+ else [int(indices)]
161
+ )
162
+ constraints.append(
163
+ dict(
164
+ atom_indices=[np.asarray(indices)],
165
+ kind=get_constraint_name(as_dict),
166
+ )
167
+ )
168
+ self.parse_trajectory_step(
169
+ dict(
170
+ atoms=dict(
171
+ lattice_vectors=lattice_vectors,
172
+ labels=labels,
173
+ positions=positions,
174
+ periodic=periodic,
175
+ velocities=velocities,
176
+ ),
177
+ constraint=constraints,
178
+ )
179
+ )
180
+
181
+ for step in self.thermodynamics_steps:
182
+ try:
183
+ traj = self.traj_parser.traj[steps.index(step)]
184
+ if (total_energy := traj.get_total_energy()) is not None:
185
+ total_energy = total_energy * ureg.eV
186
+ if (forces := traj.get_forces()) is not None:
187
+ forces = forces * ureg.eV / ureg.angstrom
188
+ if (forces_raw := traj.get_forces(apply_constraint=False)) is not None:
189
+ forces_raw * ureg.eV / ureg.angstrom
190
+ self.parse_thermodynamics_step(
191
+ dict(
192
+ energy=dict(total=dict(value=total_energy)),
193
+ forces=dict(total=dict(value=forces, value_raw=forces_raw)),
194
+ )
195
+ )
196
+ except Exception:
197
+ pass
@@ -0,0 +1,19 @@
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
+ from .parser import BOPfoxParser
@@ -0,0 +1,31 @@
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 sys
20
+ import json
21
+ import logging
22
+
23
+ from nomad.utils import configure_logging
24
+ from nomad.datamodel import EntryArchive
25
+ from atomisticparsers.bopfox import BOPfoxParser
26
+
27
+ if __name__ == '__main__':
28
+ configure_logging(console_log_level=logging.DEBUG)
29
+ archive = EntryArchive()
30
+ BOPfoxParser().parse(sys.argv[1], archive, logging)
31
+ json.dump(archive.m_to_dict(), sys.stdout, indent=2)
@@ -0,0 +1,19 @@
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
+ from . import bopfox
@@ -0,0 +1,225 @@
1
+ #
2
+ # Copyright The NOMAD Authors.
3
+ #
4
+ # This file is part of NOMAD.
5
+ # See https://nomad-lab.eu for further info.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+ import numpy as np # pylint: disable=unused-import
20
+
21
+ from nomad.metainfo import ( # pylint: disable=unused-import
22
+ MSection,
23
+ MCategory,
24
+ Category,
25
+ Package,
26
+ Quantity,
27
+ Section,
28
+ SubSection,
29
+ SectionProxy,
30
+ Reference,
31
+ JSON,
32
+ )
33
+ import runschema.run # pylint: disable=unused-import
34
+ import runschema.calculation # pylint: disable=unused-import
35
+ import runschema.method # pylint: disable=unused-import
36
+ import runschema.system # pylint: disable=unused-import
37
+
38
+
39
+ m_package = Package()
40
+
41
+
42
+ class Method(runschema.calculation.Method):
43
+ m_def = Section(validate=False, extends_base_section=True)
44
+
45
+ x_bopfox_simulation_parameters = Quantity(
46
+ type=JSON,
47
+ shape=[],
48
+ description="""
49
+ """,
50
+ )
51
+
52
+
53
+ class Energy(runschema.calculation.Energy):
54
+ m_def = Section(validate=False, extends_base_section=True)
55
+
56
+ x_bopfox_bond = SubSection(
57
+ sub_section=runschema.calculation.EnergyEntry.m_def,
58
+ description="""
59
+ Contains the value and information regarding the bond energy.
60
+ """,
61
+ )
62
+
63
+ x_bopfox_prom = SubSection(
64
+ sub_section=runschema.calculation.EnergyEntry.m_def,
65
+ description="""
66
+ Contains the value and information regarding the promotion energy.
67
+ """,
68
+ )
69
+
70
+ x_bopfox_rep1 = SubSection(
71
+ sub_section=runschema.calculation.EnergyEntry.m_def,
72
+ description="""
73
+ Contains the value and information regarding the first repulsion energy.
74
+ """,
75
+ )
76
+
77
+ x_bopfox_rep2 = SubSection(
78
+ sub_section=runschema.calculation.EnergyEntry.m_def,
79
+ description="""
80
+ Contains the value and information regarding the second repulsion energy.
81
+ """,
82
+ )
83
+
84
+ x_bopfox_rep3 = SubSection(
85
+ sub_section=runschema.calculation.EnergyEntry.m_def,
86
+ description="""
87
+ Contains the value and information regarding the third repulsion energy.
88
+ """,
89
+ )
90
+
91
+
92
+ class Forces(runschema.calculation.Forces):
93
+ m_def = Section(validate=False, extends_base_section=True)
94
+
95
+ x_bopfox_analytic = SubSection(
96
+ sub_section=runschema.calculation.ForcesEntry.m_def,
97
+ description="""
98
+ Contains the value and information regarding the analytic forces.
99
+ """,
100
+ )
101
+
102
+ x_bopfox_rep1 = SubSection(
103
+ sub_section=runschema.calculation.ForcesEntry.m_def,
104
+ description="""
105
+ Contains the value and information regarding the first analytic forces.
106
+ """,
107
+ )
108
+
109
+ x_bopfox_rep2 = SubSection(
110
+ sub_section=runschema.calculation.ForcesEntry.m_def,
111
+ description="""
112
+ Contains the value and information regarding the second analytic forces.
113
+ """,
114
+ )
115
+
116
+ x_bopfox_rep3 = SubSection(
117
+ sub_section=runschema.calculation.ForcesEntry.m_def,
118
+ description="""
119
+ Contains the value and information regarding the third analytic forces.
120
+ """,
121
+ )
122
+
123
+
124
+ class x_bopfox_onsite_levels_value(runschema.calculation.AtomicValues):
125
+ m_def = Section(validate=False)
126
+
127
+ value = Quantity(
128
+ type=np.dtype(np.float64),
129
+ shape=[],
130
+ description="""
131
+ Value of the onsite level projected on orbital and spin channel.
132
+ """,
133
+ )
134
+
135
+
136
+ class x_bopfox_onsite_levels(runschema.calculation.Atomic):
137
+ m_def = Section(validate=False)
138
+
139
+ orbital_projected = SubSection(
140
+ sub_section=x_bopfox_onsite_levels_value.m_def, repeats=True
141
+ )
142
+
143
+
144
+ class Calculation(runschema.calculation.Calculation):
145
+ m_def = Section(validate=False, extends_base_section=True)
146
+
147
+ x_bopfox_onsite_levels = SubSection(
148
+ sub_section=x_bopfox_onsite_levels.m_def, repeats=True
149
+ )
150
+
151
+
152
+ class Interaction(runschema.method.Interaction):
153
+ m_def = Section(validate=False, extends_base_section=True)
154
+
155
+ x_bopfox_valence = Quantity(
156
+ type=str,
157
+ shape=['n_atoms'],
158
+ description="""
159
+ Valence of the atoms described by the interaction.
160
+ """,
161
+ )
162
+
163
+ x_bopfox_chargetransfer = Quantity(
164
+ type=np.dtype(np.float64),
165
+ shape=['*'],
166
+ description="""
167
+ Charge transfer parameters.
168
+ """,
169
+ )
170
+
171
+ x_bopfox_cutoff = Quantity(
172
+ type=np.dtype(np.float64),
173
+ shape=[],
174
+ description="""
175
+ Cutoff distance for the interaction.
176
+ """,
177
+ )
178
+
179
+ x_bopfox_dcutoff = Quantity(
180
+ type=np.dtype(np.float64),
181
+ shape=[],
182
+ description="""
183
+ Distance from cutoff where the cutoff function is applied.
184
+ """,
185
+ )
186
+
187
+
188
+ class Model(runschema.method.Model):
189
+ m_def = Section(validate=False, extends_base_section=True)
190
+
191
+ x_bopfox_parameters = Quantity(
192
+ type=JSON,
193
+ shape=[],
194
+ description="""
195
+ """,
196
+ )
197
+
198
+
199
+ class xTB(runschema.method.xTB):
200
+ m_def = Section(validate=False, extends_base_section=True)
201
+
202
+ x_bopfox_parameters = Quantity(
203
+ type=JSON,
204
+ shape=[],
205
+ description="""
206
+ """,
207
+ )
208
+
209
+
210
+ class AtomParameters(runschema.method.AtomParameters):
211
+ m_def = Section(validate=False, extends_base_section=True)
212
+
213
+ x_bopfox_valenceorbitals = Quantity(
214
+ type=np.dtype(np.int32),
215
+ shape=[],
216
+ description="""
217
+ """,
218
+ )
219
+
220
+ x_bopfox_stonerintegral = Quantity(
221
+ type=np.dtype(np.float64),
222
+ shape=[3],
223
+ description="""
224
+ """,
225
+ )