pwdata 0.4.2__tar.gz → 0.4.4__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 (68) hide show
  1. {pwdata-0.4.2 → pwdata-0.4.4}/PKG-INFO +1 -1
  2. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/convert_files.py +15 -9
  3. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/main.py +8 -3
  4. pwdata-0.4.4/pwdata/test/mdtrajs2config.py +30 -0
  5. pwdata-0.4.4/pwdata/test/mptraj2lmdb.py +94 -0
  6. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata.egg-info/PKG-INFO +1 -1
  7. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata.egg-info/SOURCES.txt +2 -0
  8. {pwdata-0.4.2 → pwdata-0.4.4}/setup.py +1 -1
  9. {pwdata-0.4.2 → pwdata-0.4.4}/LICENSE +0 -0
  10. {pwdata-0.4.2 → pwdata-0.4.4}/README.md +0 -0
  11. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/__init__.py +0 -0
  12. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/atomconfig.py +0 -0
  13. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/build/__init__.py +0 -0
  14. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/build/cell.py +0 -0
  15. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/build/geometry.py +0 -0
  16. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/build/supercells.py +0 -0
  17. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/build/write_struc.py +0 -0
  18. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/calculators/__init__.py +0 -0
  19. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/calculators/const.py +0 -0
  20. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/calculators/unitconvert_lmps.py +0 -0
  21. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/calculators/units.py +0 -0
  22. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/check_envs.py +0 -0
  23. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/config.py +0 -0
  24. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/cp2kdata.py +0 -0
  25. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/datasets_saver.py +0 -0
  26. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/deepmd.py +0 -0
  27. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/dump.py +0 -0
  28. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/extendedxyz.py +0 -0
  29. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/fairchem/__init__.py +0 -0
  30. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/fairchem/common/__init__.py +0 -0
  31. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/fairchem/common/registry.py +0 -0
  32. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/fairchem/common/typing.py +0 -0
  33. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/fairchem/common/utils.py +0 -0
  34. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/fairchem/datasets/__init__.py +0 -0
  35. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/fairchem/datasets/_utils.py +0 -0
  36. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/fairchem/datasets/ase_datasets.py +0 -0
  37. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/fairchem/datasets/base_dataset.py +0 -0
  38. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/fairchem/datasets/embeddings/__init__.py +0 -0
  39. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/fairchem/datasets/embeddings/atomic_radii.py +0 -0
  40. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/fairchem/datasets/embeddings/continuous_embeddings.py +0 -0
  41. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/fairchem/datasets/embeddings/khot_embeddings.py +0 -0
  42. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/fairchem/datasets/embeddings/qmof_khot_embeddings.py +0 -0
  43. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/fairchem/datasets/lmdb_database.py +0 -0
  44. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/fairchem/datasets/target_metadata_guesser.py +0 -0
  45. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/fairchem/modules/__init__.py +0 -0
  46. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/fairchem/modules/transforms.py +0 -0
  47. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/fairchem/preprocessing/__init__.py +0 -0
  48. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/image.py +0 -0
  49. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/lammpsdata.py +0 -0
  50. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/lmps.py +0 -0
  51. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/meta.py +0 -0
  52. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/movement.py +0 -0
  53. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/movement_saver.py +0 -0
  54. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/outcar.py +0 -0
  55. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/pertub/__init__.py +0 -0
  56. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/pertub/perturbation.py +0 -0
  57. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/pertub/scale.py +0 -0
  58. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/poscar.py +0 -0
  59. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/pwmlff.py +0 -0
  60. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/test/__init__.py +0 -0
  61. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/test.py +0 -0
  62. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/utils/__init__.py +0 -0
  63. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata/utils/constant.py +0 -0
  64. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata.egg-info/dependency_links.txt +0 -0
  65. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata.egg-info/entry_points.txt +0 -0
  66. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata.egg-info/requires.txt +0 -0
  67. {pwdata-0.4.2 → pwdata-0.4.4}/pwdata.egg-info/top_level.txt +0 -0
  68. {pwdata-0.4.2 → pwdata-0.4.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pwdata
3
- Version: 0.4.2
3
+ Version: 0.4.4
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
@@ -277,18 +277,25 @@ def load_files(input_dict:dict, input_format:str=None, atom_types:list[str]=None
277
277
  tmp_image_data = Config(input_format, metapaths, atom_names=atom_types, query=query, cpu_nums=cpu_nums)
278
278
  image_data.images.extend(tmp_image_data.images)
279
279
  print("There are a total of {} aselmdb, and the current progress has been loaded {} %".format(lmdb_nums, np.round(idx*chunk_size/lmdb_nums, 2)))
280
-
281
280
  else:
282
281
  if len(input_dict[FORMAT.traj]) > 0:# the input is traj files
283
- for data_path in input_dict[FORMAT.traj]:
284
- image_data = Config(input_format, data_path, atom_names=atom_types, query=query, cpu_nums=cpu_nums)
285
- if not isinstance(image_data.images, list): # for the first pwmlff/npy dir only has one picture
286
- image_data.images = [image_data.images]
282
+ for data_path in tqdm(input_dict[FORMAT.traj], total=len(input_dict[FORMAT.traj])):
283
+ if image_data is None:
284
+ image_data = Config(input_format, data_path, atom_names=atom_types, query=query, cpu_nums=cpu_nums)
285
+ if not isinstance(image_data.images, list): # for the first pwmlff/npy dir only has one picture
286
+ image_data.images = [image_data.images]
287
+ else:
288
+ tmp_image_data = Config(input_format, data_path, atom_names=atom_types, query=query, cpu_nums=cpu_nums)
289
+ image_data.images.extend(tmp_image_data.images)
287
290
  else:
288
291
  for data_path in tqdm(input_dict[input_format], total=len(input_dict[input_format])):
289
- image_data = Config(input_format, data_path, atom_names=atom_types, query=query, cpu_nums=cpu_nums)
290
- if not isinstance(image_data.images, list): # for the first pwmlff/npy dir only has one picture
291
- image_data.images = [image_data.images]
292
+ if image_data is None:
293
+ image_data = Config(input_format, data_path, atom_names=atom_types, query=query, cpu_nums=cpu_nums)
294
+ if not isinstance(image_data.images, list): # for the first pwmlff/npy dir only has one picture
295
+ image_data.images = [image_data.images]
296
+ else:
297
+ tmp_image_data = Config(input_format, data_path, atom_names=atom_types, query=query, cpu_nums=cpu_nums)
298
+ image_data.images.extend(tmp_image_data.images)
292
299
  return image_data
293
300
 
294
301
  else:
@@ -308,7 +315,6 @@ def load_files(input_dict:dict, input_format:str=None, atom_types:list[str]=None
308
315
  tmp_image_data = Config(input_format, metapaths, atom_names=atom_types, query=query, cpu_nums=cpu_nums)
309
316
  image_data.images.extend(tmp_image_data.images)
310
317
  # print("There are a total of {} aselmdb, and the current progress has been loaded {} %".format(lmdb_nums, np.round(idx*chunk_size/lmdb_nums, 2)))
311
-
312
318
  else:
313
319
  for data_path in tqdm(data_list, total=len(data_list)):
314
320
  if image_data is None:
@@ -297,7 +297,8 @@ def main(cmd_list:list=None):
297
297
  cmd_list = sys.argv
298
298
  if len(cmd_list) == 2 and '.json' in cmd_list[1].lower():
299
299
  json_dict = json.load(open(cmd_list[1]))
300
- format = json_dict['format']
300
+ format = json_dict['format'] if 'format' in json_dict.keys() else None
301
+ save_format = json_dict['save_format'] if 'save_format' in json_dict.keys() else None
301
302
  raw_files = json_dict['raw_files']
302
303
  if not isinstance(raw_files, list):
303
304
  raw_files = [raw_files]
@@ -307,9 +308,13 @@ def main(cmd_list:list=None):
307
308
  cmd_list = ['pwdata', 'convert_configs']
308
309
  cmd_list.append('-i')
309
310
  cmd_list.extend(raw_files)
310
- cmd_list.extend(['-f', format])
311
+ if format is not None:
312
+ cmd_list.extend(['-f', format])
311
313
  cmd_list.extend(['-s', save_dir])
312
- cmd_list.extend(['-o', 'pwmlff/npy'])
314
+ if save_format is not None:
315
+ cmd_list.extend(['-o', save_format])
316
+ else:
317
+ cmd_list.extend(['-o', 'pwmlff/npy'])
313
318
  cmd_list.extend(['-p', '{}'.format(train_valid_ratio)])
314
319
  if shuffle:
315
320
  cmd_list.append('-r')
@@ -0,0 +1,30 @@
1
+ '''
2
+ description:
3
+ Convert various trajectory files ('pwmat/movement','vasp/outcar','cp2k/md', or 'lammps/dump')
4
+ to a single structure format ('pwmat/config', 'vasp/poscar', 'lammps/lmp')
5
+ '''
6
+
7
+ from pwdata import Config
8
+ from pwdata.utils.constant import FORMAT
9
+
10
+ def trajs2config():
11
+ atom_types = ["Hf", "O"] # for lammps
12
+ input_file = "/data/home/wuxingxing/codespace/pwdata/examples/lmps_data/HfO2/30.lammpstrj"
13
+ input_format="lammps/dump"
14
+ save_format = "pwmat/config"
15
+
16
+ image = Config(data_path=input_file, format=input_format, atom_names=atom_types)
17
+ tmp_image_data = image.images
18
+ save_dir = "./tmp_test"
19
+ for id, config in enumerate(tmp_image_data):
20
+ savename = "{}_{}".format(id, FORMAT.get_filename_by_format(save_format))
21
+ image.iamges = [config]
22
+ image.to(output_path = save_dir,
23
+ data_name = savename,
24
+ save_format = save_format,
25
+ sort = True)
26
+
27
+ if __name__=="__main__":
28
+ trajs2config()
29
+
30
+
@@ -0,0 +1,94 @@
1
+ '''
2
+ description:
3
+ Convert MPtraj JSON file to aselmdb format
4
+ '''
5
+
6
+ from pwdata import Config
7
+ from pwdata.utils.constant import FORMAT
8
+ import json
9
+ from pwdata.fairchem.datasets.ase_datasets import LMDBDatabase
10
+ from ase import Atoms
11
+ from ase.db.row import AtomsRow
12
+ from pwdata.utils.constant import get_atomic_number_from_name
13
+ from tqdm import tqdm
14
+ import numpy as np
15
+
16
+ def MPjson2lmdb():
17
+ mp_file = "/data/home/wuxingxing/codespace/pwdata/examples/mp_data/mptest.json"
18
+ save_file = "/data/home/wuxingxing/codespace/pwdata/examples/mp_data/sub.aselmdb"
19
+ Mpjson = json.load(open(mp_file))
20
+ db = LMDBDatabase(filename=save_file, readonly=False)
21
+ for key_1, val_1 in tqdm(Mpjson.items(), total=len(Mpjson.keys())):
22
+ for key_2, val_2 in val_1.items():
23
+ _atomrow, data = cvt_dict_2_atomrow(val_2)
24
+ db._write(_atomrow, key_value_pairs={}, data=data)
25
+ db.close()
26
+
27
+ def cvt_dict_2_atomrow(config:dict):
28
+ # read cell
29
+ cell = read_from_dict('matrix', config['structure']['lattice'], require=True)
30
+ # read position
31
+ atom_type_list = get_atomic_number_from_name([_['label'] for _ in config['structure']['sites']])
32
+ position = [_['xyz'] for _ in config['structure']['sites']]
33
+ # read magmom
34
+ magmom = read_from_dict('magmom', config, require=True)
35
+
36
+ atom = Atoms(positions=position,
37
+ numbers=atom_type_list,
38
+ magmoms=magmom,
39
+ cell=cell)
40
+
41
+ atom_rows = AtomsRow(atom)
42
+ atom_rows.pbc = np.ones(3, bool)
43
+ # read stress -> xx, yy, zz, yz, xz, xy
44
+ stress = read_from_dict('stress', config, require=True)
45
+ atom_rows.stress = [stress[0][0],stress[1][1],stress[2][2],stress[1][2],stress[0][2],stress[0][1]]
46
+ # read force and energy
47
+ force = read_from_dict('force', config, require=True)
48
+ energy = read_from_dict('corrected_total_energy', config, require=True)
49
+ atom_rows.__setattr__('force', force)
50
+ atom_rows.__setattr__('energy', energy)
51
+ data = {}
52
+ data['uncorrected_total_energy'] = read_from_dict('uncorrected_total_energy', config, default=None)
53
+ data['corrected_total_energy'] = read_from_dict('uncorrected_total_energy', config, default=None)
54
+ data['energy_per_atom'] = read_from_dict('energy_per_atom', config, default=None)
55
+ data['ef_per_atom'] = read_from_dict('ef_per_atom', config, default=None)
56
+ data['e_per_atom_relaxed'] = read_from_dict('e_per_atom_relaxed', config, default=None)
57
+ data['ef_per_atom_relaxed'] = read_from_dict('ef_per_atom_relaxed', config, default=None)
58
+ data['bandgap'] = read_from_dict('bandgap', config, default=None)
59
+ data['mp_id'] = read_from_dict('mp_id', config, default=None)
60
+ # atom_rows._data = data
61
+ return atom_rows, data
62
+
63
+ def read_from_dict(key:str, config:dict, default=None, require=False):
64
+ if key in config:
65
+ return config[key]
66
+ else:
67
+ if require:
68
+ raise ValueError("key {} not found in config".format(key))
69
+ else:
70
+ return default
71
+
72
+ # def test_lmdb():
73
+ # from pwdata.fairchem.datasets.ase_datasets import AseDBDataset
74
+ # search_dict = {'src': '/data/home/wuxingxing/codespace/pwdata/examples/meta_data/alex_val/alex_go_aao_001.aselmdb'}
75
+ # dataset = AseDBDataset(config=search_dict)
76
+ # atom_list = list(dataset.dbs[0].select("Li"))
77
+ # std = atom_list[0]
78
+
79
+ # search_dict = {'src': '/data/home/wuxingxing/codespace/pwdata/examples/MPtrj.aselmdb'}
80
+ # dataset2 = AseDBDataset(config=search_dict)
81
+ # atom_list2 = list(dataset2.dbs[0].select("Li"))
82
+ # dev = atom_list2[0]
83
+
84
+ # search_dict = {'src': '/data/home/wuxingxing/codespace/pwdata/examples/mp_data/sub.aselmdb'}
85
+ # dataset3 = AseDBDataset(config=search_dict)
86
+ # atom_list3 = list(dataset3.dbs[0].select())
87
+ # std3 = atom_list3[0]
88
+
89
+ # print()
90
+
91
+ if __name__=="__main__":
92
+ MPjson2lmdb()
93
+
94
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pwdata
3
- Version: 0.4.2
3
+ Version: 0.4.4
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
@@ -60,5 +60,7 @@ pwdata/pertub/__init__.py
60
60
  pwdata/pertub/perturbation.py
61
61
  pwdata/pertub/scale.py
62
62
  pwdata/test/__init__.py
63
+ pwdata/test/mdtrajs2config.py
64
+ pwdata/test/mptraj2lmdb.py
63
65
  pwdata/utils/__init__.py
64
66
  pwdata/utils/constant.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="pwdata",
8
- version="0.4.2",
8
+ version="0.4.4",
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