pwdata 0.2.17__tar.gz → 0.2.19__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 (39) hide show
  1. {pwdata-0.2.17 → pwdata-0.2.19}/PKG-INFO +1 -1
  2. pwdata-0.2.19/pwdata/check_envs.py +5 -0
  3. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/cp2kdata.py +4 -4
  4. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/datasets_saver.py +2 -2
  5. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/deepmd.py +6 -2
  6. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/dump.py +3 -2
  7. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/extendedxyz.py +8 -8
  8. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/image.py +19 -10
  9. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/main.py +56 -40
  10. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/movement.py +4 -4
  11. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/movement_saver.py +3 -2
  12. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/outcar.py +1 -1
  13. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/pwmlff.py +7 -6
  14. pwdata-0.2.19/pwdata/test.py +18 -0
  15. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata.egg-info/PKG-INFO +1 -1
  16. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata.egg-info/SOURCES.txt +2 -0
  17. {pwdata-0.2.17 → pwdata-0.2.19}/setup.py +1 -1
  18. {pwdata-0.2.17 → pwdata-0.2.19}/LICENSE +0 -0
  19. {pwdata-0.2.17 → pwdata-0.2.19}/README.md +0 -0
  20. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/__init__.py +0 -0
  21. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/atomconfig.py +0 -0
  22. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/build/__init__.py +0 -0
  23. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/build/cell.py +0 -0
  24. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/build/geometry.py +0 -0
  25. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/build/supercells.py +0 -0
  26. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/build/write_struc.py +0 -0
  27. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/calculators/__init__.py +0 -0
  28. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/calculators/const.py +0 -0
  29. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/calculators/unitconvert_lmps.py +0 -0
  30. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/calculators/units.py +0 -0
  31. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/lammpsdata.py +0 -0
  32. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/lmps.py +0 -0
  33. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/pertub/__init__.py +0 -0
  34. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/pertub/perturbation.py +0 -0
  35. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/pertub/scale.py +0 -0
  36. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata/poscar.py +0 -0
  37. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata.egg-info/dependency_links.txt +0 -0
  38. {pwdata-0.2.17 → pwdata-0.2.19}/pwdata.egg-info/top_level.txt +0 -0
  39. {pwdata-0.2.17 → pwdata-0.2.19}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pwdata
3
- Version: 0.2.17
3
+ Version: 0.2.19
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
@@ -0,0 +1,5 @@
1
+ def print_cmd():
2
+ cmd_infos()
3
+
4
+ def cmd_infos():
5
+ print("In functional development, please refer to the link\n\t\thttp://doc.lonxun.com/PWMLFF/Appendix-2/")
@@ -53,8 +53,8 @@ class CP2KMD(object):
53
53
  self.image_list.append(image)
54
54
  elif "STRESS| Analytical stress tensor" in ii:
55
55
  stress_info = parse_stress(stdout_contents[idx+2:idx+5])
56
- stress = gpa2ev(stress_info["stress"], volume)
57
- image.stress = stress
56
+ virial = gpa2ev(stress_info["stress"], volume)
57
+ image.virial = virial
58
58
 
59
59
  def read_pdb(self, traj_file):
60
60
  with open(traj_file, "r") as f:
@@ -208,8 +208,8 @@ class CP2KSCF(object):
208
208
  image.force = force_info["force"]
209
209
  elif "STRESS| Analytical stress tensor" in ii:
210
210
  stress_info = parse_stress(stdout_contents[idx+2:idx+5])
211
- stress = gpa2ev(stress_info["stress"], volume)
212
- image.stress = stress
211
+ virial = gpa2ev(stress_info["stress"], volume)
212
+ image.virial = virial
213
213
 
214
214
  def parse_position(self, position_content):
215
215
  position = [[float(_) for _ in atom.split()[4:7]] for atom in position_content]
@@ -173,8 +173,8 @@ def get_pw(image_data):
173
173
  all_energies.append(image.Ep)
174
174
  all_forces.append(image.force)
175
175
  all_ei.append(image.atomic_energy)
