emle-engine 2.0.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.
Potentially problematic release.
This version of emle-engine might be problematic. Click here for more details.
- emle/__init__.py +39 -0
- emle/_analyzer.py +337 -0
- emle/_backends/__init__.py +14 -0
- emle/_backends/_ace.py +141 -0
- emle/_backends/_aimnet2.py +136 -0
- emle/_backends/_backend.py +148 -0
- emle/_backends/_deepmd.py +186 -0
- emle/_backends/_omnip2x.py +349 -0
- emle/_backends/_orca.py +322 -0
- emle/_backends/_sander.py +232 -0
- emle/_backends/_sqm.py +230 -0
- emle/_backends/_xtb.py +126 -0
- emle/_compiler.py +279 -0
- emle/_csrc/ops.cpp +350 -0
- emle/_csrc/ops_cuda.cu +454 -0
- emle/_ops.py +173 -0
- emle/_orca_parser.py +331 -0
- emle/_resources.py +32 -0
- emle/_socket.py +211 -0
- emle/_tarball_to_extXYZ.py +236 -0
- emle/_units.py +16 -0
- emle/_utils.py +57 -0
- emle/calculator.py +1974 -0
- emle/models/__init__.py +13 -0
- emle/models/_ani.py +315 -0
- emle/models/_deepmd.py +410 -0
- emle/models/_emle.py +629 -0
- emle/models/_emle_aev_computer.py +616 -0
- emle/models/_emle_base.py +1063 -0
- emle/models/_mace.py +1368 -0
- emle/models/_patches.py +66 -0
- emle/models/_utils.py +279 -0
- emle/train/__init__.py +8 -0
- emle/train/_extxyz.py +63 -0
- emle/train/_gpr.py +205 -0
- emle/train/_ivm.py +126 -0
- emle/train/_loss.py +357 -0
- emle/train/_trainer.py +709 -0
- emle/train/_utils.py +92 -0
- emle_engine-2.0.0.data/scripts/emle-analyze +175 -0
- emle_engine-2.0.0.data/scripts/emle-compile +162 -0
- emle_engine-2.0.0.data/scripts/emle-server +777 -0
- emle_engine-2.0.0.data/scripts/emle-stop +21 -0
- emle_engine-2.0.0.data/scripts/emle-train +127 -0
- emle_engine-2.0.0.data/scripts/orca +95 -0
- emle_engine-2.0.0.data/scripts/tarball-to-extxyz +6 -0
- emle_engine-2.0.0.dist-info/METADATA +49 -0
- emle_engine-2.0.0.dist-info/RECORD +51 -0
- emle_engine-2.0.0.dist-info/WHEEL +5 -0
- emle_engine-2.0.0.dist-info/licenses/LICENSE +21 -0
- emle_engine-2.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"""Functions for converting ORCA tarball files to extXYZ format."""
|
|
2
|
+
|
|
3
|
+
__author__ = "Laetitia Kantin"
|
|
4
|
+
__email__ = "kantin@ibpc.fr"
|
|
5
|
+
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import numpy as np
|
|
10
|
+
import ase.io
|
|
11
|
+
from ase import Atoms
|
|
12
|
+
from ase.data import chemical_symbols
|
|
13
|
+
|
|
14
|
+
from ._orca_parser import ORCAParser
|
|
15
|
+
from ._units import _HARTREE_BOHR_TO_EV_A
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def tarball_to_atoms(
|
|
19
|
+
orca_tarball_path,
|
|
20
|
+
total_charge=None,
|
|
21
|
+
parse_alpha=True,
|
|
22
|
+
verbose=False,
|
|
23
|
+
):
|
|
24
|
+
"""
|
|
25
|
+
Convert ORCA tarball to a list of ASE Atoms using ORCAParser.
|
|
26
|
+
|
|
27
|
+
Parameters
|
|
28
|
+
----------
|
|
29
|
+
|
|
30
|
+
orca_tarball_path: str or Path
|
|
31
|
+
Path to the ORCA tarball file.
|
|
32
|
+
|
|
33
|
+
total_charge: int or None
|
|
34
|
+
Total charge of every frame. If None, the rounded sum of the MBIS
|
|
35
|
+
charges of each frame is used.
|
|
36
|
+
|
|
37
|
+
parse_alpha: bool
|
|
38
|
+
Whether to parse polarizability data (default: True).
|
|
39
|
+
|
|
40
|
+
verbose: bool
|
|
41
|
+
Enable verbose output (default: False).
|
|
42
|
+
|
|
43
|
+
Returns
|
|
44
|
+
-------
|
|
45
|
+
|
|
46
|
+
atoms_list: List[ase.Atoms]
|
|
47
|
+
"""
|
|
48
|
+
orca_tarball_path = Path(orca_tarball_path)
|
|
49
|
+
|
|
50
|
+
if not orca_tarball_path.exists():
|
|
51
|
+
raise FileNotFoundError(f"ORCA tarball not found: {orca_tarball_path}")
|
|
52
|
+
|
|
53
|
+
if verbose:
|
|
54
|
+
print(f"Parsing ORCA tarball: {orca_tarball_path}")
|
|
55
|
+
|
|
56
|
+
# Initialize ORCA parser
|
|
57
|
+
parser = ORCAParser(str(orca_tarball_path), alpha=parse_alpha)
|
|
58
|
+
|
|
59
|
+
if verbose:
|
|
60
|
+
print(f"Parser attributes: {list(parser.__dict__.keys())}")
|
|
61
|
+
|
|
62
|
+
# Get number of frames from parser data
|
|
63
|
+
if not (hasattr(parser, "xyz") and parser.xyz is not None):
|
|
64
|
+
raise ValueError("XYZ data not available in parser")
|
|
65
|
+
|
|
66
|
+
n_frames = len(parser.xyz)
|
|
67
|
+
if verbose:
|
|
68
|
+
print(f"Found {n_frames} frames")
|
|
69
|
+
|
|
70
|
+
# Create atoms list
|
|
71
|
+
atoms_list = []
|
|
72
|
+
|
|
73
|
+
for i in range(n_frames):
|
|
74
|
+
frame_number = i + 1
|
|
75
|
+
n_atoms = (parser.z[i] > 0).sum()
|
|
76
|
+
|
|
77
|
+
# Create ASE atoms object from parser data
|
|
78
|
+
symbols = [chemical_symbols[int(z)] for z in parser.z[i][:n_atoms]]
|
|
79
|
+
atoms = Atoms(symbols=symbols, positions=parser.xyz[i][:n_atoms])
|
|
80
|
+
|
|
81
|
+
# Add forces (ORCAParser returns Hartree/Bohr; extXYZ stores eV/A
|
|
82
|
+
# for MACE training).
|
|
83
|
+
if parser.forces[i] is not None:
|
|
84
|
+
atoms.arrays["forces_dft"] = parser.forces[i] * _HARTREE_BOHR_TO_EV_A
|
|
85
|
+
|
|
86
|
+
# Add MBIS properties
|
|
87
|
+
if not (hasattr(parser, "mbis") and parser.mbis is not None):
|
|
88
|
+
raise ValueError("MBIS data not available in parser")
|
|
89
|
+
|
|
90
|
+
# Core charges, check if it's present and available for all frames
|
|
91
|
+
if not ("q_core" in parser.mbis and len(parser.mbis["q_core"]) > i):
|
|
92
|
+
raise ValueError(f"Core charges not available for frame {frame_number}")
|
|
93
|
+
q_core = parser.mbis["q_core"][i][:n_atoms]
|
|
94
|
+
|
|
95
|
+
# Valence charges
|
|
96
|
+
if not ("q_val" in parser.mbis and len(parser.mbis["q_val"]) > i):
|
|
97
|
+
raise ValueError(f"Valence charges not available for frame {frame_number}")
|
|
98
|
+
q_val = parser.mbis["q_val"][i][:n_atoms]
|
|
99
|
+
|
|
100
|
+
# Add q_core and q_val
|
|
101
|
+
atoms.arrays["q_core"] = q_core
|
|
102
|
+
atoms.arrays["q_val"] = q_val
|
|
103
|
+
|
|
104
|
+
# Total charges
|
|
105
|
+
atoms.arrays["q"] = q_core + q_val
|
|
106
|
+
|
|
107
|
+
# Dipole moments (mu)
|
|
108
|
+
if not ("mu" in parser.mbis and len(parser.mbis["mu"]) > i):
|
|
109
|
+
raise ValueError(f"Dipole moments not available for frame {frame_number}")
|
|
110
|
+
atoms.arrays["mu"] = parser.mbis["mu"][i][:n_atoms]
|
|
111
|
+
|
|
112
|
+
# Valence width (s)
|
|
113
|
+
if not ("s" in parser.mbis and len(parser.mbis["s"]) > i):
|
|
114
|
+
raise ValueError(f"Valence width not available for frame {frame_number}")
|
|
115
|
+
atoms.arrays["s"] = parser.mbis["s"][i][:n_atoms]
|
|
116
|
+
|
|
117
|
+
# Set system properties
|
|
118
|
+
atoms.info["pos_unit"] = "angstrom"
|
|
119
|
+
if not np.isnan(parser.E_vac[i]):
|
|
120
|
+
atoms.info["energy_dft"] = parser.E_vac[i]
|
|
121
|
+
atoms.info["total_charge"] = (
|
|
122
|
+
round((q_core + q_val).sum()) if total_charge is None else total_charge
|
|
123
|
+
)
|
|
124
|
+
atoms.info["pbc"] = "F F F"
|
|
125
|
+
|
|
126
|
+
# Add polarizability
|
|
127
|
+
if parse_alpha:
|
|
128
|
+
if not (
|
|
129
|
+
hasattr(parser, "alpha")
|
|
130
|
+
and parser.alpha is not None
|
|
131
|
+
and len(parser.alpha) > i
|
|
132
|
+
):
|
|
133
|
+
raise ValueError(
|
|
134
|
+
f"Polarizability not available for frame {frame_number}"
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
alpha_tensor = parser.alpha[i]
|
|
138
|
+
if isinstance(alpha_tensor, np.ndarray) and alpha_tensor.shape == (3, 3):
|
|
139
|
+
atoms.info["alpha"] = alpha_tensor
|
|
140
|
+
else:
|
|
141
|
+
raise ValueError(
|
|
142
|
+
f"Unexpected polarizability format for frame {frame_number}: {type(alpha_tensor)}, shape: {getattr(alpha_tensor, 'shape', 'N/A')}"
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
atoms_list.append(atoms)
|
|
146
|
+
|
|
147
|
+
return atoms_list
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def orca_to_extxyz(
|
|
151
|
+
orca_tarball_path,
|
|
152
|
+
output_path=None,
|
|
153
|
+
total_charge=None,
|
|
154
|
+
parse_alpha=True,
|
|
155
|
+
verbose=False,
|
|
156
|
+
):
|
|
157
|
+
"""
|
|
158
|
+
Convert ORCA tarball to extXYZ format.
|
|
159
|
+
|
|
160
|
+
output_path: str or Path, optional
|
|
161
|
+
Output path for the extXYZ file. If None, uses the input name with a
|
|
162
|
+
'.xyz' extension. Other parameters are as for tarball_to_atoms.
|
|
163
|
+
|
|
164
|
+
Returns
|
|
165
|
+
-------
|
|
166
|
+
|
|
167
|
+
output_path: str
|
|
168
|
+
Path to the created extXYZ file.
|
|
169
|
+
"""
|
|
170
|
+
if output_path is None:
|
|
171
|
+
output_path = Path(orca_tarball_path).with_suffix(".xyz")
|
|
172
|
+
|
|
173
|
+
atoms_list = tarball_to_atoms(orca_tarball_path, total_charge, parse_alpha, verbose)
|
|
174
|
+
|
|
175
|
+
if verbose:
|
|
176
|
+
print(f"Writing extXYZ file: {output_path}")
|
|
177
|
+
|
|
178
|
+
# Write to extXYZ format
|
|
179
|
+
ase.io.write(str(output_path), atoms_list, format="extxyz")
|
|
180
|
+
|
|
181
|
+
if verbose:
|
|
182
|
+
print(f"Successfully created extXYZ file with {len(atoms_list)} frames")
|
|
183
|
+
|
|
184
|
+
return str(output_path)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def main():
|
|
188
|
+
"""Command line interface for the ORCA tarball to extXYZ converter."""
|
|
189
|
+
import argparse
|
|
190
|
+
|
|
191
|
+
parser = argparse.ArgumentParser(
|
|
192
|
+
description="Convert ORCA tarball files to extXYZ format",
|
|
193
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
parser.add_argument("input", help="Input ORCA tarball file path")
|
|
197
|
+
|
|
198
|
+
parser.add_argument(
|
|
199
|
+
"-o", "--output", help="Output extXYZ file path (default: input_name.xyz)"
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
parser.add_argument(
|
|
203
|
+
"--charge",
|
|
204
|
+
type=int,
|
|
205
|
+
default=None,
|
|
206
|
+
help="Total charge of every frame (default: rounded sum of MBIS charges per frame)",
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
parser.add_argument(
|
|
210
|
+
"--no-alpha",
|
|
211
|
+
dest="parse_alpha",
|
|
212
|
+
action="store_false",
|
|
213
|
+
help="Skip parsing polarizability data",
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
parser.add_argument(
|
|
217
|
+
"-v", "--verbose", action="store_true", help="Enable verbose output"
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
args = parser.parse_args()
|
|
221
|
+
|
|
222
|
+
try:
|
|
223
|
+
# Run conversion
|
|
224
|
+
output_file = orca_to_extxyz(
|
|
225
|
+
args.input, args.output, args.charge, args.parse_alpha, args.verbose
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
print(f"Output file: {output_file}")
|
|
229
|
+
|
|
230
|
+
except Exception as e:
|
|
231
|
+
print(f"Error during conversion: {e}", file=sys.stderr)
|
|
232
|
+
if args.verbose:
|
|
233
|
+
import traceback
|
|
234
|
+
|
|
235
|
+
traceback.print_exc()
|
|
236
|
+
sys.exit(1)
|
emle/_units.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2023-2026 The EMLE-Engine developers
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
"""EMLE-Engine constants."""
|
|
5
|
+
|
|
6
|
+
import ase as _ase
|
|
7
|
+
|
|
8
|
+
_ANGSTROM_TO_BOHR = 1.0 / _ase.units.Bohr
|
|
9
|
+
_NANOMETER_TO_BOHR = 10.0 / _ase.units.Bohr
|
|
10
|
+
_BOHR_TO_ANGSTROM = _ase.units.Bohr
|
|
11
|
+
_EV_TO_HARTREE = 1.0 / _ase.units.Hartree
|
|
12
|
+
_KCAL_MOL_TO_HARTREE = 1.0 / _ase.units.Hartree * _ase.units.kcal / _ase.units.mol
|
|
13
|
+
_HARTREE_TO_KCAL_MOL = _ase.units.Hartree / _ase.units.kcal * _ase.units.mol
|
|
14
|
+
_HARTREE_TO_KJ_MOL = _ase.units.Hartree / _ase.units.kJ * _ase.units.mol
|
|
15
|
+
_NANOMETER_TO_ANGSTROM = 10.0
|
|
16
|
+
_HARTREE_BOHR_TO_EV_A = _ase.units.Hartree / _ase.units.Bohr
|
emle/_utils.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2023-2026 The EMLE-Engine developers
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
EMLE utility functions.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import numpy as _np
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def pad_to_shape(array, shape, value=0):
|
|
12
|
+
"""
|
|
13
|
+
Pad an array to a given shape.
|
|
14
|
+
|
|
15
|
+
Parameters
|
|
16
|
+
----------
|
|
17
|
+
|
|
18
|
+
array : numpy.ndarray
|
|
19
|
+
The array to pad.
|
|
20
|
+
|
|
21
|
+
shape : tuple
|
|
22
|
+
The desired shape of the array.
|
|
23
|
+
|
|
24
|
+
value : float, optional
|
|
25
|
+
The value to use for padding.
|
|
26
|
+
|
|
27
|
+
Returns
|
|
28
|
+
-------
|
|
29
|
+
|
|
30
|
+
padded_array : numpy.ndarray
|
|
31
|
+
The padded array.
|
|
32
|
+
"""
|
|
33
|
+
pad = [(0, n_max - n) for n_max, n in zip(shape, array.shape)]
|
|
34
|
+
return _np.pad(array, pad, constant_values=value)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def pad_to_max(arrays, value=0):
|
|
38
|
+
"""
|
|
39
|
+
Pad arrays to the size of the largest array along each axis.
|
|
40
|
+
|
|
41
|
+
Parameters
|
|
42
|
+
----------
|
|
43
|
+
|
|
44
|
+
arrays : List[numpy.ndarray]
|
|
45
|
+
The arrays to pad.
|
|
46
|
+
|
|
47
|
+
value : float, optional
|
|
48
|
+
The value to use for padding.
|
|
49
|
+
|
|
50
|
+
Returns
|
|
51
|
+
-------
|
|
52
|
+
|
|
53
|
+
padded_arrays : numpy.ndarray
|
|
54
|
+
The padded arrays.
|
|
55
|
+
"""
|
|
56
|
+
shape = _np.max([_.shape for _ in arrays], axis=0)
|
|
57
|
+
return _np.array([pad_to_shape(_, shape, value) for _ in arrays])
|