pwdata 0.3.5__tar.gz → 0.3.6__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.3.5 → pwdata-0.3.6}/PKG-INFO +1 -1
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/convert_files.py +20 -3
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/datasets_saver.py +37 -68
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/extendedxyz.py +1 -1
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/pwmlff.py +1 -1
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/test.py +6 -6
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata.egg-info/PKG-INFO +1 -1
- {pwdata-0.3.5 → pwdata-0.3.6}/setup.py +1 -1
- {pwdata-0.3.5 → pwdata-0.3.6}/LICENSE +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/README.md +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/__init__.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/atomconfig.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/build/__init__.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/build/cell.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/build/geometry.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/build/supercells.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/build/write_struc.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/calculators/__init__.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/calculators/const.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/calculators/unitconvert_lmps.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/calculators/units.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/check_envs.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/config.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/cp2kdata.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/deepmd.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/dump.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/fairchem/__init__.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/fairchem/common/__init__.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/fairchem/common/registry.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/fairchem/common/typing.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/fairchem/common/utils.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/fairchem/datasets/__init__.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/fairchem/datasets/_utils.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/fairchem/datasets/ase_datasets.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/fairchem/datasets/base_dataset.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/fairchem/datasets/embeddings/__init__.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/fairchem/datasets/embeddings/atomic_radii.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/fairchem/datasets/embeddings/continuous_embeddings.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/fairchem/datasets/embeddings/khot_embeddings.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/fairchem/datasets/embeddings/qmof_khot_embeddings.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/fairchem/datasets/lmdb_database.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/fairchem/datasets/target_metadata_guesser.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/fairchem/modules/__init__.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/fairchem/modules/transforms.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/fairchem/preprocessing/__init__.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/image.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/lammpsdata.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/lmps.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/main.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/meta.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/movement.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/movement_saver.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/outcar.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/pertub/__init__.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/pertub/perturbation.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/pertub/scale.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/poscar.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/test/__init__.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/utils/__init__.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata/utils/constant.py +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata.egg-info/SOURCES.txt +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata.egg-info/dependency_links.txt +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata.egg-info/entry_points.txt +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata.egg-info/requires.txt +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/pwdata.egg-info/top_level.txt +0 -0
- {pwdata-0.3.5 → pwdata-0.3.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pwdata
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.6
|
|
4
4
|
Summary: pwdata is a data pre-processing tool for PWMLFF, 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
|
|
@@ -140,11 +140,10 @@ def save_images(savepath, image_data, output_format, train_valid_ratio=1, data_s
|
|
|
140
140
|
retain_raw = False,
|
|
141
141
|
write_patthen="a"
|
|
142
142
|
)
|
|
143
|
-
|
|
143
|
+
elif merge is False and output_format == FORMAT.extxyz:
|
|
144
144
|
save_dict = split_image_by_atomtype_nums(image_data, format=output_format)
|
|
145
145
|
for key, images in save_dict.items():
|
|
146
|
-
|
|
147
|
-
save_dir = os.path.join(savepath, key) if output_format==FORMAT.extxyz else savepath #pwmlff/npy will do split when saving images
|
|
146
|
+
save_dir = os.path.join(savepath, key)
|
|
148
147
|
image_data.images = images
|
|
149
148
|
image_data.to(
|
|
150
149
|
output_path=save_dir,
|
|
@@ -155,6 +154,16 @@ def save_images(savepath, image_data, output_format, train_valid_ratio=1, data_s
|
|
|
155
154
|
retain_raw = False,
|
|
156
155
|
write_patthen="a"
|
|
157
156
|
)
|
|
157
|
+
else: # for pwmlff/mpy
|
|
158
|
+
image_data.to(
|
|
159
|
+
output_path=savepath,
|
|
160
|
+
save_format=output_format,
|
|
161
|
+
train_ratio = train_valid_ratio,
|
|
162
|
+
random=data_shuffle,
|
|
163
|
+
seed = 2024,
|
|
164
|
+
retain_raw = False,
|
|
165
|
+
write_patthen="a"
|
|
166
|
+
)
|
|
158
167
|
|
|
159
168
|
def search_images(input_list:list[str], input_format:str):
|
|
160
169
|
res_list = set()
|
|
@@ -211,6 +220,14 @@ def load_files(input_list:list[str], input_format:str, atom_types:list[str]=None
|
|
|
211
220
|
image_data.images = [image_data.images]
|
|
212
221
|
return image_data
|
|
213
222
|
|
|
223
|
+
'''
|
|
224
|
+
description:
|
|
225
|
+
this function only used for extxyz format
|
|
226
|
+
param {*} image_data
|
|
227
|
+
param {*} format
|
|
228
|
+
return {*}
|
|
229
|
+
author: wuxingxing
|
|
230
|
+
'''
|
|
214
231
|
def split_image_by_atomtype_nums(image_data, format=None):
|
|
215
232
|
key_dict = {}
|
|
216
233
|
for idx, image in enumerate(image_data.images):
|
|
@@ -4,78 +4,19 @@ from collections import Counter
|
|
|
4
4
|
from math import ceil
|
|
5
5
|
from collections import defaultdict
|
|
6
6
|
from pwdata.calculators.const import elements
|
|
7
|
-
|
|
7
|
+
from pwdata.utils.constant import get_atomic_name_from_number, FORMAT
|
|
8
|
+
from pwdata.image import Image
|
|
8
9
|
def save_to_dataset(image_data: list, datasets_path = "./PWdata", train_data_path = "train", valid_data_path = "valid",
|
|
9
10
|
train_ratio = None, random = True, seed = 2024, retain_raw = False, data_name = None, write_patthen="w"):
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
# for key, image_data in image_lists.items():
|
|
17
|
-
# data_name = key[0]
|
|
18
|
-
# suffix = 0
|
|
19
|
-
# while os.path.exists(os.path.join(datasets_path, data_name)):
|
|
20
|
-
# suffix += 1
|
|
21
|
-
# data_name = key[0] + "_" + str(suffix)
|
|
22
|
-
# """ Get and process the data from the input file. """
|
|
23
|
-
# lattice, position, energies, ei, forces, virials, atom_type, atom_types_image, image_nums = get_pw(image_data)
|
|
24
|
-
|
|
25
|
-
# labels_path = os.path.join(datasets_path, data_name)
|
|
26
|
-
# if not os.path.exists(datasets_path):
|
|
27
|
-
# os.makedirs(datasets_path, exist_ok=True)
|
|
28
|
-
# if not os.path.exists(labels_path):
|
|
29
|
-
# os.makedirs(labels_path, exist_ok=True)
|
|
30
|
-
|
|
31
|
-
# if seed:
|
|
32
|
-
# np.random.seed(seed)
|
|
33
|
-
# indices = np.arange(image_nums) # 0, 1, 2, ..., image_nums-1
|
|
34
|
-
# if random:
|
|
35
|
-
# np.random.shuffle(indices) # shuffle the indices
|
|
36
|
-
# assert train_ratio is not None, "train_ratio must be set"
|
|
37
|
-
# train_size = ceil(image_nums * train_ratio)
|
|
38
|
-
# train_indices = indices[:train_size]
|
|
39
|
-
# val_indices = indices[train_size:]
|
|
40
|
-
# # image_nums = [image_nums]
|
|
41
|
-
# atom_types_image = atom_types_image.reshape(1, -1)
|
|
11
|
+
""" Get and process the data from the input file. """
|
|
12
|
+
image_dict = split_image_by_atomtype_nums(image_data)
|
|
13
|
+
for key, image_datas in image_dict.items():
|
|
14
|
+
save_image(image_datas, datasets_path = datasets_path, train_data_path = train_data_path, valid_data_path = valid_data_path,
|
|
15
|
+
train_ratio = train_ratio, random = random, seed = 2024, retain_raw = retain_raw, data_name = key, write_patthen=write_patthen)
|
|
42
16
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
# ei[train_indices]]
|
|
46
|
-
# val_data = [lattice[val_indices], position[val_indices], energies[val_indices],
|
|
47
|
-
# forces[val_indices], atom_types_image, atom_type,
|
|
48
|
-
# ei[val_indices]]
|
|
49
|
-
|
|
50
|
-
# if len(virials) != 0:
|
|
51
|
-
# train_data.append(virials[train_indices])
|
|
52
|
-
# val_data.append(virials[val_indices])
|
|
53
|
-
# else:
|
|
54
|
-
# train_data.append([])
|
|
55
|
-
# val_data.append([])
|
|
17
|
+
def save_image(image_data: list, datasets_path = "./PWdata", train_data_path = "train", valid_data_path = "valid",
|
|
18
|
+
train_ratio = None, random = True, seed = 2024, retain_raw = False, data_name = None, write_patthen="w"):
|
|
56
19
|
|
|
57
|
-
# if train_ratio == 1.0 or len(val_indices) == 0:
|
|
58
|
-
# labels_path = os.path.join(labels_path, train_data_path)
|
|
59
|
-
# if not os.path.exists(labels_path):
|
|
60
|
-
# os.makedirs(labels_path)
|
|
61
|
-
# if retain_raw:
|
|
62
|
-
# save_to_raw(train_data, train_data_path)
|
|
63
|
-
# save_to_npy(train_data, labels_path)
|
|
64
|
-
# else:
|
|
65
|
-
# train_path = os.path.join(labels_path, train_data_path)
|
|
66
|
-
# val_path = os.path.join(labels_path, valid_data_path)
|
|
67
|
-
# if not os.path.exists(train_path):
|
|
68
|
-
# os.makedirs(train_path)
|
|
69
|
-
# if not os.path.exists(val_path):
|
|
70
|
-
# os.makedirs(val_path)
|
|
71
|
-
# if retain_raw:
|
|
72
|
-
# save_to_raw(train_data, train_path)
|
|
73
|
-
# save_to_raw(val_data, val_path)
|
|
74
|
-
# save_to_npy(train_data, train_path)
|
|
75
|
-
# save_to_npy(val_data, val_path)
|
|
76
|
-
# else:
|
|
77
|
-
|
|
78
|
-
""" Get and process the data from the input file. """
|
|
79
20
|
lattice, position, energies, ei, forces, virials, atom_type, atom_types_image, image_nums = get_pw(image_data)
|
|
80
21
|
|
|
81
22
|
if data_name is None:
|
|
@@ -188,3 +129,31 @@ def get_pw(image_data):
|
|
|
188
129
|
if len(all_virials) != 0:
|
|
189
130
|
all_virials = np.array(all_virials).reshape(image_nums, -1)
|
|
190
131
|
return all_lattices, all_postions, all_energies, all_ei, all_forces, all_virials, atom_type, atom_types_image, image_nums
|
|
132
|
+
|
|
133
|
+
def split_image_by_atomtype_nums(image_data:list[Image]):
|
|
134
|
+
key_dict = {}
|
|
135
|
+
for idx, image in enumerate(image_data):
|
|
136
|
+
element_counts = Counter(image.atom_types_image)
|
|
137
|
+
atom_type = list(element_counts.keys())
|
|
138
|
+
counts = list(element_counts.values())
|
|
139
|
+
tmp_key = ""
|
|
140
|
+
for element, count in zip(atom_type, counts):
|
|
141
|
+
tmp_key += "{}_{}_".format(element, count)
|
|
142
|
+
if tmp_key not in key_dict:
|
|
143
|
+
key_dict[tmp_key] = [image]
|
|
144
|
+
else:
|
|
145
|
+
key_dict[tmp_key].append(image)
|
|
146
|
+
|
|
147
|
+
new_split = {}
|
|
148
|
+
for key in key_dict.keys():
|
|
149
|
+
elements = key.split('_')[:-1]
|
|
150
|
+
new_array = [int(elements[i]) for i in range(0, len(elements), 2)]
|
|
151
|
+
type_nums = elements[1::2]
|
|
152
|
+
atom_list = get_atomic_name_from_number(new_array)
|
|
153
|
+
new_key = []
|
|
154
|
+
for atom, num in zip(atom_list, type_nums):
|
|
155
|
+
new_key.append(atom)
|
|
156
|
+
new_key.append(num)
|
|
157
|
+
new_key = "".join(new_key)
|
|
158
|
+
new_split[new_key] = key_dict[key]
|
|
159
|
+
return new_split
|
|
@@ -134,7 +134,7 @@ def read_one_structures_from_lines(lines:list[str]):
|
|
|
134
134
|
pattern = r'(\w+)=("[^"]*"|\S+)'
|
|
135
135
|
matches = re.findall(pattern, lines[0])
|
|
136
136
|
result_dict = {key.lower(): value.strip('"') for key, value in matches}
|
|
137
|
-
image.Ep =
|
|
137
|
+
image.Ep = float(result_dict["energy"])
|
|
138
138
|
properties = result_dict["properties"].split(":")
|
|
139
139
|
atom_types_image, postion, force = read_properties_data(image.atom_nums, properties, lines[1:])
|
|
140
140
|
image.force = force
|
|
@@ -25,7 +25,7 @@ class PWNPY(object):
|
|
|
25
25
|
force = force.reshape(-1, atom_nums, 3)
|
|
26
26
|
for i in tqdm(range(image_nums), desc="Loading data"):
|
|
27
27
|
_virail = virial[i] if virial is not None else None
|
|
28
|
-
image = Image(lattice=lattice[i], position=coord[i], force=force[i], Ep=Ep[i], virial=virial[i] if virial is not None else None,
|
|
28
|
+
image = Image(lattice=lattice[i], position=coord[i], force=force[i], Ep=float(Ep[i]), virial=virial[i] if virial is not None else None,
|
|
29
29
|
cartesian=False, image_nums=i, atom_nums=atom_nums,
|
|
30
30
|
atomic_energy=atomic_energy[i], atom_type=atom_type, atom_types_image=atom_types_image)
|
|
31
31
|
self.image_list.append(image)
|
|
@@ -108,8 +108,8 @@ def test_convert_configs():
|
|
|
108
108
|
|
|
109
109
|
# res = search_images(config_file, config_format)
|
|
110
110
|
# print(res)
|
|
111
|
-
if config_format == FORMAT.meta:
|
|
112
|
-
|
|
111
|
+
# if config_format == FORMAT.meta:
|
|
112
|
+
# print()
|
|
113
113
|
for idj, format in enumerate([FORMAT.pwmlff_npy, FORMAT.extxyz]):
|
|
114
114
|
save_path = os.path.join(save_dir, "{}_{}_{}_{}".format(idi, idj, config_format.replace('/','_'), FORMAT.get_filename_by_format(format).split('.')[0]))
|
|
115
115
|
cmd_list = ["", "convert_configs"]
|
|
@@ -152,10 +152,10 @@ if __name__ == "__main__":
|
|
|
152
152
|
# run_cmd(["", "cvt_configs", "-h"])
|
|
153
153
|
os.chdir(os.path.join(os.path.dirname(os.path.dirname(__file__)), "examples"))
|
|
154
154
|
cmd_list = []
|
|
155
|
-
cmd_list.extend(test_scale_cell())
|
|
156
|
-
cmd_list.extend(test_super_cell())
|
|
157
|
-
cmd_list.extend(test_pertub())
|
|
158
|
-
cmd_list.extend(test_convert_config())
|
|
155
|
+
# cmd_list.extend(test_scale_cell())
|
|
156
|
+
# cmd_list.extend(test_super_cell())
|
|
157
|
+
# cmd_list.extend(test_pertub())
|
|
158
|
+
# cmd_list.extend(test_convert_config())
|
|
159
159
|
cmd_list.extend(test_convert_configs())
|
|
160
160
|
|
|
161
161
|
for cmd in cmd_list:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pwdata
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.6
|
|
4
4
|
Summary: pwdata is a data pre-processing tool for PWMLFF, 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
|
|
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|
|
5
5
|
|
|
6
6
|
setuptools.setup(
|
|
7
7
|
name="pwdata",
|
|
8
|
-
version="0.3.
|
|
8
|
+
version="0.3.6",
|
|
9
9
|
author="LonxunQuantum",
|
|
10
10
|
author_email="lonxun@pwmat.com",
|
|
11
11
|
description="pwdata is a data pre-processing tool for PWMLFF, which can be used to extract features and labels. It also provides convenient interfaces for data conversion between different software.",
|
|
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
|
|
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
|