pwdata 0.2.6__tar.gz → 0.2.7__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 (37) hide show
  1. {pwdata-0.2.6 → pwdata-0.2.7}/PKG-INFO +1 -1
  2. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/deepmd.py +13 -6
  3. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/main.py +4 -0
  4. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata.egg-info/PKG-INFO +1 -1
  5. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata.egg-info/SOURCES.txt +0 -1
  6. {pwdata-0.2.6 → pwdata-0.2.7}/setup.py +1 -1
  7. pwdata-0.2.6/pwdata/configop.py +0 -209
  8. {pwdata-0.2.6 → pwdata-0.2.7}/LICENSE +0 -0
  9. {pwdata-0.2.6 → pwdata-0.2.7}/README.md +0 -0
  10. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/__init__.py +0 -0
  11. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/atomconfig.py +0 -0
  12. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/build/__init__.py +0 -0
  13. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/build/cell.py +0 -0
  14. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/build/geometry.py +0 -0
  15. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/build/supercells.py +0 -0
  16. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/build/write_struc.py +0 -0
  17. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/calculators/__init__.py +0 -0
  18. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/calculators/const.py +0 -0
  19. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/calculators/unitconvert_lmps.py +0 -0
  20. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/calculators/units.py +0 -0
  21. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/cp2kdata.py +0 -0
  22. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/datasets_saver.py +0 -0
  23. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/dump.py +0 -0
  24. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/extendedxyz.py +0 -0
  25. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/image.py +0 -0
  26. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/lammpsdata.py +0 -0
  27. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/lmps.py +0 -0
  28. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/movement.py +0 -0
  29. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/movement_saver.py +0 -0
  30. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/outcar.py +0 -0
  31. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/pertub/__init__.py +0 -0
  32. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/pertub/perturbation.py +0 -0
  33. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/pertub/scale.py +0 -0
  34. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata/poscar.py +0 -0
  35. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata.egg-info/dependency_links.txt +0 -0
  36. {pwdata-0.2.6 → pwdata-0.2.7}/pwdata.egg-info/top_level.txt +0 -0
  37. {pwdata-0.2.6 → pwdata-0.2.7}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pwdata
3
- Version: 0.2.6
3
+ Version: 0.2.7
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
@@ -1,6 +1,7 @@
1
1
  import numpy as np
2
2
  import os, glob
3
3
  from tqdm import tqdm
4
+ from collections import Counter
4
5
  from pwdata.image import Image
5
6
  from pwdata.calculators.const import ELEMENTTABLE
6
7
 
@@ -25,13 +26,16 @@ class DPNPY(object):
25
26
 
26
27
  with open(type_map_raw, 'r') as f:
27
28
  type_map = f.read().splitlines()
28
- atom_type = [ELEMENTTABLE[atom] for atom in type_map]
29
+ _atom_type = [ELEMENTTABLE[atom] for atom in type_map]
29
30
 
30
31
  with open(type_raw, 'r') as f:
31
32
  type = f.read().splitlines()
32
33
  atom_nums = len(type)
33
- atom_types_image = [atom_type[int(atom)] for atom in type]
34
- atom_type_num = [atom_types_image.count(atom) for atom in set(atom_types_image)]
34
+ atom_types_image = [_atom_type[int(atom)] for atom in type]
35
+ sc = Counter(atom_types_image)
36
+ atom_type = list(sc.keys())
37
+ atom_type_num = list(sc.values())
38
+ # atom_type_num = [atom_types_image.count(atom) for atom in set(atom_types_image)]
35
39
 
36
40
  box, coord, energy, force, virial, image_nums = self.load_npy(npy_files, atom_nums)
37
41
 
@@ -83,13 +87,16 @@ class DPRAW(object):
83
87
 
84
88
  with open(type_map_raw, 'r') as f:
85
89
  type_map = f.read().splitlines()
86
- atom_type = [ELEMENTTABLE[atom] for atom in type_map]
90
+ _atom_type = [ELEMENTTABLE[atom] for atom in type_map]
87
91
 
88
92
  with open(type_raw, 'r') as f:
