pwdata 0.3.4__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.

Files changed (66) hide show
  1. {pwdata-0.3.4 → pwdata-0.3.6}/PKG-INFO +1 -1
  2. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/convert_files.py +20 -3
  3. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/datasets_saver.py +37 -68
  4. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/extendedxyz.py +1 -1
  5. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/main.py +20 -2
  6. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/pwmlff.py +1 -1
  7. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/test.py +6 -6
  8. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata.egg-info/PKG-INFO +1 -1
  9. {pwdata-0.3.4 → pwdata-0.3.6}/setup.py +1 -1
  10. {pwdata-0.3.4 → pwdata-0.3.6}/LICENSE +0 -0
  11. {pwdata-0.3.4 → pwdata-0.3.6}/README.md +0 -0
  12. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/__init__.py +0 -0
  13. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/atomconfig.py +0 -0
  14. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/build/__init__.py +0 -0
  15. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/build/cell.py +0 -0
  16. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/build/geometry.py +0 -0
  17. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/build/supercells.py +0 -0
  18. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/build/write_struc.py +0 -0
  19. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/calculators/__init__.py +0 -0
  20. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/calculators/const.py +0 -0
  21. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/calculators/unitconvert_lmps.py +0 -0
  22. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/calculators/units.py +0 -0
  23. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/check_envs.py +0 -0
  24. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/config.py +0 -0
  25. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/cp2kdata.py +0 -0
  26. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/deepmd.py +0 -0
  27. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/dump.py +0 -0
  28. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/fairchem/__init__.py +0 -0
  29. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/fairchem/common/__init__.py +0 -0
  30. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/fairchem/common/registry.py +0 -0
  31. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/fairchem/common/typing.py +0 -0
  32. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/fairchem/common/utils.py +0 -0
  33. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/fairchem/datasets/__init__.py +0 -0
  34. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/fairchem/datasets/_utils.py +0 -0
  35. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/fairchem/datasets/ase_datasets.py +0 -0
  36. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/fairchem/datasets/base_dataset.py +0 -0
  37. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/fairchem/datasets/embeddings/__init__.py +0 -0
  38. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/fairchem/datasets/embeddings/atomic_radii.py +0 -0
  39. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/fairchem/datasets/embeddings/continuous_embeddings.py +0 -0
  40. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/fairchem/datasets/embeddings/khot_embeddings.py +0 -0
  41. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/fairchem/datasets/embeddings/qmof_khot_embeddings.py +0 -0
  42. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/fairchem/datasets/lmdb_database.py +0 -0
  43. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/fairchem/datasets/target_metadata_guesser.py +0 -0
  44. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/fairchem/modules/__init__.py +0 -0
  45. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/fairchem/modules/transforms.py +0 -0
  46. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/fairchem/preprocessing/__init__.py +0 -0
  47. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/image.py +0 -0
  48. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/lammpsdata.py +0 -0
  49. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/lmps.py +0 -0
  50. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/meta.py +0 -0
  51. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/movement.py +0 -0
  52. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/movement_saver.py +0 -0
  53. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/outcar.py +0 -0
  54. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/pertub/__init__.py +0 -0
  55. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/pertub/perturbation.py +0 -0
  56. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/pertub/scale.py +0 -0
  57. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/poscar.py +0 -0
  58. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/test/__init__.py +0 -0
  59. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/utils/__init__.py +0 -0
  60. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata/utils/constant.py +0 -0
  61. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata.egg-info/SOURCES.txt +0 -0
  62. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata.egg-info/dependency_links.txt +0 -0
  63. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata.egg-info/entry_points.txt +0 -0
  64. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata.egg-info/requires.txt +0 -0
  65. {pwdata-0.3.4 → pwdata-0.3.6}/pwdata.egg-info/top_level.txt +0 -0
  66. {pwdata-0.3.4 → 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.4
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
- else:
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
- # print(len(images))
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
- # if hasattr(image_data[0], 'format') and image_data[0].format == 'extxyz':
11
- # image_lists = defaultdict(list)
12
- # for image in image_data:
13
- # key = (image.formula, tuple(image.pbc))
14
- # image_lists[key].append(image)
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
- # train_data = [lattice[train_indices], position[train_indices], energies[train_indices],
44
- # forces[train_indices], atom_types_image, atom_type,
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 = np.array([float(result_dict["energy"])])
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
@@ -24,6 +24,7 @@ from pwdata.build.write_struc import write_config, write_vasp, write_lammps
24
24
  import argparse
25
25
  from pwdata.convert_files import do_scale_cell, do_super_cell, do_perturb, do_convert_config, do_convert_images, do_meta_data
26
26
  from pwdata.utils.constant import FORMAT, get_atomic_name_from_number
27
+ from pwdata.check_envs import print_cmd
27
28
 
28
29
  # from pwdata.open_data.meta_data import get_meta_data
29
30
 
@@ -294,7 +295,24 @@ pwdata convert -i dirs -f extxyz -s dir
294
295
  def main(cmd_list:list=None):
295
296
  if cmd_list is None:
296
297
  cmd_list = sys.argv
297
- from check_envs import print_cmd
298
+ if len(cmd_list) == 2 and '.json' in cmd_list[1].lower():
299
+ json_dict = json.load(open(cmd_list[1]))
300
+ format = json_dict['format']
301
+ raw_files = json_dict['raw_files']
302
+ if not isinstance(raw_files, list):
303
+ raw_files = [raw_files]
304
+ train_valid_ratio = json_dict['train_valid_ratio'] if 'train_valid_ratio' in json_dict.keys() else 1.0
305
+ shuffle = json_dict['valid_shuffle'] if 'valid_shuffle' in json_dict.keys() else False
306
+ save_dir = json_dict['trainSetDir'] if 'trainSetDir' in json_dict.keys() else 'PWdata'
307
+ cmd_list = ['pwdata', 'convert_configs']
308
+ cmd_list.append('-i')
309
+ cmd_list.extend(raw_files)
310
+ cmd_list.extend(['-f', format])
311
+ cmd_list.extend(['-s', save_dir])
312
+ cmd_list.extend(['-o', 'pwmlff/npy'])
313
+ cmd_list.extend(['-p', '{}'.format(train_valid_ratio)])
314
+ if shuffle:
315
+ cmd_list.append('-r')
298
316
  if len(cmd_list) == 1 or "-h".upper() == cmd_list[1].upper() or \
299
317
  "help".upper() == cmd_list[1].upper() or "-help".upper() == cmd_list[1].upper() or "--help".upper() == cmd_list[1].upper():
300
318
  print_cmd()
@@ -319,7 +337,7 @@ def run_scale_cell(cmd_list:list[str]):
319
337
  parser.add_argument('-f', '--input_format', type=str, required=True, help="The input file format, the supported format as ['pwmat/config','vasp/poscar', 'lammps/lmp', 'cp2k/scf']")
320
338
  parser.add_argument('-s', '--savename', type=str, required=False, help="The output file name, and the input scale factor parameter will be used as a prefix, such as '0.99_atom.config'. If not provided, the 'atom.config' for pwmat/config, 'POSCAR' for vasp/poscar, 'lammps.lmp' for lammps/lmp will be used. ", default=None)
321
339
  parser.add_argument('-o', '--output_format', type=str, required=False, help="the output file format, only support the format ['pwmat/config','vasp/poscar', 'lammps/lmp']. If not provided, the input format be used. Note: that outputting 'cp2k/scf' format is not supported, the output format will be adjusted to 'pwmat/config' with the output file name 'atom.config'", default=None)
322
- 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. Note: 'pwmat/config' only support the fractional!")
340
+ 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. Note: 'pwmlff/npy' only support the fractional, 'extxyz' only support the cartesian!")
323
341
  parser.add_argument('-t', '--atom_types', type=str, required=False, nargs='+', help="the atom type list of 'lammps/lmp' or 'lammps/dump' input file, the order is same as input file", default=None)
324
342
  args = parser.parse_args(cmd_list)
325
343
  FORMAT.check_format(args.input_format, FORMAT.support_config_format)
@@ -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
- print()
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.4
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.4",
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