176
- if len(image.stress) != 0:
177
- all_virials.append(image.stress)
176
+ if len(image.virial) != 0:
177
+ all_virials.append(image.virial)
178
178
  image_nums = len(image_data)
179
179
  atom_type = np.array(image.atom_type).reshape(1, -1)
180
180
  atom_types_image = np.array(image.atom_types_image)
@@ -41,7 +41,7 @@ class DPNPY(object):
41
41
 
42
42
  for i in range(image_nums):
43
43
  virial_image = virial[i] if virial is not None else None
44
- image = Image(lattice=box[i], position=coord[i], force=force[i], Ep=energy[i], stress=virial_image,
44
+ image = Image(lattice=box[i], position=coord[i], force=force[i], Ep=energy[i], virial=virial_image,
45
45
  atom_type=atom_type, atom_nums=atom_nums, atom_types_image=atom_types_image, atom_type_num=atom_type_num,
46
46
  cartesian=True, image_nums=i)
47
47
  atomic_energy, _, _, _ = np.linalg.lstsq([atom_type_num], np.array([image.Ep]), rcond=1e-3)
@@ -103,7 +103,11 @@ class DPRAW(object):
103
103
  box, coord, energy, force, virial, image_nums = self.load_raw(raw_files, atom_nums)
104
104
 
105
105
  for i in range(image_nums):
106
- image = Image(lattice=box[i], position=coord[i], force=force[i], Ep=energy[i], stress=virial[i],
106
+ try:
107
+ virial_image = virial[i]
108
+ except Exception as e:
109
+ virial_image = None
110
+ image = Image(lattice=box[i], position=coord[i], force=force[i], Ep=energy[i], virial=virial_image,
107
111
  atom_type=atom_type, atom_nums=atom_nums, atom_types_image=atom_types_image, atom_type_num=atom_type_num,
108
112
  cartesian=True, image_nums=i)
109
113
  atomic_energy, _, _, _ = np.linalg.lstsq([atom_type_num], np.array([image.Ep]), rcond=1e-3)
@@ -68,7 +68,8 @@ class DUMP(object):
68
68
  image.atom_type_num = info["atom_type_num"]
69
69
  image.atom_types_image = info["atom_types_image"]
70
70
  image.position = info["positions"]
71
- image.force = info["forces"]
71
+ if "forces" in info.keys():
72
+ image.force = info["forces"]
72
73
  image.pbc = pbc
73
74
  image.cartesian = True
74
75
 
@@ -193,4 +194,4 @@ class DUMP(object):
193
194
  all["lattice_disp"] = lattice_disp
194
195
 
195
196
  return all
196
-
197
+
@@ -41,7 +41,7 @@ class EXTXYZ(object):
41
41
  pass
42
42
  else:
43
43
  # virial = -stress * volume
44
- image.stress = - Atoms[i].get_volume() * stress
44
+ image.virial = - Atoms[i].get_volume() * stress
45
45
  image.format = 'extxyz'
46
46
  self.image_list.append(image)
47
47
  else:
@@ -67,7 +67,7 @@ class EXTXYZ(object):
67
67
  except AttributeError:
68
68
  pass
69
69
  else:
70
- image.stress = - Atoms.get_volume() * stress
70
+ image.virial = - Atoms.get_volume() * stress
71
71
  image.format = 'extxyz'
72
72
  self.image_list.append(image)
73
73
 
@@ -84,12 +84,12 @@ def save_to_extxyz(image_data_all: list, output_path: str, data_name: str, write
84
84
  output_extended = (image_data.lattice[0][0], image_data.lattice[0][1], image_data.lattice[0][2],
85
85
  image_data.lattice[1][0], image_data.lattice[1][1], image_data.lattice[1][2],
86
86
  image_data.lattice[2][0], image_data.lattice[2][1], image_data.lattice[2][2])
87
- if image_data.stress is not None:
88
- output_head += 'stress="%.8f %.8f %.8f %.8f %.8f %.8f %.8f %.8f %.8f"'
89
- stress = image_data.get_stress()
90
- output_extended += (stress[0][0], stress[0][1], stress[0][2],
91
- stress[1][0], stress[1][1], stress[1][2],
92
- stress[2][0], stress[2][1], stress[2][2])
87
+ if image_data.virial is not None:
88
+ output_head += 'virial="%.8f %.8f %.8f %.8f %.8f %.8f %.8f %.8f %.8f"'
89
+ virial = image_data.get_virial()
90
+ output_extended += (virial[0][0], virial[0][1], virial[0][2],
91
+ virial[1][0], virial[1][1], virial[1][2],
92
+ virial[2][0], virial[2][1], virial[2][2])
93
93
  output_head += '\n'
94
94
  data_name.write(output_head % output_extended)
95
95
  for j in range(image_data.atom_nums):
@@ -8,10 +8,10 @@ from pwdata.build.cell import scaled_positions
8
8
  from pwdata.lmps import Box2l
9
9
  # 1. initial the image class
10
10
  class Image(object):
11
- def __init__(self, formula = None,
11
+ def __init__(self, formula = None,
12
12
  atom_type = None, atom_type_num = None, atom_nums = None, atom_types_image = None,
13
13
  iteration = None, Etot = None, Ep = None, Ek = None, scf = None, lattice = None,
14
- stress = None, position = None, force = None, atomic_energy = None,
14
+ virial = None, position = None, force = None, atomic_energy = None,
15
15
  content = None, image_nums = None, pbc = None, cartesian = None):
16
16
  """
17
17
  Represents an image in a AIMD trajectory.
@@ -27,7 +27,7 @@ class Image(object):
27
27
  Ek (float): The kinetic energy.
28
28
  scf (float): The index of the self-consistent field.
29
29
  lattice (list): The lattice vectors.
30
- stress (list): The stress tensor.
30
+ virial (list): The virial tensor.
31
31
  position (list): The atomic positions.
32
32
  force (list): The atomic forces.
33
33
  atomic_energy (list): The atomic energies.
@@ -47,7 +47,7 @@ class Image(object):
47
47
  self.scf = scf
48
48
  self.image_nums = image_nums
49
49
  self.lattice = lattice if lattice is not None else []
50
- self.stress = stress if stress is not None else []
50
+ self.virial = virial
51
51
  self.position = position if position is not None else [] # this position can be fractional coordinates or cartesian coordinates
52
52
  self.force = force if force is not None else []
53
53
  self.atomic_energy = atomic_energy if atomic_energy is not None else []
@@ -69,7 +69,7 @@ class Image(object):
69
69
  for name, a in prim_dict.items():
70
70
  atoms.arrays[name] = a.copy()
71
71
  return atoms
72
-
72
+
73
73
  def to(self, output_path, data_name = None, save_format = None, direct = True, sort = False, wrap = False):
74
74
  """
75
75
  Write atoms object to a new file.
@@ -192,13 +192,22 @@ class Image(object):
192
192
  """Get integer array of atomic numbers."""
193
193
  return self.arrays['atom_types_image'].copy()
194
194
 
195
+ def get_virial(self):
196
+ """Get virial tensor."""
197
+ return self._get_virial()
198
+
199
+ def _get_virial(self):
200
+ virial = np.array(self.virial).reshape(3, 3)
201
+ return virial
202
+
195
203
  def get_stress(self):
196
204
  """Get stress tensor."""
197
- return self._get_stress()
198
-
199
- def _get_stress(self):
200
- stress = np.array(self.stress).reshape(3, 3)
205
+ stress = self.get_virial() / - self.get_volume()
201
206
  return stress
207
+
208
+ def get_volume(self):
209
+ """Get volume of the unit cell."""
210
+ return np.abs(np.linalg.det(self.lattice))
202
211
 
203
212
  def _get_positions(self):
204
213
  """Return reference to positions-array for in-place manipulations."""
@@ -296,4 +305,4 @@ def cart2frac(position, lattice):
296
305
  """
297
306
  position = np.array(position).reshape(-1, 3)
298
307
  lattice = np.array(lattice).reshape(3, 3)
299
- return np.dot(position, np.linalg.inv(lattice))
308
+ return np.dot(position, np.linalg.inv(lattice))
@@ -279,46 +279,62 @@ def string2index(string: str) -> Union[int, slice, str]:
279
279
  i += (3 - len(i)) * [None]
280
280
  return slice(*i)
281
281
 
282
+ def run_cmd():
283
+ from check_envs import print_cmd
284
+ if len(sys.argv) == 1 or "-h".upper() == sys.argv[1].upper() or \
285
+ "help".upper() == sys.argv[1].upper() or "-help".upper() == sys.argv[1].upper() or "--help".upper() == sys.argv[1].upper():
286
+ print_cmd()
287
+
288
+ elif "convert_config".upper() == sys.argv[1].upper():
289
+ pass
290
+
291
+
282
292
  if __name__ == "__main__":
283
- import argparse
284
- SUPERCELL_MATRIX = [[2, 0, 0], [0, 2, 0], [0, 0, 2]]
285
- data_file = "/data/home/hfhuang/2_MLFF/2-DP/19-json-version/8-Si2/atom.config"
286
- # data_file = "/data/home/hfhuang/9_cp2k/1-SiO2/cp2k.out"
287
- # data_file = "/data/home/hfhuang/software/mlff/Si/Si64-vasprun.xml"
288
- # data_file = "/data/home/hfhuang/2_MLFF/3-outcar2movement/0/OUTCARC3N4"
289
- output_path = "/data/home/hfhuang/2_MLFF/2-DP/19-json-version/8-Si2/mlff/"
290
- output_file = "supercell.config"
291
- format = "config"
292
- pbc = [1, 1, 1]
293
- # config = Config.read(format, data_file, atom_names=["Si"], index=-1) # read dump
294
- config = Config.read(format, data_file)
295
- Config.to(file_path = output_path,
296
- file_name = output_file,
297
- file_format = 'config',
298
- direct = True,
299
- sort = False)
300
- parser = argparse.ArgumentParser(description='Convert and build structures.')
301
- parser.add_argument('--format', type=str, required=False, help='Format of the input file', default="outcar")
302
- parser.add_argument('--save_format', type=str, required=False, help='Format of the output file', default="config")
303
- parser.add_argument('--outcar_file', type=str, required=False, help='Path to the OUTCAR file')
304
- parser.add_argument('--movement_file', type=str, required=False, help='Path to the MOVEMENT file')
305
- parser.add_argument('--output_path', type=str, required=False, help='Path to the output directory', default="./")
306
- parser.add_argument('--output_file', type=str, required=False, help='Name of the output file', default="MOVEMENT")
307
- parser.add_argument('--supercell_matrix', type=list, required=False, help='Supercell matrix', default=[[1, 0, 0], [0, 1, 0], [0, 0, 1]])
308
- parser.add_argument('--pbc', type=list, required=False, help='Periodic boundary conditions flags', default=[1, 1, 1])
309
- parser.add_argument('--direct', type=bool, required=False, help='Whether to write the positions in direct (frac) coordinates', default=True)
310
- parser.add_argument('--sort', type=bool, required=False, help='Whether to sort the atoms by atomic number', default=True)
311
- parser.add_argument('--pert_num', type=int, required=False, help='Number of perturbed structures', default=50)
312
- parser.add_argument('--cell_pert_fraction', type=float, required=False, help='Fraction of the cell perturbation', default=0.03)
313
- parser.add_argument('--atom_pert_distance', type=float, required=False, help='Distance of the atom perturbation', default=0.01)
314
- parser.add_argument('--retain_raw', type=bool, required=False, help='Whether to retain raw data', default=False)
315
- parser.add_argument('--train_ratio', type=float, required=False, help='Ratio of training data', default=0.8)
316
- parser.add_argument('--random', type=bool, required=False, help='Whether to shuffle the data', default=True)
317
- parser.add_argument('--scale_factor', type=float, required=False, help='Scale factor of the lattice', default=1.0)
318
- parser.add_argument('--seed', type=int, required=False, help='Random seed', default=2024)
319
- parser.add_argument('--index', type=Union[int, slice, str], required=False, help='Index of the configuration', default=-1)
320
- parser.add_argument('--atom_names', type=list, required=False, help='Names of the atoms', default=["H"])
321
- parser.add_argument('--style', type=str, required=False, help='Style of the lammps input file', default="atomic")
293
+ # import argparse
294
+ # SUPERCELL_MATRIX = [[2, 0, 0], [0, 2, 0], [0, 0, 2]]
295
+ # data_file = "/data/home/hfhuang/2_MLFF/2-DP/19-json-version/8-Si2/atom.config"
296
+ # # data_file = "/data/home/hfhuang/9_cp2k/1-SiO2/cp2k.out"
297
+ # # data_file = "/data/home/hfhuang/software/mlff/Si/Si64-vasprun.xml"
298
+ # # data_file = "/data/home/hfhuang/2_MLFF/3-outcar2movement/0/OUTCARC3N4"
299
+ # output_path = "/data/home/hfhuang/2_MLFF/2-DP/19-json-version/8-Si2/mlff/"
300
+ # output_file = "supercell.config"
301
+ # format = "config"
302
+ # pbc = [1, 1, 1]
303
+ # # config = Config.read(format, data_file, atom_names=["Si"], index=-1) # read dump
304
+ # config = Config.read(format, data_file)
305
+ # Config.to(file_path = output_path,
306
+ # file_name = output_file,
307
+ # file_format = 'config',
308
+ # direct = True,
309
+ # sort = False)
310
+ # parser = argparse.ArgumentParser(description='Convert and build structures.')
311
+ # parser.add_argument('--format', type=str, required=False, help='Format of the input file', default="outcar")
312
+ # parser.add_argument('--save_format', type=str, required=False, help='Format of the output file', default="config")
313
+ # parser.add_argument('--outcar_file', type=str, required=False, help='Path to the OUTCAR file')
314
+ # parser.add_argument('--movement_file', type=str, required=False, help='Path to the MOVEMENT file')
315
+ # parser.add_argument('--output_path', type=str, required=False, help='Path to the output directory', default="./")
316
+ # parser.add_argument('--output_file', type=str, required=False, help='Name of the output file', default="MOVEMENT")
317
+ # parser.add_argument('--supercell_matrix', type=list, required=False, help='Supercell matrix', default=[[1, 0, 0], [0, 1, 0], [0, 0, 1]])
318
+ # parser.add_argument('--pbc', type=list, required=False, help='Periodic boundary conditions flags', default=[1, 1, 1])
319
+ # parser.add_argument('--direct', type=bool, required=False, help='Whether to write the positions in direct (frac) coordinates', default=True)
320
+ # parser.add_argument('--sort', type=bool, required=False, help='Whether to sort the atoms by atomic number', default=True)
321
+ # parser.add_argument('--pert_num', type=int, required=False, help='Number of perturbed structures', default=50)
322
+ # parser.add_argument('--cell_pert_fraction', type=float, required=False, help='Fraction of the cell perturbation', default=0.03)
323
+ # parser.add_argument('--atom_pert_distance', type=float, required=False, help='Distance of the atom perturbation', default=0.01)
324
+ # parser.add_argument('--retain_raw', type=bool, required=False, help='Whether to retain raw data', default=False)
325
+ # parser.add_argument('--train_ratio', type=float, required=False, help='Ratio of training data', default=0.8)
326
+ # parser.add_argument('--random', type=bool, required=False, help='Whether to shuffle the data', default=True)
327
+ # parser.add_argument('--scale_factor', type=float, required=False, help='Scale factor of the lattice', default=1.0)
328
+ # parser.add_argument('--seed', type=int, required=False, help='Random seed', default=2024)
329
+ # parser.add_argument('--index', type=Union[int, slice, str], required=False, help='Index of the configuration', default=-1)
330
+ # parser.add_argument('--atom_names', type=list, required=False, help='Names of the atoms', default=["H"])
331
+ # parser.add_argument('--style', type=str, required=False, help='Style of the lammps input file', default="atomic")
322
332
 
323
- args = parser.parse_args()
333
+ # args = parser.parse_args()
324
334
 
335
+ run_cmd()
336
+
337
+ config = Config.read("vasp/outcar",
338
+ "/data/home/wuxingxing/datas/al_dir/si_4_vasp/init_bulk/temp_init_bulk_work/aimd/init_config_0/0.9_scale/3_aimd/OUTCAR")
339
+ print()
340
+
@@ -27,7 +27,7 @@ class MOVEMENT(object):
27
27
  elif "Lattice" in ii:
28
28
  lattice_stress = self.parse_lattice_stress(mvm_contents[idx+1:idx+4])
29
29
  image.lattice = lattice_stress["lattice"]
30
- image.stress = lattice_stress["stress"]
30
+ image.virial = lattice_stress["virial"]
31
31
  elif " Position" in ii:
32
32
  position = self.parse_position(mvm_contents[idx+1:idx+image.atom_nums+1])
33
33
  image.position = position["position"]
@@ -71,11 +71,11 @@ class MOVEMENT(object):
71
71
  lattice2 = [float(_) for _ in self.number_pattern.findall(lattice_content[1])]
72
72
  lattice3 = [float(_) for _ in self.number_pattern.findall(lattice_content[2])]
73
73
  if "stress" in lattice_content[0]:
74
- stress = [lattice1[3:], lattice2[3:], lattice3[3:]]
74
+ virial = [lattice1[3:], lattice2[3:], lattice3[3:]]
75
75
  else:
76
- stress = []
76
+ virial = []
77
77
  lattice = [lattice1[:3], lattice2[:3], lattice3[:3]]
78
- return {"lattice": lattice, "stress": stress}
78
+ return {"lattice": lattice, "virial": virial}
79
79
 
80
80
  def parse_position(self, position_content):
81
81
  atom_types_image = []
@@ -19,8 +19,9 @@ def save_to_movement(image_data_all: list, output_path: str, data_name: str):
19
19
  data_name.write(" ******* \n")
20
20
  data_name.write("Lattice vector (Angstrom)\n")
21
21
  for j in range(3):
22
- if image_data.stress != []:
23
- data_name.write(" %16.10E %16.10E %16.10E stress (eV): %16.10E %16.10E %16.10E\n" % (image_data.lattice[j][0], image_data.lattice[j][1], image_data.lattice[j][2], image_data.virials[j][0], image_data.virials[j][1], image_data.virials[j][2]))
22
+ if image_data.virial is not None:
23
+ virial = image_data.get_virial()
24
+ data_name.write(" %16.10E %16.10E %16.10E stress (eV): %16.10E %16.10E %16.10E\n" % (image_data.lattice[j][0], image_data.lattice[j][1], image_data.lattice[j][2], virial[j][0], virial[j][1], virial[j][2]))
24
25
  else:
25
26
  data_name.write(" %16.10E %16.10E %16.10E\n" % (image_data.lattice[j][0], image_data.lattice[j][1], image_data.lattice[j][2]))
26
27
  data_name.write(" Position (normalized), move_x, move_y, move_z\n")
@@ -87,7 +87,7 @@ class OUTCAR(object):
87
87
  image.scf = int(line.split()[3][:-1])
88
88
  elif "in kB" in line:
89
89
  virial_info = self.parse_virial_info(converged_image[idx - 1])
90
- image.stress = virial_info["virial"]
90
+ image.virial = virial_info["virial"]
91
91
  elif "VOLUME and BASIS" in line:
92
92
  lattice_info = self.parse_lattice(converged_image[idx+5:idx+8])
93
93
  image.lattice = lattice_info["lattice"]
@@ -19,12 +19,13 @@ class PWNPY(object):
19
19
  if not npy_files:
20
20
  npy_files = glob.glob(os.path.join(files, "*/*.npy"))
21
21
 
22
- atom_type, atomic_energy, Ep, force, atom_types_image, lattice, coord, stress, image_nums, atom_nums = self.load_npy(npy_files)
22
+ atom_type, atomic_energy, Ep, force, atom_types_image, lattice, coord, virial, image_nums, atom_nums = self.load_npy(npy_files)
23
23
  lattice = lattice.reshape(-1, 3, 3)
24
24
  coord = coord.reshape(-1, atom_nums, 3)
25
25
  force = force.reshape(-1, atom_nums, 3)
26
26
  for i in tqdm(range(image_nums), desc="Loading data"):
27
- image = Image(lattice=lattice[i], position=coord[i], force=force[i], Ep=Ep[i], stress=stress[i],
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
29
  cartesian=False, image_nums=i, atom_nums=atom_nums,
29
30
  atomic_energy=atomic_energy[i], atom_type=atom_type, atom_types_image=atom_types_image)
30
31
  self.image_list.append(image)
@@ -34,7 +35,7 @@ class PWNPY(object):
34
35
  Ep = None
35
36
  force = None
36
37
  lattice = None
37
- stress = None
38
+ virial = None
38
39
  coord = None
39
40
  for npy_file in npy_files:
40
41
  if "atom_type" in npy_file:
@@ -50,12 +51,12 @@ class PWNPY(object):
50
51
  elif "lattice" in npy_file:
51
52
  lattice = np.load(npy_file) if lattice is None else np.concatenate((lattice, np.load(npy_file)))
52
53
  elif "virials" in npy_file:
53
- stress = np.load(npy_file) if stress is None else np.concatenate((stress, np.load(npy_file)))
54
+ virial = np.load(npy_file) if virial is None else np.concatenate((virial, np.load(npy_file)))
54
55
  elif "position" in npy_file:
55
56
  coord = np.load(npy_file) if coord is None else np.concatenate((coord, np.load(npy_file)))
56
57
 
57
58
  image_nums = len(Ep)
58
59
  atom_nums = len(atom_types_image)
59
- stress = stress.reshape(-1, 3, 3) if stress is not None else None
60
+ virial = virial.reshape(-1, 3, 3) if virial is not None else None
60
61
 
61
- return atom_type, atomic_energy, Ep.squeeze(), force, atom_types_image, lattice, coord, stress, image_nums, atom_nums
62
+ return atom_type, atomic_energy, Ep.squeeze(), force, atom_types_image, lattice, coord, virial, image_nums, atom_nums
@@ -0,0 +1,18 @@
1
+ import os, sys, glob
2
+ from main import Save_Data
3
+
4
+ def test():
5
+ work_dir = "/data/home/wuxingxing/datas/PWMLFF_library_data/HfO2/hfo2_dpgen/HfO2_liutheory"
6
+ init_dir = glob.glob(os.path.join(work_dir, "sys.*"))
7
+ init_dir = sorted(init_dir, key=lambda x: int(x.split(".")[-1]))
8
+ for i, d in enumerate(init_dir):
9
+ print(i, d)
10
+ Save_Data(data_path=d,
11
+ datasets_path=os.path.join(work_dir, "new_pwdata"),
12
+ train_ratio = 0.2,
13
+ random=False,
14
+ format="deepmd/npy"
15
+ )
16
+
17
+ if __name__ == "__main__":
18
+ test()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pwdata
3
- Version: 0.2.17
3
+ Version: 0.2.19
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,6 +3,7 @@ README.md
3
3
  setup.py
4
4
  pwdata/__init__.py
5
5
  pwdata/atomconfig.py
6
+ pwdata/check_envs.py
6
7
  pwdata/cp2kdata.py
7
8
  pwdata/datasets_saver.py
8
9
  pwdata/deepmd.py
@@ -17,6 +18,7 @@ pwdata/movement_saver.py
17
18
  pwdata/outcar.py
18
19
  pwdata/poscar.py
19
20
  pwdata/pwmlff.py
21
+ pwdata/test.py
20
22
  pwdata.egg-info/PKG-INFO
21
23
  pwdata.egg-info/SOURCES.txt
22
24
  pwdata.egg-info/dependency_links.txt
@@ -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.17",
8
+ version="0.2.19",
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