89
93
  type = f.read().splitlines()
90
94
  atom_nums = len(type)
91
- atom_types_image = [atom_type[int(atom)] for atom in type]
92
- atom_type_num = [atom_types_image.count(atom) for atom in set(atom_types_image)]
95
+ atom_types_image = [_atom_type[int(atom)] for atom in type]
96
+ sc = Counter(atom_types_image)
97
+ atom_type = list(sc.keys())
98
+ atom_type_num = list(sc.values())
99
+ # atom_type_num = [atom_types_image.count(atom) for atom in set(atom_types_image)]
93
100
 
94
101
  box, coord, energy, force, virial, image_nums = self.load_raw(raw_files, atom_nums)
95
102
 
@@ -54,6 +54,10 @@ class Save_Data(object):
54
54
  self.image_data = CP2KMD(data_path)
55
55
  elif format.lower() == 'cp2k/scf':
56
56
  self.image_data = CP2KSCF(data_path)
57
+ elif format.lower() == 'deepmd/npy':
58
+ self.image_data = DPNPY(data_path)
59
+ elif format.lower() == 'deepmd/raw':
60
+ self.image_data = DPRAW(data_path)
57
61
  self.lattice, self.position, self.energies, self.ei, self.forces, self.virials, self.atom_type, self.atom_types_image, self.image_nums = get_pw(self.image_data.get())
58
62
 
59
63
  if train_ratio is not None: # inference 时不存数据
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pwdata
3
- Version: 0.2.6
3
+ Version: 0.2.7
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
@@ -3,7 +3,6 @@ README.md
3
3
  setup.py
4
4
  pwdata/__init__.py
5
5
  pwdata/atomconfig.py
6
- pwdata/configop.py
7
6
  pwdata/cp2kdata.py
8
7
  pwdata/datasets_saver.py
9
8
  pwdata/deepmd.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.2.6",
