pwdata 0.5.9__tar.gz → 0.5.11.dev0__tar.gz
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 pwdata might be problematic. Click here for more details.
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/PKG-INFO +1 -1
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/convert_files.py +69 -2
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/extendedxyz.py +41 -11
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/image.py +12 -1
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/main.py +4 -2
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/meta.py +0 -14
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/test/mptraj2lmdb.py +5 -5
- pwdata-0.5.11.dev0/pwdata/test/test_meta_output.py +183 -0
- pwdata-0.5.11.dev0/pwdata/test/test_meta_stress.py +35 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/utils/constant.py +4 -1
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata.egg-info/PKG-INFO +1 -1
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata.egg-info/SOURCES.txt +2 -1
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/setup.py +1 -1
- pwdata-0.5.9/pwdata/tmp.py +0 -59
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/LICENSE +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/README.md +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/__init__.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/atomconfig.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/build/__init__.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/build/cell.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/build/geometry.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/build/supercells.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/build/write_struc.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/calculators/__init__.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/calculators/const.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/calculators/unitconvert_lmps.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/calculators/units.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/castepdata.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/check_envs.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/config.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/cp2kdata.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/datasets_saver.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/deepmd.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/dump.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/__init__.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/common/__init__.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/common/registry.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/common/typing.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/common/utils.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/datasets/__init__.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/datasets/_utils.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/datasets/ase_datasets.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/datasets/base_dataset.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/datasets/embeddings/__init__.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/datasets/embeddings/atomic_radii.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/datasets/embeddings/continuous_embeddings.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/datasets/embeddings/khot_embeddings.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/datasets/embeddings/qmof_khot_embeddings.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/datasets/lmdb_database.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/datasets/target_metadata_guesser.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/modules/__init__.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/modules/transforms.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/preprocessing/__init__.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/lammpsdata.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/lmps.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/meta_omol.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/molecule.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/movement.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/movement_saver.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/outcar.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/pertub/__init__.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/pertub/perturbation.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/pertub/scale.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/poscar.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/pwmlff.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/test/__init__.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/test/bamboo2lmdb.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/test/extact_outcar_with_ml.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/test/lmdb2aselmdb.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/test/matpbe2lmdb.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/test/matrcan2lmdb.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/test/mdtrajs2config.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/test/oc25.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/test/omol25.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/test/outcar2mvms.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/test/readasedb.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/test/surf_test.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/test.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/utils/__init__.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/utils/format_change.py +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata.egg-info/dependency_links.txt +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata.egg-info/entry_points.txt +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata.egg-info/requires.txt +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata.egg-info/top_level.txt +0 -0
- {pwdata-0.5.9 → pwdata-0.5.11.dev0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pwdata
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.11.dev0
|
|
4
4
|
Summary: pwdata is a data pre-processing tool for MatPL, which can be used to extract features and labels. It also provides convenient interfaces for data conversion between different software.
|
|
5
5
|
Home-page: https://github.com/LonxunQuantum/pwdata
|
|
6
6
|
Author: LonxunQuantum
|
|
@@ -3,6 +3,7 @@ import sys
|
|
|
3
3
|
import glob
|
|
4
4
|
import numpy as np
|
|
5
5
|
import random
|
|
6
|
+
import tempfile
|
|
6
7
|
from pwdata.config import Config
|
|
7
8
|
from pwdata.build.supercells import make_supercell
|
|
8
9
|
from pwdata.pertub.perturbation import perturb_structure
|
|
@@ -11,9 +12,10 @@ from pwdata.utils.constant import FORMAT, ELEMENTTABLE, get_atomic_name_from_num
|
|
|
11
12
|
from pwdata.castepdata import looks_like_castep_traj
|
|
12
13
|
from pwdata.image import Image
|
|
13
14
|
from collections import Counter
|
|
15
|
+
from ase import Atoms
|
|
14
16
|
from ase.build import general_surface
|
|
15
17
|
from ase.db.row import AtomsRow
|
|
16
|
-
from pwdata.fairchem.datasets.ase_datasets import AseDBDataset
|
|
18
|
+
from pwdata.fairchem.datasets.ase_datasets import AseDBDataset, LMDBDatabase
|
|
17
19
|
from concurrent.futures import ProcessPoolExecutor, as_completed
|
|
18
20
|
import multiprocessing
|
|
19
21
|
from tqdm import tqdm
|
|
@@ -243,8 +245,73 @@ param {*} data_shuffle
|
|
|
243
245
|
return {*}
|
|
244
246
|
author: wuxingxing
|
|
245
247
|
'''
|
|
248
|
+
def image_to_atomrow(image):
|
|
249
|
+
if image.Ep is None:
|
|
250
|
+
raise ValueError("META output requires energy for every image")
|
|
251
|
+
if image.force is None:
|
|
252
|
+
raise ValueError("META output requires forces for every image")
|
|
253
|
+
positions = image.position
|
|
254
|
+
if not image.cartesian:
|
|
255
|
+
positions = np.dot(positions, image.lattice)
|
|
256
|
+
atoms = Atoms(
|
|
257
|
+
positions=positions,
|
|
258
|
+
numbers=image.atom_types_image,
|
|
259
|
+
cell=image.lattice,
|
|
260
|
+
pbc=image.pbc,
|
|
261
|
+
)
|
|
262
|
+
atom_row = AtomsRow(atoms)
|
|
263
|
+
atom_row.energy = image.Ep
|
|
264
|
+
atom_row.force = image.force
|
|
265
|
+
atom_row.forces = image.force
|
|
266
|
+
if image.virial is not None:
|
|
267
|
+
volume = image.get_volume()
|
|
268
|
+
if volume == 0:
|
|
269
|
+
raise ValueError("Cannot write virial to META format for a zero-volume cell")
|
|
270
|
+
virial = np.asarray(image.virial).reshape(3, 3)
|
|
271
|
+
if not np.allclose(virial, virial.T, rtol=1e-7, atol=1e-8):
|
|
272
|
+
raise ValueError("META output requires a symmetric virial tensor")
|
|
273
|
+
virial = (virial + virial.T) / 2
|
|
274
|
+
stress = -virial / volume
|
|
275
|
+
atom_row.stress = np.array([
|
|
276
|
+
stress[0, 0], stress[1, 1], stress[2, 2],
|
|
277
|
+
stress[1, 2], stress[0, 2], stress[0, 1],
|
|
278
|
+
])
|
|
279
|
+
return atom_row
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def save_to_meta(savepath, images, data_shuffle=False):
|
|
283
|
+
os.makedirs(savepath, exist_ok=True)
|
|
284
|
+
output_file = os.path.join(savepath, FORMAT.meta_name)
|
|
285
|
+
if os.path.exists(output_file):
|
|
286
|
+
raise FileExistsError("META output already exists: {}".format(output_file))
|
|
287
|
+
output_images = list(images)
|
|
288
|
+
if data_shuffle:
|
|
289
|
+
random.Random(2024).shuffle(output_images)
|
|
290
|
+
descriptor, temporary_file = tempfile.mkstemp(
|
|
291
|
+
prefix=".dataset-", suffix=".aselmdb", dir=savepath
|
|
292
|
+
)
|
|
293
|
+
os.close(descriptor)
|
|
294
|
+
os.remove(temporary_file)
|
|
295
|
+
try:
|
|
296
|
+
with LMDBDatabase(filename=temporary_file, readonly=False) as database:
|
|
297
|
+
for index, image in enumerate(tqdm(output_images, desc="writing META")):
|
|
298
|
+
database._write(
|
|
299
|
+
image_to_atomrow(image),
|
|
300
|
+
key_value_pairs={},
|
|
301
|
+
data={"idx": index},
|
|
302
|
+
)
|
|
303
|
+
os.replace(temporary_file, output_file)
|
|
304
|
+
finally:
|
|
305
|
+
for path in (temporary_file, temporary_file + "-lock"):
|
|
306
|
+
if os.path.exists(path):
|
|
307
|
+
os.remove(path)
|
|
308
|
+
return output_file
|
|
309
|
+
|
|
310
|
+
|
|
246
311
|
def save_images(savepath, image_data, output_format, data_shuffle=False, merge=True):
|
|
247
|
-
if merge is True and output_format == FORMAT.
|
|
312
|
+
if merge is True and output_format == FORMAT.meta:
|
|
313
|
+
save_to_meta(savepath, image_data.images, data_shuffle)
|
|
314
|
+
elif merge is True and output_format == FORMAT.extxyz:
|
|
248
315
|
save_dir = savepath
|
|
249
316
|
image_data.to(
|
|
250
317
|
data_path=save_dir,
|
|
@@ -55,32 +55,45 @@ def get_xyz_content(image_data:Image):
|
|
|
55
55
|
xyz_content +="%d\n" % image_data.atom_nums
|
|
56
56
|
# data_name.write("Iteration: %s\n" % image_data.iteration)
|
|
57
57
|
has_bec = image_data.bec is not None and len(image_data.bec) > 0
|
|
58
|
+
has_fragment = image_data.fragment is not None and len(image_data.fragment) > 0
|
|
59
|
+
has_charge = image_data.charge is not None and len(image_data.charge) > 0
|
|
58
60
|
properties_head = "Properties=species:S:1:pos:R:3:"
|
|
59
61
|
properties_head += "bec:R:9:" if has_bec else ""
|
|
60
62
|
properties_head += "force:R:3"
|
|
63
|
+
properties_head += ":fragment:I:1" if has_fragment else ""
|
|
64
|
+
properties_head += ":charge:R:1" if has_charge else ""
|
|
61
65
|
output_head = 'Lattice="%.5f %.5f %.5f %.5f %.5f %.5f %.5f %.5f %.5f" {} pbc="T T T" energy={} '.format(properties_head, image_data.Ep)
|
|
62
66
|
output_extended = (image_data.lattice[0][0], image_data.lattice[0][1], image_data.lattice[0][2],
|
|
63
67
|
image_data.lattice[1][0], image_data.lattice[1][1], image_data.lattice[1][2],
|
|
64
68
|
image_data.lattice[2][0], image_data.lattice[2][1], image_data.lattice[2][2])
|
|
65
69
|
if image_data.virial is not None and len(image_data.virial) > 0:
|
|
66
|
-
output_head += 'virial="%.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f"'
|
|
70
|
+
output_head += 'virial="%.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f" '
|
|
67
71
|
virial = image_data.get_virial()
|
|
68
72
|
output_extended += (virial[0][0], virial[0][1], virial[0][2],
|
|
69
73
|
virial[1][0], virial[1][1], virial[1][2],
|
|
70
74
|
virial[2][0], virial[2][1], virial[2][2])
|
|
75
|
+
if image_data.fragment_charge_status is not None:
|
|
76
|
+
output_head += "fragment_charge_status={} ".format(image_data.fragment_charge_status)
|
|
71
77
|
output_head += '\n'
|
|
72
78
|
xyz_content += output_head % output_extended
|
|
73
79
|
|
|
74
80
|
for j in range(image_data.atom_nums):
|
|
81
|
+
properties_format = "%s"
|
|
82
|
+
properties = [elements[image_data.atom_types_image[j]], image_data.position[j][0], image_data.position[j][1], image_data.position[j][2]]
|
|
83
|
+
properties_format += " %14.8f %14.8f %14.8f"
|
|
75
84
|
if has_bec:
|
|
76
|
-
properties_format
|
|
77
|
-
properties
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
properties_format += " " + " %14.8f" * 9
|
|
86
|
+
properties.extend(image_data.bec[j].reshape(-1))
|
|
87
|
+
properties_format += " %14.8f %14.8f %14.8f"
|
|
88
|
+
properties.extend([image_data.force[j][0], image_data.force[j][1], image_data.force[j][2]])
|
|
89
|
+
if has_fragment:
|
|
90
|
+
properties_format += " %d"
|
|
91
|
+
properties.append(image_data.fragment[j])
|
|
92
|
+
if has_charge:
|
|
93
|
+
properties_format += " %14.8f"
|
|
94
|
+
properties.append(image_data.charge[j])
|
|
95
|
+
properties_format += "\n"
|
|
96
|
+
xyz_content += properties_format % tuple(properties)
|
|
84
97
|
return xyz_content
|
|
85
98
|
|
|
86
99
|
def read_structures(
|
|
@@ -142,11 +155,14 @@ def read_one_structures_from_lines(lines:list[str]):
|
|
|
142
155
|
result_dict = {key.lower(): value.strip('"') for key, value in matches}
|
|
143
156
|
image.Ep = float(result_dict["energy"])
|
|
144
157
|
properties = result_dict["properties"].split(":")
|
|
145
|
-
atom_types_image, postion, force, bec = read_properties_data(image.atom_nums, properties, lines[1:])
|
|
158
|
+
atom_types_image, postion, force, bec, fragment, charge = read_properties_data(image.atom_nums, properties, lines[1:])
|
|
146
159
|
image.force = force
|
|
147
160
|
image.position = postion
|
|
148
161
|
image.atom_types_image = atom_types_image
|
|
149
162
|
image.bec = bec
|
|
163
|
+
image.fragment = fragment
|
|
164
|
+
image.charge = charge
|
|
165
|
+
image.fragment_charge_status = result_dict.get("fragment_charge_status")
|
|
150
166
|
lattice = [float(i) for i in result_dict["lattice"].split()]
|
|
151
167
|
assert len(lattice) == 9, "lattice in extxyz file should has 9 elements"
|
|
152
168
|
image.lattice = np.array(lattice).reshape(-1, 3)
|
|
@@ -190,6 +206,10 @@ def read_properties_data(
|
|
|
190
206
|
assert force_key in property_map, "force or forces property is required in extxyz file"
|
|
191
207
|
if "bec" in property_map:
|
|
192
208
|
assert property_map["bec"][1] == 9, "bec in extxyz file should has 9 elements per atom"
|
|
209
|
+
if "fragment" in property_map:
|
|
210
|
+
assert property_map["fragment"][1] == 1, "fragment in extxyz file should has 1 element per atom"
|
|
211
|
+
if "charge" in property_map:
|
|
212
|
+
assert property_map["charge"][1] == 1, "charge in extxyz file should has 1 element per atom"
|
|
193
213
|
|
|
194
214
|
species_offset, _ = property_map["species"]
|
|
195
215
|
pos_offset, pos_size = property_map["pos"]
|
|
@@ -198,11 +218,15 @@ def read_properties_data(
|
|
|
198
218
|
assert force_size == 3, "force in extxyz file should has 3 elements per atom"
|
|
199
219
|
|
|
200
220
|
bec_offset = property_map["bec"][0] if "bec" in property_map else None
|
|
221
|
+
fragment_offset = property_map["fragment"][0] if "fragment" in property_map else None
|
|
222
|
+
charge_offset = property_map["charge"][0] if "charge" in property_map else None
|
|
201
223
|
assert num_atom == len(lines)
|
|
202
224
|
type_list = []
|
|
203
225
|
force = []
|
|
204
226
|
position= []
|
|
205
227
|
bec = [] if bec_offset is not None else None
|
|
228
|
+
fragment = [] if fragment_offset is not None else None
|
|
229
|
+
charge = [] if charge_offset is not None else None
|
|
206
230
|
for line in lines:
|
|
207
231
|
data = line.split()
|
|
208
232
|
type_list.append(ELEMENTTABLE[data[species_offset]])
|
|
@@ -210,9 +234,15 @@ def read_properties_data(
|
|
|
210
234
|
position.append([float(data[pos_offset]), float(data[pos_offset + 1]), float(data[pos_offset + 2])])
|
|
211
235
|
if bec_offset is not None:
|
|
212
236
|
bec.append([float(data[bec_offset + i]) for i in range(9)])
|
|
237
|
+
if fragment_offset is not None:
|
|
238
|
+
fragment.append(int(data[fragment_offset]))
|
|
239
|
+
if charge_offset is not None:
|
|
240
|
+
charge.append(float(data[charge_offset]))
|
|
213
241
|
type_list = np.array(type_list) #.reshape(-1, 1)
|
|
214
242
|
position = np.array(position)
|
|
215
243
|
force = np.array(force)
|
|
216
244
|
bec = np.array(bec).reshape(num_atom, 9) if bec is not None else None
|
|
217
|
-
|
|
245
|
+
fragment = np.array(fragment, dtype=int) if fragment is not None else None
|
|
246
|
+
charge = np.array(charge, dtype=float) if charge is not None else None
|
|
247
|
+
return type_list, position, force, bec, fragment, charge
|
|
218
248
|
|
|
@@ -13,7 +13,8 @@ class Image(object):
|
|
|
13
13
|
atom_type = None, atom_type_num = None, atom_nums = None, atom_types_image = None,
|
|
14
14
|
iteration = None, Etot = None, Ep = None, Ek = None, scf = None, lattice = None,
|
|
15
15
|
virial = None, position = None, force = None, atomic_energy = None,
|
|
16
|
-
bec = None,
|
|
16
|
+
bec = None, fragment = None, charge = None, fragment_charge_status = None,
|
|
17
|
+
content = None, image_nums = None, pbc = None, cartesian = None):
|
|
17
18
|
"""
|
|
18
19
|
Represents an image in a AIMD trajectory.
|
|
19
20
|
|
|
@@ -30,6 +31,9 @@ class Image(object):
|
|
|
30
31
|
lattice (list): The lattice vectors.
|
|
31
32
|
virial (list): The virial tensor.
|
|
32
33
|
bec (list): The Born effective charge tensor per atom, shape (atom_nums, 9).
|
|
34
|
+
fragment (list): The fragment index per atom, shape (atom_nums,).
|
|
35
|
+
charge (list): The atomic charge per atom, shape (atom_nums,), may contain np.nan.
|
|
36
|
+
fragment_charge_status (str): The status of fragment charge, such as resolved or unresolved.
|
|
33
37
|
position (list): The atomic positions.
|
|
34
38
|
force (list): The atomic forces.
|
|
35
39
|
atomic_energy (list): The atomic energies.
|
|
@@ -51,6 +55,9 @@ class Image(object):
|
|
|
51
55
|
self.lattice = to_numpy_array(lattice)
|
|
52
56
|
self.virial = to_numpy_array(virial)
|
|
53
57
|
self.bec = to_numpy_array(bec)
|
|
58
|
+
self.fragment = to_numpy_array(fragment)
|
|
59
|
+
self.charge = to_numpy_array(charge)
|
|
60
|
+
self.fragment_charge_status = fragment_charge_status
|
|
54
61
|
self.position = to_numpy_array(position) # this position can be fractional coordinates or cartesian coordinates
|
|
55
62
|
self.force = to_numpy_array(force)
|
|
56
63
|
self.atomic_energy = to_numpy_array(atomic_energy)
|
|
@@ -69,6 +76,10 @@ class Image(object):
|
|
|
69
76
|
self.atomic_energy = self.atomic_energy[sort_indices]
|
|
70
77
|
if self.bec is not None:
|
|
71
78
|
self.bec = self.bec[sort_indices]
|
|
79
|
+
if self.fragment is not None:
|
|
80
|
+
self.fragment = self.fragment[sort_indices]
|
|
81
|
+
if self.charge is not None:
|
|
82
|
+
self.charge = self.charge[sort_indices]
|
|
72
83
|
cout_type, indices = np.unique(self.atom_types_image, return_index=True)
|
|
73
84
|
sorted_indices = np.argsort(indices)
|
|
74
85
|
cout_type = cout_type[sorted_indices]
|
|
@@ -343,7 +343,7 @@ def run_convert_configs(cmd_list:list[str]):
|
|
|
343
343
|
parser.add_argument('-i', '--input', type=str, required=True, nargs='+', help="The directory or file path of the datas.\nYou can also use JSON file to list all file paths in 'datapath': [], such as 'pwdata/test/meta_data.json'")
|
|
344
344
|
parser.add_argument('-f', '--input_format', type=str, required=False, default=None, help="The input file format, if not specified, the format will be automatically inferred based on the input files. the supported format as {}".format(FORMAT.support_images_format))
|
|
345
345
|
parser.add_argument('-s', '--savepath', type=str, required=False, help="The output dir path, if not provided, the current dir will be used", default="./")
|
|
346
|
-
parser.add_argument('-o', '--output_format', type=str, required=False, default='pwmlff/npy', help="the output file format, only support the format ['pwmlff/npy','extxyz'], if not provided, the 'pwmlff/npy' format be used. ")
|
|
346
|
+
parser.add_argument('-o', '--output_format', type=str, required=False, default='pwmlff/npy', help="the output file format, only support the format ['pwmlff/npy','extxyz','meta'], if not provided, the 'pwmlff/npy' format be used. ")
|
|
347
347
|
# parser.add_argument('-c', '--cartesian', action='store_true', help="if '-c' is set, the cartesian coordinates will be used, otherwise the fractional coordinates will be used.")
|
|
348
348
|
parser.add_argument('-r', '--split_rand', action='store_true', help="Whether to randomly divide the dataset into training and test sets, '-r' is randomly")
|
|
349
349
|
parser.add_argument('-m', '--merge', type=int, required=False, default=1, help="if '-m 1' the output config files will save into one xyzfile. Otherwise, the out configs will be saved separately according to the structural element types. The default value is 1")
|
|
@@ -378,9 +378,11 @@ def run_convert_configs(cmd_list:list[str]):
|
|
|
378
378
|
else:
|
|
379
379
|
args.gap = f"::{args.gap}"
|
|
380
380
|
# FORMAT.check_format(args.input_format, FORMAT.support_images_format)
|
|
381
|
-
FORMAT.check_format(args.output_format, [FORMAT.pwmlff_npy, FORMAT.extxyz])
|
|
381
|
+
FORMAT.check_format(args.output_format, [FORMAT.pwmlff_npy, FORMAT.extxyz, FORMAT.meta])
|
|
382
382
|
|
|
383
383
|
merge = True if args.merge == 1 else False
|
|
384
|
+
if args.output_format == FORMAT.meta and not merge:
|
|
385
|
+
raise ValueError("META output requires -m 1")
|
|
384
386
|
do_convert_images(input_list, args.input_format, args.savepath, args.output_format, args.split_rand, args.gap, atom_types, args.query, args.cpu_nums, merge)
|
|
385
387
|
|
|
386
388
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import numpy as np
|
|
2
|
-
import re
|
|
3
2
|
import os, glob
|
|
4
3
|
from tqdm import tqdm
|
|
5
4
|
from pwdata.image import Image
|
|
@@ -85,10 +84,6 @@ class META(object):
|
|
|
85
84
|
"""处理每个 atom_list 并转换为对象列表"""
|
|
86
85
|
return [to_image(Atoms) for Atoms in atom_list]
|
|
87
86
|
|
|
88
|
-
# MPtrj LMDB stores stress in kbar rather than eV/ų
|
|
89
|
-
# 1 kbar = 6.241509e-4 eV/ų
|
|
90
|
-
KBAR_TO_EV_PER_A3 = 6.241509e-4
|
|
91
|
-
|
|
92
87
|
def load_and_query_db(db_address, atom_types, query, filter_with_elements):
|
|
93
88
|
# 加载数据库
|
|
94
89
|
try:
|
|
@@ -109,15 +104,6 @@ def load_and_query_db(db_address, atom_types, query, filter_with_elements):
|
|
|
109
104
|
else: # query is not None and atom_types is None
|
|
110
105
|
atom_list.extend(list(dbs.select(query)))
|
|
111
106
|
|
|
112
|
-
# MPtrj 系列数据集 stress 单位为 kbar,需转为 eV/ų
|
|
113
|
-
if re.search(r'mptrj', db_address, re.IGNORECASE):
|
|
114
|
-
for atoms in atom_list:
|
|
115
|
-
try:
|
|
116
|
-
stress_val = atoms.stress
|
|
117
|
-
if stress_val is not None:
|
|
118
|
-
atoms.stress = np.array(stress_val, dtype=float) * KBAR_TO_EV_PER_A3
|
|
119
|
-
except (AttributeError, TypeError):
|
|
120
|
-
pass
|
|
121
107
|
return atom_list
|
|
122
108
|
|
|
123
109
|
def query_fun(row, elements):
|
|
@@ -12,9 +12,9 @@ from tqdm import tqdm
|
|
|
12
12
|
import numpy as np
|
|
13
13
|
|
|
14
14
|
def MPjson2lmdb():
|
|
15
|
-
mp_file = "/data/home/wuxingxing/codespace/pwdata_dev/examples/mp_data/mptest.json"
|
|
16
|
-
|
|
17
|
-
save_file = "/data/
|
|
15
|
+
# mp_file = "/data/home/wuxingxing/codespace/pwdata_dev/examples/mp_data/mptest.json"
|
|
16
|
+
mp_file = "/data/public/wuxingxing/MPtrj/MPtrj_2022.9_full.json"# 12G too big
|
|
17
|
+
save_file = "/data/public/wuxingxing/MPtrj/mptrj-Ep-uncorrected.aselmdb"
|
|
18
18
|
matjson = json.load(open(mp_file))
|
|
19
19
|
db = LMDBDatabase(filename=save_file, readonly=False)
|
|
20
20
|
for key_1, val_1 in tqdm(matjson.items(), total=len(matjson.keys())):
|
|
@@ -39,12 +39,12 @@ def cvt_mpdict_2_atomrow(config:dict):
|
|
|
39
39
|
stress = read_from_dict('stress', config, require=True)
|
|
40
40
|
atom_rows.stress = [stress[0][0],stress[1][1],stress[2][2],stress[1][2],stress[0][2],stress[0][1]]
|
|
41
41
|
force = read_from_dict('force', config, require=True)
|
|
42
|
-
energy = read_from_dict('
|
|
42
|
+
energy = read_from_dict('uncorrected_total_energy', config, require=True)
|
|
43
43
|
atom_rows.__setattr__('force', force)
|
|
44
44
|
atom_rows.__setattr__('energy', energy)
|
|
45
45
|
data = {}
|
|
46
46
|
data['uncorrected_total_energy'] = read_from_dict('uncorrected_total_energy', config, default=None)
|
|
47
|
-
data['corrected_total_energy'] = read_from_dict('
|
|
47
|
+
data['corrected_total_energy'] = read_from_dict('corrected_total_energy', config, default=None)
|
|
48
48
|
data['energy_per_atom'] = read_from_dict('energy_per_atom', config, default=None)
|
|
49
49
|
data['ef_per_atom'] = read_from_dict('ef_per_atom', config, default=None)
|
|
50
50
|
data['e_per_atom_relaxed'] = read_from_dict('e_per_atom_relaxed', config, default=None)
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import pytest
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from pwdata.config import Config
|
|
6
|
+
from pwdata.convert_files import image_to_atomrow, save_to_meta
|
|
7
|
+
from pwdata.image import Image
|
|
8
|
+
from pwdata.main import run_convert_configs
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
EXTXYZ_FRAME = """2
|
|
12
|
+
Lattice=\"3.0 0.0 0.0 0.0 4.0 0.0 0.0 0.0 5.0\" Properties=species:S:1:pos:R:3:forces:R:3 energy=-1.25 virial=\"1.0 0.2 0.3 0.2 2.0 0.4 0.3 0.4 3.0\" pbc=\"T F T\"
|
|
13
|
+
H 0.1 0.2 0.3 1.0 2.0 3.0
|
|
14
|
+
O 1.1 1.2 1.3 -1.0 -2.0 -3.0
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def make_image(lattice=None, energy=-1.0, force=None, virial=None):
|
|
19
|
+
return Image(
|
|
20
|
+
atom_nums=1,
|
|
21
|
+
atom_types_image=[1],
|
|
22
|
+
lattice=np.eye(3) if lattice is None else lattice,
|
|
23
|
+
position=[[0.0, 0.0, 0.0]],
|
|
24
|
+
force=[[0.0, 0.0, 0.0]] if force is None else force,
|
|
25
|
+
Ep=energy,
|
|
26
|
+
virial=np.eye(3) if virial is None else virial,
|
|
27
|
+
pbc=[True, True, True],
|
|
28
|
+
cartesian=True,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_cvt_configs_writes_meta_database_readable_by_pwdata(tmp_path):
|
|
33
|
+
source = tmp_path / "input.xyz"
|
|
34
|
+
output_dir = tmp_path / "output"
|
|
35
|
+
source.write_text(EXTXYZ_FRAME, encoding="utf-8")
|
|
36
|
+
source_image = Config(data_path=str(source), format="extxyz").images[0]
|
|
37
|
+
|
|
38
|
+
run_convert_configs(
|
|
39
|
+
[
|
|
40
|
+
"-i",
|
|
41
|
+
str(source),
|
|
42
|
+
"-f",
|
|
43
|
+
"extxyz",
|
|
44
|
+
"-s",
|
|
45
|
+
str(output_dir),
|
|
46
|
+
"-o",
|
|
47
|
+
"meta",
|
|
48
|
+
]
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
output_file = output_dir / "dataset.aselmdb"
|
|
52
|
+
assert output_file.is_file()
|
|
53
|
+
|
|
54
|
+
converted = Config(data_path=str(output_file), format="meta")
|
|
55
|
+
assert len(converted.images) == 1
|
|
56
|
+
image = converted.images[0]
|
|
57
|
+
|
|
58
|
+
np.testing.assert_array_equal(image.atom_types_image, [1, 8])
|
|
59
|
+
np.testing.assert_allclose(image.lattice, np.diag([3.0, 4.0, 5.0]))
|
|
60
|
+
np.testing.assert_allclose(
|
|
61
|
+
image.position, [[0.1, 0.2, 0.3], [1.1, 1.2, 1.3]]
|
|
62
|
+
)
|
|
63
|
+
np.testing.assert_array_equal(image.pbc, source_image.pbc)
|
|
64
|
+
assert image.Ep == -1.25
|
|
65
|
+
np.testing.assert_allclose(
|
|
66
|
+
image.force, [[1.0, 2.0, 3.0], [-1.0, -2.0, -3.0]]
|
|
67
|
+
)
|
|
68
|
+
np.testing.assert_allclose(
|
|
69
|
+
image.virial, [[1.0, 0.2, 0.3], [0.2, 2.0, 0.4], [0.3, 0.4, 3.0]]
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def test_cvt_configs_rejects_unmerged_meta_output(tmp_path):
|
|
74
|
+
source = tmp_path / "input.xyz"
|
|
75
|
+
source.write_text(EXTXYZ_FRAME, encoding="utf-8")
|
|
76
|
+
|
|
77
|
+
with pytest.raises(ValueError, match="META output requires -m 1"):
|
|
78
|
+
run_convert_configs(
|
|
79
|
+
[
|
|
80
|
+
"-i",
|
|
81
|
+
str(source),
|
|
82
|
+
"-f",
|
|
83
|
+
"extxyz",
|
|
84
|
+
"-s",
|
|
85
|
+
str(tmp_path / "output"),
|
|
86
|
+
"-o",
|
|
87
|
+
"meta",
|
|
88
|
+
"-m",
|
|
89
|
+
"0",
|
|
90
|
+
]
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_cvt_configs_converts_pwmlff_npy_to_meta(tmp_path):
|
|
95
|
+
source = Path(__file__).parents[2] / "examples" / "pwmlff_data" / "LiSiC" / "C2"
|
|
96
|
+
output_dir = tmp_path / "output"
|
|
97
|
+
expected = Config(data_path=str(source), format="pwmlff/npy")
|
|
98
|
+
|
|
99
|
+
run_convert_configs(
|
|
100
|
+
[
|
|
101
|
+
"-i",
|
|
102
|
+
str(source),
|
|
103
|
+
"-f",
|
|
104
|
+
"pwmlff/npy",
|
|
105
|
+
"-s",
|
|
106
|
+
str(output_dir),
|
|
107
|
+
"-o",
|
|
108
|
+
"meta",
|
|
109
|
+
]
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
converted = Config(
|
|
113
|
+
data_path=str(output_dir / "dataset.aselmdb"), format="meta"
|
|
114
|
+
)
|
|
115
|
+
assert len(converted.images) == len(expected.images) == 15
|
|
116
|
+
np.testing.assert_array_equal(
|
|
117
|
+
converted.images[0].atom_types_image, expected.images[0].atom_types_image
|
|
118
|
+
)
|
|
119
|
+
expected_position = expected.images[0].position
|
|
120
|
+
if not expected.images[0].cartesian:
|
|
121
|
+
expected_position = np.dot(expected_position, expected.images[0].lattice)
|
|
122
|
+
np.testing.assert_allclose(converted.images[0].position, expected_position)
|
|
123
|
+
np.testing.assert_allclose(converted.images[0].force, expected.images[0].force)
|
|
124
|
+
np.testing.assert_allclose(converted.images[0].virial, expected.images[0].virial)
|
|
125
|
+
assert converted.images[0].Ep == expected.images[0].Ep
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def test_cvt_configs_refuses_to_append_to_existing_meta_database(tmp_path):
|
|
129
|
+
source = tmp_path / "input.xyz"
|
|
130
|
+
output_dir = tmp_path / "output"
|
|
131
|
+
source.write_text(EXTXYZ_FRAME, encoding="utf-8")
|
|
132
|
+
args = [
|
|
133
|
+
"-i",
|
|
134
|
+
str(source),
|
|
135
|
+
"-f",
|
|
136
|
+
"extxyz",
|
|
137
|
+
"-s",
|
|
138
|
+
str(output_dir),
|
|
139
|
+
"-o",
|
|
140
|
+
"meta",
|
|
141
|
+
]
|
|
142
|
+
run_convert_configs(args)
|
|
143
|
+
|
|
144
|
+
with pytest.raises(FileExistsError, match="already exists"):
|
|
145
|
+
run_convert_configs(args)
|
|
146
|
+
|
|
147
|
+
converted = Config(
|
|
148
|
+
data_path=str(output_dir / "dataset.aselmdb"), format="meta"
|
|
149
|
+
)
|
|
150
|
+
assert len(converted.images) == 1
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
@pytest.mark.parametrize(
|
|
154
|
+
("energy", "force", "missing_label"),
|
|
155
|
+
[(None, [[0.0, 0.0, 0.0]], "energy"), (-1.0, None, "forces")],
|
|
156
|
+
)
|
|
157
|
+
def test_meta_output_rejects_missing_training_labels(energy, force, missing_label):
|
|
158
|
+
image = make_image(energy=energy, force=force)
|
|
159
|
+
if missing_label == "forces":
|
|
160
|
+
image.force = None
|
|
161
|
+
|
|
162
|
+
with pytest.raises(ValueError, match="requires {}".format(missing_label)):
|
|
163
|
+
image_to_atomrow(image)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def test_meta_output_rejects_asymmetric_virial():
|
|
167
|
+
image = make_image(
|
|
168
|
+
virial=[[1.0, 0.2, 0.0], [0.4, 2.0, 0.0], [0.0, 0.0, 3.0]]
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
with pytest.raises(ValueError, match="symmetric virial"):
|
|
172
|
+
image_to_atomrow(image)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def test_meta_output_removes_partial_database_after_failure(tmp_path):
|
|
176
|
+
valid_image = make_image()
|
|
177
|
+
invalid_image = make_image(lattice=np.zeros((3, 3)))
|
|
178
|
+
|
|
179
|
+
with pytest.raises(ValueError, match="zero-volume cell"):
|
|
180
|
+
save_to_meta(tmp_path, [valid_image, invalid_image])
|
|
181
|
+
|
|
182
|
+
assert not (tmp_path / "dataset.aselmdb").exists()
|
|
183
|
+
assert list(tmp_path.iterdir()) == []
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import shutil
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
import pytest
|
|
5
|
+
from ase import Atoms
|
|
6
|
+
from ase.calculators.singlepoint import SinglePointCalculator
|
|
7
|
+
|
|
8
|
+
from pwdata.config import Config
|
|
9
|
+
from pwdata.fairchem.datasets.ase_datasets import LMDBDatabase
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@pytest.mark.parametrize("cpu_nums", [1, 2])
|
|
13
|
+
@pytest.mark.parametrize("relative_path", ["mptrj.aselmdb", "MPTRJ/dataset.aselmdb"])
|
|
14
|
+
def test_meta_stress_is_independent_of_database_path(tmp_path, cpu_nums, relative_path):
|
|
15
|
+
stress = np.array([[0.1, 0.02, 0.03], [0.02, -0.2, 0.04], [0.03, 0.04, 0.3]])
|
|
16
|
+
atoms = Atoms("H", positions=[[0.0, 0.0, 0.0]], cell=[2.0, 3.0, 4.0], pbc=True)
|
|
17
|
+
atoms.calc = SinglePointCalculator(
|
|
18
|
+
atoms, energy=-1.25, forces=np.zeros((1, 3)), stress=stress
|
|
19
|
+
)
|
|
20
|
+
source = tmp_path / "standard.aselmdb"
|
|
21
|
+
db = LMDBDatabase(filename=str(source), readonly=False)
|
|
22
|
+
try:
|
|
23
|
+
db.write(atoms)
|
|
24
|
+
finally:
|
|
25
|
+
db.close()
|
|
26
|
+
copied = tmp_path / relative_path
|
|
27
|
+
copied.parent.mkdir(parents=True, exist_ok=True)
|
|
28
|
+
shutil.copyfile(source, copied)
|
|
29
|
+
|
|
30
|
+
expected = -stress * atoms.get_volume()
|
|
31
|
+
for path in (source, copied):
|
|
32
|
+
image = Config(data_path=str(path), format="meta", cpu_nums=cpu_nums).images[0]
|
|
33
|
+
np.testing.assert_allclose(image.virial, expected)
|
|
34
|
+
assert image.Ep == -1.25
|
|
35
|
+
np.testing.assert_array_equal(image.force, np.zeros((1, 3)))
|
|
@@ -38,6 +38,7 @@ class FORMAT:
|
|
|
38
38
|
extxyz="extxyz"
|
|
39
39
|
extxyz_name="extxyz.xyz"
|
|
40
40
|
meta = "meta"
|
|
41
|
+
meta_name = "dataset.aselmdb"
|
|
41
42
|
traj = "traj"
|
|
42
43
|
|
|
43
44
|
support_config_format = [pwmat_config, vasp_poscar, lammps_lmp, cp2k_scf, castep_scf]
|
|
@@ -62,6 +63,8 @@ class FORMAT:
|
|
|
62
63
|
return FORMAT.pwmlff_npy_name
|
|
63
64
|
elif input_format == FORMAT.extxyz:
|
|
64
65
|
return FORMAT.extxyz_name
|
|
66
|
+
elif input_format == FORMAT.meta:
|
|
67
|
+
return FORMAT.meta_name
|
|
65
68
|
else:
|
|
66
69
|
raise ValueError("Unknown format: {}".format(input_format))
|
|
67
70
|
|
|
@@ -146,4 +149,4 @@ def get_atomic_name_from_str(atom_strs):
|
|
|
146
149
|
return get_atomic_number_from_name(atom_strs)
|
|
147
150
|
|
|
148
151
|
def check_atom_type_name(atom_types:list[str]):
|
|
149
|
-
return all([_ in ELEMENTTABLE.keys() for _ in atom_types])
|
|
152
|
+
return all([_ in ELEMENTTABLE.keys() for _ in atom_types])
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pwdata
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.11.dev0
|
|
4
4
|
Summary: pwdata is a data pre-processing tool for MatPL, which can be used to extract features and labels. It also provides convenient interfaces for data conversion between different software.
|
|
5
5
|
Home-page: https://github.com/LonxunQuantum/pwdata
|
|
6
6
|
Author: LonxunQuantum
|
|
@@ -25,7 +25,6 @@ pwdata/outcar.py
|
|
|
25
25
|
pwdata/poscar.py
|
|
26
26
|
pwdata/pwmlff.py
|
|
27
27
|
pwdata/test.py
|
|
28
|
-
pwdata/tmp.py
|
|
29
28
|
pwdata.egg-info/PKG-INFO
|
|
30
29
|
pwdata.egg-info/SOURCES.txt
|
|
31
30
|
pwdata.egg-info/dependency_links.txt
|
|
@@ -76,6 +75,8 @@ pwdata/test/omol25.py
|
|
|
76
75
|
pwdata/test/outcar2mvms.py
|
|
77
76
|
pwdata/test/readasedb.py
|
|
78
77
|
pwdata/test/surf_test.py
|
|
78
|
+
pwdata/test/test_meta_output.py
|
|
79
|
+
pwdata/test/test_meta_stress.py
|
|
79
80
|
pwdata/utils/__init__.py
|
|
80
81
|
pwdata/utils/constant.py
|
|
81
82
|
pwdata/utils/format_change.py
|
|
@@ -11,7 +11,7 @@ with open("README.md", "r") as fh:
|
|
|
11
11
|
|
|
12
12
|
setuptools.setup(
|
|
13
13
|
name="pwdata",
|
|
14
|
-
version="0.5.
|
|
14
|
+
version="0.5.11.dev0",
|
|
15
15
|
author="LonxunQuantum",
|
|
16
16
|
author_email="lonxun@pwmat.com",
|
|
17
17
|
description="pwdata is a data pre-processing tool for MatPL, which can be used to extract features and labels. It also provides convenient interfaces for data conversion between different software.",
|
pwdata-0.5.9/pwdata/tmp.py
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
from ase.io import read, write
|
|
2
|
-
import os
|
|
3
|
-
import glob
|
|
4
|
-
|
|
5
|
-
"""
|
|
6
|
-
xyz_file = "/data/home/wuxingxing/codespace/EDM/outputs/edm_qm9/bk_eval/stabel_pwmat/0/molecule_stable_000.xyz"
|
|
7
|
-
atoms = read(xyz_file)
|
|
8
|
-
atoms.center(vacuum=8)
|
|
9
|
-
# 获取原子符号列表,并排序
|
|
10
|
-
symbols = atoms.get_chemical_symbols()
|
|
11
|
-
sorted_indices = sorted(range(len(symbols)), key=lambda i: symbols[i])
|
|
12
|
-
|
|
13
|
-
# 按排序后的索引重新排列原子
|
|
14
|
-
atoms_sorted = atoms[sorted_indices]
|
|
15
|
-
|
|
16
|
-
save_file = "/data/home/wuxingxing/codespace/EDM/outputs/edm_qm9/bk_eval/stabel_pwmat/0/sort.0.POSCAR"
|
|
17
|
-
write(filename=save_file, images=atoms_sorted, format="vasp")
|
|
18
|
-
"""
|
|
19
|
-
|
|
20
|
-
pseudo = ["/data/home/wuxingxing/codespace/EDM/outputs/edm_qm9/bk_eval/stabel_pwmat/F.SG15.PBE.UPF",
|
|
21
|
-
"/data/home/wuxingxing/codespace/EDM/outputs/edm_qm9/bk_eval/stabel_pwmat/N.SG15.PBE.UPF",
|
|
22
|
-
"/data/home/wuxingxing/codespace/EDM/outputs/edm_qm9/bk_eval/stabel_pwmat/C.SG15.PBE.UPF",
|
|
23
|
-
"/data/home/wuxingxing/codespace/EDM/outputs/edm_qm9/bk_eval/stabel_pwmat/H.SG15.PBE.UPF",
|
|
24
|
-
"/data/home/wuxingxing/codespace/EDM/outputs/edm_qm9/bk_eval/stabel_pwmat/O.SG15.PBE.UPF",
|
|
25
|
-
"/data/home/wuxingxing/codespace/EDM/outputs/edm_qm9/bk_eval/stabel_pwmat/etot.input",
|
|
26
|
-
"/data/home/wuxingxing/codespace/EDM/outputs/edm_qm9/bk_eval/stabel_pwmat/run.sh"]
|
|
27
|
-
|
|
28
|
-
def set_path():
|
|
29
|
-
xyz_path = "/data/home/wuxingxing/codespace/EDM/outputs/edm_qm9/bk_eval/molecules"
|
|
30
|
-
save_path= "/data/home/wuxingxing/codespace/EDM/outputs/edm_qm9/bk_eval/stabel_pwmat"
|
|
31
|
-
xyz_files = glob.glob(os.path.join(xyz_path, "molecule_stable_*.xyz"))
|
|
32
|
-
for xyz_file in xyz_files:
|
|
33
|
-
if "molecule_stable_000.xyz" in os.path.basename(xyz_file):
|
|
34
|
-
pass
|
|
35
|
-
atoms = read(xyz_file)
|
|
36
|
-
atoms.center(vacuum=8)
|
|
37
|
-
# 获取原子符号列表,并排序
|
|
38
|
-
symbols = atoms.get_chemical_symbols()
|
|
39
|
-
sorted_indices = sorted(range(len(symbols)), key=lambda i: symbols[i])
|
|
40
|
-
|
|
41
|
-
# 按排序后的索引重新排列原子
|
|
42
|
-
atoms_sorted = atoms[sorted_indices]
|
|
43
|
-
idx = int(xyz_file.split("/")[-1].split("_")[-1].split(".")[0])
|
|
44
|
-
save_dir = os.path.join(save_path, "{}".format(idx))
|
|
45
|
-
if not os.path.exists(save_dir):
|
|
46
|
-
os.makedirs(save_dir)
|
|
47
|
-
save_file = os.path.join(save_dir, "POSCAR")
|
|
48
|
-
write(filename=save_file, images=atoms_sorted, format="vasp")
|
|
49
|
-
|
|
50
|
-
for _tmp in pseudo:
|
|
51
|
-
os.system(f"cp {_tmp} {save_dir}")
|
|
52
|
-
|
|
53
|
-
cwd = os.getcwd()
|
|
54
|
-
os.chdir(save_dir)
|
|
55
|
-
os.system("pwdata cvt_config -i POSCAR -f vasp/poscar -o pwmat/config")
|
|
56
|
-
os.chdir(cwd)
|
|
57
|
-
|
|
58
|
-
if __name__ == "__main__":
|
|
59
|
-
set_path() # pwmat
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/datasets/embeddings/continuous_embeddings.py
RENAMED
|
File without changes
|
|
File without changes
|
{pwdata-0.5.9 → pwdata-0.5.11.dev0}/pwdata/fairchem/datasets/embeddings/qmof_khot_embeddings.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|