8
+ version="0.2.7",
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.",
@@ -1,209 +0,0 @@
1
- import os
2
-
3
- from pwdata.poscar import POSCAR
4
- from pwdata.atomconfig import CONFIG
5
- from pwdata.build.supercells import make_supercell
6
- from pwdata.pertub.perturbation import BatchPerturbStructure
7
- from pwdata.pertub.scale import BatchScaleCell
8
- from pwdata import Config
9
- from pwdata.lammpsdata import LMP
10
- from pwdata.dump import DUMP
11
-
12
- def extract_config(config_path:str, format:str, pbc:list[int]=[1,1,1], atom_names: list[str] = None):
13
- if format.lower() == "config" or format.lower() == "pwmat":
14
- image = CONFIG(config_path, pbc).image_list[0]
15
- elif format.lower() == "poscar" or format.lower() == "vasp":
16
- image = POSCAR(config_path, pbc).image_list[0]
17
- elif format.lower() == "lmp" or format.lower() == "lammps":
18
- image = LMP(config_path).image_list[0]
19
- elif format.lower() == "dump":# for lammps single structure traj file
20
- image = DUMP(dump_file=config_path, atom_names=atom_names).image_list[0]
21
- else:
22
- raise ValueError("Invalid format")
23
- return image
24
-
25
- def save_config(config, input_format:str = None, wrap = False, direct = True, sort = True, \
26
- save_format:str=None, save_path:str=None, save_name:str=None, atom_names: list[str] = None):
27
- if isinstance(config, str):
28
- config = extract_config(config_path=config, format=input_format, atom_names=atom_names)
29
-
30
- config.to(output_path=save_path,
31
- data_name =save_name,
32
- save_format=save_format,
33
- direct =direct,
34
- sort =sort,
35
- wrap =wrap
36
- )
37
- return os.path.join(save_path, save_name)
38
-
39
- def do_super_cell(config, input_format:str=None, supercell_matrix:list[int]=None, pbc:list[int]=[1, 1, 1], direct = True, sort = True, \
40
- save_format:str=None, save_path:str=None, save_name:str=None):
41
- if isinstance(config, str):
42
- config = extract_config(config_path=config, format=input_format)
43
- # Make a supercell
44
- supercell = make_supercell(config, supercell_matrix, pbc)
45
- # Write out the structure
46
- supercell.to(output_path = save_path,
47
- data_name = save_name,
48
- save_format = save_format,
49
- direct = direct,
50
- sort = sort)
51
- return os.path.join(save_path, save_name)
52
-
53
- def do_scale(config, input_format:str=None, scale_factor:float=None,
54
- direct:bool=True, sort:bool=True, save_format:str=None, save_path:str=None, save_name:str=None):
55
- if isinstance(config, str):
56
- config = extract_config(config_path=config, format=input_format)
57
- scaled_struct = BatchScaleCell.batch_scale(config, scale_factor)
58
- scaled_struct.to(output_path = save_path,
59
- data_name = save_name,
60
- save_format = save_format,
61
- direct = direct,
62
- sort = sort)
63
- return os.path.join(save_path, save_name)
64
-
65
- def do_pertub(config, input_format:str=None, pert_num:int=None, cell_pert_fraction:float=None, atom_pert_distance:float=None, \
66
- direct:bool=True, sort:bool=True, save_format:str=None, save_path:str=None, save_name:str=None):
67
- if isinstance(config, str):
68
- config = extract_config(config_path=config, format=input_format)
69
-
70
- if not os.path.exists(save_path):
71
- os.makedirs(save_path)
72
- perturbed_structs = BatchPerturbStructure.batch_perturb(config, pert_num, cell_pert_fraction, atom_pert_distance)
73
- for tmp_perturbed_idx, tmp_pertubed_struct in enumerate(perturbed_structs):
74
- tmp_pertubed_struct.to(output_path = save_path,
75
- data_name = "{}_{}".format(tmp_perturbed_idx, save_name),
76
- save_format = save_format,
77
- direct = direct,
78
- sort = sort)
79
- print("pertub {} done!".format(os.path.join(save_path, "{}_{}".format(tmp_perturbed_idx, save_name))))
80
-
81
- '''
82
- description:
83
- if merge is ture, save pwdata to datasets_path/data_name ...
84
- else:
85
- save pwdata to datasets_path/data_name/train or valid
86
- return {*}
87
- author: wuxingxing
88
- '''
89
- def extract_pwdata(data_list:list[str],
90
- data_format:str="movement",
91
- datasets_path="PWdata",
92
- train_valid_ratio:float=0.8,
93
- data_shuffle:bool=True,
94
- merge_data:bool=False
95
- ):
96
- data_name = None
97
- if merge_data:
98
- data_name = os.path.basename(datasets_path)
99
- if not os.path.isabs(datasets_path):
100
- # data_name = datasets_path
101
- datasets_path = os.path.dirname(os.path.join(os.getcwd(), datasets_path))
102
- else:
103
- datasets_path = os.path.dirname(datasets_path)
104
- multi_data = []
105
- for data_path in data_list:
106
- image_data = Config.read(data_format, data_path)
107
- multi_data += image_data
108
- get_all = Config.get(multi_data)
109
- Config.save(image_data_dict=get_all,
110
- datasets_path=datasets_path,
111
- train_data_path="train",
112
- valid_data_path="valid",
113
- train_ratio = train_valid_ratio,
114
- random=data_shuffle,
115
- seed = 2024,
116
- retain_raw = False,
117
- data_name = data_name
118
- )
119
- else:
120
- for data_path in data_list:
121
- image_data = Config.read(data_format, data_path)
122
- get_all = Config.get(image_data)
123
- Config.save(image_data_dict=get_all,
124
- datasets_path=datasets_path,
125
- train_data_path="train",
126
- valid_data_path="valid",
127
- train_ratio = train_valid_ratio,
128
- random=data_shuffle,
129
- seed = 2024,
130
- retain_raw = False
131
- )
132
-
133
- if __name__ == "__main__":
134
- # in_config = "/data/home/wuxingxing/datas/al_dir/si_5_pwmat/sys_config/structures/1.config"
135
- # save_path = "/data/home/wuxingxing/datas/al_dir/si_5_pwmat/sys_config/structures"
136
- # image = extract_config(config_path=in_config, format="pwmat")
137
-
138
- # save_config(image, wrap=False, direct=True, sort=True,\
139
- # save_format="pwmat", save_path=save_path, save_name="temp_atom.config")
140
- # save_config(image, wrap=False, direct=True, sort=True,\
141
- # save_format="vasp", save_path=save_path, save_name="temp_poscar")
142
-
143
- # do_super_cell(config=image,
144
- # supercell_matrix=[[2,0,0], [0,2,0], [0,0,2]],
145
- # pbc=[1, 1, 1],
146
- # direct = True,
147
- # sort = True, \
148
- # save_format="pwmat", save_path=save_path, save_name="temp_super_atom.config")
149
-
150
- # do_super_cell(config="/data/home/wuxingxing/datas/al_dir/si_5_pwmat/sys_config/structures/44_POSCAR",
151
- # input_format="vasp",
152
- # supercell_matrix=[[2,0,0], [0,2,0], [0,0,2]],
153
- # pbc=[1, 1, 1],
154
- # direct = True,
155
- # sort = True, \
156
- # save_format="pwmat", save_path=save_path, save_name="temp_super_atom_from_poscar.config")
157
-
158
-
159
- # do_super_cell(config="/data/home/wuxingxing/datas/al_dir/si_5_pwmat/sys_config/structures/44_POSCAR",
160
- # input_format="vasp",
161
- # supercell_matrix=[[2,0,0], [0,2,0], [0,0,2]],
162
- # pbc=[1, 1, 1],
163
- # direct = True,
164
- # sort = True, \
165
- # save_format="vasp", save_path=save_path, save_name="temp_super_poscar")
166
-
167
- # do_scale(config=image,
168
- # scale_factor=0.99,
169
- # direct=True,
170
- # sort=True,
171
- # save_format="pwmat", save_path=save_path, save_name="temp_scale_atom.config")
172
-
173
- # do_scale(config=image,
174
- # scale_factor=0.99,
175
- # direct=True,
176
- # sort=True,
177
- # save_format="vasp", save_path=save_path, save_name="temp_scale_poscar")
178
-
179
- # save_path = "/data/home/wuxingxing/datas/al_dir/si_5_pwmat/sys_config/structures/temp_pwmat_pertub"
180
- # do_pertub(config=image,
181
- # pert_num=50,
182
- # cell_pert_fraction=0.01,
183
- # atom_pert_distance=0.04,
184
- # direct=True,
185
- # sort=True,
186
- # save_format="pwmat", save_path=save_path, save_name="pertub.config")
187
-
188
- # save_path = "/data/home/wuxingxing/datas/al_dir/si_5_pwmat/sys_config/structures/temp_vasp_pertub"
189
- # do_pertub(config=image,
190
- # pert_num=50,
191
- # cell_pert_fraction=0.01,
192
- # atom_pert_distance=0.04,
193
- # direct=True,
194
- # sort=True,
195
- # save_format="vasp", save_path=save_path, save_name="pertub.poscar")
196
-
197
- # convert trajs to config for model_deviation calculate
198
- import glob
199
- traj_dir = "/data/home/wuxingxing/datas/al_dir/si_5_pwmat/iter.0000/temp_run_iter_work/explore/md/md.000.sys.000/md.000.sys.000.t.000/traj"
200
- save_dir = "/data/home/wuxingxing/datas/al_dir/si_5_pwmat/iter.0000/temp_run_iter_work/explore/md/md.000.sys.000/md.000.sys.000.t.000/traj2config"
201
- if not os.path.exists(save_dir):
202
- os.makedirs(save_dir)
203
- trajs = glob.glob(os.path.join(traj_dir, "*.lammpstrj"))
204
- trajs = sorted(trajs)
205
- for traj in trajs:
206
- save_name = "{}.config".format(os.path.basename(traj).split('.')[0])
207
- save_config(traj, input_format="dump", wrap=False, direct=True, sort=True,\
208
- save_format="pwmat", save_path=save_dir, save_name=save_name)
209
- print("{} to {} done!".format(traj, save_name))
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